Auto merge of #100989 - lcnr:implied-bounds-uwu, r=spastorino

no unnormalized types for implied bounds outside borrowck

fixes #100910 - introduced in https://github.com/rust-lang/rust/pull/100676 - by only considering normalized types for wf.

r? types
This commit is contained in:
bors 2022-08-27 11:37:06 +00:00
commit 3b3f3b72c5
3 changed files with 60 additions and 1 deletions

View file

@ -124,7 +124,18 @@ impl<'a, 'tcx> ObligationCtxt<'a, 'tcx> {
let hir_id = tcx.hir().local_def_id_to_hir_id(def_id);
let cause = ObligationCause::misc(span, hir_id);
for ty in assumed_wf_types {
implied_bounds.insert(ty);
// FIXME(@lcnr): rustc currently does not check wf for types
// pre-normalization, meaning that implied bounds are sometimes
// incorrect. See #100910 for more details.
//
// Not adding the unnormalized types here mostly fixes that, except
// that there are projections which are still ambiguous in the item definition
// but do normalize successfully when using the item, see #98543.
//
// Anyways, I will hopefully soon change implied bounds to make all of this
// sound and then uncomment this line again.
// implied_bounds.insert(ty);
let normalized = self.normalize(cause.clone(), param_env, ty);
implied_bounds.insert(normalized);
}