Skip to content

Commit b33955a

Browse files
committed
Add checks & fallback branch
1 parent 82ab171 commit b33955a

File tree

1 file changed

+13
-1
lines changed
  • compiler/rustc_trait_selection/src/traits/error_reporting

1 file changed

+13
-1
lines changed

compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2157,6 +2157,9 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
21572157
}
21582158

21592159
ty::PredicateKind::ConstEvaluatable(data) => {
2160+
if predicate.references_error() || self.is_tainted_by_errors() {
2161+
return;
2162+
}
21602163
let subst = data.substs.iter().find(|g| g.has_infer_types_or_consts());
21612164
if let Some(subst) = subst {
21622165
let mut err = self.emit_inference_failure_err(
@@ -2169,7 +2172,16 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
21692172
err.note(&format!("cannot satisfy `{}`", predicate));
21702173
err
21712174
} else {
2172-
todo!();
2175+
// If we can't find a substitution, just print a generic error
2176+
let mut err = struct_span_err!(
2177+
self.tcx.sess,
2178+
span,
2179+
E0284,
2180+
"type annotations needed: cannot satisfy `{}`",
2181+
predicate,
2182+
);
2183+
err.span_label(span, &format!("cannot satisfy `{}`", predicate));
2184+
err
21732185
}
21742186
}
21752187
_ => {

0 commit comments

Comments
 (0)