diff options
| author | Kivooeo <Kivooeo123@gmail.com> | 2025-06-27 20:45:19 +0500 |
|---|---|---|
| committer | Kivooeo <Kivooeo123@gmail.com> | 2025-06-30 11:16:18 +0500 |
| commit | 580bc128441236345a5f3d5022af5a60091451ac (patch) | |
| tree | cc6da2041600800d4ca648758150fc155f6a9225 | |
| parent | 74657a4a1a8b18bed905bd997aa390a90a3b943f (diff) | |
| download | rust-580bc128441236345a5f3d5022af5a60091451ac.tar.gz rust-580bc128441236345a5f3d5022af5a60091451ac.zip | |
cleaned up some tests
| -rw-r--r-- | tests/ui/compiletest-self-test/ui-test-missing-annotations-detection.rs | 9 | ||||
| -rw-r--r-- | tests/ui/derives/derive-Debug-enum-variants.rs | 31 | ||||
| -rw-r--r-- | tests/ui/fmt/debug-single-call.rs | 7 | ||||
| -rw-r--r-- | tests/ui/linkage-attr/link-section-placement.rs | 3 | ||||
| -rw-r--r-- | tests/ui/log-err-phi.rs | 7 | ||||
| -rw-r--r-- | tests/ui/resolve/struct-function-same-name.rs | 4 | ||||
| -rw-r--r-- | tests/ui/resolve/type-param-local-var-shadowing.rs | 9 |
7 files changed, 43 insertions, 27 deletions
diff --git a/tests/ui/compiletest-self-test/ui-test-missing-annotations-detection.rs b/tests/ui/compiletest-self-test/ui-test-missing-annotations-detection.rs index 2a73e49e172..3a110bdad35 100644 --- a/tests/ui/compiletest-self-test/ui-test-missing-annotations-detection.rs +++ b/tests/ui/compiletest-self-test/ui-test-missing-annotations-detection.rs @@ -1,6 +1,9 @@ -//@ should-fail +//! Regression test checks UI tests without error annotations are detected as failing. +//! +//! This tests that when we forget to use any `//~ ERROR` comments whatsoever, +//! the test doesn't succeed +//! Originally created in https://github.com/rust-lang/rust/pull/56244 -// this test ensures that when we forget to use -// any `//~ ERROR` comments whatsoever, that the test doesn't succeed +//@ should-fail fn main() {} diff --git a/tests/ui/derives/derive-Debug-enum-variants.rs b/tests/ui/derives/derive-Debug-enum-variants.rs index cb82cb4878a..26f527f7664 100644 --- a/tests/ui/derives/derive-Debug-enum-variants.rs +++ b/tests/ui/derives/derive-Debug-enum-variants.rs @@ -1,21 +1,30 @@ +//! Test that `#[derive(Debug)]` for enums correctly formats variant names. + //@ run-pass -#![allow(non_camel_case_types)] -#![allow(dead_code)] #[derive(Debug)] -enum foo { - a(usize), - b(String), - c, +enum Foo { + A(usize), + C, } #[derive(Debug)] -enum bar { - d, e, f +enum Bar { + D, } pub fn main() { - assert_eq!("a(22)".to_string(), format!("{:?}", foo::a(22))); - assert_eq!("c".to_string(), format!("{:?}", foo::c)); - assert_eq!("d".to_string(), format!("{:?}", bar::d)); + // Test variant with data + let foo_a = Foo::A(22); + assert_eq!("A(22)".to_string(), format!("{:?}", foo_a)); + + if let Foo::A(value) = foo_a { + println!("Value: {}", value); // This needs to remove #[allow(dead_code)] + } + + // Test unit variant + assert_eq!("C".to_string(), format!("{:?}", Foo::C)); + + // Test unit variant from different enum + assert_eq!("D".to_string(), format!("{:?}", Bar::D)); } diff --git a/tests/ui/fmt/debug-single-call.rs b/tests/ui/fmt/debug-single-call.rs index bb8c29694b5..b59a766c71a 100644 --- a/tests/ui/fmt/debug-single-call.rs +++ b/tests/ui/fmt/debug-single-call.rs @@ -1,9 +1,12 @@ +//! Test that Debug::fmt is called exactly once during formatting. +//! +//! This is a regression test for PR https://github.com/rust-lang/rust/pull/10715 + //@ run-pass //@ needs-threads use std::cell::Cell; -use std::fmt; -use std::thread; +use std::{fmt, thread}; struct Foo(Cell<isize>); diff --git a/tests/ui/linkage-attr/link-section-placement.rs b/tests/ui/linkage-attr/link-section-placement.rs index a8de8c2e1e7..6a143bfedb4 100644 --- a/tests/ui/linkage-attr/link-section-placement.rs +++ b/tests/ui/linkage-attr/link-section-placement.rs @@ -1,8 +1,9 @@ +//! Test placement of functions and statics in custom link sections + //@ run-pass // FIXME(static_mut_refs): Do not allow `static_mut_refs` lint #![allow(static_mut_refs)] - #![allow(non_upper_case_globals)] #[cfg(not(target_vendor = "apple"))] #[link_section = ".moretext"] diff --git a/tests/ui/log-err-phi.rs b/tests/ui/log-err-phi.rs deleted file mode 100644 index 1bb97758782..00000000000 --- a/tests/ui/log-err-phi.rs +++ /dev/null @@ -1,7 +0,0 @@ -//@ run-pass - -pub fn main() { - if false { - println!("{}", "foobar"); - } -} diff --git a/tests/ui/resolve/struct-function-same-name.rs b/tests/ui/resolve/struct-function-same-name.rs index 338a3156a9a..bb2837d7ca6 100644 --- a/tests/ui/resolve/struct-function-same-name.rs +++ b/tests/ui/resolve/struct-function-same-name.rs @@ -1,3 +1,5 @@ +//! Test that a struct and function can have the same name +//! //@ run-pass #![allow(non_snake_case)] @@ -23,7 +25,7 @@ impl Product for Foo { } fn Foo(x: isize, y: isize) -> Foo { - Foo { x: x, y: y } + Foo { x, y } } pub fn main() { diff --git a/tests/ui/resolve/type-param-local-var-shadowing.rs b/tests/ui/resolve/type-param-local-var-shadowing.rs index f858369f7ce..e08379e2acf 100644 --- a/tests/ui/resolve/type-param-local-var-shadowing.rs +++ b/tests/ui/resolve/type-param-local-var-shadowing.rs @@ -1,8 +1,13 @@ +//! Test that items in subscopes correctly shadow type parameters and local variables +//! +//! Regression test for https://github.com/rust-lang/rust/issues/23880 + //@ run-pass -// Tests that items in subscopes can shadow type parameters and local variables (see issue #23880). #![allow(unused)] -struct Foo<X> { x: Box<X> } +struct Foo<X> { + x: Box<X>, +} impl<Bar> Foo<Bar> { fn foo(&self) { type Bar = i32; |
