Remove tag field from relations
This commit is contained in:
parent
5753b30676
commit
8dbb63a585
@ -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<T: Relate<TyCtxt<'tcx>>>(
|
||||
&mut self,
|
||||
|
@ -1934,10 +1934,6 @@ fn cx(&self) -> TyCtxt<'tcx> {
|
||||
self.0.tcx
|
||||
}
|
||||
|
||||
fn tag(&self) -> &'static str {
|
||||
"SameTypeModuloInfer"
|
||||
}
|
||||
|
||||
fn relate_with_variance<T: relate::Relate<TyCtxt<'tcx>>>(
|
||||
&mut self,
|
||||
_variance: ty::Variance,
|
||||
|
@ -110,7 +110,7 @@ fn no_match<T>(&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<TyCtxt<'tcx>> for MatchAgainstHigherRankedOutlives<'tcx> {
|
||||
fn tag(&self) -> &'static str {
|
||||
"MatchAgainstHigherRankedOutlives"
|
||||
}
|
||||
|
||||
fn cx(&self) -> TyCtxt<'tcx> {
|
||||
self.tcx
|
||||
}
|
||||
@ -154,13 +150,12 @@ fn relate_with_variance<T: Relate<TyCtxt<'tcx>>>(
|
||||
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<T>(
|
||||
&mut self,
|
||||
pattern: ty::Binder<'tcx, T>,
|
||||
|
@ -79,6 +79,7 @@ pub fn super_combine_tys<R>(
|
||||
where
|
||||
R: PredicateEmittingRelation<InferCtxt<'tcx>>,
|
||||
{
|
||||
debug!("super_combine_tys::<{}>({:?}, {:?})", std::any::type_name::<R>(), 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<R>(
|
||||
where
|
||||
R: PredicateEmittingRelation<InferCtxt<'tcx>>,
|
||||
{
|
||||
debug!("{}.consts({:?}, {:?})", relation.tag(), a, b);
|
||||
debug!("super_combine_consts::<{}>({:?}, {:?})", std::any::type_name::<R>(), a, b);
|
||||
debug_assert!(!a.has_escaping_bound_vars());
|
||||
debug_assert!(!b.has_escaping_bound_vars());
|
||||
|
||||
if a == b {
|
||||
return Ok(a);
|
||||
}
|
||||
|
@ -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,
|
||||
|
@ -23,10 +23,6 @@ pub fn new(fields: &'combine mut CombineFields<'infcx, 'tcx>) -> Glb<'combine, '
|
||||
}
|
||||
|
||||
impl<'tcx> TypeRelation<TyCtxt<'tcx>> 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<T: Relate<TyCtxt<'tcx>>>(
|
||||
}
|
||||
}
|
||||
|
||||
#[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>,
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -23,10 +23,6 @@ pub fn new(fields: &'combine mut CombineFields<'infcx, 'tcx>) -> Lub<'combine, '
|
||||
}
|
||||
|
||||
impl<'tcx> TypeRelation<TyCtxt<'tcx>> 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>,
|
||||
|
@ -28,10 +28,6 @@ pub fn new(
|
||||
}
|
||||
|
||||
impl<'tcx> TypeRelation<TyCtxt<'tcx>> 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<T: Relate<TyCtxt<'tcx>>>(
|
||||
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>,
|
||||
|
@ -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<TyCtxt<'tcx>> for MatchAgainstFreshVars<'tcx> {
|
||||
fn tag(&self) -> &'static str {
|
||||
"MatchAgainstFreshVars"
|
||||
}
|
||||
|
||||
fn cx(&self) -> TyCtxt<'tcx> {
|
||||
self.tcx
|
||||
}
|
||||
@ -50,7 +46,7 @@ fn relate_with_variance<T: Relate<TyCtxt<'tcx>>>(
|
||||
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);
|
||||
}
|
||||
|
@ -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<I>) -> VarianceDiagInfo<I> {
|
||||
pub trait TypeRelation<I: Interner>: 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<T: Relate<I>>(&mut self, a: T, b: T) -> RelateResult<I, T> {
|
||||
Relate::relate(self, a, b)
|
||||
@ -69,17 +66,13 @@ fn relate<T: Relate<I>>(&mut self, a: T, b: T) -> RelateResult<I, T> {
|
||||
/// 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<I, I::GenericArgs> {
|
||||
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<I: Interner, R: TypeRelation<I>>(
|
||||
mut a: I::Const,
|
||||
mut b: I::Const,
|
||||
) -> RelateResult<I, I::Const> {
|
||||
debug!("{}.structurally_relate_consts(a = {:?}, b = {:?})", relation.tag(), a, b);
|
||||
trace!(
|
||||
"structurally_relate_consts::<{}>(a = {:?}, b = {:?})",
|
||||
std::any::type_name::<R>(),
|
||||
a,
|
||||
b
|
||||
);
|
||||
let cx = relation.cx();
|
||||
|
||||
if cx.features().generic_const_exprs() {
|
||||
@ -579,7 +577,12 @@ pub fn structurally_relate_consts<I: Interner, R: TypeRelation<I>>(
|
||||
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::<R>(),
|
||||
a,
|
||||
b
|
||||
);
|
||||
|
||||
// Currently, the values that can be unified are primitive types,
|
||||
// and those that derive both `PartialEq` and `Eq`, corresponding
|
||||
|
Loading…
Reference in New Issue
Block a user