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_ast_lowering/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_ast_lowering/src/lib.rs')
| -rw-r--r-- | compiler/rustc_ast_lowering/src/lib.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index d13e26d2510..3f48fe67dbb 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -2466,7 +2466,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { /// See [`hir::ConstArg`] for when to use this function vs /// [`Self::lower_anon_const_to_const_arg`]. fn lower_anon_const_to_anon_const(&mut self, c: &AnonConst) -> &'hir hir::AnonConst { - if c.value.is_potential_trivial_const_arg() { + if c.value.is_potential_trivial_const_arg(true) { // HACK(min_generic_const_args): see DefCollector::visit_anon_const // Over there, we guess if this is a bare param and only create a def if // we think it's not. However we may can guess wrong (see there for example) |
