Give items related to issue 33140 a more meaningful name
This commit is contained in:
parent
20aa2d81e3
commit
9e739b723b
6 changed files with 49 additions and 46 deletions
|
@ -243,37 +243,39 @@ fn param_env_reveal_all_normalized(tcx: TyCtxt<'_>, def_id: DefId) -> ty::ParamE
|
|||
tcx.param_env(def_id).with_reveal_all_normalized(tcx)
|
||||
}
|
||||
|
||||
/// If `def_id` is an issue 33140 hack impl, returns its self type; otherwise, returns `None`.
|
||||
/// If the given trait impl enables exploiting the former order dependence of trait objects,
|
||||
/// returns its self type; otherwise, returns `None`.
|
||||
///
|
||||
/// See [`ty::ImplOverlapKind::Issue33140`] for more details.
|
||||
fn issue33140_self_ty(tcx: TyCtxt<'_>, def_id: DefId) -> Option<EarlyBinder<Ty<'_>>> {
|
||||
debug!("issue33140_self_ty({:?})", def_id);
|
||||
|
||||
let impl_ = tcx
|
||||
.impl_trait_header(def_id)
|
||||
.unwrap_or_else(|| bug!("issue33140_self_ty called on inherent impl {:?}", def_id));
|
||||
/// See [`ty::ImplOverlapKind::FutureCompatOrderDepTraitObjects`] for more details.
|
||||
#[instrument(level = "debug", skip(tcx))]
|
||||
fn self_ty_of_trait_impl_enabling_order_dep_trait_object_hack(
|
||||
tcx: TyCtxt<'_>,
|
||||
def_id: DefId,
|
||||
) -> Option<EarlyBinder<Ty<'_>>> {
|
||||
let impl_ =
|
||||
tcx.impl_trait_header(def_id).unwrap_or_else(|| bug!("called on inherent impl {def_id:?}"));
|
||||
|
||||
let trait_ref = impl_.trait_ref.skip_binder();
|
||||
debug!("issue33140_self_ty({:?}), trait-ref={:?}", def_id, trait_ref);
|
||||
debug!(?trait_ref);
|
||||
|
||||
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.
|
||||
if !is_marker_like {
|
||||
debug!("issue33140_self_ty - not marker-like!");
|
||||
debug!("not marker-like!");
|
||||
return None;
|
||||
}
|
||||
|
||||
// impl must be `impl Trait for dyn Marker1 + Marker2 + ...`
|
||||
if trait_ref.args.len() != 1 {
|
||||
debug!("issue33140_self_ty - impl has args!");
|
||||
debug!("impl has args!");
|
||||
return None;
|
||||
}
|
||||
|
||||
let predicates = tcx.predicates_of(def_id);
|
||||
if predicates.parent.is_some() || !predicates.predicates.is_empty() {
|
||||
debug!("issue33140_self_ty - impl has predicates {:?}!", predicates);
|
||||
debug!(?predicates, "impl has predicates!");
|
||||
return None;
|
||||
}
|
||||
|
||||
|
@ -284,10 +286,10 @@ fn issue33140_self_ty(tcx: TyCtxt<'_>, def_id: DefId) -> Option<EarlyBinder<Ty<'
|
|||
};
|
||||
|
||||
if self_ty_matches {
|
||||
debug!("issue33140_self_ty - MATCHES!");
|
||||
debug!("MATCHES!");
|
||||
Some(EarlyBinder::bind(self_ty))
|
||||
} else {
|
||||
debug!("issue33140_self_ty - non-matching self type");
|
||||
debug!("non-matching self type");
|
||||
None
|
||||
}
|
||||
}
|
||||
|
@ -351,7 +353,7 @@ pub(crate) fn provide(providers: &mut Providers) {
|
|||
adt_sized_constraint,
|
||||
param_env,
|
||||
param_env_reveal_all_normalized,
|
||||
issue33140_self_ty,
|
||||
self_ty_of_trait_impl_enabling_order_dep_trait_object_hack,
|
||||
defaultness,
|
||||
unsizing_params_for_adt,
|
||||
..*providers
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue