diff options
Diffstat (limited to 'tests')
18 files changed, 207 insertions, 16 deletions
diff --git a/tests/crashes/132826.rs b/tests/crashes/132826.rs deleted file mode 100644 index 9889cecdac5..00000000000 --- a/tests/crashes/132826.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ known-bug: #132826 -pub trait MyTrait { - type Item; -} - -impl<K> MyTrait for Vec<K> { - type Item = Vec<K>; -} - -impl<K> From<Vec<K>> for <Vec<K> as MyTrait>::Item {} diff --git a/tests/pretty/postfix-yield.rs b/tests/pretty/postfix-yield.rs new file mode 100644 index 00000000000..f76e8142ae8 --- /dev/null +++ b/tests/pretty/postfix-yield.rs @@ -0,0 +1,15 @@ +// This demonstrates a proposed alternate or additional option of having yield in postfix position. +//@ edition: 2024 +//@ pp-exact + +#![feature(gen_blocks, coroutines, coroutine_trait, yield_expr)] + +use std::ops::{Coroutine, CoroutineState}; +use std::pin::pin; + +fn main() { + let mut gn = gen { yield 1; 2.yield; (1 + 2).yield; }; + + let mut coro = + pin!(#[coroutine] |_: i32| { let x = 1.yield; (x + 2).yield; }); +} diff --git a/tests/ui/coherence/orphan-check-error-reporting-ty-var.rs b/tests/ui/coherence/orphan-check-error-reporting-ty-var.rs new file mode 100644 index 00000000000..99a83453354 --- /dev/null +++ b/tests/ui/coherence/orphan-check-error-reporting-ty-var.rs @@ -0,0 +1,17 @@ +// Regression test for #132826. + +// Make sure we don't try to resolve the variable `K1` in the generics of the impl +// (which only has `K2`). + +pub trait MyTrait { + type Item; +} + +impl<K1> MyTrait for Vec<K1> { + type Item = Vec<K1>; +} + +impl<K2> From<Vec<K2>> for <Vec<K2> as MyTrait>::Item {} +//~^ ERROR only traits defined in the current crate can be implemented for arbitrary types + +fn main() {} diff --git a/tests/ui/coherence/orphan-check-error-reporting-ty-var.stderr b/tests/ui/coherence/orphan-check-error-reporting-ty-var.stderr new file mode 100644 index 00000000000..f229f8b2e38 --- /dev/null +++ b/tests/ui/coherence/orphan-check-error-reporting-ty-var.stderr @@ -0,0 +1,16 @@ +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/orphan-check-error-reporting-ty-var.rs:14:1 + | +LL | impl<K2> From<Vec<K2>> for <Vec<K2> as MyTrait>::Item {} + | ^^^^^^^^^-------------^^^^^-------------------------- + | | | + | | `Vec` is not defined in the current crate + | `Vec` is not defined in the current crate + | + = note: impl doesn't have any local type before any uncovered type parameters + = note: for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules + = note: define and implement a trait or new type instead + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0117`. diff --git a/tests/ui/consts/miri_unleashed/extern-static.stderr b/tests/ui/consts/miri_unleashed/extern-static.stderr index 0979a5e4fb1..4dbabbe44a2 100644 --- a/tests/ui/consts/miri_unleashed/extern-static.stderr +++ b/tests/ui/consts/miri_unleashed/extern-static.stderr @@ -2,13 +2,13 @@ error[E0080]: could not evaluate static initializer --> $DIR/extern-static.rs:11:25 | LL | unsafe { let _val = DATA; } - | ^^^^ cannot access extern static (DefId(0:4 ~ extern_static[c41e]::{extern#0}::DATA)) + | ^^^^ cannot access extern static `DATA` error[E0080]: could not evaluate static initializer --> $DIR/extern-static.rs:16:14 | LL | unsafe { DATA = 0; } - | ^^^^^^^^ cannot access extern static (DefId(0:4 ~ extern_static[c41e]::{extern#0}::DATA)) + | ^^^^^^^^ cannot access extern static `DATA` error: aborting due to 2 previous errors diff --git a/tests/ui/consts/miri_unleashed/tls.stderr b/tests/ui/consts/miri_unleashed/tls.stderr index a00b7eb1312..ef836544303 100644 --- a/tests/ui/consts/miri_unleashed/tls.stderr +++ b/tests/ui/consts/miri_unleashed/tls.stderr @@ -2,13 +2,13 @@ error[E0080]: could not evaluate static initializer --> $DIR/tls.rs:11:25 | LL | unsafe { let _val = A; } - | ^ cannot access thread local static (DefId(0:4 ~ tls[ca29]::A)) + | ^ cannot access thread local static `A` error[E0080]: could not evaluate static initializer --> $DIR/tls.rs:20:26 | LL | unsafe { let _val = &A; } - | ^ cannot access thread local static (DefId(0:4 ~ tls[ca29]::A)) + | ^ cannot access thread local static `A` warning: skipping const checks | diff --git a/tests/ui/coroutine/postfix-yield.rs b/tests/ui/coroutine/postfix-yield.rs new file mode 100644 index 00000000000..ff843138c8c --- /dev/null +++ b/tests/ui/coroutine/postfix-yield.rs @@ -0,0 +1,34 @@ +// This demonstrates a proposed alternate or additional option of having yield in postfix position. + +//@ run-pass +//@ edition: 2024 + +#![feature(gen_blocks, coroutines, coroutine_trait, yield_expr)] + +use std::ops::{Coroutine, CoroutineState}; +use std::pin::pin; + +fn main() { + // generators (i.e. yield doesn't return anything useful) + let mut gn = gen { + yield 1; + 2.yield; + }; + + assert_eq!(gn.next(), Some(1)); + assert_eq!(gn.next(), Some(2)); + assert_eq!(gn.next(), None); + + //coroutines (i.e. yield returns something useful) + let mut coro = pin!( + #[coroutine] + |_: i32| { + let x = 1.yield; + (x + 2).yield; + } + ); + + assert_eq!(coro.as_mut().resume(0), CoroutineState::Yielded(1)); + assert_eq!(coro.as_mut().resume(2), CoroutineState::Yielded(4)); + assert_eq!(coro.as_mut().resume(3), CoroutineState::Complete(())); +} diff --git a/tests/ui/extern/issue-28324.stderr b/tests/ui/extern/issue-28324.stderr index 1fccb34fdf3..93eb6ff8174 100644 --- a/tests/ui/extern/issue-28324.stderr +++ b/tests/ui/extern/issue-28324.stderr @@ -2,7 +2,7 @@ error[E0080]: could not evaluate static initializer --> $DIR/issue-28324.rs:5:23 | LL | pub static BAZ: u32 = *&error_message_count; - | ^^^^^^^^^^^^^^^^^^^^^ cannot access extern static (DefId(0:4 ~ issue_28324[8ec4]::{extern#0}::error_message_count)) + | ^^^^^^^^^^^^^^^^^^^^^ cannot access extern static `error_message_count` error[E0133]: use of extern static is unsafe and requires unsafe function or block --> $DIR/issue-28324.rs:5:25 diff --git a/tests/ui/invalid-compile-flags/print.stderr b/tests/ui/invalid-compile-flags/print.stderr index df0c3977dc8..4ea06a06539 100644 --- a/tests/ui/invalid-compile-flags/print.stderr +++ b/tests/ui/invalid-compile-flags/print.stderr @@ -1,4 +1,5 @@ error: unknown print request: `yyyy` | = help: valid print requests are: `all-target-specs-json`, `calling-conventions`, `cfg`, `check-cfg`, `code-models`, `crate-name`, `deployment-target`, `file-names`, `host-tuple`, `link-args`, `native-static-libs`, `relocation-models`, `split-debuginfo`, `stack-protector-strategies`, `sysroot`, `target-cpus`, `target-features`, `target-libdir`, `target-list`, `target-spec-json`, `tls-models` + = help: for more information, see the rustc book: https://doc.rust-lang.org/rustc/command-line-arguments.html#--print-print-compiler-information diff --git a/tests/ui/rustc-print-info-issue-138612.rs b/tests/ui/rustc-print-info-issue-138612.rs new file mode 100644 index 00000000000..65b595635b1 --- /dev/null +++ b/tests/ui/rustc-print-info-issue-138612.rs @@ -0,0 +1,2 @@ +//@ check-fail +//@ compile-flags: /dev/null --print lints diff --git a/tests/ui/rustc-print-info-issue-138612.stderr b/tests/ui/rustc-print-info-issue-138612.stderr new file mode 100644 index 00000000000..4f7ed821952 --- /dev/null +++ b/tests/ui/rustc-print-info-issue-138612.stderr @@ -0,0 +1,6 @@ +error: unknown print request: `lints` + | + = help: valid print requests are: `all-target-specs-json`, `calling-conventions`, `cfg`, `check-cfg`, `code-models`, `crate-name`, `deployment-target`, `file-names`, `host-tuple`, `link-args`, `native-static-libs`, `relocation-models`, `split-debuginfo`, `stack-protector-strategies`, `sysroot`, `target-cpus`, `target-features`, `target-libdir`, `target-list`, `target-spec-json`, `tls-models` + = help: use `-Whelp` to print a list of lints + = help: for more information, see the rustc book: https://doc.rust-lang.org/rustc/command-line-arguments.html#--print-print-compiler-information + diff --git a/tests/ui/statics/issue-14227.stderr b/tests/ui/statics/issue-14227.stderr index 0aeb973bff3..3551821a3da 100644 --- a/tests/ui/statics/issue-14227.stderr +++ b/tests/ui/statics/issue-14227.stderr @@ -2,7 +2,7 @@ error[E0080]: could not evaluate static initializer --> $DIR/issue-14227.rs:4:21 | LL | static CRASH: u32 = symbol; - | ^^^^^^ cannot access extern static (DefId(0:4 ~ issue_14227[1133]::{extern#0}::symbol)) + | ^^^^^^ cannot access extern static `symbol` error[E0133]: use of extern static is unsafe and requires unsafe function or block --> $DIR/issue-14227.rs:4:21 diff --git a/tests/ui/uninhabited/auxiliary/staged-api.rs b/tests/ui/uninhabited/auxiliary/staged-api.rs new file mode 100644 index 00000000000..342ecf020ea --- /dev/null +++ b/tests/ui/uninhabited/auxiliary/staged-api.rs @@ -0,0 +1,8 @@ +#![feature(staged_api)] +#![stable(feature = "stable", since = "1.0.0")] + +#[stable(feature = "stable", since = "1.0.0")] +pub struct Foo<T> { + #[unstable(feature = "unstable", issue = "none")] + pub field: T, +} diff --git a/tests/ui/uninhabited/uninhabited-pin-field.rs b/tests/ui/uninhabited/uninhabited-pin-field.rs new file mode 100644 index 00000000000..3d0d9a7a4f8 --- /dev/null +++ b/tests/ui/uninhabited/uninhabited-pin-field.rs @@ -0,0 +1,10 @@ +use std::pin::Pin; + +enum Void {} + +fn demo(x: Pin<Void>) { + match x {} + //~^ ERROR non-exhaustive patterns +} + +fn main() {} diff --git a/tests/ui/uninhabited/uninhabited-pin-field.stderr b/tests/ui/uninhabited/uninhabited-pin-field.stderr new file mode 100644 index 00000000000..93254ca9b98 --- /dev/null +++ b/tests/ui/uninhabited/uninhabited-pin-field.stderr @@ -0,0 +1,19 @@ +error[E0004]: non-exhaustive patterns: type `Pin<Void>` is non-empty + --> $DIR/uninhabited-pin-field.rs:6:11 + | +LL | match x {} + | ^ + | +note: `Pin<Void>` defined here + --> $SRC_DIR/core/src/pin.rs:LL:COL + = note: the matched value is of type `Pin<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.current.stderr b/tests/ui/uninhabited/uninhabited-unstable-field.current.stderr new file mode 100644 index 00000000000..9e0feb4c473 --- /dev/null +++ b/tests/ui/uninhabited/uninhabited-unstable-field.current.stderr @@ -0,0 +1,22 @@ +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 new file mode 100644 index 00000000000..9e0feb4c473 --- /dev/null +++ b/tests/ui/uninhabited/uninhabited-unstable-field.exhaustive.stderr @@ -0,0 +1,22 @@ +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 new file mode 100644 index 00000000000..9b507c518ab --- /dev/null +++ b/tests/ui/uninhabited/uninhabited-unstable-field.rs @@ -0,0 +1,29 @@ +//@ aux-build: staged-api.rs +//@ revisions: current exhaustive + +#![feature(exhaustive_patterns)] + +extern crate staged_api; + +use staged_api::Foo; + +enum Void {} + +fn demo(x: Foo<Void>) { + match x {} + //~^ ERROR non-exhaustive patterns +} + +// Ensure that the pattern is not considered unreachable. +fn demo2(x: Foo<Void>) { + match x { + Foo { .. } => {} + } +} + +// Same as above, but for wildcard. +fn demo3(x: Foo<Void>) { + match x { _ => {} } +} + +fn main() {} |
