Skip to content

Commit 4baa1cf

Browse files
Register obligations that will fail rather than eagerly erroring in coerce_unsized
1 parent 4d30011 commit 4baa1cf

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

compiler/rustc_hir_typeck/src/coercion.rs

+5-10
Original file line numberDiff line numberDiff line change
@@ -725,16 +725,11 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
725725
}
726726

727727
// Dyn-compatibility violations or miscellaneous.
728-
Err(err) => {
729-
let guar = self.err_ctxt().report_selection_error(
730-
obligation.clone(),
731-
&obligation,
732-
&err,
733-
);
734-
self.fcx.set_tainted_by_errors(guar);
735-
// Treat this like an obligation and follow through
736-
// with the unsizing - the lack of a coercion should
737-
// be silent, as it causes a type mismatch later.
728+
Err(_) => {
729+
// Previously we reported an error here; instead of doing that,
730+
// we just register the failing obligation which will be reported
731+
// in the outer selection loop.
732+
coercion.obligations.push(obligation);
738733
}
739734

740735
Ok(Some(impl_source)) => queue.extend(impl_source.nested_obligations()),

0 commit comments

Comments
 (0)