Skip to content

Commit 161b4cb

Browse files
Remove unnecessary StructurallyRelateAliases from CombineFields/TypeRelating
1 parent fa871ac commit 161b4cb

File tree

5 files changed

+10
-16
lines changed

5 files changed

+10
-16
lines changed

compiler/rustc_infer/src/infer/at.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use rustc_middle::bug;
2929
use rustc_middle::ty::{Const, ImplSubject};
3030

3131
use super::*;
32-
use crate::infer::relate::{Relate, StructurallyRelateAliases, TypeRelation};
32+
use crate::infer::relate::{Relate, TypeRelation};
3333
use crate::traits::Obligation;
3434

3535
/// Whether we should define opaque types or just treat them opaquely.
@@ -169,7 +169,7 @@ impl<'a, 'tcx> At<'a, 'tcx> {
169169
T: Relate<TyCtxt<'tcx>>,
170170
{
171171
let mut fields = CombineFields::new(self.infcx, trace, self.param_env, define_opaque_types);
172-
fields.equate(StructurallyRelateAliases::No).relate(expected, actual)?;
172+
fields.equate().relate(expected, actual)?;
173173
Ok(InferOk {
174174
value: (),
175175
obligations: fields

compiler/rustc_infer/src/infer/relate/combine.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ use rustc_middle::traits::solve::Goal;
2222
pub use rustc_middle::ty::relate::combine::*;
2323
use rustc_middle::ty::{self, TyCtxt, Upcast};
2424

25-
use super::StructurallyRelateAliases;
2625
use super::glb::Glb;
2726
use super::lub::Lub;
2827
use super::type_relating::TypeRelating;
@@ -68,19 +67,16 @@ impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> {
6867
self.infcx.tcx
6968
}
7069

71-
pub fn equate<'a>(
72-
&'a mut self,
73-
structurally_relate_aliases: StructurallyRelateAliases,
74-
) -> TypeRelating<'a, 'infcx, 'tcx> {
75-
TypeRelating::new(self, structurally_relate_aliases, ty::Invariant)
70+
pub fn equate<'a>(&'a mut self) -> TypeRelating<'a, 'infcx, 'tcx> {
71+
TypeRelating::new(self, ty::Invariant)
7672
}
7773

7874
pub fn sub<'a>(&'a mut self) -> TypeRelating<'a, 'infcx, 'tcx> {
79-
TypeRelating::new(self, StructurallyRelateAliases::No, ty::Covariant)
75+
TypeRelating::new(self, ty::Covariant)
8076
}
8177

8278
pub fn sup<'a>(&'a mut self) -> TypeRelating<'a, 'infcx, 'tcx> {
83-
TypeRelating::new(self, StructurallyRelateAliases::No, ty::Contravariant)
79+
TypeRelating::new(self, ty::Contravariant)
8480
}
8581

8682
pub fn lub<'a>(&'a mut self) -> Lub<'a, 'infcx, 'tcx> {

compiler/rustc_infer/src/infer/relate/glb.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for Glb<'_, '_, 'tcx> {
3636
b: T,
3737
) -> RelateResult<'tcx, T> {
3838
match variance {
39-
ty::Invariant => self.fields.equate(StructurallyRelateAliases::No).relate(a, b),
39+
ty::Invariant => self.fields.equate().relate(a, b),
4040
ty::Covariant => self.relate(a, b),
4141
// FIXME(#41044) -- not correct, need test
4242
ty::Bivariant => Ok(a),

compiler/rustc_infer/src/infer/relate/lub.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for Lub<'_, '_, 'tcx> {
3636
b: T,
3737
) -> RelateResult<'tcx, T> {
3838
match variance {
39-
ty::Invariant => self.fields.equate(StructurallyRelateAliases::No).relate(a, b),
39+
ty::Invariant => self.fields.equate().relate(a, b),
4040
ty::Covariant => self.relate(a, b),
4141
// FIXME(#41044) -- not correct, need test
4242
ty::Bivariant => Ok(a),

compiler/rustc_infer/src/infer/relate/type_relating.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,15 @@ use crate::infer::{DefineOpaqueTypes, InferCtxt, SubregionOrigin};
1515
/// Enforce that `a` is equal to or a subtype of `b`.
1616
pub struct TypeRelating<'combine, 'a, 'tcx> {
1717
fields: &'combine mut CombineFields<'a, 'tcx>,
18-
structurally_relate_aliases: StructurallyRelateAliases,
1918
ambient_variance: ty::Variance,
2019
}
2120

2221
impl<'combine, 'infcx, 'tcx> TypeRelating<'combine, 'infcx, 'tcx> {
2322
pub fn new(
2423
f: &'combine mut CombineFields<'infcx, 'tcx>,
25-
structurally_relate_aliases: StructurallyRelateAliases,
2624
ambient_variance: ty::Variance,
2725
) -> TypeRelating<'combine, 'infcx, 'tcx> {
28-
TypeRelating { fields: f, structurally_relate_aliases, ambient_variance }
26+
TypeRelating { fields: f, ambient_variance }
2927
}
3028
}
3129

@@ -300,7 +298,7 @@ impl<'tcx> PredicateEmittingRelation<InferCtxt<'tcx>> for TypeRelating<'_, '_, '
300298
}
301299

302300
fn structurally_relate_aliases(&self) -> StructurallyRelateAliases {
303-
self.structurally_relate_aliases
301+
StructurallyRelateAliases::No
304302
}
305303

306304
fn register_predicates(

0 commit comments

Comments
 (0)