diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-06-20 18:20:12 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-20 18:20:12 +0200 |
| commit | 2fa148e11a3c4bb0204694f012b954cc68b4951b (patch) | |
| tree | 237764d520752937f8880943b617db976b9ee44a | |
| parent | bbf94b29fb507aace9cddc13554052766d141d34 (diff) | |
| parent | 1e42bb606d9abcfa22ee248e3a8598f813632418 (diff) | |
| download | rust-2fa148e11a3c4bb0204694f012b954cc68b4951b.tar.gz rust-2fa148e11a3c4bb0204694f012b954cc68b4951b.zip | |
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`
| -rw-r--r-- | compiler/rustc_resolve/src/def_collector.rs | 3 | ||||
| -rw-r--r-- | tests/ui/resolve/path-attr-in-const-block.rs | 9 | ||||
| -rw-r--r-- | tests/ui/resolve/path-attr-in-const-block.stderr | 8 |
3 files changed, 20 insertions, 0 deletions
diff --git a/compiler/rustc_resolve/src/def_collector.rs b/compiler/rustc_resolve/src/def_collector.rs index fb6e55f2b7b..60789c08313 100644 --- a/compiler/rustc_resolve/src/def_collector.rs +++ b/compiler/rustc_resolve/src/def_collector.rs @@ -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, diff --git a/tests/ui/resolve/path-attr-in-const-block.rs b/tests/ui/resolve/path-attr-in-const-block.rs new file mode 100644 index 00000000000..076511d26d6 --- /dev/null +++ b/tests/ui/resolve/path-attr-in-const-block.rs @@ -0,0 +1,9 @@ +// issue#126516 +// issue#126647 + +fn main() { + const { + #![path = foo!()] + //~^ ERROR: cannot find macro `foo` in this scope + } +} diff --git a/tests/ui/resolve/path-attr-in-const-block.stderr b/tests/ui/resolve/path-attr-in-const-block.stderr new file mode 100644 index 00000000000..8f9e58157c8 --- /dev/null +++ b/tests/ui/resolve/path-attr-in-const-block.stderr @@ -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 + |
