From 43e39260f9bc02e79891b87f346b456a069967f5 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Tue, 25 Feb 2025 10:22:19 +0000 Subject: [PATCH] Keep items around even if builtin macros on them fail to parse --- compiler/rustc_expand/src/expand.rs | 4 ++-- .../define_opaques_attr/generics.rs | 1 - .../define_opaques_attr/generics.stderr | 9 +-------- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/compiler/rustc_expand/src/expand.rs b/compiler/rustc_expand/src/expand.rs index c523bcece72..87f01be26c2 100644 --- a/compiler/rustc_expand/src/expand.rs +++ b/compiler/rustc_expand/src/expand.rs @@ -780,8 +780,8 @@ impl<'a, 'b> MacroExpander<'a, 'b> { } } Err(err) => { - let guar = err.emit(); - fragment_kind.dummy(span, guar) + let _guar = err.emit(); + fragment_kind.expect_from_annotatables(iter::once(item)) } } } diff --git a/tests/ui/type-alias-impl-trait/define_opaques_attr/generics.rs b/tests/ui/type-alias-impl-trait/define_opaques_attr/generics.rs index 11825dc54ee..2ca2a753e20 100644 --- a/tests/ui/type-alias-impl-trait/define_opaques_attr/generics.rs +++ b/tests/ui/type-alias-impl-trait/define_opaques_attr/generics.rs @@ -10,4 +10,3 @@ fn foo() {} #[define_opaque(Tait<()>)] //~^ ERROR: expected one of `(`, `,`, `::`, or `=`, found `<` fn main() {} -//~^ ERROR: `main` function not found diff --git a/tests/ui/type-alias-impl-trait/define_opaques_attr/generics.stderr b/tests/ui/type-alias-impl-trait/define_opaques_attr/generics.stderr index 8f33f336728..96e8bc9851c 100644 --- a/tests/ui/type-alias-impl-trait/define_opaques_attr/generics.stderr +++ b/tests/ui/type-alias-impl-trait/define_opaques_attr/generics.stderr @@ -10,12 +10,6 @@ error: expected one of `(`, `,`, `::`, or `=`, found `<` LL | #[define_opaque(Tait<()>)] | ^ expected one of `(`, `,`, `::`, or `=` -error[E0601]: `main` function not found in crate `generics` - --> $DIR/generics.rs:12:13 - | -LL | fn main() {} - | ^ consider adding a `main` function to `$DIR/generics.rs` - error: unconstrained opaque type --> $DIR/generics.rs:3:16 | @@ -24,6 +18,5 @@ LL | type Tait = impl Sized; | = note: `Tait` must be used in combination with a concrete type within the same crate -error: aborting due to 4 previous errors +error: aborting due to 3 previous errors -For more information about this error, try `rustc --explain E0601`.