about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src/traits
diff options
context:
space:
mode:
authorKatherine Philip <kurerunoshikaku@yahoo.com>2022-07-13 10:25:58 -0700
committerKatherine Philip <kurerunoshikaku@yahoo.com>2022-07-13 16:29:05 -0700
commitb33955a0ef3b38f2c9448b1dcab82c31b097438e (patch)
treeeda7cca0a0ac32e5ecf18e9a45a83adbaa5e4546 /compiler/rustc_trait_selection/src/traits
parent82ab171673d10f16c67a52d50ef1f5b197656bbd (diff)
downloadrust-b33955a0ef3b38f2c9448b1dcab82c31b097438e.tar.gz
rust-b33955a0ef3b38f2c9448b1dcab82c31b097438e.zip
Add checks & fallback branch
Diffstat (limited to 'compiler/rustc_trait_selection/src/traits')
-rw-r--r--compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs14
1 files changed, 13 insertions, 1 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs
index 8396df4a243..925e8012819 100644
--- a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs
+++ b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs
@@ -2157,6 +2157,9 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
             }
 
             ty::PredicateKind::ConstEvaluatable(data) => {
+                if predicate.references_error() || self.is_tainted_by_errors() {
+                    return;
+                }
                 let subst = data.substs.iter().find(|g| g.has_infer_types_or_consts());
                 if let Some(subst) = subst {
                     let mut err = self.emit_inference_failure_err(
@@ -2169,7 +2172,16 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
                     err.note(&format!("cannot satisfy `{}`", predicate));
                     err
                 } else {
-                    todo!();
+                    // If we can't find a substitution, just print a generic error
+                    let mut err = struct_span_err!(
+                        self.tcx.sess,
+                        span,
+                        E0284,
+                        "type annotations needed: cannot satisfy `{}`",
+                        predicate,
+                    );
+                    err.span_label(span, &format!("cannot satisfy `{}`", predicate));
+                    err
                 }
             }
             _ => {