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 27da982

Browse files
Fix generalizer bug
1 parent f5631bf commit 27da982

File tree

2 files changed

+5
-16
lines changed

2 files changed

+5
-16
lines changed

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

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,16 +108,11 @@ impl<'tcx> InferCtxt<'tcx> {
108108
} else {
109109
// HACK: make sure that we `a_is_expected` continues to be
110110
// correct when relating the generalized type with the source.
111-
if target_is_expected == relation.a_is_expected() {
112-
relation.relate_with_variance(
113-
ambient_variance,
114-
ty::VarianceDiagInfo::default(),
115-
generalized_ty,
116-
source_ty,
117-
)?;
111+
if target_is_expected {
112+
relation.relate(generalized_ty, source_ty)?;
118113
} else {
119114
relation.relate_with_variance(
120-
ambient_variance.xform(ty::Contravariant),
115+
ty::Contravariant,
121116
ty::VarianceDiagInfo::default(),
122117
source_ty,
123118
generalized_ty,

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -125,18 +125,12 @@ impl<'tcx> TypeRelation<'tcx> for TypeRelating<'_, '_, 'tcx> {
125125
}
126126

127127
(&ty::Infer(TyVar(a_vid)), _) => {
128-
infcx.instantiate_ty_var(
129-
self,
130-
self.a_is_expected,
131-
a_vid,
132-
self.ambient_variance,
133-
b,
134-
)?;
128+
infcx.instantiate_ty_var(self, true, a_vid, self.ambient_variance, b)?;
135129
}
136130
(_, &ty::Infer(TyVar(b_vid))) => {
137131
infcx.instantiate_ty_var(
138132
self,
139-
!self.a_is_expected,
133+
false,
140134
b_vid,
141135
self.ambient_variance.xform(ty::Contravariant),
142136
a,

0 commit comments

Comments
(0)

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