Skip to content

Commit

Permalink
Rollup merge of rust-lang#112777 - compiler-errors:normalize-weak-mor…
Browse files Browse the repository at this point in the history
…e, r=oli-obk

Continue folding in query normalizer on weak aliases

Fixes rust-lang#112752
Fixes rust-lang#112731 (same root cause, so didn't make a test for it)
fixes rust-lang#112776

r? `@oli-obk`
  • Loading branch information
jyn514 authored Jun 19, 2023
2 parents 6bf51c8 + 493b18b commit 7fe7a98
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
8 changes: 6 additions & 2 deletions compiler/rustc_trait_selection/src/traits/query/normalize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,12 @@ impl<'cx, 'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for QueryNormalizer<'cx, 'tcx>
};
// `tcx.normalize_projection_ty` may normalize to a type that still has
// unevaluated consts, so keep normalizing here if that's the case.
if res != ty && res.has_type_flags(ty::TypeFlags::HAS_CT_PROJECTION) {
res.try_super_fold_with(self)?
// Similarly, `tcx.normalize_weak_ty` will only unwrap one layer of type
// and we need to continue folding it to reveal the TAIT behind it.
if res != ty
&& (res.has_type_flags(ty::TypeFlags::HAS_CT_PROJECTION) || kind == ty::Weak)
{
res.try_fold_with(self)?
} else {
res
}
Expand Down
12 changes: 12 additions & 0 deletions tests/ui/type-alias-impl-trait/debug-ty-with-weak.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// compile-flags: --crate-type=lib -Cdebuginfo=2
// build-pass

#![feature(type_alias_impl_trait)]

type Debuggable = impl core::fmt::Debug;

static mut TEST: Option<Debuggable> = None;

fn foo() -> Debuggable {
0u32
}

0 comments on commit 7fe7a98

Please sign in to comment.