Skip to content

Commit 68f2f1e

Browse files
authored
Rollup merge of #112777 - compiler-errors:normalize-weak-more, r=oli-obk
Continue folding in query normalizer on weak aliases Fixes #112752 Fixes #112731 (same root cause, so didn't make a test for it) fixes #112776 r? ```@oli-obk```
2 parents 6de869f + 493b18b commit 68f2f1e

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

compiler/rustc_trait_selection/src/traits/query/normalize.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,12 @@ impl<'cx, 'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for QueryNormalizer<'cx, 'tcx>
322322
};
323323
// `tcx.normalize_projection_ty` may normalize to a type that still has
324324
// unevaluated consts, so keep normalizing here if that's the case.
325-
if res != ty && res.has_type_flags(ty::TypeFlags::HAS_CT_PROJECTION) {
326-
res.try_super_fold_with(self)?
325+
// Similarly, `tcx.normalize_weak_ty` will only unwrap one layer of type
326+
// and we need to continue folding it to reveal the TAIT behind it.
327+
if res != ty
328+
&& (res.has_type_flags(ty::TypeFlags::HAS_CT_PROJECTION) || kind == ty::Weak)
329+
{
330+
res.try_fold_with(self)?
327331
} else {
328332
res
329333
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// compile-flags: --crate-type=lib -Cdebuginfo=2
2+
// build-pass
3+
4+
#![feature(type_alias_impl_trait)]
5+
6+
type Debuggable = impl core::fmt::Debug;
7+
8+
static mut TEST: Option<Debuggable> = None;
9+
10+
fn foo() -> Debuggable {
11+
0u32
12+
}

0 commit comments

Comments
 (0)