diff --git a/compiler/rustc_borrowck/src/type_check/relate_tys.rs b/compiler/rustc_borrowck/src/type_check/relate_tys.rs index ea4a94e57b3..8da4d80badf 100644 --- a/compiler/rustc_borrowck/src/type_check/relate_tys.rs +++ b/compiler/rustc_borrowck/src/type_check/relate_tys.rs @@ -313,10 +313,6 @@ fn cx(&self) -> TyCtxt<'tcx> { self.type_checker.infcx.tcx } - fn tag(&self) -> &'static str { - "nll::subtype" - } - #[instrument(skip(self, info), level = "trace", ret)] fn relate_with_variance>>( &mut self, diff --git a/compiler/rustc_infer/src/error_reporting/infer/mod.rs b/compiler/rustc_infer/src/error_reporting/infer/mod.rs index a4af721cf75..1401d16108a 100644 --- a/compiler/rustc_infer/src/error_reporting/infer/mod.rs +++ b/compiler/rustc_infer/src/error_reporting/infer/mod.rs @@ -1934,10 +1934,6 @@ fn cx(&self) -> TyCtxt<'tcx> { self.0.tcx } - fn tag(&self) -> &'static str { - "SameTypeModuloInfer" - } - fn relate_with_variance>>( &mut self, _variance: ty::Variance, diff --git a/compiler/rustc_infer/src/infer/outlives/test_type_match.rs b/compiler/rustc_infer/src/infer/outlives/test_type_match.rs index d60d9113d91..c63eeaf812c 100644 --- a/compiler/rustc_infer/src/infer/outlives/test_type_match.rs +++ b/compiler/rustc_infer/src/infer/outlives/test_type_match.rs @@ -110,7 +110,7 @@ fn no_match(&self) -> RelateResult<'tcx, T> { /// Binds the pattern variable `br` to `value`; returns an `Err` if the pattern /// is already bound to a different value. - #[instrument(level = "debug", skip(self))] + #[instrument(level = "trace", skip(self))] fn bind( &mut self, br: ty::BoundRegion, @@ -133,10 +133,6 @@ fn bind( } impl<'tcx> TypeRelation> for MatchAgainstHigherRankedOutlives<'tcx> { - fn tag(&self) -> &'static str { - "MatchAgainstHigherRankedOutlives" - } - fn cx(&self) -> TyCtxt<'tcx> { self.tcx } @@ -154,13 +150,12 @@ fn relate_with_variance>>( if variance != ty::Bivariant { self.relate(a, b) } else { Ok(a) } } - #[instrument(skip(self), level = "debug")] + #[instrument(skip(self), level = "trace")] fn regions( &mut self, pattern: ty::Region<'tcx>, value: ty::Region<'tcx>, ) -> RelateResult<'tcx, ty::Region<'tcx>> { - debug!("self.pattern_depth = {:?}", self.pattern_depth); if let ty::RegionKind::ReBound(depth, br) = pattern.kind() && depth == self.pattern_depth { @@ -172,7 +167,7 @@ fn regions( } } - #[instrument(skip(self), level = "debug")] + #[instrument(skip(self), level = "trace")] fn tys(&mut self, pattern: Ty<'tcx>, value: Ty<'tcx>) -> RelateResult<'tcx, Ty<'tcx>> { // FIXME(non_lifetime_binders): What to do here? if matches!(pattern.kind(), ty::Error(_) | ty::Bound(..)) { @@ -185,13 +180,12 @@ fn tys(&mut self, pattern: Ty<'tcx>, value: Ty<'tcx>) -> RelateResult<'tcx, Ty<' } } - #[instrument(skip(self), level = "debug")] + #[instrument(skip(self), level = "trace")] fn consts( &mut self, pattern: ty::Const<'tcx>, value: ty::Const<'tcx>, ) -> RelateResult<'tcx, ty::Const<'tcx>> { - debug!("{}.consts({:?}, {:?})", self.tag(), pattern, value); if pattern == value { Ok(pattern) } else { @@ -199,6 +193,7 @@ fn consts( } } + #[instrument(skip(self), level = "trace")] fn binders( &mut self, pattern: ty::Binder<'tcx, T>, diff --git a/compiler/rustc_infer/src/infer/relate/combine.rs b/compiler/rustc_infer/src/infer/relate/combine.rs index c93b89756f9..1dc03de4c8b 100644 --- a/compiler/rustc_infer/src/infer/relate/combine.rs +++ b/compiler/rustc_infer/src/infer/relate/combine.rs @@ -79,6 +79,7 @@ pub fn super_combine_tys( where R: PredicateEmittingRelation>, { + debug!("super_combine_tys::<{}>({:?}, {:?})", std::any::type_name::(), a, b); debug_assert!(!a.has_escaping_bound_vars()); debug_assert!(!b.has_escaping_bound_vars()); @@ -174,9 +175,10 @@ pub fn super_combine_consts( where R: PredicateEmittingRelation>, { - debug!("{}.consts({:?}, {:?})", relation.tag(), a, b); + debug!("super_combine_consts::<{}>({:?}, {:?})", std::any::type_name::(), a, b); debug_assert!(!a.has_escaping_bound_vars()); debug_assert!(!b.has_escaping_bound_vars()); + if a == b { return Ok(a); } diff --git a/compiler/rustc_infer/src/infer/relate/generalize.rs b/compiler/rustc_infer/src/infer/relate/generalize.rs index ace439545b8..30cfbcae6b2 100644 --- a/compiler/rustc_infer/src/infer/relate/generalize.rs +++ b/compiler/rustc_infer/src/infer/relate/generalize.rs @@ -401,10 +401,6 @@ fn cx(&self) -> TyCtxt<'tcx> { self.infcx.tcx } - fn tag(&self) -> &'static str { - "Generalizer" - } - fn relate_item_args( &mut self, item_def_id: DefId, diff --git a/compiler/rustc_infer/src/infer/relate/glb.rs b/compiler/rustc_infer/src/infer/relate/glb.rs index 819a47fcf93..4f2cf2c43e7 100644 --- a/compiler/rustc_infer/src/infer/relate/glb.rs +++ b/compiler/rustc_infer/src/infer/relate/glb.rs @@ -23,10 +23,6 @@ pub fn new(fields: &'combine mut CombineFields<'infcx, 'tcx>) -> Glb<'combine, ' } impl<'tcx> TypeRelation> for Glb<'_, '_, 'tcx> { - fn tag(&self) -> &'static str { - "Glb" - } - fn cx(&self) -> TyCtxt<'tcx> { self.fields.tcx() } @@ -47,17 +43,17 @@ fn relate_with_variance>>( } } + #[instrument(skip(self), level = "trace")] fn tys(&mut self, a: Ty<'tcx>, b: Ty<'tcx>) -> RelateResult<'tcx, Ty<'tcx>> { lattice::super_lattice_tys(self, a, b) } + #[instrument(skip(self), level = "trace")] fn regions( &mut self, a: ty::Region<'tcx>, b: ty::Region<'tcx>, ) -> RelateResult<'tcx, ty::Region<'tcx>> { - debug!("{}.regions({:?}, {:?})", self.tag(), a, b); - let origin = SubregionOrigin::Subtype(Box::new(self.fields.trace.clone())); // GLB(&'static u8, &'a u8) == &RegionLUB('static, 'a) u8 == &'static u8 Ok(self.fields.infcx.inner.borrow_mut().unwrap_region_constraints().lub_regions( @@ -68,6 +64,7 @@ fn regions( )) } + #[instrument(skip(self), level = "trace")] fn consts( &mut self, a: ty::Const<'tcx>, diff --git a/compiler/rustc_infer/src/infer/relate/lattice.rs b/compiler/rustc_infer/src/infer/relate/lattice.rs index 46e7466141a..d1d87071562 100644 --- a/compiler/rustc_infer/src/infer/relate/lattice.rs +++ b/compiler/rustc_infer/src/infer/relate/lattice.rs @@ -56,8 +56,6 @@ pub fn super_lattice_tys<'a, 'tcx: 'a, L>( where L: LatticeDir<'a, 'tcx>, { - debug!("{}", this.tag()); - if a == b { return Ok(a); } diff --git a/compiler/rustc_infer/src/infer/relate/lub.rs b/compiler/rustc_infer/src/infer/relate/lub.rs index 56d325c5dc1..2eb20f311cf 100644 --- a/compiler/rustc_infer/src/infer/relate/lub.rs +++ b/compiler/rustc_infer/src/infer/relate/lub.rs @@ -23,10 +23,6 @@ pub fn new(fields: &'combine mut CombineFields<'infcx, 'tcx>) -> Lub<'combine, ' } impl<'tcx> TypeRelation> for Lub<'_, '_, 'tcx> { - fn tag(&self) -> &'static str { - "Lub" - } - fn cx(&self) -> TyCtxt<'tcx> { self.fields.tcx() } @@ -51,13 +47,12 @@ fn tys(&mut self, a: Ty<'tcx>, b: Ty<'tcx>) -> RelateResult<'tcx, Ty<'tcx>> { lattice::super_lattice_tys(self, a, b) } + #[instrument(skip(self), level = "trace")] fn regions( &mut self, a: ty::Region<'tcx>, b: ty::Region<'tcx>, ) -> RelateResult<'tcx, ty::Region<'tcx>> { - debug!("{}.regions({:?}, {:?})", self.tag(), a, b); - let origin = SubregionOrigin::Subtype(Box::new(self.fields.trace.clone())); // LUB(&'static u8, &'a u8) == &RegionGLB('static, 'a) u8 == &'a u8 Ok(self.fields.infcx.inner.borrow_mut().unwrap_region_constraints().glb_regions( @@ -68,6 +63,7 @@ fn regions( )) } + #[instrument(skip(self), level = "trace")] fn consts( &mut self, a: ty::Const<'tcx>, diff --git a/compiler/rustc_infer/src/infer/relate/type_relating.rs b/compiler/rustc_infer/src/infer/relate/type_relating.rs index 97bd858defb..3fe35354286 100644 --- a/compiler/rustc_infer/src/infer/relate/type_relating.rs +++ b/compiler/rustc_infer/src/infer/relate/type_relating.rs @@ -28,10 +28,6 @@ pub fn new( } impl<'tcx> TypeRelation> for TypeRelating<'_, '_, 'tcx> { - fn tag(&self) -> &'static str { - "TypeRelating" - } - fn cx(&self) -> TyCtxt<'tcx> { self.fields.infcx.tcx } @@ -71,7 +67,7 @@ fn relate_with_variance>>( r } - #[instrument(skip(self), level = "debug")] + #[instrument(skip(self), level = "trace")] fn tys(&mut self, a: Ty<'tcx>, b: Ty<'tcx>) -> RelateResult<'tcx, Ty<'tcx>> { if a == b { return Ok(a); @@ -166,12 +162,12 @@ fn tys(&mut self, a: Ty<'tcx>, b: Ty<'tcx>) -> RelateResult<'tcx, Ty<'tcx>> { Ok(a) } + #[instrument(skip(self), level = "trace")] fn regions( &mut self, a: ty::Region<'tcx>, b: ty::Region<'tcx>, ) -> RelateResult<'tcx, ty::Region<'tcx>> { - debug!("{}.regions({:?}, {:?})", self.tag(), a, b); let origin = SubregionOrigin::Subtype(Box::new(self.fields.trace.clone())); match self.ambient_variance { @@ -209,6 +205,7 @@ fn regions( Ok(a) } + #[instrument(skip(self), level = "trace")] fn consts( &mut self, a: ty::Const<'tcx>, diff --git a/compiler/rustc_trait_selection/src/traits/select/_match.rs b/compiler/rustc_trait_selection/src/traits/select/_match.rs index 8676f30a53b..7ead65721f9 100644 --- a/compiler/rustc_trait_selection/src/traits/select/_match.rs +++ b/compiler/rustc_trait_selection/src/traits/select/_match.rs @@ -3,7 +3,7 @@ }; use rustc_middle::ty::error::{ExpectedFound, TypeError}; use rustc_middle::ty::{self, InferConst, Ty, TyCtxt}; -use tracing::{debug, instrument}; +use tracing::instrument; /// A type "A" *matches* "B" if the fresh types in B could be /// instantiated with values so as to make it equal to A. Matching is @@ -32,10 +32,6 @@ pub fn new(tcx: TyCtxt<'tcx>) -> MatchAgainstFreshVars<'tcx> { } impl<'tcx> TypeRelation> for MatchAgainstFreshVars<'tcx> { - fn tag(&self) -> &'static str { - "MatchAgainstFreshVars" - } - fn cx(&self) -> TyCtxt<'tcx> { self.tcx } @@ -50,7 +46,7 @@ fn relate_with_variance>>( self.relate(a, b) } - #[instrument(skip(self), level = "debug")] + #[instrument(skip(self), level = "trace")] fn regions( &mut self, a: ty::Region<'tcx>, @@ -59,7 +55,7 @@ fn regions( Ok(a) } - #[instrument(skip(self), level = "debug")] + #[instrument(skip(self), level = "trace")] fn tys(&mut self, a: Ty<'tcx>, b: Ty<'tcx>) -> RelateResult<'tcx, Ty<'tcx>> { if a == b { return Ok(a); @@ -83,12 +79,12 @@ fn tys(&mut self, a: Ty<'tcx>, b: Ty<'tcx>) -> RelateResult<'tcx, Ty<'tcx>> { } } + #[instrument(skip(self), level = "trace")] fn consts( &mut self, a: ty::Const<'tcx>, b: ty::Const<'tcx>, ) -> RelateResult<'tcx, ty::Const<'tcx>> { - debug!("{}.consts({:?}, {:?})", self.tag(), a, b); if a == b { return Ok(a); } diff --git a/compiler/rustc_type_ir/src/relate.rs b/compiler/rustc_type_ir/src/relate.rs index a8f48d14af5..ae840ec0210 100644 --- a/compiler/rustc_type_ir/src/relate.rs +++ b/compiler/rustc_type_ir/src/relate.rs @@ -1,7 +1,7 @@ use std::iter; use rustc_ast_ir::Mutability; -use tracing::{debug, instrument}; +use tracing::{instrument, trace}; use crate::error::{ExpectedFound, TypeError}; use crate::fold::TypeFoldable; @@ -58,9 +58,6 @@ pub fn xform(self, other: VarianceDiagInfo) -> VarianceDiagInfo { pub trait TypeRelation: Sized { fn cx(&self) -> I; - /// Returns a static string we can use for printouts. - fn tag(&self) -> &'static str; - /// Generic relation routine suitable for most anything. fn relate>(&mut self, a: T, b: T) -> RelateResult { Relate::relate(self, a, b) @@ -69,17 +66,13 @@ fn relate>(&mut self, a: T, b: T) -> RelateResult { /// Relate the two args for the given item. The default /// is to look up the variance for the item and proceed /// accordingly. + #[instrument(skip(self), level = "trace")] fn relate_item_args( &mut self, item_def_id: I::DefId, a_arg: I::GenericArgs, b_arg: I::GenericArgs, ) -> RelateResult { - debug!( - "relate_item_args(item_def_id={:?}, a_arg={:?}, b_arg={:?})", - item_def_id, a_arg, b_arg - ); - let cx = self.cx(); let opt_variances = cx.variances_of(item_def_id); relate_args_with_variances(self, item_def_id, opt_variances, a_arg, b_arg, true) @@ -571,7 +564,12 @@ pub fn structurally_relate_consts>( mut a: I::Const, mut b: I::Const, ) -> RelateResult { - debug!("{}.structurally_relate_consts(a = {:?}, b = {:?})", relation.tag(), a, b); + trace!( + "structurally_relate_consts::<{}>(a = {:?}, b = {:?})", + std::any::type_name::(), + a, + b + ); let cx = relation.cx(); if cx.features().generic_const_exprs() { @@ -579,7 +577,12 @@ pub fn structurally_relate_consts>( b = cx.expand_abstract_consts(b); } - debug!("{}.structurally_relate_consts(normed_a = {:?}, normed_b = {:?})", relation.tag(), a, b); + trace!( + "structurally_relate_consts::<{}>(normed_a = {:?}, normed_b = {:?})", + std::any::type_name::(), + a, + b + ); // Currently, the values that can be unified are primitive types, // and those that derive both `PartialEq` and `Eq`, corresponding