Some tracing/instrument cleanups
This commit is contained in:
parent
0c13565ca6
commit
9e27c6c133
@ -2279,6 +2279,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
|
|
||||||
/// Returns `true` if the impls are the same polarity and the trait either
|
/// Returns `true` if the impls are the same polarity and the trait either
|
||||||
/// has no items or is annotated `#[marker]` and prevents item overrides.
|
/// has no items or is annotated `#[marker]` and prevents item overrides.
|
||||||
|
#[instrument(level = "debug", skip(self), ret)]
|
||||||
pub fn impls_are_allowed_to_overlap(
|
pub fn impls_are_allowed_to_overlap(
|
||||||
self,
|
self,
|
||||||
def_id1: DefId,
|
def_id1: DefId,
|
||||||
@ -2297,19 +2298,11 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
match (self.impl_polarity(def_id1), self.impl_polarity(def_id2)) {
|
match (self.impl_polarity(def_id1), self.impl_polarity(def_id2)) {
|
||||||
(ImplPolarity::Reservation, _) | (_, ImplPolarity::Reservation) => {
|
(ImplPolarity::Reservation, _) | (_, ImplPolarity::Reservation) => {
|
||||||
// `#[rustc_reservation_impl]` impls don't overlap with anything
|
// `#[rustc_reservation_impl]` impls don't overlap with anything
|
||||||
debug!(
|
|
||||||
"impls_are_allowed_to_overlap({:?}, {:?}) = Some(Permitted) (reservations)",
|
|
||||||
def_id1, def_id2
|
|
||||||
);
|
|
||||||
return Some(ImplOverlapKind::Permitted { marker: false });
|
return Some(ImplOverlapKind::Permitted { marker: false });
|
||||||
}
|
}
|
||||||
(ImplPolarity::Positive, ImplPolarity::Negative)
|
(ImplPolarity::Positive, ImplPolarity::Negative)
|
||||||
| (ImplPolarity::Negative, ImplPolarity::Positive) => {
|
| (ImplPolarity::Negative, ImplPolarity::Positive) => {
|
||||||
// `impl AutoTrait for Type` + `impl !AutoTrait for Type`
|
// `impl AutoTrait for Type` + `impl !AutoTrait for Type`
|
||||||
debug!(
|
|
||||||
"impls_are_allowed_to_overlap({:?}, {:?}) - None (differing polarities)",
|
|
||||||
def_id1, def_id2
|
|
||||||
);
|
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
(ImplPolarity::Positive, ImplPolarity::Positive)
|
(ImplPolarity::Positive, ImplPolarity::Positive)
|
||||||
@ -2324,30 +2317,18 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if is_marker_overlap {
|
if is_marker_overlap {
|
||||||
debug!(
|
|
||||||
"impls_are_allowed_to_overlap({:?}, {:?}) = Some(Permitted) (marker overlap)",
|
|
||||||
def_id1, def_id2
|
|
||||||
);
|
|
||||||
Some(ImplOverlapKind::Permitted { marker: true })
|
Some(ImplOverlapKind::Permitted { marker: true })
|
||||||
} else {
|
} else {
|
||||||
if let Some(self_ty1) = self.issue33140_self_ty(def_id1) {
|
if let Some(self_ty1) = self.issue33140_self_ty(def_id1) {
|
||||||
if let Some(self_ty2) = self.issue33140_self_ty(def_id2) {
|
if let Some(self_ty2) = self.issue33140_self_ty(def_id2) {
|
||||||
if self_ty1 == self_ty2 {
|
if self_ty1 == self_ty2 {
|
||||||
debug!(
|
|
||||||
"impls_are_allowed_to_overlap({:?}, {:?}) - issue #33140 HACK",
|
|
||||||
def_id1, def_id2
|
|
||||||
);
|
|
||||||
return Some(ImplOverlapKind::Issue33140);
|
return Some(ImplOverlapKind::Issue33140);
|
||||||
} else {
|
} else {
|
||||||
debug!(
|
debug!("found {self_ty1:?} != {self_ty2:?}");
|
||||||
"impls_are_allowed_to_overlap({:?}, {:?}) - found {:?} != {:?}",
|
|
||||||
def_id1, def_id2, self_ty1, self_ty2
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
debug!("impls_are_allowed_to_overlap({:?}, {:?}) = None", def_id1, def_id2);
|
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ pub struct FutureCompatOverlapError<'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// The result of attempting to insert an impl into a group of children.
|
/// The result of attempting to insert an impl into a group of children.
|
||||||
|
#[derive(Debug)]
|
||||||
enum Inserted<'tcx> {
|
enum Inserted<'tcx> {
|
||||||
/// The impl was inserted as a new child in this group of children.
|
/// The impl was inserted as a new child in this group of children.
|
||||||
BecameNewSibling(Option<FutureCompatOverlapError<'tcx>>),
|
BecameNewSibling(Option<FutureCompatOverlapError<'tcx>>),
|
||||||
@ -82,6 +83,7 @@ impl<'tcx> ChildrenExt<'tcx> for Children {
|
|||||||
|
|
||||||
/// Attempt to insert an impl into this set of children, while comparing for
|
/// Attempt to insert an impl into this set of children, while comparing for
|
||||||
/// specialization relationships.
|
/// specialization relationships.
|
||||||
|
#[instrument(level = "debug", skip(self, tcx), ret)]
|
||||||
fn insert(
|
fn insert(
|
||||||
&mut self,
|
&mut self,
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
@ -92,18 +94,13 @@ impl<'tcx> ChildrenExt<'tcx> for Children {
|
|||||||
let mut last_lint = None;
|
let mut last_lint = None;
|
||||||
let mut replace_children = Vec::new();
|
let mut replace_children = Vec::new();
|
||||||
|
|
||||||
debug!("insert(impl_def_id={:?}, simplified_self={:?})", impl_def_id, simplified_self,);
|
|
||||||
|
|
||||||
let possible_siblings = match simplified_self {
|
let possible_siblings = match simplified_self {
|
||||||
Some(st) => PotentialSiblings::Filtered(filtered_children(self, st)),
|
Some(st) => PotentialSiblings::Filtered(filtered_children(self, st)),
|
||||||
None => PotentialSiblings::Unfiltered(iter_children(self)),
|
None => PotentialSiblings::Unfiltered(iter_children(self)),
|
||||||
};
|
};
|
||||||
|
|
||||||
for possible_sibling in possible_siblings {
|
for possible_sibling in possible_siblings {
|
||||||
debug!(
|
debug!(?possible_sibling);
|
||||||
"insert: impl_def_id={:?}, simplified_self={:?}, possible_sibling={:?}",
|
|
||||||
impl_def_id, simplified_self, possible_sibling,
|
|
||||||
);
|
|
||||||
|
|
||||||
let create_overlap_error = |overlap: traits::coherence::OverlapResult<'tcx>| {
|
let create_overlap_error = |overlap: traits::coherence::OverlapResult<'tcx>| {
|
||||||
let trait_ref = overlap.impl_header.trait_ref.unwrap();
|
let trait_ref = overlap.impl_header.trait_ref.unwrap();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user