about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2024-12-27 19:47:10 +0100
committerGitHub <noreply@github.com>2024-12-27 19:47:10 +0100
commit26fb78a891e4ee27b16445a66160da05fde3d7bb (patch)
treee213c74797332027e51a74eab1b8d3d4e779cda8 /tests
parent95e66ff8b4d5e6f422226176c7dfe2153f2871dc (diff)
parentf349d720e785645c59d12cbf8709da5294e45709 (diff)
downloadrust-26fb78a891e4ee27b16445a66160da05fde3d7bb.tar.gz
rust-26fb78a891e4ee27b16445a66160da05fde3d7bb.zip
Rollup merge of #134798 - compiler-errors:err-auto, r=jackh726
Make `ty::Error` implement all auto traits

I have no idea what's up with the crashes test I fixed--I really don't want to look into it since it has to do something with borrowck and multiple layers of opaques. I think the underlying idea of allowing error types to implement all auto traits is justified though.

Fixes #134796
Fixes #131050

r? lcnr
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/consts/error-is-freeze.rs14
-rw-r--r--tests/ui/consts/error-is-freeze.stderr14
-rw-r--r--tests/ui/impl-trait/auto-trait-contains-err.rs (renamed from tests/crashes/131050.rs)4
-rw-r--r--tests/ui/impl-trait/auto-trait-contains-err.stderr11
4 files changed, 42 insertions, 1 deletions
diff --git a/tests/ui/consts/error-is-freeze.rs b/tests/ui/consts/error-is-freeze.rs
new file mode 100644
index 00000000000..fe27d029e66
--- /dev/null
+++ b/tests/ui/consts/error-is-freeze.rs
@@ -0,0 +1,14 @@
+// Make sure we treat the error type as freeze to suppress useless errors.
+
+struct MyStruct {
+    foo: Option<UndefinedType>,
+    //~^ ERROR cannot find type `UndefinedType` in this scope
+}
+impl MyStruct {
+    pub const EMPTY_REF: &'static Self = &Self::EMPTY;
+    pub const EMPTY: Self = Self {
+        foo: None,
+    };
+}
+
+fn main() {}
diff --git a/tests/ui/consts/error-is-freeze.stderr b/tests/ui/consts/error-is-freeze.stderr
new file mode 100644
index 00000000000..f3bfd1ea5e2
--- /dev/null
+++ b/tests/ui/consts/error-is-freeze.stderr
@@ -0,0 +1,14 @@
+error[E0412]: cannot find type `UndefinedType` in this scope
+  --> $DIR/error-is-freeze.rs:4:17
+   |
+LL |     foo: Option<UndefinedType>,
+   |                 ^^^^^^^^^^^^^ not found in this scope
+   |
+help: you might be missing a type parameter
+   |
+LL | struct MyStruct<UndefinedType> {
+   |                +++++++++++++++
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0412`.
diff --git a/tests/crashes/131050.rs b/tests/ui/impl-trait/auto-trait-contains-err.rs
index 3e3a600ef3d..d7f094211d7 100644
--- a/tests/crashes/131050.rs
+++ b/tests/ui/impl-trait/auto-trait-contains-err.rs
@@ -1,9 +1,9 @@
-//@ known-bug: #131050
 //@ compile-flags: --edition=2021
 
 use std::future::Future;
 
 fn invalid_future() -> impl Future {}
+//~^ ERROR `()` is not a future
 
 fn create_complex_future() -> impl Future<Output = impl ReturnsSend> {
     async { &|| async { invalid_future().await } }
@@ -21,3 +21,5 @@ where
     R: Send,
 {
 }
+
+fn main() {}
diff --git a/tests/ui/impl-trait/auto-trait-contains-err.stderr b/tests/ui/impl-trait/auto-trait-contains-err.stderr
new file mode 100644
index 00000000000..4da6b285ae1
--- /dev/null
+++ b/tests/ui/impl-trait/auto-trait-contains-err.stderr
@@ -0,0 +1,11 @@
+error[E0277]: `()` is not a future
+  --> $DIR/auto-trait-contains-err.rs:5:24
+   |
+LL | fn invalid_future() -> impl Future {}
+   |                        ^^^^^^^^^^^ `()` is not a future
+   |
+   = help: the trait `Future` is not implemented for `()`
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0277`.