about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2025-07-21 08:42:52 +0000
committerbors <bors@rust-lang.org>2025-07-21 08:42:52 +0000
commit67819923ac8ea353aaa775303f4c3aacbf41d010 (patch)
tree65d7d7e4e2f504909be510ce925d89d57ec77dfc /tests
parente05ab47e6c418fb2b9faa2eae9a7e70c65c98eaa (diff)
parentf0da6e2990f1d9d965e212c6410904319848756d (diff)
Auto merge of #144238 - jhpratt:rollup-xb8aida, r=jhpratt
Rollup of 8 pull requests

Successful merges:

 - rust-lang/rust#144144 (tests: Skip supported-crate-types test on musl hosts)
 - rust-lang/rust#144159 (opt-dist: change build_dir field to be an actual build dir)
 - rust-lang/rust#144162 (Debug impls for DropElaborators)
 - rust-lang/rust#144189 (Add non-regression test for rust-lang/rust#144168)
 - rust-lang/rust#144216 (Don't consider unstable fields always-inhabited)
 - rust-lang/rust#144229 (Miri subtree update)
 - rust-lang/rust#144230 (Option::as_slice: fix comment)
 - rust-lang/rust#144235 (Fix run-make tests on musl hosts)

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/print-request/supported-crate-types.rs5
-rw-r--r--tests/ui/resolve/underscore-bindings-disambiguators.rs27
-rw-r--r--tests/ui/resolve/underscore-bindings-disambiguators.stderr70
-rw-r--r--tests/ui/uninhabited/auxiliary/staged-api.rs6
-rw-r--r--tests/ui/uninhabited/uninhabited-unstable-field.current.stderr22
-rw-r--r--tests/ui/uninhabited/uninhabited-unstable-field.exhaustive.stderr22
-rw-r--r--tests/ui/uninhabited/uninhabited-unstable-field.rs30
-rw-r--r--tests/ui/uninhabited/uninhabited-unstable-field.stderr40
8 files changed, 171 insertions, 51 deletions
diff --git a/tests/ui/print-request/supported-crate-types.rs b/tests/ui/print-request/supported-crate-types.rs
index c8b4c0c1a41..50185a231ee 100644
--- a/tests/ui/print-request/supported-crate-types.rs
+++ b/tests/ui/print-request/supported-crate-types.rs
@@ -8,6 +8,11 @@
 
 //@ check-pass
 
+// FIXME: musl targets are currently statically linked, but running on a musl host
+// requires dynamic linkage, which in turn changes the supported crate types for
+// x86_64-unknown-linux-musl.
+//@ ignore-musl
+
 //@ revisions: wasm musl linux
 
 //@[wasm] compile-flags: --target=wasm32-unknown-unknown --print=supported-crate-types -Zunstable-options
diff --git a/tests/ui/resolve/underscore-bindings-disambiguators.rs b/tests/ui/resolve/underscore-bindings-disambiguators.rs
new file mode 100644
index 00000000000..8c89b39f859
--- /dev/null
+++ b/tests/ui/resolve/underscore-bindings-disambiguators.rs
@@ -0,0 +1,27 @@
+// Regression test for issue #144168 where some `_` bindings were incorrectly only allowed once per
+// module, failing with "error[E0428]: the name `_` is defined multiple times".
+
+// This weird/complex setup is reduced from `zerocopy-0.8.25` where the issue was encountered.
+
+#![crate_type = "lib"]
+
+macro_rules! impl_for_transmute_from {
+    () => {
+        const _: () = {};
+    };
+}
+
+mod impls {
+    use super::*;
+    impl_for_transmute_from!();
+    impl_for_transmute_from!();
+    const _: () = todo!(); //~ ERROR: evaluation panicked
+    const _: () = todo!(); //~ ERROR: evaluation panicked
+    const _: () = todo!(); //~ ERROR: evaluation panicked
+    const _: () = todo!(); //~ ERROR: evaluation panicked
+    const _: () = todo!(); //~ ERROR: evaluation panicked
+}
+use X as Y; //~ ERROR: unresolved import
+use Z as W; //~ ERROR: unresolved import
+
+const _: () = todo!(); //~ ERROR: evaluation panicked
diff --git a/tests/ui/resolve/underscore-bindings-disambiguators.stderr b/tests/ui/resolve/underscore-bindings-disambiguators.stderr
new file mode 100644
index 00000000000..0c8081a0c56
--- /dev/null
+++ b/tests/ui/resolve/underscore-bindings-disambiguators.stderr
@@ -0,0 +1,70 @@
+error[E0432]: unresolved import `X`
+  --> $DIR/underscore-bindings-disambiguators.rs:24:5
+   |
+LL | use X as Y;
+   |     -^^^^^
+   |     |
+   |     no `X` in the root
+   |     help: a similar name exists in the module: `_`
+
+error[E0432]: unresolved import `Z`
+  --> $DIR/underscore-bindings-disambiguators.rs:25:5
+   |
+LL | use Z as W;
+   |     -^^^^^
+   |     |
+   |     no `Z` in the root
+   |     help: a similar name exists in the module: `_`
+
+error[E0080]: evaluation panicked: not yet implemented
+  --> $DIR/underscore-bindings-disambiguators.rs:18:19
+   |
+LL |     const _: () = todo!();
+   |                   ^^^^^^^ evaluation of `impls::_` failed here
+   |
+   = note: this error originates in the macro `todo` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0080]: evaluation panicked: not yet implemented
+  --> $DIR/underscore-bindings-disambiguators.rs:19:19
+   |
+LL |     const _: () = todo!();
+   |                   ^^^^^^^ evaluation of `impls::_` failed here
+   |
+   = note: this error originates in the macro `todo` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0080]: evaluation panicked: not yet implemented
+  --> $DIR/underscore-bindings-disambiguators.rs:20:19
+   |
+LL |     const _: () = todo!();
+   |                   ^^^^^^^ evaluation of `impls::_` failed here
+   |
+   = note: this error originates in the macro `todo` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0080]: evaluation panicked: not yet implemented
+  --> $DIR/underscore-bindings-disambiguators.rs:21:19
+   |
+LL |     const _: () = todo!();
+   |                   ^^^^^^^ evaluation of `impls::_` failed here
+   |
+   = note: this error originates in the macro `todo` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0080]: evaluation panicked: not yet implemented
+  --> $DIR/underscore-bindings-disambiguators.rs:22:19
+   |
+LL |     const _: () = todo!();
+   |                   ^^^^^^^ evaluation of `impls::_` failed here
+   |
+   = note: this error originates in the macro `todo` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0080]: evaluation panicked: not yet implemented
+  --> $DIR/underscore-bindings-disambiguators.rs:27:15
+   |
+LL | const _: () = todo!();
+   |               ^^^^^^^ evaluation of `_` failed here
+   |
+   = note: this error originates in the macro `todo` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: aborting due to 8 previous errors
+
+Some errors have detailed explanations: E0080, E0432.
+For more information about an error, try `rustc --explain E0080`.
diff --git a/tests/ui/uninhabited/auxiliary/staged-api.rs b/tests/ui/uninhabited/auxiliary/staged-api.rs
index 342ecf020ea..925bb1e0c65 100644
--- a/tests/ui/uninhabited/auxiliary/staged-api.rs
+++ b/tests/ui/uninhabited/auxiliary/staged-api.rs
@@ -6,3 +6,9 @@ pub struct Foo<T> {
     #[unstable(feature = "unstable", issue = "none")]
     pub field: T,
 }
+
+#[unstable(feature = "my_coro_state", issue = "none")]
+pub enum MyCoroutineState<Y, R> {
+    Yielded(Y),
+    Complete(R),
+}
diff --git a/tests/ui/uninhabited/uninhabited-unstable-field.current.stderr b/tests/ui/uninhabited/uninhabited-unstable-field.current.stderr
deleted file mode 100644
index 9e0feb4c473..00000000000
--- a/tests/ui/uninhabited/uninhabited-unstable-field.current.stderr
+++ /dev/null
@@ -1,22 +0,0 @@
-error[E0004]: non-exhaustive patterns: type `Foo<Void>` is non-empty
-  --> $DIR/uninhabited-unstable-field.rs:13:11
-   |
-LL |     match x {}
-   |           ^
-   |
-note: `Foo<Void>` defined here
-  --> $DIR/auxiliary/staged-api.rs:5:1
-   |
-LL | pub struct Foo<T> {
-   | ^^^^^^^^^^^^^^^^^
-   = note: the matched value is of type `Foo<Void>`
-help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown
-   |
-LL ~     match x {
-LL +         _ => todo!(),
-LL ~     }
-   |
-
-error: aborting due to 1 previous error
-
-For more information about this error, try `rustc --explain E0004`.
diff --git a/tests/ui/uninhabited/uninhabited-unstable-field.exhaustive.stderr b/tests/ui/uninhabited/uninhabited-unstable-field.exhaustive.stderr
deleted file mode 100644
index 9e0feb4c473..00000000000
--- a/tests/ui/uninhabited/uninhabited-unstable-field.exhaustive.stderr
+++ /dev/null
@@ -1,22 +0,0 @@
-error[E0004]: non-exhaustive patterns: type `Foo<Void>` is non-empty
-  --> $DIR/uninhabited-unstable-field.rs:13:11
-   |
-LL |     match x {}
-   |           ^
-   |
-note: `Foo<Void>` defined here
-  --> $DIR/auxiliary/staged-api.rs:5:1
-   |
-LL | pub struct Foo<T> {
-   | ^^^^^^^^^^^^^^^^^
-   = note: the matched value is of type `Foo<Void>`
-help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown
-   |
-LL ~     match x {
-LL +         _ => todo!(),
-LL ~     }
-   |
-
-error: aborting due to 1 previous error
-
-For more information about this error, try `rustc --explain E0004`.
diff --git a/tests/ui/uninhabited/uninhabited-unstable-field.rs b/tests/ui/uninhabited/uninhabited-unstable-field.rs
index 9b507c518ab..321b864aa27 100644
--- a/tests/ui/uninhabited/uninhabited-unstable-field.rs
+++ b/tests/ui/uninhabited/uninhabited-unstable-field.rs
@@ -1,29 +1,45 @@
 //@ aux-build: staged-api.rs
-//@ revisions: current exhaustive
-
+//! The field of `Pin` used to be public, which would cause `Pin<Void>` to be uninhabited. To remedy
+//! this, we temporarily made it so unstable fields are always considered inhabited. This has now
+//! been reverted, and this file ensures that we don't special-case unstable fields wrt
+//! inhabitedness anymore.
 #![feature(exhaustive_patterns)]
+#![feature(never_type)]
+#![feature(my_coro_state)] // Custom feature from `staged-api.rs`
+#![deny(unreachable_patterns)]
 
 extern crate staged_api;
 
-use staged_api::Foo;
+use staged_api::{Foo, MyCoroutineState};
 
 enum Void {}
 
 fn demo(x: Foo<Void>) {
     match x {}
-    //~^ ERROR non-exhaustive patterns
 }
 
-// Ensure that the pattern is not considered unreachable.
+// Ensure that the pattern is considered unreachable.
 fn demo2(x: Foo<Void>) {
     match x {
-        Foo { .. } => {}
+        Foo { .. } => {} //~ ERROR unreachable
     }
 }
 
 // Same as above, but for wildcard.
 fn demo3(x: Foo<Void>) {
-    match x { _ => {} }
+    match x {
+        _ => {} //~ ERROR unreachable
+    }
+}
+
+fn unstable_enum(x: MyCoroutineState<i32, !>) {
+    match x {
+        MyCoroutineState::Yielded(_) => {}
+    }
+    match x {
+        MyCoroutineState::Yielded(_) => {}
+        MyCoroutineState::Complete(_) => {} //~ ERROR unreachable
+    }
 }
 
 fn main() {}
diff --git a/tests/ui/uninhabited/uninhabited-unstable-field.stderr b/tests/ui/uninhabited/uninhabited-unstable-field.stderr
new file mode 100644
index 00000000000..a0c9f9366a6
--- /dev/null
+++ b/tests/ui/uninhabited/uninhabited-unstable-field.stderr
@@ -0,0 +1,40 @@
+error: unreachable pattern
+  --> $DIR/uninhabited-unstable-field.rs:24:9
+   |
+LL |         Foo { .. } => {}
+   |         ^^^^^^^^^^------
+   |         |
+   |         matches no values because `Foo<Void>` is uninhabited
+   |         help: remove the match arm
+   |
+   = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
+note: the lint level is defined here
+  --> $DIR/uninhabited-unstable-field.rs:9:9
+   |
+LL | #![deny(unreachable_patterns)]
+   |         ^^^^^^^^^^^^^^^^^^^^
+
+error: unreachable pattern
+  --> $DIR/uninhabited-unstable-field.rs:31:9
+   |
+LL |         _ => {}
+   |         ^------
+   |         |
+   |         matches no values because `Foo<Void>` is uninhabited
+   |         help: remove the match arm
+   |
+   = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
+
+error: unreachable pattern
+  --> $DIR/uninhabited-unstable-field.rs:41:9
+   |
+LL |         MyCoroutineState::Complete(_) => {}
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------
+   |         |
+   |         matches no values because `!` is uninhabited
+   |         help: remove the match arm
+   |
+   = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
+
+error: aborting due to 3 previous errors
+