1
Fork 0

Give items related to issue 33140 a more meaningful name

This commit is contained in:
León Orell Valerian Liehr 2024-04-25 01:58:41 +02:00
parent 20aa2d81e3
commit 9e739b723b
No known key found for this signature in database
GPG key ID: D17A07215F68E713
6 changed files with 49 additions and 46 deletions

View file

@ -847,8 +847,10 @@ rustc_queries! {
separate_provide_extern
}
query issue33140_self_ty(key: DefId) -> Option<ty::EarlyBinder<ty::Ty<'tcx>>> {
desc { |tcx| "computing Self type wrt issue #33140 `{}`", tcx.def_path_str(key) }
query self_ty_of_trait_impl_enabling_order_dep_trait_object_hack(
key: DefId
) -> Option<ty::EarlyBinder<ty::Ty<'tcx>>> {
desc { |tcx| "computing self type wrt issue #33140 `{}`", tcx.def_path_str(key) }
}
/// Maps a `DefId` of a type to a list of its inherent impls.

View file

@ -1503,14 +1503,14 @@ pub enum ImplOverlapKind {
/// Whether or not the impl is permitted due to the trait being a `#[marker]` trait
marker: bool,
},
/// These impls are allowed to overlap, but that raises
/// an issue #33140 future-compatibility warning.
/// These impls are allowed to overlap, but that raises an
/// issue #33140 future-compatibility warning (tracked in #56484).
///
/// Some background: in Rust 1.0, the trait-object types `Send + Sync` (today's
/// `dyn Send + Sync`) and `Sync + Send` (now `dyn Sync + Send`) were different.
///
/// The widely-used version 0.1.0 of the crate `traitobject` had accidentally relied
/// that difference, making what reduces to the following set of impls:
/// The widely-used version 0.1.0 of the crate `traitobject` had accidentally relied on
/// that difference, doing what reduces to the following set of impls:
///
/// ```compile_fail,(E0119)
/// trait Trait {}
@ -1535,7 +1535,7 @@ pub enum ImplOverlapKind {
/// 4. Neither of the impls can have any where-clauses.
///
/// Once `traitobject` 0.1.0 is no longer an active concern, this hack can be removed.
Issue33140,
FutureCompatOrderDepTraitObjects,
}
/// Useful source information about where a desugared associated type for an
@ -1730,27 +1730,26 @@ impl<'tcx> TyCtxt<'tcx> {
| (ImplPolarity::Negative, ImplPolarity::Negative) => {}
};
let is_marker_overlap = {
let is_marker_impl =
|trait_ref: TraitRef<'_>| -> bool { self.trait_def(trait_ref.def_id).is_marker };
is_marker_impl(trait_ref1) && is_marker_impl(trait_ref2)
};
let is_marker_impl = |trait_ref: TraitRef<'_>| self.trait_def(trait_ref.def_id).is_marker;
let is_marker_overlap = is_marker_impl(trait_ref1) && is_marker_impl(trait_ref2);
if is_marker_overlap {
Some(ImplOverlapKind::Permitted { marker: true })
} else {
if let Some(self_ty1) = self.issue33140_self_ty(def_id1) {
if let Some(self_ty2) = self.issue33140_self_ty(def_id2) {
if self_ty1 == self_ty2 {
return Some(ImplOverlapKind::Issue33140);
} else {
debug!("found {self_ty1:?} != {self_ty2:?}");
}
}
}
None
return Some(ImplOverlapKind::Permitted { marker: true });
}
if let Some(self_ty1) =
self.self_ty_of_trait_impl_enabling_order_dep_trait_object_hack(def_id1)
&& let Some(self_ty2) =
self.self_ty_of_trait_impl_enabling_order_dep_trait_object_hack(def_id2)
{
if self_ty1 == self_ty2 {
return Some(ImplOverlapKind::FutureCompatOrderDepTraitObjects);
} else {
debug!("found {self_ty1:?} != {self_ty2:?}");
}
}
None
}
/// Returns `ty::VariantDef` if `res` refers to a struct,