diff options
| -rw-r--r-- | compiler/rustc_ast_lowering/src/item.rs | 5 | ||||
| -rw-r--r-- | src/test/ui/attributes/issue-90873.rs | 5 | ||||
| -rw-r--r-- | src/test/ui/attributes/issue-90873.stderr | 30 |
3 files changed, 40 insertions, 0 deletions
diff --git a/compiler/rustc_ast_lowering/src/item.rs b/compiler/rustc_ast_lowering/src/item.rs index 6a4571cf6d2..692f3936824 100644 --- a/compiler/rustc_ast_lowering/src/item.rs +++ b/compiler/rustc_ast_lowering/src/item.rs @@ -40,6 +40,11 @@ impl ItemLowerer<'_, '_, '_> { } impl<'a> Visitor<'a> for ItemLowerer<'a, '_, '_> { + fn visit_attribute(&mut self, _: &'a Attribute) { + // We do not want to lower expressions that appear in attributes, + // as they are not accessible to the rest of the HIR. + } + fn visit_item(&mut self, item: &'a Item) { let hir_id = self.lctx.with_hir_id_owner(item.id, |lctx| { let node = lctx.without_in_scope_lifetime_defs(|lctx| lctx.lower_item(item)); diff --git a/src/test/ui/attributes/issue-90873.rs b/src/test/ui/attributes/issue-90873.rs new file mode 100644 index 00000000000..79ec59e4dc0 --- /dev/null +++ b/src/test/ui/attributes/issue-90873.rs @@ -0,0 +1,5 @@ +#![u=||{static d=||1;}] +//~^ unexpected token +//~| cannot find attribute `u` in this scope +//~| `main` function not found in crate `issue_90873` +//~| missing type for `static` item diff --git a/src/test/ui/attributes/issue-90873.stderr b/src/test/ui/attributes/issue-90873.stderr new file mode 100644 index 00000000000..b249be8d0e2 --- /dev/null +++ b/src/test/ui/attributes/issue-90873.stderr @@ -0,0 +1,30 @@ +error: unexpected token: `|| + { + static d: _ = || 1; + }` + --> $DIR/issue-90873.rs:1:6 + | +LL | #![u=||{static d=||1;}] + | ^^^^^^^^^^^^^^^^^ + +error: cannot find attribute `u` in this scope + --> $DIR/issue-90873.rs:1:4 + | +LL | #![u=||{static d=||1;}] + | ^ + +error[E0601]: `main` function not found in crate `issue_90873` + --> $DIR/issue-90873.rs:1:1 + | +LL | #![u=||{static d=||1;}] + | ^^^^^^^^^^^^^^^^^^^^^^^ consider adding a `main` function to `$DIR/issue-90873.rs` + +error: missing type for `static` item + --> $DIR/issue-90873.rs:1:16 + | +LL | #![u=||{static d=||1;}] + | ^ help: provide a type for the item: `d: <type>` + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0601`. |
