Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 1d5eaf8

Browse files
committedFeb 29, 2024
Fallout from removing a_is_expected
1 parent 8f4d9e4 commit 1d5eaf8

File tree

12 files changed

+44
-120
lines changed

12 files changed

+44
-120
lines changed
 

‎compiler/rustc_borrowck/src/type_check/relate_tys.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,7 @@ impl<'me, 'bccx, 'tcx> NllTypeRelating<'me, 'bccx, 'tcx> {
160160
),
161161
};
162162
let cause = ObligationCause::dummy_with_span(self.span());
163-
let obligations =
164-
infcx.handle_opaque_type(a, b, true, &cause, self.param_env())?.obligations;
163+
let obligations = infcx.handle_opaque_type(a, b, &cause, self.param_env())?.obligations;
165164
self.register_obligations(obligations);
166165
Ok(())
167166
}
@@ -330,10 +329,6 @@ impl<'bccx, 'tcx> TypeRelation<'tcx> for NllTypeRelating<'_, 'bccx, 'tcx> {
330329
"nll::subtype"
331330
}
332331

333-
fn a_is_expected(&self) -> bool {
334-
true
335-
}
336-
337332
#[instrument(skip(self, info), level = "trace", ret)]
338333
fn relate_with_variance<T: Relate<'tcx>>(
339334
&mut self,

‎compiler/rustc_infer/src/infer/error_reporting/mod.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2654,10 +2654,6 @@ impl<'tcx> TypeRelation<'tcx> for SameTypeModuloInfer<'_, 'tcx> {
26542654
"SameTypeModuloInfer"
26552655
}
26562656

2657-
fn a_is_expected(&self) -> bool {
2658-
true
2659-
}
2660-
26612657
fn relate_with_variance<T: relate::Relate<'tcx>>(
26622658
&mut self,
26632659
_variance: ty::Variance,

‎compiler/rustc_infer/src/infer/opaque_types.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,7 @@ impl<'tcx> InferCtxt<'tcx> {
7878
span,
7979
});
8080
obligations.extend(
81-
self.handle_opaque_type(ty, ty_var, true, &cause, param_env)
82-
.unwrap()
83-
.obligations,
81+
self.handle_opaque_type(ty, ty_var, &cause, param_env).unwrap().obligations,
8482
);
8583
ty_var
8684
}
@@ -94,14 +92,12 @@ impl<'tcx> InferCtxt<'tcx> {
9492
&self,
9593
a: Ty<'tcx>,
9694
b: Ty<'tcx>,
97-
a_is_expected: bool,
9895
cause: &ObligationCause<'tcx>,
9996
param_env: ty::ParamEnv<'tcx>,
10097
) -> InferResult<'tcx, ()> {
10198
if a.references_error() || b.references_error() {
10299
return Ok(InferOk { value: (), obligations: vec![] });
103100
}
104-
let (a, b) = if a_is_expected { (a, b) } else { (b, a) };
105101
let process = |a: Ty<'tcx>, b: Ty<'tcx>| match *a.kind() {
106102
ty::Alias(ty::Opaque, ty::AliasTy { def_id, args, .. }) if def_id.is_local() => {
107103
let def_id = def_id.expect_local();

‎compiler/rustc_infer/src/infer/outlives/test_type_match.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,6 @@ impl<'tcx> TypeRelation<'tcx> for MatchAgainstHigherRankedOutlives<'tcx> {
144144
self.tcx
145145
}
146146

147-
fn a_is_expected(&self) -> bool {
148-
true
149-
} // irrelevant
150-
151147
#[instrument(level = "trace", skip(self))]
152148
fn relate_with_variance<T: Relate<'tcx>>(
153149
&mut self,

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

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,6 @@
1717
//!
1818
//! On success, the LUB/GLB operations return the appropriate bound. The
1919
//! return value of `Equate` or `Sub` shouldn't really be used.
20-
//!
21-
//! ## Contravariance
22-
//!
23-
//! We explicitly track which argument is expected using
24-
//! [TypeRelation::a_is_expected], so when dealing with contravariance
25-
//! this should be correctly updated.
2620
2721
use super::glb::Glb;
2822
use super::lub::Lub;
@@ -57,7 +51,6 @@ impl<'tcx> InferCtxt<'tcx> {
5751
where
5852
R: ObligationEmittingRelation<'tcx>,
5953
{
60-
let a_is_expected = relation.a_is_expected();
6154
debug_assert!(!a.has_escaping_bound_vars());
6255
debug_assert!(!b.has_escaping_bound_vars());
6356

@@ -68,20 +61,20 @@ impl<'tcx> InferCtxt<'tcx> {
6861
.borrow_mut()
6962
.int_unification_table()
7063
.unify_var_var(a_id, b_id)
71-
.map_err(|e| int_unification_error(a_is_expected, e))?;
64+
.map_err(|e| int_unification_error(true, e))?;
7265
Ok(a)
7366
}
7467
(&ty::Infer(ty::IntVar(v_id)), &ty::Int(v)) => {
75-
self.unify_integral_variable(a_is_expected, v_id, IntType(v))
68+
self.unify_integral_variable(true, v_id, IntType(v))
7669
}
7770
(&ty::Int(v), &ty::Infer(ty::IntVar(v_id))) => {
78-
self.unify_integral_variable(!a_is_expected, v_id, IntType(v))
71+
self.unify_integral_variable(false, v_id, IntType(v))
7972
}
8073
(&ty::Infer(ty::IntVar(v_id)), &ty::Uint(v)) => {
81-
self.unify_integral_variable(a_is_expected, v_id, UintType(v))
74+
self.unify_integral_variable(true, v_id, UintType(v))
8275
}
8376
(&ty::Uint(v), &ty::Infer(ty::IntVar(v_id))) => {
84-
self.unify_integral_variable(!a_is_expected, v_id, UintType(v))
77+
self.unify_integral_variable(false, v_id, UintType(v))
8578
}
8679

8780
// Relate floating-point variables to other types
@@ -90,14 +83,14 @@ impl<'tcx> InferCtxt<'tcx> {
9083
.borrow_mut()
9184
.float_unification_table()
9285
.unify_var_var(a_id, b_id)
93-
.map_err(|e| float_unification_error(a_is_expected, e))?;
86+
.map_err(|e| float_unification_error(true, e))?;
9487
Ok(a)
9588
}
9689
(&ty::Infer(ty::FloatVar(v_id)), &ty::Float(v)) => {
97-
self.unify_float_variable(a_is_expected, v_id, v)
90+
self.unify_float_variable(true, v_id, v)
9891
}
9992
(&ty::Float(v), &ty::Infer(ty::FloatVar(v_id))) => {
100-
self.unify_float_variable(!a_is_expected, v_id, v)
93+
self.unify_float_variable(false, v_id, v)
10194
}
10295

10396
// We don't expect `TyVar` or `Fresh*` vars at this point with lazy norm.
@@ -130,7 +123,7 @@ impl<'tcx> InferCtxt<'tcx> {
130123

131124
// All other cases of inference are errors
132125
(&ty::Infer(_), _) | (_, &ty::Infer(_)) => {
133-
Err(TypeError::Sorts(ty::relate::expected_found(relation, a, b)))
126+
Err(TypeError::Sorts(ty::relate::expected_found(a, b)))
134127
}
135128

136129
// During coherence, opaque types should be treated as *possibly*
@@ -228,12 +221,12 @@ impl<'tcx> InferCtxt<'tcx> {
228221
}
229222

230223
(ty::ConstKind::Infer(InferConst::Var(vid)), _) => {
231-
self.instantiate_const_var(relation, relation.a_is_expected(), vid, b)?;
224+
self.instantiate_const_var(relation, true, vid, b)?;
232225
Ok(b)
233226
}
234227

235228
(_, ty::ConstKind::Infer(InferConst::Var(vid))) => {
236-
self.instantiate_const_var(relation, !relation.a_is_expected(), vid, a)?;
229+
self.instantiate_const_var(relation, false, vid, a)?;
237230
Ok(a)
238231
}
239232

@@ -250,8 +243,6 @@ impl<'tcx> InferCtxt<'tcx> {
250243
{
251244
match relation.structurally_relate_aliases() {
252245
StructurallyRelateAliases::No => {
253-
let (a, b) = if relation.a_is_expected() { (a, b) } else { (b, a) };
254-
255246
relation.register_predicates([if self.next_trait_solver() {
256247
ty::PredicateKind::AliasRelate(
257248
a.into(),

‎compiler/rustc_infer/src/infer/relate/generalize.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ impl<'tcx> InferCtxt<'tcx> {
130130
// instantiate_ty_var(?b, A) # expected and variance flipped
131131
// A rel A'
132132
// ```
133-
if target_is_expected == relation.a_is_expected() {
133+
if target_is_expected {
134134
relation.relate(generalized_ty, source_ty)?;
135135
} else {
136136
debug!("flip relation");
@@ -206,7 +206,7 @@ impl<'tcx> InferCtxt<'tcx> {
206206

207207
// HACK: make sure that we `a_is_expected` continues to be
208208
// correct when relating the generalized type with the source.
209-
if target_is_expected == relation.a_is_expected() {
209+
if target_is_expected {
210210
relation.relate_with_variance(
211211
ty::Variance::Invariant,
212212
ty::VarianceDiagInfo::default(),
@@ -398,10 +398,6 @@ impl<'tcx> TypeRelation<'tcx> for Generalizer<'_, 'tcx> {
398398
"Generalizer"
399399
}
400400

401-
fn a_is_expected(&self) -> bool {
402-
true
403-
}
404-
405401
fn relate_item_args(
406402
&mut self,
407403
item_def_id: DefId,

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ impl<'tcx> TypeRelation<'tcx> for Glb<'_, '_, 'tcx> {
3030
self.fields.tcx()
3131
}
3232

33-
fn a_is_expected(&self) -> bool {
34-
true
35-
}
36-
3733
fn relate_with_variance<T: Relate<'tcx>>(
3834
&mut self,
3935
variance: ty::Variance,

‎compiler/rustc_infer/src/infer/relate/lattice.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,7 @@ where
116116
&& !this.infcx().next_trait_solver() =>
117117
{
118118
this.register_obligations(
119-
infcx
120-
.handle_opaque_type(a, b, this.a_is_expected(), this.cause(), this.param_env())?
121-
.obligations,
119+
infcx.handle_opaque_type(a, b, this.cause(), this.param_env())?.obligations,
122120
);
123121
Ok(a)
124122
}

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ impl<'tcx> TypeRelation<'tcx> for Lub<'_, '_, 'tcx> {
3030
self.fields.tcx()
3131
}
3232

33-
fn a_is_expected(&self) -> bool {
34-
true
35-
}
36-
3733
fn relate_with_variance<T: Relate<'tcx>>(
3834
&mut self,
3935
variance: ty::Variance,

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,6 @@ impl<'tcx> TypeRelation<'tcx> for TypeRelating<'_, '_, 'tcx> {
3535
self.fields.infcx.tcx
3636
}
3737

38-
fn a_is_expected(&self) -> bool {
39-
true
40-
}
41-
4238
fn relate_with_variance<T: Relate<'tcx>>(
4339
&mut self,
4440
variance: ty::Variance,
@@ -139,7 +135,7 @@ impl<'tcx> TypeRelation<'tcx> for TypeRelating<'_, '_, 'tcx> {
139135
{
140136
self.fields.obligations.extend(
141137
infcx
142-
.handle_opaque_type(a, b, true, &self.fields.trace.cause, self.param_env())?
138+
.handle_opaque_type(a, b, &self.fields.trace.cause, self.param_env())?
143139
.obligations,
144140
);
145141
}

‎compiler/rustc_middle/src/ty/_match.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@ impl<'tcx> TypeRelation<'tcx> for MatchAgainstFreshVars<'tcx> {
3737
self.tcx
3838
}
3939

40-
fn a_is_expected(&self) -> bool {
41-
true
42-
} // irrelevant
43-
4440
fn relate_with_variance<T: Relate<'tcx>>(
4541
&mut self,
4642
_: ty::Variance,
@@ -75,7 +71,7 @@ impl<'tcx> TypeRelation<'tcx> for MatchAgainstFreshVars<'tcx> {
7571
) => Ok(a),
7672

7773
(&ty::Infer(_), _) | (_, &ty::Infer(_)) => {
78-
Err(TypeError::Sorts(relate::expected_found(self, a, b)))
74+
Err(TypeError::Sorts(relate::expected_found(a, b)))
7975
}
8076

8177
(&ty::Error(guar), _) | (_, &ty::Error(guar)) => Ok(Ty::new_error(self.tcx(), guar)),
@@ -100,7 +96,7 @@ impl<'tcx> TypeRelation<'tcx> for MatchAgainstFreshVars<'tcx> {
10096
}
10197

10298
(ty::ConstKind::Infer(_), _) | (_, ty::ConstKind::Infer(_)) => {
103-
return Err(TypeError::ConstMismatch(relate::expected_found(self, a, b)));
99+
return Err(TypeError::ConstMismatch(relate::expected_found(a, b)));
104100
}
105101

106102
_ => {}

‎compiler/rustc_middle/src/ty/relate.rs

Lines changed: 25 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,12 @@ use std::iter;
1515

1616
pub type RelateResult<'tcx, T> = Result<T, TypeError<'tcx>>;
1717

18-
#[derive(Clone, Debug)]
19-
pub enum Cause {
20-
ExistentialRegionBound, // relating an existential region bound
21-
}
22-
2318
pub trait TypeRelation<'tcx>: Sized {
2419
fn tcx(&self) -> TyCtxt<'tcx>;
2520

2621
/// Returns a static string we can use for printouts.
2722
fn tag(&self) -> &'static str;
2823

29-
/// Returns `true` if the value `a` is the "expected" type in the
30-
/// relation. Just affects error messages.
31-
fn a_is_expected(&self) -> bool;
32-
3324
/// Generic relation routine suitable for most anything.
3425
fn relate<T: Relate<'tcx>>(&mut self, a: T, b: T) -> RelateResult<'tcx, T> {
3526
Relate::relate(self, a, b)
@@ -171,11 +162,7 @@ impl<'tcx> Relate<'tcx> for ty::FnSig<'tcx> {
171162
let tcx = relation.tcx();
172163

173164
if a.c_variadic != b.c_variadic {
174-
return Err(TypeError::VariadicMismatch(expected_found(
175-
relation,
176-
a.c_variadic,
177-
b.c_variadic,
178-
)));
165+
return Err(TypeError::VariadicMismatch(expected_found(a.c_variadic, b.c_variadic)));
179166
}
180167
let unsafety = relation.relate(a.unsafety, b.unsafety)?;
181168
let abi = relation.relate(a.abi, b.abi)?;
@@ -220,39 +207,31 @@ impl<'tcx> Relate<'tcx> for ty::FnSig<'tcx> {
220207

221208
impl<'tcx> Relate<'tcx> for ty::BoundConstness {
222209
fn relate<R: TypeRelation<'tcx>>(
223-
relation: &mut R,
210+
_relation: &mut R,
224211
a: ty::BoundConstness,
225212
b: ty::BoundConstness,
226213
) -> RelateResult<'tcx, ty::BoundConstness> {
227-
if a != b {
228-
Err(TypeError::ConstnessMismatch(expected_found(relation, a, b)))
229-
} else {
230-
Ok(a)
231-
}
214+
if a != b { Err(TypeError::ConstnessMismatch(expected_found(a, b))) } else { Ok(a) }
232215
}
233216
}
234217

235218
impl<'tcx> Relate<'tcx> for hir::Unsafety {
236219
fn relate<R: TypeRelation<'tcx>>(
237-
relation: &mut R,
220+
_relation: &mut R,
238221
a: hir::Unsafety,
239222
b: hir::Unsafety,
240223
) -> RelateResult<'tcx, hir::Unsafety> {
241-
if a != b {
242-
Err(TypeError::UnsafetyMismatch(expected_found(relation, a, b)))
243-
} else {
244-
Ok(a)
245-
}
224+
if a != b { Err(TypeError::UnsafetyMismatch(expected_found(a, b))) } else { Ok(a) }
246225
}
247226
}
248227

249228
impl<'tcx> Relate<'tcx> for abi::Abi {
250229
fn relate<R: TypeRelation<'tcx>>(
251-
relation: &mut R,
230+
_relation: &mut R,
252231
a: abi::Abi,
253232
b: abi::Abi,
254233
) -> RelateResult<'tcx, abi::Abi> {
255-
if a == b { Ok(a) } else { Err(TypeError::AbiMismatch(expected_found(relation, a, b))) }
234+
if a == b { Ok(a) } else { Err(TypeError::AbiMismatch(expected_found(a, b))) }
256235
}
257236
}
258237

@@ -263,7 +242,7 @@ impl<'tcx> Relate<'tcx> for ty::AliasTy<'tcx> {
263242
b: ty::AliasTy<'tcx>,
264243
) -> RelateResult<'tcx, ty::AliasTy<'tcx>> {
265244
if a.def_id != b.def_id {
266-
Err(TypeError::ProjectionMismatched(expected_found(relation, a.def_id, b.def_id)))
245+
Err(TypeError::ProjectionMismatched(expected_found(a.def_id, b.def_id)))
267246
} else {
268247
let args = match relation.tcx().def_kind(a.def_id) {
269248
DefKind::OpaqueTy => relate_args_with_variances(
@@ -291,7 +270,7 @@ impl<'tcx> Relate<'tcx> for ty::ExistentialProjection<'tcx> {
291270
b: ty::ExistentialProjection<'tcx>,
292271
) -> RelateResult<'tcx, ty::ExistentialProjection<'tcx>> {
293272
if a.def_id != b.def_id {
294-
Err(TypeError::ProjectionMismatched(expected_found(relation, a.def_id, b.def_id)))
273+
Err(TypeError::ProjectionMismatched(expected_found(a.def_id, b.def_id)))
295274
} else {
296275
let term = relation.relate_with_variance(
297276
ty::Invariant,
@@ -318,7 +297,7 @@ impl<'tcx> Relate<'tcx> for ty::TraitRef<'tcx> {
318297
) -> RelateResult<'tcx, ty::TraitRef<'tcx>> {
319298
// Different traits cannot be related.
320299
if a.def_id != b.def_id {
321-
Err(TypeError::Traits(expected_found(relation, a.def_id, b.def_id)))
300+
Err(TypeError::Traits(expected_found(a.def_id, b.def_id)))
322301
} else {
323302
let args = relate_args_invariantly(relation, a.args, b.args)?;
324303
Ok(ty::TraitRef::new(relation.tcx(), a.def_id, args))
@@ -334,7 +313,7 @@ impl<'tcx> Relate<'tcx> for ty::ExistentialTraitRef<'tcx> {
334313
) -> RelateResult<'tcx, ty::ExistentialTraitRef<'tcx>> {
335314
// Different traits cannot be related.
336315
if a.def_id != b.def_id {
337-
Err(TypeError::Traits(expected_found(relation, a.def_id, b.def_id)))
316+
Err(TypeError::Traits(expected_found(a.def_id, b.def_id)))
338317
} else {
339318
let args = relate_args_invariantly(relation, a.args, b.args)?;
340319
Ok(ty::ExistentialTraitRef { def_id: a.def_id, args })
@@ -510,9 +489,9 @@ pub fn structurally_relate_tys<'tcx, R: TypeRelation<'tcx>>(
510489
let sz_b = sz_b.try_to_target_usize(tcx);
511490

512491
match (sz_a, sz_b) {
513-
(Some(sz_a_val), Some(sz_b_val)) if sz_a_val != sz_b_val => Err(
514-
TypeError::FixedArraySize(expected_found(relation, sz_a_val, sz_b_val)),
515-
),
492+
(Some(sz_a_val), Some(sz_b_val)) if sz_a_val != sz_b_val => {
493+
Err(TypeError::FixedArraySize(expected_found(sz_a_val, sz_b_val)))
494+
}
516495
_ => Err(err),
517496
}
518497
}
@@ -531,9 +510,9 @@ pub fn structurally_relate_tys<'tcx, R: TypeRelation<'tcx>>(
531510
iter::zip(as_, bs).map(|(a, b)| relation.relate(a, b)),
532511
)?)
533512
} else if !(as_.is_empty() || bs.is_empty()) {
534-
Err(TypeError::TupleSize(expected_found(relation, as_.len(), bs.len())))
513+
Err(TypeError::TupleSize(expected_found(as_.len(), bs.len())))
535514
} else {
536-
Err(TypeError::Sorts(expected_found(relation, a, b)))
515+
Err(TypeError::Sorts(expected_found(a, b)))
537516
}
538517
}
539518

@@ -554,7 +533,7 @@ pub fn structurally_relate_tys<'tcx, R: TypeRelation<'tcx>>(
554533
Ok(Ty::new_alias(tcx, a_kind, alias_ty))
555534
}
556535

557-
_ => Err(TypeError::Sorts(expected_found(relation, a, b))),
536+
_ => Err(TypeError::Sorts(expected_found(a, b))),
558537
}
559538
}
560539

@@ -652,13 +631,13 @@ pub fn structurally_relate_consts<'tcx, R: TypeRelation<'tcx>>(
652631
let related_args = tcx.mk_const_list(&related_args);
653632
Expr::FunctionCall(func, related_args)
654633
}
655-
_ => return Err(TypeError::ConstMismatch(expected_found(r, a, b))),
634+
_ => return Err(TypeError::ConstMismatch(expected_found(a, b))),
656635
};
657636
return Ok(ty::Const::new_expr(tcx, expr, a.ty()));
658637
}
659638
_ => false,
660639
};
661-
if is_match { Ok(a) } else { Err(TypeError::ConstMismatch(expected_found(relation, a, b))) }
640+
if is_match { Ok(a) } else { Err(TypeError::ConstMismatch(expected_found(a, b))) }
662641
}
663642

664643
impl<'tcx> Relate<'tcx> for &'tcx ty::List<ty::PolyExistentialPredicate<'tcx>> {
@@ -680,7 +659,7 @@ impl<'tcx> Relate<'tcx> for &'tcx ty::List<ty::PolyExistentialPredicate<'tcx>> {
680659
b_v.sort_by(|a, b| a.skip_binder().stable_cmp(tcx, &b.skip_binder()));
681660
b_v.dedup();
682661
if a_v.len() != b_v.len() {
683-
return Err(TypeError::ExistentialMismatch(expected_found(relation, a, b)));
662+
return Err(TypeError::ExistentialMismatch(expected_found(a, b)));
684663
}
685664

686665
let v = iter::zip(a_v, b_v).map(|(ep_a, ep_b)| {
@@ -692,7 +671,7 @@ impl<'tcx> Relate<'tcx> for &'tcx ty::List<ty::PolyExistentialPredicate<'tcx>> {
692671
relation.relate(ep_a.rebind(a), ep_b.rebind(b))?.skip_binder(),
693672
))),
694673
(AutoTrait(a), AutoTrait(b)) if a == b => Ok(ep_a.rebind(AutoTrait(a))),
695-
_ => Err(TypeError::ExistentialMismatch(expected_found(relation, a, b))),
674+
_ => Err(TypeError::ExistentialMismatch(expected_found(a, b))),
696675
}
697676
});
698677
tcx.mk_poly_existential_predicates_from_iter(v)
@@ -792,15 +771,11 @@ impl<'tcx> Relate<'tcx> for GenericArg<'tcx> {
792771

793772
impl<'tcx> Relate<'tcx> for ty::ImplPolarity {
794773
fn relate<R: TypeRelation<'tcx>>(
795-
relation: &mut R,
774+
_relation: &mut R,
796775
a: ty::ImplPolarity,
797776
b: ty::ImplPolarity,
798777
) -> RelateResult<'tcx, ty::ImplPolarity> {
799-
if a != b {
800-
Err(TypeError::PolarityMismatch(expected_found(relation, a, b)))
801-
} else {
802-
Ok(a)
803-
}
778+
if a != b { Err(TypeError::PolarityMismatch(expected_found(a, b))) } else { Ok(a) }
804779
}
805780
}
806781

@@ -834,9 +809,6 @@ impl<'tcx> Relate<'tcx> for Term<'tcx> {
834809
///////////////////////////////////////////////////////////////////////////
835810
// Error handling
836811

837-
pub fn expected_found<'tcx, R, T>(relation: &mut R, a: T, b: T) -> ExpectedFound<T>
838-
where
839-
R: TypeRelation<'tcx>,
840-
{
841-
ExpectedFound::new(relation.a_is_expected(), a, b)
812+
pub fn expected_found<T>(a: T, b: T) -> ExpectedFound<T> {
813+
ExpectedFound::new(true, a, b)
842814
}

0 commit comments

Comments
 (0)
Please sign in to comment.