Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit feee6fb

Browse files
committed
Auto merge of rust-lang#140601 - fmease:ignore-malformed-metas-interpolated_BETA, r=nnethercote
[beta] [also fit for beta rollup] [HOTFIX] Don't delay a bug on malformed meta items involving interpolated tokens Directly fixes rust-lang#140612. <details><summary>Outdated Information</summary> Directly fixes the 3 crater regressions reported in rust-lang#137687 (comment) (NB: The containing issue rust-lang#137687 is in fact *not* an instance of these regressions, see rust-lang#137687 (comment)). </details> **Why is this a separate PR for `beta`**? Well, the crater regressions were already fixed on master albeit unintentionally so, namely by PR rust-lang#124141 which we **certainly** don't want to backport! So this is simply a hotfix. PR rust-lang#140584 will then provide the regression test for master, too, so it doesn't get 'lost'. [`@]T-release,` if/once accepted by T-compiler, this PR will be fit for beta rollup and can be cherry-picked. <details><summary>Slightly Outdated & Irrelevant Information</summary> FYI, we may also want to (separately) backport PR rust-lang#140584 to [fix] rust-lang#137687 (which, again, is not an instance of the crater regressions) but it's unclear if it's really necessary (since it's fuzzer-generated and I don't know of any real users who are impacted). </details> cc `@jdonszelmann` r? fmease
2 parents af91af4 + 3864645 commit feee6fb

File tree

3 files changed

+30
-9
lines changed

3 files changed

+30
-9
lines changed

‎compiler/rustc_attr_parsing/src/parser.rs‎

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use rustc_ast_pretty::pprust;
1313
use rustc_errors::DiagCtxtHandle;
1414
use rustc_hir::{self as hir, AttrPath};
1515
use rustc_span::symbol::{Ident, kw, sym};
16-
use rustc_span::{ErrorGuaranteed,Span, Symbol};
16+
use rustc_span::{Span, Symbol};
1717

1818
pub struct SegmentIterator<'a> {
1919
offset: usize,
@@ -176,7 +176,7 @@ impl<'a> ArgParser<'a> {
176176
pub enum MetaItemOrLitParser<'a> {
177177
MetaItemParser(MetaItemParser<'a>),
178178
Lit(MetaItemLit),
179-
Err(Span,ErrorGuaranteed),
179+
Err(Span),
180180
}
181181

182182
impl<'a> MetaItemOrLitParser<'a> {
@@ -186,7 +186,7 @@ impl<'a> MetaItemOrLitParser<'a> {
186186
generic_meta_item_parser.span()
187187
}
188188
MetaItemOrLitParser::Lit(meta_item_lit) => meta_item_lit.span,
189-
MetaItemOrLitParser::Err(span, _) => *span,
189+
MetaItemOrLitParser::Err(span) => *span,
190190
}
191191
}
192192

@@ -495,12 +495,9 @@ impl<'a> MetaItemListParserContext<'a> {
495495
// where the macro didn't expand to a literal. An error is already given
496496
// for this at this point, and then we do continue. This makes this path
497497
// reachable...
498-
let e = self.dcx.span_delayed_bug(
499-
*span,
500-
"expr in place where literal is expected (builtin attr parsing)",
501-
);
502-
503-
return Some(MetaItemOrLitParser::Err(*span, e));
498+
// NOTE: For backward compatibility we can't emit any error / delayed bug here (yet).
499+
// See <https://github.com/rust-lang/rust/issues/140612>
500+
return Some(MetaItemOrLitParser::Err(*span));
504501
} else {
505502
self.next_path()?
506503
};
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
extern crate proc_macro;
2+
3+
use proc_macro::TokenStream;
4+
5+
#[proc_macro_derive(Derive, attributes(arg))]
6+
pub fn derive(_: TokenStream) -> TokenStream {
7+
TokenStream::new()
8+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Regression test for <https://github.com/rust-lang/rust/issues/137687#issuecomment-2816312274>.
2+
//@ proc-macro: derive_macro_with_helper.rs
3+
//@ edition: 2018
4+
//@ check-pass
5+
6+
macro_rules! call_macro {
7+
($text:expr) => {
8+
#[derive(derive_macro_with_helper::Derive)]
9+
#[arg($text)]
10+
pub struct Foo;
11+
};
12+
}
13+
14+
call_macro!(1 + 1);
15+
16+
fn main() {}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /