about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2022-04-06 21:10:43 -0700
committerMichael Goulet <michael@errs.io>2022-04-06 21:11:07 -0700
commit7bd22e29d0d604e594ba03b51bd8c3fc82959215 (patch)
tree0dc9f729393cec7d794bd67b17ac734d6ec7e235
parent8f36334ca939a67cce3f37f24953ff6f2d3f3d33 (diff)
downloadrust-7bd22e29d0d604e594ba03b51bd8c3fc82959215.tar.gz
rust-7bd22e29d0d604e594ba03b51bd8c3fc82959215.zip
only downgrade Error -> Ambiguous if type error is in predicate
-rw-r--r--compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs4
-rw-r--r--src/test/ui/functions-closures/fn-help-with-err-generic-is-not-function.rs8
-rw-r--r--src/test/ui/functions-closures/fn-help-with-err-generic-is-not-function.stderr19
-rw-r--r--src/test/ui/typeck/autoderef-with-param-env-error.rs9
-rw-r--r--src/test/ui/typeck/autoderef-with-param-env-error.stderr12
5 files changed, 25 insertions, 27 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs b/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs
index cf472813e9e..4bb0ce29b63 100644
--- a/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs
+++ b/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs
@@ -231,8 +231,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
             // `Err(Unimplemented)` to `Ok(None)`. This helps us avoid
             // emitting additional spurious errors, since we're guaranteed
             // to have emitted at least one.
-            if stack.obligation.references_error() {
-                debug!("no results for error type, treating as ambiguous");
+            if stack.obligation.predicate.references_error() {
+                debug!(?stack.obligation.predicate, "found error type in predicate, treating as ambiguous");
                 return Ok(None);
             }
             return Err(Unimplemented);
diff --git a/src/test/ui/functions-closures/fn-help-with-err-generic-is-not-function.rs b/src/test/ui/functions-closures/fn-help-with-err-generic-is-not-function.rs
index 26deb598762..e48ab4aa96f 100644
--- a/src/test/ui/functions-closures/fn-help-with-err-generic-is-not-function.rs
+++ b/src/test/ui/functions-closures/fn-help-with-err-generic-is-not-function.rs
@@ -8,15 +8,7 @@ where
     //~^ ERROR cannot find type `T` in this scope
     //~| NOTE not found in this scope
 {
-    // The part where it claims that there is no method named `len` is a bug. Feel free to fix it.
-    // This test is intended to ensure that a different bug, where it claimed
-    // that `v` was a function, does not regress.
     fn method(v: Vec<u8>) { v.len(); }
-    //~^ ERROR type annotations needed
-    //~| NOTE cannot infer type
-    //~| NOTE type must be known at this point
-    //~| ERROR no method named `len`
-    //~| NOTE private field, not a method
 }
 
 fn main() {}
diff --git a/src/test/ui/functions-closures/fn-help-with-err-generic-is-not-function.stderr b/src/test/ui/functions-closures/fn-help-with-err-generic-is-not-function.stderr
index 958ce3c25d0..26bdf460f5e 100644
--- a/src/test/ui/functions-closures/fn-help-with-err-generic-is-not-function.stderr
+++ b/src/test/ui/functions-closures/fn-help-with-err-generic-is-not-function.stderr
@@ -12,21 +12,6 @@ error[E0412]: cannot find type `T` in this scope
 LL |     T: Copy,
    |     ^ not found in this scope
 
-error[E0282]: type annotations needed
-  --> $DIR/fn-help-with-err-generic-is-not-function.rs:14:31
-   |
-LL |     fn method(v: Vec<u8>) { v.len(); }
-   |                               ^^^ cannot infer type
-   |
-   = note: type must be known at this point
-
-error[E0599]: no method named `len` found for struct `Vec<u8>` in the current scope
-  --> $DIR/fn-help-with-err-generic-is-not-function.rs:14:31
-   |
-LL |     fn method(v: Vec<u8>) { v.len(); }
-   |                               ^^^ private field, not a method
-
-error: aborting due to 4 previous errors
+error: aborting due to 2 previous errors
 
-Some errors have detailed explanations: E0282, E0412, E0599.
-For more information about an error, try `rustc --explain E0282`.
+For more information about this error, try `rustc --explain E0412`.
diff --git a/src/test/ui/typeck/autoderef-with-param-env-error.rs b/src/test/ui/typeck/autoderef-with-param-env-error.rs
new file mode 100644
index 00000000000..ec96c61c63e
--- /dev/null
+++ b/src/test/ui/typeck/autoderef-with-param-env-error.rs
@@ -0,0 +1,9 @@
+fn foo()
+where
+    T: Send,
+    //~^ cannot find type `T` in this scope
+{
+    let s = "abc".to_string();
+}
+
+fn main() {}
diff --git a/src/test/ui/typeck/autoderef-with-param-env-error.stderr b/src/test/ui/typeck/autoderef-with-param-env-error.stderr
new file mode 100644
index 00000000000..cde800336dd
--- /dev/null
+++ b/src/test/ui/typeck/autoderef-with-param-env-error.stderr
@@ -0,0 +1,12 @@
+error[E0412]: cannot find type `T` in this scope
+  --> $DIR/autoderef-with-param-env-error.rs:3:5
+   |
+LL | fn foo()
+   |       - help: you might be missing a type parameter: `<T>`
+LL | where
+LL |     T: Send,
+   |     ^ not found in this scope
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0412`.