Skip to content

Commit

Permalink
Remove unnecessary StructurallyRelateAliases from CombineFields/TypeR…
Browse files Browse the repository at this point in the history
…elating
  • Loading branch information
compiler-errors committed Oct 7, 2024
1 parent 1794eec commit e43376a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 21 deletions.
4 changes: 2 additions & 2 deletions compiler/rustc_infer/src/infer/at.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use rustc_middle::bug;
use rustc_middle::ty::{Const, ImplSubject};

use super::*;
use crate::infer::relate::{Relate, StructurallyRelateAliases, TypeRelation};
use crate::infer::relate::{Relate, TypeRelation};
use crate::traits::Obligation;

/// Whether we should define opaque types or just treat them opaquely.
Expand Down Expand Up @@ -168,7 +168,7 @@ impl<'a, 'tcx> At<'a, 'tcx> {
T: Relate<TyCtxt<'tcx>>,
{
let mut fields = CombineFields::new(self.infcx, trace, self.param_env, define_opaque_types);
fields.equate(StructurallyRelateAliases::No).relate(expected, actual)?;
fields.equate().relate(expected, actual)?;
Ok(InferOk {
value: (),
obligations: fields
Expand Down
12 changes: 4 additions & 8 deletions compiler/rustc_infer/src/infer/relate/combine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
//! return value of `Equate` or `Sub` shouldn't really be used.

use rustc_middle::traits::solve::Goal;
use rustc_middle::ty::relate::StructurallyRelateAliases;
pub use rustc_middle::ty::relate::combine::*;
use rustc_middle::ty::{self, TyCtxt, Upcast};

Expand Down Expand Up @@ -72,19 +71,16 @@ impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> {
self.infcx.tcx
}

pub(crate) fn equate<'a>(
&'a mut self,
structurally_relate_aliases: StructurallyRelateAliases,
) -> TypeRelating<'a, 'infcx, 'tcx> {
TypeRelating::new(self, structurally_relate_aliases, ty::Invariant)
pub(crate) fn equate<'a>(&'a mut self) -> TypeRelating<'a, 'infcx, 'tcx> {
TypeRelating::new(self, ty::Invariant)
}

pub(crate) fn sub<'a>(&'a mut self) -> TypeRelating<'a, 'infcx, 'tcx> {
TypeRelating::new(self, StructurallyRelateAliases::No, ty::Covariant)
TypeRelating::new(self, ty::Covariant)
}

pub(crate) fn sup<'a>(&'a mut self) -> TypeRelating<'a, 'infcx, 'tcx> {
TypeRelating::new(self, StructurallyRelateAliases::No, ty::Contravariant)
TypeRelating::new(self, ty::Contravariant)
}

pub(crate) fn lub<'a>(&'a mut self) -> LatticeOp<'a, 'infcx, 'tcx> {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_infer/src/infer/relate/lattice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for LatticeOp<'_, '_, 'tcx> {
b: T,
) -> RelateResult<'tcx, T> {
match variance {
ty::Invariant => self.fields.equate(StructurallyRelateAliases::No).relate(a, b),
ty::Invariant => self.fields.equate().relate(a, b),
ty::Covariant => self.relate(a, b),
// FIXME(#41044) -- not correct, need test
ty::Bivariant => Ok(a),
Expand Down
12 changes: 2 additions & 10 deletions compiler/rustc_infer/src/infer/relate/type_relating.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ pub(crate) struct TypeRelating<'combine, 'a, 'tcx> {
// resulting nested `goals`.
fields: &'combine mut CombineFields<'a, 'tcx>,

// Immutable field.
structurally_relate_aliases: StructurallyRelateAliases,
// Mutable field.
ambient_variance: ty::Variance,

Expand Down Expand Up @@ -52,15 +50,9 @@ pub(crate) struct TypeRelating<'combine, 'a, 'tcx> {
impl<'combine, 'infcx, 'tcx> TypeRelating<'combine, 'infcx, 'tcx> {
pub(crate) fn new(
f: &'combine mut CombineFields<'infcx, 'tcx>,
structurally_relate_aliases: StructurallyRelateAliases,
ambient_variance: ty::Variance,
) -> TypeRelating<'combine, 'infcx, 'tcx> {
TypeRelating {
fields: f,
structurally_relate_aliases,
ambient_variance,
cache: Default::default(),
}
TypeRelating { fields: f, ambient_variance, cache: Default::default() }
}
}

Expand Down Expand Up @@ -341,7 +333,7 @@ impl<'tcx> PredicateEmittingRelation<InferCtxt<'tcx>> for TypeRelating<'_, '_, '
}

fn structurally_relate_aliases(&self) -> StructurallyRelateAliases {
self.structurally_relate_aliases
StructurallyRelateAliases::No
}

fn register_predicates(
Expand Down

0 comments on commit e43376a

Please sign in to comment.