about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/compiletest-self-test/ui-test-missing-annotations-detection.rs9
-rw-r--r--tests/ui/derives/derive-Debug-enum-variants.rs30
-rw-r--r--tests/ui/fmt/debug-single-call.rs (renamed from tests/ui/logging-only-prints-once.rs)7
-rw-r--r--tests/ui/linkage-attr/link-section-placement.rs (renamed from tests/ui/link-section.rs)3
-rw-r--r--tests/ui/log-err-phi.rs7
-rw-r--r--tests/ui/log-knows-the-names-of-variants.rs21
-rw-r--r--tests/ui/loud_ui.rs6
-rw-r--r--tests/ui/resolve/struct-function-same-name.rs (renamed from tests/ui/max-min-classes.rs)4
-rw-r--r--tests/ui/resolve/type-param-local-var-shadowing.rs (renamed from tests/ui/lexical-scoping.rs)9
9 files changed, 56 insertions, 40 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
new file mode 100644
index 00000000000..3a110bdad35
--- /dev/null
+++ b/tests/ui/compiletest-self-test/ui-test-missing-annotations-detection.rs
@@ -0,0 +1,9 @@
+//! 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
+
+//@ should-fail
+
+fn main() {}
diff --git a/tests/ui/derives/derive-Debug-enum-variants.rs b/tests/ui/derives/derive-Debug-enum-variants.rs
new file mode 100644
index 00000000000..26f527f7664
--- /dev/null
+++ b/tests/ui/derives/derive-Debug-enum-variants.rs
@@ -0,0 +1,30 @@
+//! Test that `#[derive(Debug)]` for enums correctly formats variant names.
+
+//@ run-pass
+
+#[derive(Debug)]
+enum Foo {
+    A(usize),
+    C,
+}
+
+#[derive(Debug)]
+enum Bar {
+    D,
+}
+
+pub fn main() {
+    // 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/logging-only-prints-once.rs b/tests/ui/fmt/debug-single-call.rs
index bb8c29694b5..b59a766c71a 100644
--- a/tests/ui/logging-only-prints-once.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/link-section.rs b/tests/ui/linkage-attr/link-section-placement.rs
index a8de8c2e1e7..6a143bfedb4 100644
--- a/tests/ui/link-section.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/log-knows-the-names-of-variants.rs b/tests/ui/log-knows-the-names-of-variants.rs
deleted file mode 100644
index cb82cb4878a..00000000000
--- a/tests/ui/log-knows-the-names-of-variants.rs
+++ /dev/null
@@ -1,21 +0,0 @@
-//@ run-pass
-
-#![allow(non_camel_case_types)]
-#![allow(dead_code)]
-#[derive(Debug)]
-enum foo {
-  a(usize),
-  b(String),
-  c,
-}
-
-#[derive(Debug)]
-enum bar {
-  d, e, f
-}
-
-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));
-}
diff --git a/tests/ui/loud_ui.rs b/tests/ui/loud_ui.rs
deleted file mode 100644
index 2a73e49e172..00000000000
--- a/tests/ui/loud_ui.rs
+++ /dev/null
@@ -1,6 +0,0 @@
-//@ should-fail
-
-// this test ensures that when we forget to use
-// any `//~ ERROR` comments whatsoever, that the test doesn't succeed
-
-fn main() {}
diff --git a/tests/ui/max-min-classes.rs b/tests/ui/resolve/struct-function-same-name.rs
index 338a3156a9a..bb2837d7ca6 100644
--- a/tests/ui/max-min-classes.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/lexical-scoping.rs b/tests/ui/resolve/type-param-local-var-shadowing.rs
index f858369f7ce..e08379e2acf 100644
--- a/tests/ui/lexical-scoping.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;