Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d4356b8

Browse files
Fallout from removing a_is_expected
1 parent 08fdb83 commit d4356b8

File tree

12 files changed

+44
-109
lines changed

12 files changed

+44
-109
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
@@ -2669,10 +2669,6 @@ impl<'tcx> TypeRelation<'tcx> for SameTypeModuloInfer<'_, 'tcx> {
26692669
"SameTypeModuloInfer"
26702670
}
26712671

2672-
fn a_is_expected(&self) -> bool {
2673-
true
2674-
}
2675-
26762672
fn relate_with_variance<T: relate::Relate<'tcx>>(
26772673
&mut self,
26782674
_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 & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ impl<'tcx> InferCtxt<'tcx> {
5757
where
5858
R: ObligationEmittingRelation<'tcx>,
5959
{
60-
let a_is_expected = relation.a_is_expected();
6160
debug_assert!(!a.has_escaping_bound_vars());
6261
debug_assert!(!b.has_escaping_bound_vars());
6362

@@ -68,20 +67,20 @@ impl<'tcx> InferCtxt<'tcx> {
6867
.borrow_mut()
6968
.int_unification_table()
7069
.unify_var_var(a_id, b_id)
71-
.map_err(|e| int_unification_error(a_is_expected, e))?;
70+
.map_err(|e| int_unification_error(true, e))?;
7271
Ok(a)
7372
}
7473
(&ty::Infer(ty::IntVar(v_id)), &ty::Int(v)) => {
75-
self.unify_integral_variable(a_is_expected, v_id, IntType(v))
74+
self.unify_integral_variable(true, v_id, IntType(v))
7675
}
7776
(&ty::Int(v), &ty::Infer(ty::IntVar(v_id))) => {
78-
self.unify_integral_variable(!a_is_expected, v_id, IntType(v))
77+
self.unify_integral_variable(!true, v_id, IntType(v))
7978
}
8079
(&ty::Infer(ty::IntVar(v_id)), &ty::Uint(v)) => {
81-
self.unify_integral_variable(a_is_expected, v_id, UintType(v))
80+
self.unify_integral_variable(true, v_id, UintType(v))
8281
}
8382
(&ty::Uint(v), &ty::Infer(ty::IntVar(v_id))) => {
84-
self.unify_integral_variable(!a_is_expected, v_id, UintType(v))
83+
self.unify_integral_variable(!true, v_id, UintType(v))
8584
}
8685

8786
// Relate floating-point variables to other types
@@ -90,14 +89,14 @@ impl<'tcx> InferCtxt<'tcx> {
9089
.borrow_mut()
9190
.float_unification_table()
9291
.unify_var_var(a_id, b_id)
93-
.map_err(|e| float_unification_error(a_is_expected, e))?;
92+
.map_err(|e| float_unification_error(true, e))?;
9493
Ok(a)
9594
}
9695
(&ty::Infer(ty::FloatVar(v_id)), &ty::Float(v)) => {
97-
self.unify_float_variable(a_is_expected, v_id, v)
96+
self.unify_float_variable(true, v_id, v)
9897
}
9998
(&ty::Float(v), &ty::Infer(ty::FloatVar(v_id))) => {
100-
self.unify_float_variable(!a_is_expected, v_id, v)
99+
self.unify_float_variable(!true, v_id, v)
101100
}
102101

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

131130
// All other cases of inference are errors
132131
(&ty::Infer(_), _) | (_, &ty::Infer(_)) => {
133-
Err(TypeError::Sorts(ty::relate::expected_found(relation,a, b)))
132+
Err(TypeError::Sorts(ty::relate::expected_found(a, b)))
134133
}
135134

136135
// During coherence, opaque types should be treated as *possibly*
@@ -228,12 +227,12 @@ impl<'tcx> InferCtxt<'tcx> {
228227
}
229228

230229
(ty::ConstKind::Infer(InferConst::Var(vid)), _) => {
231-
self.instantiate_const_var(relation, relation.a_is_expected(), vid, b)?;
230+
self.instantiate_const_var(relation, true, vid, b)?;
232231
Ok(b)
233232
}
234233

235234
(_, ty::ConstKind::Infer(InferConst::Var(vid))) => {
236-
self.instantiate_const_var(relation, !relation.a_is_expected(), vid, a)?;
235+
self.instantiate_const_var(relation, false, vid, a)?;
237236
Ok(a)
238237
}
239238

@@ -250,8 +249,6 @@ impl<'tcx> InferCtxt<'tcx> {
250249
{
251250
match relation.structurally_relate_aliases() {
252251
StructurallyRelateAliases::No => {
253-
let (a, b) = if relation.a_is_expected() { (a, b) } else { (b, a) };
254-
255252
relation.register_predicates([if self.next_trait_solver() {
256253
ty::PredicateKind::AliasRelate(
257254
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
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /