Skip to content

Commit 3f2f843

Browse files
committed
Ensure we don't accidentally succeed when we want to report an error
1 parent 9889a6f commit 3f2f843

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

compiler/rustc_hir_typeck/src/coercion.rs

+12-7
Original file line numberDiff line numberDiff line change
@@ -1245,11 +1245,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
12451245
expr,
12461246
);
12471247

1248-
return self
1248+
return Err(self
12491249
.commit_if_ok(|_| {
1250-
self.at(cause, self.param_env).lub(DefineOpaqueTypes::No, prev_ty, new_ty)
1250+
self.at(cause, self.param_env).lub(DefineOpaqueTypes::Yes, prev_ty, new_ty)
12511251
})
1252-
.map(|ok| self.register_infer_ok_obligations(ok));
1252+
.unwrap_err());
12531253
}
12541254
}
12551255

@@ -1259,10 +1259,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
12591259
if let Some(e) = first_error {
12601260
Err(e)
12611261
} else {
1262-
self.commit_if_ok(|_| {
1263-
self.at(cause, self.param_env).lub(DefineOpaqueTypes::No, prev_ty, new_ty)
1264-
})
1265-
.map(|ok| self.register_infer_ok_obligations(ok))
1262+
Err(self
1263+
.commit_if_ok(|_| {
1264+
self.at(cause, self.param_env).lub(
1265+
DefineOpaqueTypes::Yes,
1266+
prev_ty,
1267+
new_ty,
1268+
)
1269+
})
1270+
.unwrap_err())
12661271
}
12671272
}
12681273
Ok(ok) => {

0 commit comments

Comments
 (0)