about summary refs log tree commit diff
diff options
context:
space:
mode:
authorreddevilmidzy <midzy0228@gmail.com>2025-04-18 00:44:11 +0900
committerreddevilmidzy <midzy0228@gmail.com>2025-04-21 16:16:38 +0900
commitdd2d6b222b7a7ad615e612b55fcf3933d4036be3 (patch)
tree869e539efd5abe6f8959d687af7fac80a1fa0a67
parentf433fa46b0fd27d35219357ad75f54d294081bc4 (diff)
downloadrust-dd2d6b222b7a7ad615e612b55fcf3933d4036be3.tar.gz
rust-dd2d6b222b7a7ad615e612b55fcf3933d4036be3.zip
Cleaned up 5 tests in `tests/ui`
-rw-r--r--tests/ui/borrowck/writing-to-immutable-vec.rs (renamed from tests/ui/writing-to-immutable-vec.rs)0
-rw-r--r--tests/ui/borrowck/writing-to-immutable-vec.stderr (renamed from tests/ui/writing-to-immutable-vec.stderr)0
-rw-r--r--tests/ui/deref-patterns/deref-non-pointer.rs (renamed from tests/ui/deref-non-pointer.rs)0
-rw-r--r--tests/ui/deref-patterns/deref-non-pointer.stderr (renamed from tests/ui/deref-non-pointer.stderr)0
-rw-r--r--tests/ui/lazy-and-or.rs12
-rw-r--r--tests/ui/list.rs9
-rw-r--r--tests/ui/minus-string.rs1
-rw-r--r--tests/ui/or-patterns/lazy-and-or.rs25
-rw-r--r--tests/ui/recursion/recursive-enum-box.rs21
-rw-r--r--tests/ui/typeck/minus-string.rs7
-rw-r--r--tests/ui/typeck/minus-string.stderr (renamed from tests/ui/minus-string.stderr)6
11 files changed, 56 insertions, 25 deletions
diff --git a/tests/ui/writing-to-immutable-vec.rs b/tests/ui/borrowck/writing-to-immutable-vec.rs
index dbcc3f0bbe9..dbcc3f0bbe9 100644
--- a/tests/ui/writing-to-immutable-vec.rs
+++ b/tests/ui/borrowck/writing-to-immutable-vec.rs
diff --git a/tests/ui/writing-to-immutable-vec.stderr b/tests/ui/borrowck/writing-to-immutable-vec.stderr
index 06e1684dffe..06e1684dffe 100644
--- a/tests/ui/writing-to-immutable-vec.stderr
+++ b/tests/ui/borrowck/writing-to-immutable-vec.stderr
diff --git a/tests/ui/deref-non-pointer.rs b/tests/ui/deref-patterns/deref-non-pointer.rs
index 82ab355e697..82ab355e697 100644
--- a/tests/ui/deref-non-pointer.rs
+++ b/tests/ui/deref-patterns/deref-non-pointer.rs
diff --git a/tests/ui/deref-non-pointer.stderr b/tests/ui/deref-patterns/deref-non-pointer.stderr
index 3ee354819e5..3ee354819e5 100644
--- a/tests/ui/deref-non-pointer.stderr
+++ b/tests/ui/deref-patterns/deref-non-pointer.stderr
diff --git a/tests/ui/lazy-and-or.rs b/tests/ui/lazy-and-or.rs
deleted file mode 100644
index f9dbeb68959..00000000000
--- a/tests/ui/lazy-and-or.rs
+++ /dev/null
@@ -1,12 +0,0 @@
-//@ run-pass
-
-fn incr(x: &mut isize) -> bool { *x += 1; assert!((false)); return false; }
-
-pub fn main() {
-    let x = 1 == 2 || 3 == 3;
-    assert!((x));
-    let mut y: isize = 10;
-    println!("{}", x || incr(&mut y));
-    assert_eq!(y, 10);
-    if true && x { assert!((true)); } else { assert!((false)); }
-}
diff --git a/tests/ui/list.rs b/tests/ui/list.rs
deleted file mode 100644
index 443c4c9f28f..00000000000
--- a/tests/ui/list.rs
+++ /dev/null
@@ -1,9 +0,0 @@
-//@ run-pass
-
-#![allow(non_camel_case_types)]
-
-enum list { #[allow(dead_code)] cons(isize, Box<list>), nil, }
-
-pub fn main() {
-    list::cons(10, Box::new(list::cons(11, Box::new(list::cons(12, Box::new(list::nil))))));
-}
diff --git a/tests/ui/minus-string.rs b/tests/ui/minus-string.rs
deleted file mode 100644
index b83347b937e..00000000000
--- a/tests/ui/minus-string.rs
+++ /dev/null
@@ -1 +0,0 @@
-fn main() { -"foo".to_string(); } //~ ERROR cannot apply unary operator `-` to type `String`
diff --git a/tests/ui/or-patterns/lazy-and-or.rs b/tests/ui/or-patterns/lazy-and-or.rs
new file mode 100644
index 00000000000..3d69553132b
--- /dev/null
+++ b/tests/ui/or-patterns/lazy-and-or.rs
@@ -0,0 +1,25 @@
+//@ run-pass
+// This test verifies the short-circuiting behavior of logical operators `||` and `&&`.
+// It ensures that the right-hand expression is not evaluated when the left-hand
+// expression is sufficient to determine the result.
+
+fn would_panic_if_called(x: &mut isize) -> bool {
+    *x += 1;
+    assert!(false, "This function should never be called due to short-circuiting");
+    false
+}
+
+fn main() {
+    let x = 1 == 2 || 3 == 3;
+    assert!(x);
+
+    let mut y: isize = 10;
+    println!("Result of short-circuit: {}", x || would_panic_if_called(&mut y));
+    assert_eq!(y, 10, "y should remain 10 if short-circuiting works correctly");
+
+    if true && x {
+        assert!(true);
+    } else {
+        assert!(false, "This branch should not be reached");
+    }
+}
diff --git a/tests/ui/recursion/recursive-enum-box.rs b/tests/ui/recursion/recursive-enum-box.rs
new file mode 100644
index 00000000000..540b0c55360
--- /dev/null
+++ b/tests/ui/recursion/recursive-enum-box.rs
@@ -0,0 +1,21 @@
+//@ run-pass
+// A smoke test for recursive enum structures using Box<T>.
+// This test constructs a linked list-like structure to exercise memory allocation and ownership.
+// Originally introduced in 2010, this is one of Rust’s earliest test cases.
+
+#![allow(dead_code)]
+
+enum List {
+    Cons(isize, Box<List>),
+    Nil,
+}
+
+fn main() {
+    List::Cons(
+        10,
+        Box::new(List::Cons(
+            11,
+            Box::new(List::Cons(12, Box::new(List::Nil))),
+        )),
+    );
+}
diff --git a/tests/ui/typeck/minus-string.rs b/tests/ui/typeck/minus-string.rs
new file mode 100644
index 00000000000..1c0f73a3713
--- /dev/null
+++ b/tests/ui/typeck/minus-string.rs
@@ -0,0 +1,7 @@
+// Regression test for issue #813.
+// This ensures that the unary negation operator `-` cannot be applied to an owned `String`.
+// Previously, due to a type-checking bug, this was mistakenly accepted by the compiler.
+
+fn main() {
+    -"foo".to_string(); //~ ERROR cannot apply unary operator `-` to type `String`
+}
diff --git a/tests/ui/minus-string.stderr b/tests/ui/typeck/minus-string.stderr
index 153965c810e..d2ebcd01ff9 100644
--- a/tests/ui/minus-string.stderr
+++ b/tests/ui/typeck/minus-string.stderr
@@ -1,8 +1,8 @@
 error[E0600]: cannot apply unary operator `-` to type `String`
-  --> $DIR/minus-string.rs:1:13
+  --> $DIR/minus-string.rs:6:5
    |
-LL | fn main() { -"foo".to_string(); }
-   |             ^^^^^^^^^^^^^^^^^^ cannot apply unary operator `-`
+LL |     -"foo".to_string();
+   |     ^^^^^^^^^^^^^^^^^^ cannot apply unary operator `-`
    |
 note: the foreign item type `String` doesn't implement `Neg`
   --> $SRC_DIR/alloc/src/string.rs:LL:COL