Skip to content

Commit

Permalink
collect attrs in const block expr
Browse files Browse the repository at this point in the history
  • Loading branch information
bvanjoi committed Jun 20, 2024
1 parent 1d96de2 commit 1e42bb6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
3 changes: 3 additions & 0 deletions compiler/rustc_resolve/src/def_collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 9 additions & 0 deletions tests/ui/resolve/path-attr-in-const-block.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// issue#126516
// issue#126647

fn main() {
const {
#![path = foo!()]
//~^ ERROR: cannot find macro `foo` in this scope
}
}
8 changes: 8 additions & 0 deletions tests/ui/resolve/path-attr-in-const-block.stderr
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 1e42bb6

Please sign in to comment.