diff options
| author | bors <bors@rust-lang.org> | 2024-09-22 00:31:03 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-09-22 00:31:03 +0000 |
| commit | 55043f067dcf7067e7c6ebccf3639af94ff57bda (patch) | |
| tree | b68c490fe50e1087af0df4daf9674e9bc1eec23c /compiler/rustc_resolve/src/lib.rs | |
| parent | 764e6aec81517cde60214ccd00a709a34eb0c07d (diff) | |
| parent | 781ec111b728a4d1ae513ae57d5eecf27680a216 (diff) | |
| download | rust-55043f067dcf7067e7c6ebccf3639af94ff57bda.tar.gz rust-55043f067dcf7067e7c6ebccf3639af94ff57bda.zip | |
Auto merge of #130337 - BoxyUwU:anon_const_macro_call, r=camelid
Fix anon const def-creation when macros are involved take 2
Fixes #130321
There were two cases that #129137 did not handle correctly:
- Given a const argument `Foo<{ bar!() }>` in which `bar!()` expands to `N`, we would visit the anon const and then visit the `{ bar() }` expression instead of visiting the macro call. This meant that we would build a def for the anon const as `{ bar!() }` is not a trivial const argument as `bar!()` is not a path.
- Given a const argument `Foo<{ bar!() }>` is which `bar!()` expands to `{ qux!() }` in which `qux!()` expands to `N`, it should not be considered a trivial const argument as `{{ N }}` has two pairs of braces. If we only looked at `qux`'s expansion it would *look* like a trivial const argument even though it is not. We have to track whether we have "unwrapped" a brace already when recursing into the expansions of `bar`/`qux`/any macro
r? `@camelid`
Diffstat (limited to 'compiler/rustc_resolve/src/lib.rs')
| -rw-r--r-- | compiler/rustc_resolve/src/lib.rs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs index c05bd9e72ea..3bb1f6b52a7 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs @@ -190,6 +190,11 @@ impl InvocationParent { #[derive(Copy, Debug, Clone)] struct PendingAnonConstInfo { + // A const arg is only a "trivial" const arg if it has at *most* one set of braces + // around the argument. We track whether we have stripped an outter brace so that + // if a macro expands to a braced expression *and* the macro was itself inside of + // some braces then we can consider it to be a non-trivial const argument. + block_was_stripped: bool, id: NodeId, span: Span, } |
