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`
This commit is contained in:
@@ -4546,7 +4546,7 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
|
||||
);
|
||||
|
||||
self.resolve_anon_const_manual(
|
||||
constant.value.is_potential_trivial_const_arg(),
|
||||
constant.value.is_potential_trivial_const_arg(true),
|
||||
anon_const_kind,
|
||||
|this| this.resolve_expr(&constant.value, None),
|
||||
)
|
||||
@@ -4710,7 +4710,7 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
|
||||
// that is how they will be later lowered to HIR.
|
||||
if const_args.contains(&idx) {
|
||||
self.resolve_anon_const_manual(
|
||||
argument.is_potential_trivial_const_arg(),
|
||||
argument.is_potential_trivial_const_arg(true),
|
||||
AnonConstKind::ConstArg(IsRepeatExpr::No),
|
||||
|this| this.resolve_expr(argument, None),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user