From 1549585f26881927ea8305e0724d2d1f1dc45ade Mon Sep 17 00:00:00 2001 From: Kivooeo Date: Tue, 1 Jul 2025 19:28:14 +0500 Subject: moved tests --- .../reexport-test-harness-entry-point.rs | 11 +++ tests/ui/const-ptr/pointer-address-stability.rs | 8 +++ tests/ui/diagnostic-flags/error-format-short.rs | 9 +++ .../ui/diagnostic-flags/error-format-short.stderr | 3 + tests/ui/drop/drop-once-on-move.rs | 33 +++++++++ tests/ui/drop/drop-scope-exit.rs | 31 ++++++++ tests/ui/generics/trait-incorrect-generic-args.rs | 13 ++++ .../generics/trait-incorrect-generic-args.stderr | 31 ++++++++ tests/ui/io-checks/io-stdout-blocking-writes.rs | 83 ++++++++++++++++++++++ tests/ui/reexport-test-harness-main.rs | 11 --- tests/ui/resource-assign-is-not-copy.rs | 33 --------- tests/ui/resource-destruct.rs | 31 -------- tests/ui/seq-args.rs | 13 ---- tests/ui/seq-args.stderr | 31 -------- tests/ui/shadow-bool.rs | 18 ----- tests/ui/shadowed-use-visibility.rs | 13 ---- tests/ui/shadowed/primitive-type-shadowing.rs | 18 +++++ tests/ui/shadowed/use-shadows-reexport.rs | 13 ++++ tests/ui/short-error-format.rs | 9 --- tests/ui/short-error-format.stderr | 3 - tests/ui/sized-borrowed-pointer.rs | 9 --- tests/ui/sized-cycle-note.rs | 7 -- tests/ui/sized-cycle-note.stderr | 19 ----- tests/ui/sized-owned-pointer.rs | 10 --- tests/ui/sized/recursive-type-infinite-size.rs | 7 ++ tests/ui/sized/recursive-type-infinite-size.stderr | 19 +++++ tests/ui/sized/sized-box-unsized-content.rs | 10 +++ tests/ui/sized/sized-reference-to-unsized.rs | 9 +++ tests/ui/sse2.rs | 26 ------- tests/ui/stable-addr-of.rs | 8 --- tests/ui/std-uncopyable-atomics.rs | 16 ----- tests/ui/std-uncopyable-atomics.stderr | 51 ------------- tests/ui/stdio-is-blocking.rs | 83 ---------------------- tests/ui/string-box-error.rs | 12 ---- tests/ui/sync/atomic-types-not-copyable.rs | 16 +++++ tests/ui/sync/atomic-types-not-copyable.stderr | 51 +++++++++++++ .../ui/target-feature/target-feature-detection.rs | 26 +++++++ tests/ui/traits/error-trait-object-from-string.rs | 12 ++++ 38 files changed, 403 insertions(+), 403 deletions(-) create mode 100644 tests/ui/attributes/reexport-test-harness-entry-point.rs create mode 100644 tests/ui/const-ptr/pointer-address-stability.rs create mode 100644 tests/ui/diagnostic-flags/error-format-short.rs create mode 100644 tests/ui/diagnostic-flags/error-format-short.stderr create mode 100644 tests/ui/drop/drop-once-on-move.rs create mode 100644 tests/ui/drop/drop-scope-exit.rs create mode 100644 tests/ui/generics/trait-incorrect-generic-args.rs create mode 100644 tests/ui/generics/trait-incorrect-generic-args.stderr create mode 100644 tests/ui/io-checks/io-stdout-blocking-writes.rs delete mode 100644 tests/ui/reexport-test-harness-main.rs delete mode 100644 tests/ui/resource-assign-is-not-copy.rs delete mode 100644 tests/ui/resource-destruct.rs delete mode 100644 tests/ui/seq-args.rs delete mode 100644 tests/ui/seq-args.stderr delete mode 100644 tests/ui/shadow-bool.rs delete mode 100644 tests/ui/shadowed-use-visibility.rs create mode 100644 tests/ui/shadowed/primitive-type-shadowing.rs create mode 100644 tests/ui/shadowed/use-shadows-reexport.rs delete mode 100644 tests/ui/short-error-format.rs delete mode 100644 tests/ui/short-error-format.stderr delete mode 100644 tests/ui/sized-borrowed-pointer.rs delete mode 100644 tests/ui/sized-cycle-note.rs delete mode 100644 tests/ui/sized-cycle-note.stderr delete mode 100644 tests/ui/sized-owned-pointer.rs create mode 100644 tests/ui/sized/recursive-type-infinite-size.rs create mode 100644 tests/ui/sized/recursive-type-infinite-size.stderr create mode 100644 tests/ui/sized/sized-box-unsized-content.rs create mode 100644 tests/ui/sized/sized-reference-to-unsized.rs delete mode 100644 tests/ui/sse2.rs delete mode 100644 tests/ui/stable-addr-of.rs delete mode 100644 tests/ui/std-uncopyable-atomics.rs delete mode 100644 tests/ui/std-uncopyable-atomics.stderr delete mode 100644 tests/ui/stdio-is-blocking.rs delete mode 100644 tests/ui/string-box-error.rs create mode 100644 tests/ui/sync/atomic-types-not-copyable.rs create mode 100644 tests/ui/sync/atomic-types-not-copyable.stderr create mode 100644 tests/ui/target-feature/target-feature-detection.rs create mode 100644 tests/ui/traits/error-trait-object-from-string.rs diff --git a/tests/ui/attributes/reexport-test-harness-entry-point.rs b/tests/ui/attributes/reexport-test-harness-entry-point.rs new file mode 100644 index 00000000000..f79828fc7d6 --- /dev/null +++ b/tests/ui/attributes/reexport-test-harness-entry-point.rs @@ -0,0 +1,11 @@ +//@ run-pass +//@ compile-flags:--test + +#![reexport_test_harness_main = "test_main"] + +#[cfg(test)] +fn _unused() { + // should resolve to the entry point function the --test harness + // creates. + test_main(); +} diff --git a/tests/ui/const-ptr/pointer-address-stability.rs b/tests/ui/const-ptr/pointer-address-stability.rs new file mode 100644 index 00000000000..e330a4853ce --- /dev/null +++ b/tests/ui/const-ptr/pointer-address-stability.rs @@ -0,0 +1,8 @@ +//@ run-pass +// Issue #2040 + + +pub fn main() { + let foo: isize = 1; + assert_eq!(&foo as *const isize, &foo as *const isize); +} diff --git a/tests/ui/diagnostic-flags/error-format-short.rs b/tests/ui/diagnostic-flags/error-format-short.rs new file mode 100644 index 00000000000..719870a04fb --- /dev/null +++ b/tests/ui/diagnostic-flags/error-format-short.rs @@ -0,0 +1,9 @@ +//@ compile-flags: --error-format=short + +fn foo(_: u32) {} + +fn main() { + foo("Bonjour".to_owned()); + let x = 0u32; + x.salut(); +} diff --git a/tests/ui/diagnostic-flags/error-format-short.stderr b/tests/ui/diagnostic-flags/error-format-short.stderr new file mode 100644 index 00000000000..1a4a6d4df88 --- /dev/null +++ b/tests/ui/diagnostic-flags/error-format-short.stderr @@ -0,0 +1,3 @@ +$DIR/short-error-format.rs:6:9: error[E0308]: mismatched types: expected `u32`, found `String` +$DIR/short-error-format.rs:8:7: error[E0599]: no method named `salut` found for type `u32` in the current scope: method not found in `u32` +error: aborting due to 2 previous errors diff --git a/tests/ui/drop/drop-once-on-move.rs b/tests/ui/drop/drop-once-on-move.rs new file mode 100644 index 00000000000..ab426016901 --- /dev/null +++ b/tests/ui/drop/drop-once-on-move.rs @@ -0,0 +1,33 @@ +//@ run-pass + +#![allow(non_camel_case_types)] +use std::cell::Cell; + +#[derive(Debug)] +struct r<'a> { + i: &'a Cell, +} + +impl<'a> Drop for r<'a> { + fn drop(&mut self) { + self.i.set(self.i.get() + 1); + } +} + +fn r(i: &Cell) -> r<'_> { + r { + i: i + } +} + +pub fn main() { + let i = &Cell::new(0); + // Even though these look like copies, they are guaranteed not to be + { + let a = r(i); + let b = (a, 10); + let (c, _d) = b; + println!("{:?}", c); + } + assert_eq!(i.get(), 1); +} diff --git a/tests/ui/drop/drop-scope-exit.rs b/tests/ui/drop/drop-scope-exit.rs new file mode 100644 index 00000000000..480cbe091a7 --- /dev/null +++ b/tests/ui/drop/drop-scope-exit.rs @@ -0,0 +1,31 @@ +//@ run-pass + +#![allow(non_camel_case_types)] +use std::cell::Cell; + +struct shrinky_pointer<'a> { + i: &'a Cell, +} + +impl<'a> Drop for shrinky_pointer<'a> { + fn drop(&mut self) { + println!("Hello!"); self.i.set(self.i.get() - 1); + } +} + +impl<'a> shrinky_pointer<'a> { + pub fn look_at(&self) -> isize { return self.i.get(); } +} + +fn shrinky_pointer(i: &Cell) -> shrinky_pointer<'_> { + shrinky_pointer { + i: i + } +} + +pub fn main() { + let my_total = &Cell::new(10); + { let pt = shrinky_pointer(my_total); assert_eq!(pt.look_at(), 10); } + println!("my_total = {}", my_total.get()); + assert_eq!(my_total.get(), 9); +} diff --git a/tests/ui/generics/trait-incorrect-generic-args.rs b/tests/ui/generics/trait-incorrect-generic-args.rs new file mode 100644 index 00000000000..627dfcc3198 --- /dev/null +++ b/tests/ui/generics/trait-incorrect-generic-args.rs @@ -0,0 +1,13 @@ +fn main() { + trait Seq { } + + impl Seq for Vec { + //~^ ERROR trait takes 0 generic arguments but 1 generic argument + /* ... */ + } + + impl Seq for u32 { + //~^ ERROR trait takes 0 generic arguments but 1 generic argument + /* Treat the integer as a sequence of bits */ + } +} diff --git a/tests/ui/generics/trait-incorrect-generic-args.stderr b/tests/ui/generics/trait-incorrect-generic-args.stderr new file mode 100644 index 00000000000..6e0d484d013 --- /dev/null +++ b/tests/ui/generics/trait-incorrect-generic-args.stderr @@ -0,0 +1,31 @@ +error[E0107]: trait takes 0 generic arguments but 1 generic argument was supplied + --> $DIR/seq-args.rs:4:13 + | +LL | impl Seq for Vec { + | ^^^--- help: remove the unnecessary generics + | | + | expected 0 generic arguments + | +note: trait defined here, with 0 generic parameters + --> $DIR/seq-args.rs:2:11 + | +LL | trait Seq { } + | ^^^ + +error[E0107]: trait takes 0 generic arguments but 1 generic argument was supplied + --> $DIR/seq-args.rs:9:10 + | +LL | impl Seq for u32 { + | ^^^------ help: remove the unnecessary generics + | | + | expected 0 generic arguments + | +note: trait defined here, with 0 generic parameters + --> $DIR/seq-args.rs:2:11 + | +LL | trait Seq { } + | ^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0107`. diff --git a/tests/ui/io-checks/io-stdout-blocking-writes.rs b/tests/ui/io-checks/io-stdout-blocking-writes.rs new file mode 100644 index 00000000000..615530dcd47 --- /dev/null +++ b/tests/ui/io-checks/io-stdout-blocking-writes.rs @@ -0,0 +1,83 @@ +//@ run-pass +//@ needs-subprocess + +use std::env; +use std::io::prelude::*; +use std::process::Command; +use std::thread; + +const THREADS: usize = 20; +const WRITES: usize = 100; +const WRITE_SIZE: usize = 1024 * 32; + +fn main() { + let args = env::args().collect::>(); + if args.len() == 1 { + parent(); + } else { + child(); + } +} + +fn parent() { + let me = env::current_exe().unwrap(); + let mut cmd = Command::new(me); + cmd.arg("run-the-test"); + let output = cmd.output().unwrap(); + assert!(output.status.success()); + assert_eq!(output.stderr.len(), 0); + assert_eq!(output.stdout.len(), WRITES * THREADS * WRITE_SIZE); + for byte in output.stdout.iter() { + assert_eq!(*byte, b'a'); + } +} + +fn child() { + let threads = (0..THREADS).map(|_| { + thread::spawn(|| { + let buf = [b'a'; WRITE_SIZE]; + for _ in 0..WRITES { + write_all(&buf); + } + }) + }).collect::>(); + + for thread in threads { + thread.join().unwrap(); + } +} + +#[cfg(unix)] +fn write_all(buf: &[u8]) { + use std::fs::File; + use std::mem; + use std::os::unix::prelude::*; + + let mut file = unsafe { File::from_raw_fd(1) }; + let res = file.write_all(buf); + mem::forget(file); + res.unwrap(); +} + +#[cfg(windows)] +fn write_all(buf: &[u8]) { + use std::fs::File; + use std::mem; + use std::os::windows::raw::*; + use std::os::windows::prelude::*; + + const STD_OUTPUT_HANDLE: u32 = (-11i32) as u32; + + extern "system" { + fn GetStdHandle(handle: u32) -> HANDLE; + } + + let mut file = unsafe { + let handle = GetStdHandle(STD_OUTPUT_HANDLE); + assert!(!handle.is_null()); + File::from_raw_handle(handle) + }; + let res = file.write_all(buf); + mem::forget(file); + res.unwrap(); +} diff --git a/tests/ui/reexport-test-harness-main.rs b/tests/ui/reexport-test-harness-main.rs deleted file mode 100644 index f79828fc7d6..00000000000 --- a/tests/ui/reexport-test-harness-main.rs +++ /dev/null @@ -1,11 +0,0 @@ -//@ run-pass -//@ compile-flags:--test - -#![reexport_test_harness_main = "test_main"] - -#[cfg(test)] -fn _unused() { - // should resolve to the entry point function the --test harness - // creates. - test_main(); -} diff --git a/tests/ui/resource-assign-is-not-copy.rs b/tests/ui/resource-assign-is-not-copy.rs deleted file mode 100644 index ab426016901..00000000000 --- a/tests/ui/resource-assign-is-not-copy.rs +++ /dev/null @@ -1,33 +0,0 @@ -//@ run-pass - -#![allow(non_camel_case_types)] -use std::cell::Cell; - -#[derive(Debug)] -struct r<'a> { - i: &'a Cell, -} - -impl<'a> Drop for r<'a> { - fn drop(&mut self) { - self.i.set(self.i.get() + 1); - } -} - -fn r(i: &Cell) -> r<'_> { - r { - i: i - } -} - -pub fn main() { - let i = &Cell::new(0); - // Even though these look like copies, they are guaranteed not to be - { - let a = r(i); - let b = (a, 10); - let (c, _d) = b; - println!("{:?}", c); - } - assert_eq!(i.get(), 1); -} diff --git a/tests/ui/resource-destruct.rs b/tests/ui/resource-destruct.rs deleted file mode 100644 index 480cbe091a7..00000000000 --- a/tests/ui/resource-destruct.rs +++ /dev/null @@ -1,31 +0,0 @@ -//@ run-pass - -#![allow(non_camel_case_types)] -use std::cell::Cell; - -struct shrinky_pointer<'a> { - i: &'a Cell, -} - -impl<'a> Drop for shrinky_pointer<'a> { - fn drop(&mut self) { - println!("Hello!"); self.i.set(self.i.get() - 1); - } -} - -impl<'a> shrinky_pointer<'a> { - pub fn look_at(&self) -> isize { return self.i.get(); } -} - -fn shrinky_pointer(i: &Cell) -> shrinky_pointer<'_> { - shrinky_pointer { - i: i - } -} - -pub fn main() { - let my_total = &Cell::new(10); - { let pt = shrinky_pointer(my_total); assert_eq!(pt.look_at(), 10); } - println!("my_total = {}", my_total.get()); - assert_eq!(my_total.get(), 9); -} diff --git a/tests/ui/seq-args.rs b/tests/ui/seq-args.rs deleted file mode 100644 index 627dfcc3198..00000000000 --- a/tests/ui/seq-args.rs +++ /dev/null @@ -1,13 +0,0 @@ -fn main() { - trait Seq { } - - impl Seq for Vec { - //~^ ERROR trait takes 0 generic arguments but 1 generic argument - /* ... */ - } - - impl Seq for u32 { - //~^ ERROR trait takes 0 generic arguments but 1 generic argument - /* Treat the integer as a sequence of bits */ - } -} diff --git a/tests/ui/seq-args.stderr b/tests/ui/seq-args.stderr deleted file mode 100644 index 6e0d484d013..00000000000 --- a/tests/ui/seq-args.stderr +++ /dev/null @@ -1,31 +0,0 @@ -error[E0107]: trait takes 0 generic arguments but 1 generic argument was supplied - --> $DIR/seq-args.rs:4:13 - | -LL | impl Seq for Vec { - | ^^^--- help: remove the unnecessary generics - | | - | expected 0 generic arguments - | -note: trait defined here, with 0 generic parameters - --> $DIR/seq-args.rs:2:11 - | -LL | trait Seq { } - | ^^^ - -error[E0107]: trait takes 0 generic arguments but 1 generic argument was supplied - --> $DIR/seq-args.rs:9:10 - | -LL | impl Seq for u32 { - | ^^^------ help: remove the unnecessary generics - | | - | expected 0 generic arguments - | -note: trait defined here, with 0 generic parameters - --> $DIR/seq-args.rs:2:11 - | -LL | trait Seq { } - | ^^^ - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0107`. diff --git a/tests/ui/shadow-bool.rs b/tests/ui/shadow-bool.rs deleted file mode 100644 index 8cba2c1710b..00000000000 --- a/tests/ui/shadow-bool.rs +++ /dev/null @@ -1,18 +0,0 @@ -//@ check-pass - -mod bar { - pub trait QueryId { - const SOME_PROPERTY: bool; - } -} - -use bar::QueryId; - -#[allow(non_camel_case_types)] -pub struct bool; - -impl QueryId for bool { - const SOME_PROPERTY: core::primitive::bool = true; -} - -fn main() {} diff --git a/tests/ui/shadowed-use-visibility.rs b/tests/ui/shadowed-use-visibility.rs deleted file mode 100644 index 5ce4103b559..00000000000 --- a/tests/ui/shadowed-use-visibility.rs +++ /dev/null @@ -1,13 +0,0 @@ -//@ run-pass - -#![allow(unused_imports)] -mod foo { - pub fn f() {} - - pub use self::f as bar; - use crate::foo as bar; -} - -fn main() { - foo::bar(); -} diff --git a/tests/ui/shadowed/primitive-type-shadowing.rs b/tests/ui/shadowed/primitive-type-shadowing.rs new file mode 100644 index 00000000000..8cba2c1710b --- /dev/null +++ b/tests/ui/shadowed/primitive-type-shadowing.rs @@ -0,0 +1,18 @@ +//@ check-pass + +mod bar { + pub trait QueryId { + const SOME_PROPERTY: bool; + } +} + +use bar::QueryId; + +#[allow(non_camel_case_types)] +pub struct bool; + +impl QueryId for bool { + const SOME_PROPERTY: core::primitive::bool = true; +} + +fn main() {} diff --git a/tests/ui/shadowed/use-shadows-reexport.rs b/tests/ui/shadowed/use-shadows-reexport.rs new file mode 100644 index 00000000000..5ce4103b559 --- /dev/null +++ b/tests/ui/shadowed/use-shadows-reexport.rs @@ -0,0 +1,13 @@ +//@ run-pass + +#![allow(unused_imports)] +mod foo { + pub fn f() {} + + pub use self::f as bar; + use crate::foo as bar; +} + +fn main() { + foo::bar(); +} diff --git a/tests/ui/short-error-format.rs b/tests/ui/short-error-format.rs deleted file mode 100644 index 719870a04fb..00000000000 --- a/tests/ui/short-error-format.rs +++ /dev/null @@ -1,9 +0,0 @@ -//@ compile-flags: --error-format=short - -fn foo(_: u32) {} - -fn main() { - foo("Bonjour".to_owned()); - let x = 0u32; - x.salut(); -} diff --git a/tests/ui/short-error-format.stderr b/tests/ui/short-error-format.stderr deleted file mode 100644 index 1a4a6d4df88..00000000000 --- a/tests/ui/short-error-format.stderr +++ /dev/null @@ -1,3 +0,0 @@ -$DIR/short-error-format.rs:6:9: error[E0308]: mismatched types: expected `u32`, found `String` -$DIR/short-error-format.rs:8:7: error[E0599]: no method named `salut` found for type `u32` in the current scope: method not found in `u32` -error: aborting due to 2 previous errors diff --git a/tests/ui/sized-borrowed-pointer.rs b/tests/ui/sized-borrowed-pointer.rs deleted file mode 100644 index bd213c067db..00000000000 --- a/tests/ui/sized-borrowed-pointer.rs +++ /dev/null @@ -1,9 +0,0 @@ -//@ run-pass - -#![allow(dead_code)] -// Possibly-dynamic size of typaram should be cleared at pointer boundary. - - -fn bar() { } -fn foo() { bar::<&T>() } -pub fn main() { } diff --git a/tests/ui/sized-cycle-note.rs b/tests/ui/sized-cycle-note.rs deleted file mode 100644 index 766a5fa0de3..00000000000 --- a/tests/ui/sized-cycle-note.rs +++ /dev/null @@ -1,7 +0,0 @@ -struct Baz { q: Option } -//~^ ERROR recursive types `Baz` and `Foo` have infinite size -struct Foo { q: Option } - -impl Foo { fn bar(&self) {} } - -fn main() {} diff --git a/tests/ui/sized-cycle-note.stderr b/tests/ui/sized-cycle-note.stderr deleted file mode 100644 index 21e54c12fed..00000000000 --- a/tests/ui/sized-cycle-note.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error[E0072]: recursive types `Baz` and `Foo` have infinite size - --> $DIR/sized-cycle-note.rs:1:1 - | -LL | struct Baz { q: Option } - | ^^^^^^^^^^ --- recursive without indirection -LL | -LL | struct Foo { q: Option } - | ^^^^^^^^^^ --- recursive without indirection - | -help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to break the cycle - | -LL ~ struct Baz { q: Option> } -LL | -LL ~ struct Foo { q: Option> } - | - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0072`. diff --git a/tests/ui/sized-owned-pointer.rs b/tests/ui/sized-owned-pointer.rs deleted file mode 100644 index b35c0f91abd..00000000000 --- a/tests/ui/sized-owned-pointer.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ run-pass - -#![allow(dead_code)] -// Possibly-dynamic size of typaram should be cleared at pointer boundary. - - - -fn bar() { } -fn foo() { bar::>() } -pub fn main() { } diff --git a/tests/ui/sized/recursive-type-infinite-size.rs b/tests/ui/sized/recursive-type-infinite-size.rs new file mode 100644 index 00000000000..766a5fa0de3 --- /dev/null +++ b/tests/ui/sized/recursive-type-infinite-size.rs @@ -0,0 +1,7 @@ +struct Baz { q: Option } +//~^ ERROR recursive types `Baz` and `Foo` have infinite size +struct Foo { q: Option } + +impl Foo { fn bar(&self) {} } + +fn main() {} diff --git a/tests/ui/sized/recursive-type-infinite-size.stderr b/tests/ui/sized/recursive-type-infinite-size.stderr new file mode 100644 index 00000000000..21e54c12fed --- /dev/null +++ b/tests/ui/sized/recursive-type-infinite-size.stderr @@ -0,0 +1,19 @@ +error[E0072]: recursive types `Baz` and `Foo` have infinite size + --> $DIR/sized-cycle-note.rs:1:1 + | +LL | struct Baz { q: Option } + | ^^^^^^^^^^ --- recursive without indirection +LL | +LL | struct Foo { q: Option } + | ^^^^^^^^^^ --- recursive without indirection + | +help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to break the cycle + | +LL ~ struct Baz { q: Option> } +LL | +LL ~ struct Foo { q: Option> } + | + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0072`. diff --git a/tests/ui/sized/sized-box-unsized-content.rs b/tests/ui/sized/sized-box-unsized-content.rs new file mode 100644 index 00000000000..b35c0f91abd --- /dev/null +++ b/tests/ui/sized/sized-box-unsized-content.rs @@ -0,0 +1,10 @@ +//@ run-pass + +#![allow(dead_code)] +// Possibly-dynamic size of typaram should be cleared at pointer boundary. + + + +fn bar() { } +fn foo() { bar::>() } +pub fn main() { } diff --git a/tests/ui/sized/sized-reference-to-unsized.rs b/tests/ui/sized/sized-reference-to-unsized.rs new file mode 100644 index 00000000000..bd213c067db --- /dev/null +++ b/tests/ui/sized/sized-reference-to-unsized.rs @@ -0,0 +1,9 @@ +//@ run-pass + +#![allow(dead_code)] +// Possibly-dynamic size of typaram should be cleared at pointer boundary. + + +fn bar() { } +fn foo() { bar::<&T>() } +pub fn main() { } diff --git a/tests/ui/sse2.rs b/tests/ui/sse2.rs deleted file mode 100644 index a1894cc03db..00000000000 --- a/tests/ui/sse2.rs +++ /dev/null @@ -1,26 +0,0 @@ -//@ run-pass - -#![allow(stable_features)] -#![feature(cfg_target_feature)] - -use std::env; - -fn main() { - match env::var("TARGET") { - Ok(s) => { - // Skip this tests on i586-unknown-linux-gnu where sse2 is disabled - if s.contains("i586") { - return - } - } - Err(_) => return, - } - if cfg!(any(target_arch = "x86", target_arch = "x86_64")) { - assert!(cfg!(target_feature = "sse2"), - "SSE2 was not detected as available on an x86 platform"); - } - // check a negative case too -- certainly not enabled by default - #[expect(unexpected_cfgs)] - { assert!(cfg!(not(target_feature = "ferris_wheel")), - "🎡 shouldn't be detected as available by default on any platform") }; -} diff --git a/tests/ui/stable-addr-of.rs b/tests/ui/stable-addr-of.rs deleted file mode 100644 index e330a4853ce..00000000000 --- a/tests/ui/stable-addr-of.rs +++ /dev/null @@ -1,8 +0,0 @@ -//@ run-pass -// Issue #2040 - - -pub fn main() { - let foo: isize = 1; - assert_eq!(&foo as *const isize, &foo as *const isize); -} diff --git a/tests/ui/std-uncopyable-atomics.rs b/tests/ui/std-uncopyable-atomics.rs deleted file mode 100644 index d85864ecac2..00000000000 --- a/tests/ui/std-uncopyable-atomics.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Issue #8380 - - -use std::sync::atomic::*; -use std::ptr; - -fn main() { - let x = AtomicBool::new(false); - let x = *&x; //~ ERROR: cannot move out of a shared reference - let x = AtomicIsize::new(0); - let x = *&x; //~ ERROR: cannot move out of a shared reference - let x = AtomicUsize::new(0); - let x = *&x; //~ ERROR: cannot move out of a shared reference - let x: AtomicPtr = AtomicPtr::new(ptr::null_mut()); - let x = *&x; //~ ERROR: cannot move out of a shared reference -} diff --git a/tests/ui/std-uncopyable-atomics.stderr b/tests/ui/std-uncopyable-atomics.stderr deleted file mode 100644 index 8c5d0b96096..00000000000 --- a/tests/ui/std-uncopyable-atomics.stderr +++ /dev/null @@ -1,51 +0,0 @@ -error[E0507]: cannot move out of a shared reference - --> $DIR/std-uncopyable-atomics.rs:9:13 - | -LL | let x = *&x; - | ^^^ move occurs because value has type `std::sync::atomic::AtomicBool`, which does not implement the `Copy` trait - | -help: consider removing the dereference here - | -LL - let x = *&x; -LL + let x = &x; - | - -error[E0507]: cannot move out of a shared reference - --> $DIR/std-uncopyable-atomics.rs:11:13 - | -LL | let x = *&x; - | ^^^ move occurs because value has type `std::sync::atomic::AtomicIsize`, which does not implement the `Copy` trait - | -help: consider removing the dereference here - | -LL - let x = *&x; -LL + let x = &x; - | - -error[E0507]: cannot move out of a shared reference - --> $DIR/std-uncopyable-atomics.rs:13:13 - | -LL | let x = *&x; - | ^^^ move occurs because value has type `std::sync::atomic::AtomicUsize`, which does not implement the `Copy` trait - | -help: consider removing the dereference here - | -LL - let x = *&x; -LL + let x = &x; - | - -error[E0507]: cannot move out of a shared reference - --> $DIR/std-uncopyable-atomics.rs:15:13 - | -LL | let x = *&x; - | ^^^ move occurs because value has type `std::sync::atomic::AtomicPtr`, which does not implement the `Copy` trait - | -help: consider removing the dereference here - | -LL - let x = *&x; -LL + let x = &x; - | - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0507`. diff --git a/tests/ui/stdio-is-blocking.rs b/tests/ui/stdio-is-blocking.rs deleted file mode 100644 index 615530dcd47..00000000000 --- a/tests/ui/stdio-is-blocking.rs +++ /dev/null @@ -1,83 +0,0 @@ -//@ run-pass -//@ needs-subprocess - -use std::env; -use std::io::prelude::*; -use std::process::Command; -use std::thread; - -const THREADS: usize = 20; -const WRITES: usize = 100; -const WRITE_SIZE: usize = 1024 * 32; - -fn main() { - let args = env::args().collect::>(); - if args.len() == 1 { - parent(); - } else { - child(); - } -} - -fn parent() { - let me = env::current_exe().unwrap(); - let mut cmd = Command::new(me); - cmd.arg("run-the-test"); - let output = cmd.output().unwrap(); - assert!(output.status.success()); - assert_eq!(output.stderr.len(), 0); - assert_eq!(output.stdout.len(), WRITES * THREADS * WRITE_SIZE); - for byte in output.stdout.iter() { - assert_eq!(*byte, b'a'); - } -} - -fn child() { - let threads = (0..THREADS).map(|_| { - thread::spawn(|| { - let buf = [b'a'; WRITE_SIZE]; - for _ in 0..WRITES { - write_all(&buf); - } - }) - }).collect::>(); - - for thread in threads { - thread.join().unwrap(); - } -} - -#[cfg(unix)] -fn write_all(buf: &[u8]) { - use std::fs::File; - use std::mem; - use std::os::unix::prelude::*; - - let mut file = unsafe { File::from_raw_fd(1) }; - let res = file.write_all(buf); - mem::forget(file); - res.unwrap(); -} - -#[cfg(windows)] -fn write_all(buf: &[u8]) { - use std::fs::File; - use std::mem; - use std::os::windows::raw::*; - use std::os::windows::prelude::*; - - const STD_OUTPUT_HANDLE: u32 = (-11i32) as u32; - - extern "system" { - fn GetStdHandle(handle: u32) -> HANDLE; - } - - let mut file = unsafe { - let handle = GetStdHandle(STD_OUTPUT_HANDLE); - assert!(!handle.is_null()); - File::from_raw_handle(handle) - }; - let res = file.write_all(buf); - mem::forget(file); - res.unwrap(); -} diff --git a/tests/ui/string-box-error.rs b/tests/ui/string-box-error.rs deleted file mode 100644 index 9a7cd81ee04..00000000000 --- a/tests/ui/string-box-error.rs +++ /dev/null @@ -1,12 +0,0 @@ -//@ run-pass -// Ensure that both `Box` and `Box` can be -// obtained from `String`. - -use std::error::Error; - -fn main() { - let _err1: Box = From::from("test".to_string()); - let _err2: Box = From::from("test".to_string()); - let _err3: Box = From::from("test"); - let _err4: Box = From::from("test"); -} diff --git a/tests/ui/sync/atomic-types-not-copyable.rs b/tests/ui/sync/atomic-types-not-copyable.rs new file mode 100644 index 00000000000..d85864ecac2 --- /dev/null +++ b/tests/ui/sync/atomic-types-not-copyable.rs @@ -0,0 +1,16 @@ +// Issue #8380 + + +use std::sync::atomic::*; +use std::ptr; + +fn main() { + let x = AtomicBool::new(false); + let x = *&x; //~ ERROR: cannot move out of a shared reference + let x = AtomicIsize::new(0); + let x = *&x; //~ ERROR: cannot move out of a shared reference + let x = AtomicUsize::new(0); + let x = *&x; //~ ERROR: cannot move out of a shared reference + let x: AtomicPtr = AtomicPtr::new(ptr::null_mut()); + let x = *&x; //~ ERROR: cannot move out of a shared reference +} diff --git a/tests/ui/sync/atomic-types-not-copyable.stderr b/tests/ui/sync/atomic-types-not-copyable.stderr new file mode 100644 index 00000000000..8c5d0b96096 --- /dev/null +++ b/tests/ui/sync/atomic-types-not-copyable.stderr @@ -0,0 +1,51 @@ +error[E0507]: cannot move out of a shared reference + --> $DIR/std-uncopyable-atomics.rs:9:13 + | +LL | let x = *&x; + | ^^^ move occurs because value has type `std::sync::atomic::AtomicBool`, which does not implement the `Copy` trait + | +help: consider removing the dereference here + | +LL - let x = *&x; +LL + let x = &x; + | + +error[E0507]: cannot move out of a shared reference + --> $DIR/std-uncopyable-atomics.rs:11:13 + | +LL | let x = *&x; + | ^^^ move occurs because value has type `std::sync::atomic::AtomicIsize`, which does not implement the `Copy` trait + | +help: consider removing the dereference here + | +LL - let x = *&x; +LL + let x = &x; + | + +error[E0507]: cannot move out of a shared reference + --> $DIR/std-uncopyable-atomics.rs:13:13 + | +LL | let x = *&x; + | ^^^ move occurs because value has type `std::sync::atomic::AtomicUsize`, which does not implement the `Copy` trait + | +help: consider removing the dereference here + | +LL - let x = *&x; +LL + let x = &x; + | + +error[E0507]: cannot move out of a shared reference + --> $DIR/std-uncopyable-atomics.rs:15:13 + | +LL | let x = *&x; + | ^^^ move occurs because value has type `std::sync::atomic::AtomicPtr`, which does not implement the `Copy` trait + | +help: consider removing the dereference here + | +LL - let x = *&x; +LL + let x = &x; + | + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0507`. diff --git a/tests/ui/target-feature/target-feature-detection.rs b/tests/ui/target-feature/target-feature-detection.rs new file mode 100644 index 00000000000..a1894cc03db --- /dev/null +++ b/tests/ui/target-feature/target-feature-detection.rs @@ -0,0 +1,26 @@ +//@ run-pass + +#![allow(stable_features)] +#![feature(cfg_target_feature)] + +use std::env; + +fn main() { + match env::var("TARGET") { + Ok(s) => { + // Skip this tests on i586-unknown-linux-gnu where sse2 is disabled + if s.contains("i586") { + return + } + } + Err(_) => return, + } + if cfg!(any(target_arch = "x86", target_arch = "x86_64")) { + assert!(cfg!(target_feature = "sse2"), + "SSE2 was not detected as available on an x86 platform"); + } + // check a negative case too -- certainly not enabled by default + #[expect(unexpected_cfgs)] + { assert!(cfg!(not(target_feature = "ferris_wheel")), + "🎡 shouldn't be detected as available by default on any platform") }; +} diff --git a/tests/ui/traits/error-trait-object-from-string.rs b/tests/ui/traits/error-trait-object-from-string.rs new file mode 100644 index 00000000000..9a7cd81ee04 --- /dev/null +++ b/tests/ui/traits/error-trait-object-from-string.rs @@ -0,0 +1,12 @@ +//@ run-pass +// Ensure that both `Box` and `Box` can be +// obtained from `String`. + +use std::error::Error; + +fn main() { + let _err1: Box = From::from("test".to_string()); + let _err2: Box = From::from("test".to_string()); + let _err3: Box = From::from("test"); + let _err4: Box = From::from("test"); +} -- cgit 1.4.1-3-g733a5 From 066a281f60fd5071a50cf15a28ed40f15bef7563 Mon Sep 17 00:00:00 2001 From: Kivooeo Date: Tue, 1 Jul 2025 19:28:38 +0500 Subject: cleaned up some tests --- .../reexport-test-harness-entry-point.rs | 3 +++ tests/ui/const-ptr/pointer-address-stability.rs | 7 +++++-- tests/ui/diagnostic-flags/error-format-short.rs | 3 +++ .../ui/diagnostic-flags/error-format-short.stderr | 4 ++-- tests/ui/drop/drop-once-on-move.rs | 8 +++++--- tests/ui/drop/drop-scope-exit.rs | 20 +++++++++++------- tests/ui/generics/trait-incorrect-generic-args.rs | 4 +++- .../generics/trait-incorrect-generic-args.stderr | 12 +++++------ tests/ui/io-checks/io-stdout-blocking-writes.rs | 24 +++++++++++++--------- tests/ui/shadowed/primitive-type-shadowing.rs | 3 +++ tests/ui/shadowed/use-shadows-reexport.rs | 2 ++ tests/ui/sized/recursive-type-infinite-size.rs | 17 +++++++++++---- tests/ui/sized/recursive-type-infinite-size.stderr | 22 ++++++++++++-------- tests/ui/sized/sized-box-unsized-content.rs | 13 ++++++------ tests/ui/sized/sized-reference-to-unsized.rs | 12 ++++++----- tests/ui/sync/atomic-types-not-copyable.rs | 8 +++++--- tests/ui/sync/atomic-types-not-copyable.stderr | 8 ++++---- .../ui/target-feature/target-feature-detection.rs | 19 ++++++++++++----- tests/ui/traits/error-trait-object-from-string.rs | 5 +++-- 19 files changed, 126 insertions(+), 68 deletions(-) diff --git a/tests/ui/attributes/reexport-test-harness-entry-point.rs b/tests/ui/attributes/reexport-test-harness-entry-point.rs index f79828fc7d6..95765a719ed 100644 --- a/tests/ui/attributes/reexport-test-harness-entry-point.rs +++ b/tests/ui/attributes/reexport-test-harness-entry-point.rs @@ -1,3 +1,6 @@ +//! Check that `#[reexport_test_harness_main]` correctly reexports the test harness entry point +//! and allows it to be called from within the code. + //@ run-pass //@ compile-flags:--test diff --git a/tests/ui/const-ptr/pointer-address-stability.rs b/tests/ui/const-ptr/pointer-address-stability.rs index e330a4853ce..84a36e1ddf5 100644 --- a/tests/ui/const-ptr/pointer-address-stability.rs +++ b/tests/ui/const-ptr/pointer-address-stability.rs @@ -1,6 +1,9 @@ -//@ run-pass -// Issue #2040 +//! Check that taking the address of a stack variable with `&` +//! yields a stable and comparable pointer. +//! +//! Regression test for . +//@ run-pass pub fn main() { let foo: isize = 1; diff --git a/tests/ui/diagnostic-flags/error-format-short.rs b/tests/ui/diagnostic-flags/error-format-short.rs index 719870a04fb..4c793cd1b18 100644 --- a/tests/ui/diagnostic-flags/error-format-short.rs +++ b/tests/ui/diagnostic-flags/error-format-short.rs @@ -1,3 +1,6 @@ +//! Check that compile errors are formatted in the "short" style +//! when `--error-format=short` is used. + //@ compile-flags: --error-format=short fn foo(_: u32) {} diff --git a/tests/ui/diagnostic-flags/error-format-short.stderr b/tests/ui/diagnostic-flags/error-format-short.stderr index 1a4a6d4df88..0a097e2f623 100644 --- a/tests/ui/diagnostic-flags/error-format-short.stderr +++ b/tests/ui/diagnostic-flags/error-format-short.stderr @@ -1,3 +1,3 @@ -$DIR/short-error-format.rs:6:9: error[E0308]: mismatched types: expected `u32`, found `String` -$DIR/short-error-format.rs:8:7: error[E0599]: no method named `salut` found for type `u32` in the current scope: method not found in `u32` +$DIR/error-format-short.rs:9:9: error[E0308]: mismatched types: expected `u32`, found `String` +$DIR/error-format-short.rs:11:7: error[E0599]: no method named `salut` found for type `u32` in the current scope: method not found in `u32` error: aborting due to 2 previous errors diff --git a/tests/ui/drop/drop-once-on-move.rs b/tests/ui/drop/drop-once-on-move.rs index ab426016901..da018058076 100644 --- a/tests/ui/drop/drop-once-on-move.rs +++ b/tests/ui/drop/drop-once-on-move.rs @@ -1,3 +1,7 @@ +//! Check that types not implementing `Copy` are moved, not copied, during assignment +//! operations, and their `Drop` implementation is called exactly once when the +//! value goes out of scope. + //@ run-pass #![allow(non_camel_case_types)] @@ -15,9 +19,7 @@ impl<'a> Drop for r<'a> { } fn r(i: &Cell) -> r<'_> { - r { - i: i - } + r { i } } pub fn main() { diff --git a/tests/ui/drop/drop-scope-exit.rs b/tests/ui/drop/drop-scope-exit.rs index 480cbe091a7..4d003fec712 100644 --- a/tests/ui/drop/drop-scope-exit.rs +++ b/tests/ui/drop/drop-scope-exit.rs @@ -1,31 +1,37 @@ +//! Check that the `Drop` implementation is called when a value goes out of scope. + //@ run-pass #![allow(non_camel_case_types)] use std::cell::Cell; struct shrinky_pointer<'a> { - i: &'a Cell, + i: &'a Cell, } impl<'a> Drop for shrinky_pointer<'a> { fn drop(&mut self) { - println!("Hello!"); self.i.set(self.i.get() - 1); + println!("Hello!"); + self.i.set(self.i.get() - 1); } } impl<'a> shrinky_pointer<'a> { - pub fn look_at(&self) -> isize { return self.i.get(); } + pub fn look_at(&self) -> isize { + return self.i.get(); + } } fn shrinky_pointer(i: &Cell) -> shrinky_pointer<'_> { - shrinky_pointer { - i: i - } + shrinky_pointer { i } } pub fn main() { let my_total = &Cell::new(10); - { let pt = shrinky_pointer(my_total); assert_eq!(pt.look_at(), 10); } + { + let pt = shrinky_pointer(my_total); + assert_eq!(pt.look_at(), 10); + } println!("my_total = {}", my_total.get()); assert_eq!(my_total.get(), 9); } diff --git a/tests/ui/generics/trait-incorrect-generic-args.rs b/tests/ui/generics/trait-incorrect-generic-args.rs index 627dfcc3198..9715100b19c 100644 --- a/tests/ui/generics/trait-incorrect-generic-args.rs +++ b/tests/ui/generics/trait-incorrect-generic-args.rs @@ -1,5 +1,7 @@ +//! Check for compilation errors when a trait is used with an incorrect number of generic arguments. + fn main() { - trait Seq { } + trait Seq {} impl Seq for Vec { //~^ ERROR trait takes 0 generic arguments but 1 generic argument diff --git a/tests/ui/generics/trait-incorrect-generic-args.stderr b/tests/ui/generics/trait-incorrect-generic-args.stderr index 6e0d484d013..afc4ff03d94 100644 --- a/tests/ui/generics/trait-incorrect-generic-args.stderr +++ b/tests/ui/generics/trait-incorrect-generic-args.stderr @@ -1,5 +1,5 @@ error[E0107]: trait takes 0 generic arguments but 1 generic argument was supplied - --> $DIR/seq-args.rs:4:13 + --> $DIR/trait-incorrect-generic-args.rs:6:13 | LL | impl Seq for Vec { | ^^^--- help: remove the unnecessary generics @@ -7,13 +7,13 @@ LL | impl Seq for Vec { | expected 0 generic arguments | note: trait defined here, with 0 generic parameters - --> $DIR/seq-args.rs:2:11 + --> $DIR/trait-incorrect-generic-args.rs:4:11 | -LL | trait Seq { } +LL | trait Seq {} | ^^^ error[E0107]: trait takes 0 generic arguments but 1 generic argument was supplied - --> $DIR/seq-args.rs:9:10 + --> $DIR/trait-incorrect-generic-args.rs:11:10 | LL | impl Seq for u32 { | ^^^------ help: remove the unnecessary generics @@ -21,9 +21,9 @@ LL | impl Seq for u32 { | expected 0 generic arguments | note: trait defined here, with 0 generic parameters - --> $DIR/seq-args.rs:2:11 + --> $DIR/trait-incorrect-generic-args.rs:4:11 | -LL | trait Seq { } +LL | trait Seq {} | ^^^ error: aborting due to 2 previous errors diff --git a/tests/ui/io-checks/io-stdout-blocking-writes.rs b/tests/ui/io-checks/io-stdout-blocking-writes.rs index 615530dcd47..1197b7f43be 100644 --- a/tests/ui/io-checks/io-stdout-blocking-writes.rs +++ b/tests/ui/io-checks/io-stdout-blocking-writes.rs @@ -1,10 +1,12 @@ +//! Check that writes to standard output are blocking, avoiding interleaving +//! even with concurrent writes from multiple threads. + //@ run-pass //@ needs-subprocess -use std::env; use std::io::prelude::*; use std::process::Command; -use std::thread; +use std::{env, thread}; const THREADS: usize = 20; const WRITES: usize = 100; @@ -33,14 +35,16 @@ fn parent() { } fn child() { - let threads = (0..THREADS).map(|_| { - thread::spawn(|| { - let buf = [b'a'; WRITE_SIZE]; - for _ in 0..WRITES { - write_all(&buf); - } + let threads = (0..THREADS) + .map(|_| { + thread::spawn(|| { + let buf = [b'a'; WRITE_SIZE]; + for _ in 0..WRITES { + write_all(&buf); + } + }) }) - }).collect::>(); + .collect::>(); for thread in threads { thread.join().unwrap(); @@ -63,8 +67,8 @@ fn write_all(buf: &[u8]) { fn write_all(buf: &[u8]) { use std::fs::File; use std::mem; - use std::os::windows::raw::*; use std::os::windows::prelude::*; + use std::os::windows::raw::*; const STD_OUTPUT_HANDLE: u32 = (-11i32) as u32; diff --git a/tests/ui/shadowed/primitive-type-shadowing.rs b/tests/ui/shadowed/primitive-type-shadowing.rs index 8cba2c1710b..fdcb4246a82 100644 --- a/tests/ui/shadowed/primitive-type-shadowing.rs +++ b/tests/ui/shadowed/primitive-type-shadowing.rs @@ -1,3 +1,6 @@ +//! Check that a primitive type can be shadowed by a user-defined type, and the primitive type +//! can still be referenced using its fully qualified path (e.g., `core::primitive::bool`). + //@ check-pass mod bar { diff --git a/tests/ui/shadowed/use-shadows-reexport.rs b/tests/ui/shadowed/use-shadows-reexport.rs index 5ce4103b559..d220e4b406b 100644 --- a/tests/ui/shadowed/use-shadows-reexport.rs +++ b/tests/ui/shadowed/use-shadows-reexport.rs @@ -1,3 +1,5 @@ +//! Check that a local `use` declaration can shadow a re-exported item within the same module. + //@ run-pass #![allow(unused_imports)] diff --git a/tests/ui/sized/recursive-type-infinite-size.rs b/tests/ui/sized/recursive-type-infinite-size.rs index 766a5fa0de3..5cd8e895573 100644 --- a/tests/ui/sized/recursive-type-infinite-size.rs +++ b/tests/ui/sized/recursive-type-infinite-size.rs @@ -1,7 +1,16 @@ -struct Baz { q: Option } -//~^ ERROR recursive types `Baz` and `Foo` have infinite size -struct Foo { q: Option } +//! Check for compilation errors when recursive types are defined in a way +//! that leads to an infinite size. -impl Foo { fn bar(&self) {} } +struct Baz { + //~^ ERROR recursive types `Baz` and `Foo` have infinite size + q: Option, +} +struct Foo { + q: Option, +} + +impl Foo { + fn bar(&self) {} +} fn main() {} diff --git a/tests/ui/sized/recursive-type-infinite-size.stderr b/tests/ui/sized/recursive-type-infinite-size.stderr index 21e54c12fed..98ac36c4bb6 100644 --- a/tests/ui/sized/recursive-type-infinite-size.stderr +++ b/tests/ui/sized/recursive-type-infinite-size.stderr @@ -1,17 +1,23 @@ error[E0072]: recursive types `Baz` and `Foo` have infinite size - --> $DIR/sized-cycle-note.rs:1:1 + --> $DIR/recursive-type-infinite-size.rs:4:1 | -LL | struct Baz { q: Option } - | ^^^^^^^^^^ --- recursive without indirection +LL | struct Baz { + | ^^^^^^^^^^ LL | -LL | struct Foo { q: Option } - | ^^^^^^^^^^ --- recursive without indirection +LL | q: Option, + | --- recursive without indirection +LL | } +LL | struct Foo { + | ^^^^^^^^^^ +LL | q: Option, + | --- recursive without indirection | help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to break the cycle | -LL ~ struct Baz { q: Option> } -LL | -LL ~ struct Foo { q: Option> } +LL ~ q: Option>, +LL | } +LL | struct Foo { +LL ~ q: Option>, | error: aborting due to 1 previous error diff --git a/tests/ui/sized/sized-box-unsized-content.rs b/tests/ui/sized/sized-box-unsized-content.rs index b35c0f91abd..9cc202a1582 100644 --- a/tests/ui/sized/sized-box-unsized-content.rs +++ b/tests/ui/sized/sized-box-unsized-content.rs @@ -1,10 +1,11 @@ +//! Check that `Box` is `Sized`, even when `T` is a dynamically sized type. + //@ run-pass #![allow(dead_code)] -// Possibly-dynamic size of typaram should be cleared at pointer boundary. - - -fn bar() { } -fn foo() { bar::>() } -pub fn main() { } +fn bar() {} +fn foo() { + bar::>() +} +pub fn main() {} diff --git a/tests/ui/sized/sized-reference-to-unsized.rs b/tests/ui/sized/sized-reference-to-unsized.rs index bd213c067db..ac2934d8fe6 100644 --- a/tests/ui/sized/sized-reference-to-unsized.rs +++ b/tests/ui/sized/sized-reference-to-unsized.rs @@ -1,9 +1,11 @@ +//! Check that a reference to a potentially unsized type (`&T`) is itself considered `Sized`. + //@ run-pass #![allow(dead_code)] -// Possibly-dynamic size of typaram should be cleared at pointer boundary. - -fn bar() { } -fn foo() { bar::<&T>() } -pub fn main() { } +fn bar() {} +fn foo() { + bar::<&T>() +} +pub fn main() {} diff --git a/tests/ui/sync/atomic-types-not-copyable.rs b/tests/ui/sync/atomic-types-not-copyable.rs index d85864ecac2..d96414676ee 100644 --- a/tests/ui/sync/atomic-types-not-copyable.rs +++ b/tests/ui/sync/atomic-types-not-copyable.rs @@ -1,8 +1,10 @@ -// Issue #8380 +//! Check that atomic types from `std::sync::atomic` are not `Copy` +//! and cannot be moved out of a shared reference. +//! +//! Regression test for . - -use std::sync::atomic::*; use std::ptr; +use std::sync::atomic::*; fn main() { let x = AtomicBool::new(false); diff --git a/tests/ui/sync/atomic-types-not-copyable.stderr b/tests/ui/sync/atomic-types-not-copyable.stderr index 8c5d0b96096..05103f5d8f2 100644 --- a/tests/ui/sync/atomic-types-not-copyable.stderr +++ b/tests/ui/sync/atomic-types-not-copyable.stderr @@ -1,5 +1,5 @@ error[E0507]: cannot move out of a shared reference - --> $DIR/std-uncopyable-atomics.rs:9:13 + --> $DIR/atomic-types-not-copyable.rs:11:13 | LL | let x = *&x; | ^^^ move occurs because value has type `std::sync::atomic::AtomicBool`, which does not implement the `Copy` trait @@ -11,7 +11,7 @@ LL + let x = &x; | error[E0507]: cannot move out of a shared reference - --> $DIR/std-uncopyable-atomics.rs:11:13 + --> $DIR/atomic-types-not-copyable.rs:13:13 | LL | let x = *&x; | ^^^ move occurs because value has type `std::sync::atomic::AtomicIsize`, which does not implement the `Copy` trait @@ -23,7 +23,7 @@ LL + let x = &x; | error[E0507]: cannot move out of a shared reference - --> $DIR/std-uncopyable-atomics.rs:13:13 + --> $DIR/atomic-types-not-copyable.rs:15:13 | LL | let x = *&x; | ^^^ move occurs because value has type `std::sync::atomic::AtomicUsize`, which does not implement the `Copy` trait @@ -35,7 +35,7 @@ LL + let x = &x; | error[E0507]: cannot move out of a shared reference - --> $DIR/std-uncopyable-atomics.rs:15:13 + --> $DIR/atomic-types-not-copyable.rs:17:13 | LL | let x = *&x; | ^^^ move occurs because value has type `std::sync::atomic::AtomicPtr`, which does not implement the `Copy` trait diff --git a/tests/ui/target-feature/target-feature-detection.rs b/tests/ui/target-feature/target-feature-detection.rs index a1894cc03db..3404bfbe782 100644 --- a/tests/ui/target-feature/target-feature-detection.rs +++ b/tests/ui/target-feature/target-feature-detection.rs @@ -1,3 +1,6 @@ +//! Check that `cfg!(target_feature = "...")` correctly detects available CPU features, +//! specifically `sse2` on x86/x86_64 platforms, and correctly reports absent features. + //@ run-pass #![allow(stable_features)] @@ -10,17 +13,23 @@ fn main() { Ok(s) => { // Skip this tests on i586-unknown-linux-gnu where sse2 is disabled if s.contains("i586") { - return + return; } } Err(_) => return, } if cfg!(any(target_arch = "x86", target_arch = "x86_64")) { - assert!(cfg!(target_feature = "sse2"), - "SSE2 was not detected as available on an x86 platform"); + assert!( + cfg!(target_feature = "sse2"), + "SSE2 was not detected as available on an x86 platform" + ); } // check a negative case too -- certainly not enabled by default #[expect(unexpected_cfgs)] - { assert!(cfg!(not(target_feature = "ferris_wheel")), - "🎡 shouldn't be detected as available by default on any platform") }; + { + assert!( + cfg!(not(target_feature = "ferris_wheel")), + "🎡 shouldn't be detected as available by default on any platform" + ) + }; } diff --git a/tests/ui/traits/error-trait-object-from-string.rs b/tests/ui/traits/error-trait-object-from-string.rs index 9a7cd81ee04..896f164a04d 100644 --- a/tests/ui/traits/error-trait-object-from-string.rs +++ b/tests/ui/traits/error-trait-object-from-string.rs @@ -1,6 +1,7 @@ +//! Check that `String` and `&str` can be converted into `Box` and +//! `Box` trait objects + //@ run-pass -// Ensure that both `Box` and `Box` can be -// obtained from `String`. use std::error::Error; -- cgit 1.4.1-3-g733a5