Skip to content

Commit 02ad984

Browse files
Comment, and bail early if bound vars list differs
1 parent d018144 commit 02ad984

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

compiler/rustc_infer/src/infer/equate.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ impl<'tcx> TypeRelation<'tcx> for Equate<'_, '_, 'tcx> {
110110
.obligations,
111111
);
112112
}
113+
// Optimization of GeneratorWitness relation since we know that all
114+
// free regions are replaced with bound regions during construction.
115+
// This greatly speeds up equating of GeneratorWitness.
113116
(&ty::GeneratorWitness(a_types), &ty::GeneratorWitness(b_types)) => {
114117
let a_types = infcx.tcx.anonymize_bound_vars(a_types);
115118
let b_types = infcx.tcx.anonymize_bound_vars(b_types);
@@ -121,11 +124,9 @@ impl<'tcx> TypeRelation<'tcx> for Equate<'_, '_, 'tcx> {
121124
self.relate(a, b)?;
122125
}
123126
} else {
124-
self.fields.infcx.super_combine_tys(
125-
self,
126-
infcx.tcx.mk_generator_witness(a_types),
127-
infcx.tcx.mk_generator_witness(b_types),
128-
)?;
127+
return Err(ty::error::TypeError::Sorts(ty::relate::expected_found(
128+
self, a, b,
129+
)));
129130
}
130131
}
131132

compiler/rustc_infer/src/infer/sub.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,9 @@ impl<'tcx> TypeRelation<'tcx> for Sub<'_, '_, 'tcx> {
164164
);
165165
Ok(ga)
166166
}
167+
// Optimization of GeneratorWitness relation since we know that all
168+
// free regions are replaced with bound regions during construction.
169+
// This greatly speeds up subtyping of GeneratorWitness.
167170
(&ty::GeneratorWitness(a_types), &ty::GeneratorWitness(b_types)) => {
168171
let a_types = infcx.tcx.anonymize_bound_vars(a_types);
169172
let b_types = infcx.tcx.anonymize_bound_vars(b_types);
@@ -174,14 +177,10 @@ impl<'tcx> TypeRelation<'tcx> for Sub<'_, '_, 'tcx> {
174177
for (a, b) in std::iter::zip(a_types, b_types) {
175178
self.relate(a, b)?;
176179
}
180+
Ok(a)
177181
} else {
178-
self.fields.infcx.super_combine_tys(
179-
self,
180-
infcx.tcx.mk_generator_witness(a_types),
181-
infcx.tcx.mk_generator_witness(b_types),
182-
)?;
182+
Err(ty::error::TypeError::Sorts(ty::relate::expected_found(self, a, b)))
183183
}
184-
Ok(a)
185184
}
186185

187186
_ => {

0 commit comments

Comments
 (0)