Rollup merge of #126735 - bvanjoi:fix-126647, r=petrochenkov

collect attrs in const block expr

Fixes #126516
Fixes #126647

It was forgotten to collect these attributes in the const block expression.

r? `@petrochenkov`
This commit is contained in:
Matthias Krüger 2024-06-20 18:20:12 +02:00 committed by GitHub
commit 2fa148e11a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 20 additions and 0 deletions

View File

@ -343,6 +343,9 @@ impl<'a, 'b, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'b, 'tcx> {
self.create_def(expr.id, kw::Empty, DefKind::Closure, expr.span)
}
ExprKind::ConstBlock(ref constant) => {
for attr in &expr.attrs {
visit::walk_attribute(self, attr);
}
let def = self.create_def(
constant.id,
kw::Empty,

View File

@ -0,0 +1,9 @@
// issue#126516
// issue#126647
fn main() {
const {
#![path = foo!()]
//~^ ERROR: cannot find macro `foo` in this scope
}
}

View File

@ -0,0 +1,8 @@
error: cannot find macro `foo` in this scope
--> $DIR/path-attr-in-const-block.rs:6:19
|
LL | #![path = foo!()]
| ^^^
error: aborting due to 1 previous error