summary refs log tree commit diff
path: root/tests/ui/traits/error-reporting
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 /tests/ui/traits/error-reporting
parentb8bb2968ce1e44d01520c9d59ee6299ed66df3f9 (diff)
downloadrust-d8dc31fd3d2a03bc4b01974328c92d2ffb2f4fea.tar.gz
rust-d8dc31fd3d2a03bc4b01974328c92d2ffb2f4fea.zip
Consider param-env candidates even if they have errors
Diffstat (limited to 'tests/ui/traits/error-reporting')
-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
4 files changed, 48 insertions, 0 deletions
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`.