1
Fork 0

Stop calling impl_polarity when impl_trait_ref was also called

This commit is contained in:
Oli Scherer 2024-02-10 22:27:03 +00:00
parent ab0e8b3145
commit b43fbe63e7
12 changed files with 96 additions and 77 deletions

View file

@ -257,14 +257,15 @@ fn param_env_reveal_all_normalized(tcx: TyCtxt<'_>, def_id: DefId) -> ty::ParamE
fn issue33140_self_ty(tcx: TyCtxt<'_>, def_id: DefId) -> Option<EarlyBinder<Ty<'_>>> {
debug!("issue33140_self_ty({:?})", def_id);
let trait_ref = tcx
.impl_trait_ref(def_id)
let impl_ = tcx
.impl_trait_header(def_id)
.unwrap_or_else(|| bug!("issue33140_self_ty called on inherent impl {:?}", def_id))
.skip_binder();
let trait_ref = impl_.trait_ref;
debug!("issue33140_self_ty({:?}), trait-ref={:?}", def_id, trait_ref);
let is_marker_like = tcx.impl_polarity(def_id) == ty::ImplPolarity::Positive
let is_marker_like = impl_.polarity == ty::ImplPolarity::Positive
&& tcx.associated_item_def_ids(trait_ref.def_id).is_empty();
// Check whether these impls would be ok for a marker trait.