Skip to content

Commit 341f12d

Browse files
committed
Properly track the depth when expanding free alias types
1 parent e43d139 commit 341f12d

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

compiler/rustc_middle/src/ty/util.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,9 +1052,11 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for FreeAliasTypeExpander<'tcx> {
10521052
}
10531053

10541054
self.depth += 1;
1055-
ensure_sufficient_stack(|| {
1055+
let ty = ensure_sufficient_stack(|| {
10561056
self.tcx.type_of(alias.def_id).instantiate(self.tcx, alias.args).fold_with(self)
1057-
})
1057+
});
1058+
self.depth -= 1;
1059+
ty
10581060
}
10591061

10601062
fn fold_const(&mut self, ct: ty::Const<'tcx>) -> ty::Const<'tcx> {
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// In several type analysis passes we employ a specialized expansion procedure.
2+
// This procedure used to incorrectly track expansion depth (growing much faster
3+
// than normalization depth) resulting in its internal assertion triggering.
4+
//
5+
// issue: <https://github.com/rust-lang/rust/issues/142419>
6+
//@ check-pass
7+
#![feature(lazy_type_alias)]
8+
#![expect(incomplete_features)]
9+
10+
type T0 = (T1, T1, T1, T1);
11+
type T1 = (T2, T2, T2, T2);
12+
type T2 = (T3, T3, T3, T3);
13+
type T3 = (T4, T4, T4, T4);
14+
type T4 = (T5, T5, T5, T5);
15+
type T5 = (T6, T6, T6, T6);
16+
type T6 = (T7, T7, T7, T7);
17+
type T7 = ();
18+
19+
fn accept(_: T0) {}
20+
fn main() {}

0 commit comments

Comments
 (0)