about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2024-10-23 23:49:46 +0000
committerMichael Goulet <michael@errs.io>2024-10-24 01:48:44 +0000
commitd8dc31fd3d2a03bc4b01974328c92d2ffb2f4fea (patch)
treeee3dc46be9840ae6f3a5235ba6330c4bf43349c5
parentb8bb2968ce1e44d01520c9d59ee6299ed66df3f9 (diff)
downloadrust-d8dc31fd3d2a03bc4b01974328c92d2ffb2f4fea.tar.gz
rust-d8dc31fd3d2a03bc4b01974328c92d2ffb2f4fea.zip
Consider param-env candidates even if they have errors
-rw-r--r--compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs1
-rw-r--r--tests/crashes/110630.rs28
-rw-r--r--tests/crashes/115808.rs27
-rw-r--r--tests/crashes/121052.rs32
-rw-r--r--tests/ui/async-await/in-trait/unconstrained-impl-region.rs1
-rw-r--r--tests/ui/async-await/in-trait/unconstrained-impl-region.stderr17
-rw-r--r--tests/ui/traits/error-reporting/apit-with-bad-path.rs10
-rw-r--r--tests/ui/traits/error-reporting/apit-with-bad-path.stderr14
-rw-r--r--tests/ui/traits/error-reporting/where-clause-with-bad-path.rs10
-rw-r--r--tests/ui/traits/error-reporting/where-clause-with-bad-path.stderr14
10 files changed, 50 insertions, 104 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 eea3867190d..c0122d3d552 100644
--- a/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs
+++ b/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs
@@ -244,7 +244,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
             .param_env
             .caller_bounds()
             .iter()
-            .filter(|p| !p.references_error())
             .filter_map(|p| p.as_trait_clause())
             // Micro-optimization: filter out predicates relating to different traits.
             .filter(|p| p.def_id() == stack.obligation.predicate.def_id())
diff --git a/tests/crashes/110630.rs b/tests/crashes/110630.rs
deleted file mode 100644
index f17f6f0781f..00000000000
--- a/tests/crashes/110630.rs
+++ /dev/null
@@ -1,28 +0,0 @@
-//@ known-bug: #110630
-
-#![feature(generic_const_exprs)]
-
-use std::ops::Mul;
-
-pub trait Indices<const N: usize> {
-    const NUM_ELEMS: usize = I::NUM_ELEMS * N;
-}
-
-pub trait Concat<J> {
-    type Output;
-}
-
-pub struct Tensor<I: Indices<N>, const N: usize>
-where
-    [u8; I::NUM_ELEMS]: Sized, {}
-
-impl<I: Indices<N>, J: Indices<N>, const N: usize> Mul<Tensor<J, N>> for Tensor<I, N>
-where
-    I: Concat<T>,
-    <I as Concat<J>>::Output: Indices<N>,
-    [u8; I::NUM_ELEMS]: Sized,
-    [u8; J::NUM_ELEMS]: Sized,
-    [u8; <I as Concat<J>>::Output::NUM_ELEMS]: Sized,
-{
-    type Output = Tensor<<I as Concat<J>>::Output, N>;
-}
diff --git a/tests/crashes/115808.rs b/tests/crashes/115808.rs
deleted file mode 100644
index 79196ac9c65..00000000000
--- a/tests/crashes/115808.rs
+++ /dev/null
@@ -1,27 +0,0 @@
-//@ known-bug: #115808
-#![feature(generic_const_exprs)]
-
-use std::ops::Mul;
-
-pub trait Indices<const N: usize> {
-    const NUM_ELEMS: usize;
-}
-
-pub trait Concat<J> {
-    type Output;
-}
-
-pub struct Tensor<I: Indices<N>, const N: usize>
-where
-    [u8; I::NUM_ELEMS]: Sized, {}
-
-impl<I: Indices<N>, J: Indices<N>, const N: usize> Mul<Tensor<J, N>> for Tensor<I, N>
-where
-    I: Concat<FN>,
-    <I as Concat<J>>::Output: Indices<N>,
-    [u8; I::NUM_ELEMS]: Sized,
-    [u8; J::NUM_ELEMS]: Sized,
-    [u8; <I as Concat<J>>::Output::NUM_ELEMS]: Sized,
-{
-    type Output = Tensor<<I as Concat<J>>::Output, N>;
-}
diff --git a/tests/crashes/121052.rs b/tests/crashes/121052.rs
deleted file mode 100644
index 5d16b06db23..00000000000
--- a/tests/crashes/121052.rs
+++ /dev/null
@@ -1,32 +0,0 @@
-//@ known-bug: #121052
-#![feature(generic_const_exprs, with_negative_coherence)]
-
-use std::ops::Mul;
-
-pub trait Indices<const N: usize> {
-    const NUM_ELEMS: usize;
-}
-
-impl<I: Indices<N>, J: Indices<N>, const N: usize> Mul for Tensor<I, N>
-where
-    I: Concat<J>,
-    <I as Concat<J>>::Output: Indices<N>,
-    [u8; I::NUM_ELEMS]: Sized,
-    [u8; J::NUM_ELEMS]: Sized,
-    [u8; <I as Concat<J>>::Output::NUM_ELEMS]: Sized,
-{
-}
-
-pub trait Concat<J> {}
-
-pub struct Tensor<I: Indices<N>, const N: usize> {}
-
-impl<I: Indices<N>, J: Indices<N>, const N: usize> Mul for Tensor<I, N>
-where
-    I: Concat<J>,
-    <I as Concat<J>>::Output: Indices<N>,
-    [u8; I::NUM_ELEMS]: Sized,
-    [u8; J::NUM_ELEMS]: Sized,
-    [u8; <I as Concat<J>>::Output::NUM_ELEMS]: Sized,
-{
-}
diff --git a/tests/ui/async-await/in-trait/unconstrained-impl-region.rs b/tests/ui/async-await/in-trait/unconstrained-impl-region.rs
index 95ba1f3f277..9382c232364 100644
--- a/tests/ui/async-await/in-trait/unconstrained-impl-region.rs
+++ b/tests/ui/async-await/in-trait/unconstrained-impl-region.rs
@@ -14,7 +14,6 @@ impl<'a> Actor for () {
 //~^ ERROR the lifetime parameter `'a` is not constrained by the impl trait, self type, or predicates
     type Message = &'a ();
     async fn on_mount(self, _: impl Inbox<&'a ()>) {}
-    //~^ ERROR the trait bound `impl Inbox<&'a ()>: Inbox<&'a ()>` is not satisfied
 }
 
 fn main() {}
diff --git a/tests/ui/async-await/in-trait/unconstrained-impl-region.stderr b/tests/ui/async-await/in-trait/unconstrained-impl-region.stderr
index 80dc5fdc747..ef7e4ef0eb8 100644
--- a/tests/ui/async-await/in-trait/unconstrained-impl-region.stderr
+++ b/tests/ui/async-await/in-trait/unconstrained-impl-region.stderr
@@ -1,22 +1,9 @@
-error[E0277]: the trait bound `impl Inbox<&'a ()>: Inbox<&'a ()>` is not satisfied
-  --> $DIR/unconstrained-impl-region.rs:16:5
-   |
-LL |     async fn on_mount(self, _: impl Inbox<&'a ()>) {}
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Inbox<&'a ()>` is not implemented for `impl Inbox<&'a ()>`
-   |
-note: required by a bound in `<() as Actor>::on_mount`
-  --> $DIR/unconstrained-impl-region.rs:16:37
-   |
-LL |     async fn on_mount(self, _: impl Inbox<&'a ()>) {}
-   |                                     ^^^^^^^^^^^^^ required by this bound in `<() as Actor>::on_mount`
-
 error[E0207]: the lifetime parameter `'a` is not constrained by the impl trait, self type, or predicates
   --> $DIR/unconstrained-impl-region.rs:13:6
    |
 LL | impl<'a> Actor for () {
    |      ^^ unconstrained lifetime parameter
 
-error: aborting due to 2 previous errors
+error: aborting due to 1 previous error
 
-Some errors have detailed explanations: E0207, E0277.
-For more information about an error, try `rustc --explain E0207`.
+For more information about this error, try `rustc --explain E0207`.
diff --git a/tests/ui/traits/error-reporting/apit-with-bad-path.rs b/tests/ui/traits/error-reporting/apit-with-bad-path.rs
new file mode 100644
index 00000000000..57184b9d0a9
--- /dev/null
+++ b/tests/ui/traits/error-reporting/apit-with-bad-path.rs
@@ -0,0 +1,10 @@
+// Ensure that we don't emit an E0270 for "`impl AsRef<Path>: AsRef<Path>` not satisfied".
+
+fn foo(filename: impl AsRef<Path>) {
+    //~^ ERROR cannot find type `Path` in this scope
+    std::fs::write(filename, "hello").unwrap();
+}
+
+fn main() {
+    foo("/tmp/hello");
+}
diff --git a/tests/ui/traits/error-reporting/apit-with-bad-path.stderr b/tests/ui/traits/error-reporting/apit-with-bad-path.stderr
new file mode 100644
index 00000000000..19bd5e78b47
--- /dev/null
+++ b/tests/ui/traits/error-reporting/apit-with-bad-path.stderr
@@ -0,0 +1,14 @@
+error[E0412]: cannot find type `Path` in this scope
+  --> $DIR/apit-with-bad-path.rs:3:29
+   |
+LL | fn foo(filename: impl AsRef<Path>) {
+   |                             ^^^^ not found in this scope
+   |
+help: consider importing this struct
+   |
+LL + use std::path::Path;
+   |
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0412`.
diff --git a/tests/ui/traits/error-reporting/where-clause-with-bad-path.rs b/tests/ui/traits/error-reporting/where-clause-with-bad-path.rs
new file mode 100644
index 00000000000..cbe14887de4
--- /dev/null
+++ b/tests/ui/traits/error-reporting/where-clause-with-bad-path.rs
@@ -0,0 +1,10 @@
+// Ensure that we don't emit an E0270 for "`impl AsRef<Path>: AsRef<Path>` not satisfied".
+
+fn foo<T: AsRef<Path>>(filename: T) {
+    //~^ ERROR cannot find type `Path` in this scope
+    std::fs::write(filename, "hello").unwrap();
+}
+
+fn main() {
+    foo("/tmp/hello");
+}
diff --git a/tests/ui/traits/error-reporting/where-clause-with-bad-path.stderr b/tests/ui/traits/error-reporting/where-clause-with-bad-path.stderr
new file mode 100644
index 00000000000..1137178f611
--- /dev/null
+++ b/tests/ui/traits/error-reporting/where-clause-with-bad-path.stderr
@@ -0,0 +1,14 @@
+error[E0412]: cannot find type `Path` in this scope
+  --> $DIR/where-clause-with-bad-path.rs:3:17
+   |
+LL | fn foo<T: AsRef<Path>>(filename: T) {
+   |                 ^^^^ not found in this scope
+   |
+help: consider importing this struct
+   |
+LL + use std::path::Path;
+   |
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0412`.