about summary refs log tree commit diff
diff options
context:
space:
mode:
authorKivooeo <Kivooeo123@gmail.com>2025-05-31 00:30:37 +0500
committerKivooeo <Kivooeo123@gmail.com>2025-05-31 19:49:19 +0500
commitafc64242b61041ee2f6e107c9483957dacfbf090 (patch)
tree8e284f9cea9aa064af69bcf701d697623a7328ca
parent8afd71079a729ac002298239f5010ccaac5807ca (diff)
downloadrust-afc64242b61041ee2f6e107c9483957dacfbf090.tar.gz
rust-afc64242b61041ee2f6e107c9483957dacfbf090.zip
cleaned up some tests
-rw-r--r--tests/ui/autoderef-full-lval.rs25
-rw-r--r--tests/ui/autoref-autoderef/autoderef-box-no-add.rs35
-rw-r--r--tests/ui/autoref-autoderef/autoderef-box-no-add.stderr (renamed from tests/ui/autoderef-full-lval.stderr)4
-rw-r--r--tests/ui/functions-closures/bare-fn-implements-fn-mut.rs (renamed from tests/ui/bare-fn-implements-fn-mut.rs)4
-rw-r--r--tests/ui/lint/overflowing-literals-valid.rs (renamed from tests/ui/big-literals.rs)4
-rw-r--r--tests/ui/methods/vec-autoderef-autoref.rs (renamed from tests/ui/auto-ref-slice-plus-ref.rs)7
-rw-r--r--tests/ui/methods/vec-autoderef-autoref.stderr (renamed from tests/ui/auto-ref-slice-plus-ref.stderr)16
-rw-r--r--tests/ui/str/str-static-literal.rs (renamed from tests/ui/bare-static-string.rs)2
8 files changed, 57 insertions, 40 deletions
diff --git a/tests/ui/autoderef-full-lval.rs b/tests/ui/autoderef-full-lval.rs
deleted file mode 100644
index 0fadc5c9827..00000000000
--- a/tests/ui/autoderef-full-lval.rs
+++ /dev/null
@@ -1,25 +0,0 @@
-struct Clam {
-    x: Box<isize>,
-    y: Box<isize>,
-}
-
-
-
-struct Fish {
-    a: Box<isize>,
-}
-
-fn main() {
-    let a: Clam = Clam{ x: Box::new(1), y: Box::new(2) };
-    let b: Clam = Clam{ x: Box::new(10), y: Box::new(20) };
-    let z: isize = a.x + b.y;
-    //~^ ERROR cannot add `Box<isize>` to `Box<isize>`
-    println!("{}", z);
-    assert_eq!(z, 21);
-    let forty: Fish = Fish{ a: Box::new(40) };
-    let two: Fish = Fish{ a: Box::new(2) };
-    let answer: isize = forty.a + two.a;
-    //~^ ERROR cannot add `Box<isize>` to `Box<isize>`
-    println!("{}", answer);
-    assert_eq!(answer, 42);
-}
diff --git a/tests/ui/autoref-autoderef/autoderef-box-no-add.rs b/tests/ui/autoref-autoderef/autoderef-box-no-add.rs
new file mode 100644
index 00000000000..f8085c1ae96
--- /dev/null
+++ b/tests/ui/autoref-autoderef/autoderef-box-no-add.rs
@@ -0,0 +1,35 @@
+//! Tests that auto-dereferencing does not allow addition of `Box<isize>` values.
+//!
+//! This test ensures that `Box<isize>` fields in structs (`Clam` and `Fish`) are not
+//! automatically dereferenced to `isize` during addition operations, as `Box<isize>`
+//! does not implement the `Add` trait.
+
+struct Clam {
+    x: Box<isize>,
+    y: Box<isize>,
+}
+
+struct Fish {
+    a: Box<isize>,
+}
+
+fn main() {
+    let a: Clam = Clam {
+        x: Box::new(1),
+        y: Box::new(2),
+    };
+    let b: Clam = Clam {
+        x: Box::new(10),
+        y: Box::new(20),
+    };
+    let z: isize = a.x + b.y;
+    //~^ ERROR cannot add `Box<isize>` to `Box<isize>`
+    println!("{}", z);
+    assert_eq!(z, 21);
+    let forty: Fish = Fish { a: Box::new(40) };
+    let two: Fish = Fish { a: Box::new(2) };
+    let answer: isize = forty.a + two.a;
+    //~^ ERROR cannot add `Box<isize>` to `Box<isize>`
+    println!("{}", answer);
+    assert_eq!(answer, 42);
+}
diff --git a/tests/ui/autoderef-full-lval.stderr b/tests/ui/autoref-autoderef/autoderef-box-no-add.stderr
index d90238a7fb2..20ef3352831 100644
--- a/tests/ui/autoderef-full-lval.stderr
+++ b/tests/ui/autoref-autoderef/autoderef-box-no-add.stderr
@@ -1,5 +1,5 @@
 error[E0369]: cannot add `Box<isize>` to `Box<isize>`
-  --> $DIR/autoderef-full-lval.rs:15:24
+  --> $DIR/autoderef-box-no-add.rs:25:24
    |
 LL |     let z: isize = a.x + b.y;
    |                    --- ^ --- Box<isize>
@@ -13,7 +13,7 @@ note: the foreign item type `Box<isize>` doesn't implement `Add`
    = note: not implement `Add`
 
 error[E0369]: cannot add `Box<isize>` to `Box<isize>`
-  --> $DIR/autoderef-full-lval.rs:21:33
+  --> $DIR/autoderef-box-no-add.rs:31:33
    |
 LL |     let answer: isize = forty.a + two.a;
    |                         ------- ^ ----- Box<isize>
diff --git a/tests/ui/bare-fn-implements-fn-mut.rs b/tests/ui/functions-closures/bare-fn-implements-fn-mut.rs
index 49b31f28f8a..52d5ad3d0f7 100644
--- a/tests/ui/bare-fn-implements-fn-mut.rs
+++ b/tests/ui/functions-closures/bare-fn-implements-fn-mut.rs
@@ -1,3 +1,7 @@
+//! Tests that bare functions implement the `FnMut` trait.
+//!
+//! See <https://github.com/rust-lang/rust/issues/15448>.
+
 //@ run-pass
 
 fn call_f<F:FnMut()>(mut f: F) {
diff --git a/tests/ui/big-literals.rs b/tests/ui/lint/overflowing-literals-valid.rs
index d2f447a595c..08aa092ee71 100644
--- a/tests/ui/big-literals.rs
+++ b/tests/ui/lint/overflowing-literals-valid.rs
@@ -1,5 +1,7 @@
+//! Test that valid large numeric literals do not trigger the `overflowing_literals` lint.
+
 //@ run-pass
-// Catch mistakes in the overflowing literals lint.
+
 #![deny(overflowing_literals)]
 
 pub fn main() {
diff --git a/tests/ui/auto-ref-slice-plus-ref.rs b/tests/ui/methods/vec-autoderef-autoref.rs
index 00b279d3226..38c0ba8574b 100644
--- a/tests/ui/auto-ref-slice-plus-ref.rs
+++ b/tests/ui/methods/vec-autoderef-autoref.rs
@@ -1,8 +1,7 @@
-fn main() {
-
-    // Testing that method lookup does not automatically borrow
-    // vectors to slices then automatically create a self reference.
+//! Test that method resolution does not autoderef `Vec`
+//! into a slice or perform additional autorefs.
 
+fn main() {
     let mut a = vec![0];
     a.test_mut(); //~ ERROR no method named `test_mut` found
     a.test(); //~ ERROR no method named `test` found
diff --git a/tests/ui/auto-ref-slice-plus-ref.stderr b/tests/ui/methods/vec-autoderef-autoref.stderr
index 806c1ee064f..61c3bcc5b3b 100644
--- a/tests/ui/auto-ref-slice-plus-ref.stderr
+++ b/tests/ui/methods/vec-autoderef-autoref.stderr
@@ -1,12 +1,12 @@
 error[E0599]: no method named `test_mut` found for struct `Vec<{integer}>` in the current scope
-  --> $DIR/auto-ref-slice-plus-ref.rs:7:7
+  --> $DIR/vec-autoderef-autoref.rs:6:7
    |
 LL |     a.test_mut();
    |       ^^^^^^^^
    |
    = help: items from traits can only be used if the trait is implemented and in scope
 note: `MyIter` defines an item `test_mut`, perhaps you need to implement it
-  --> $DIR/auto-ref-slice-plus-ref.rs:14:1
+  --> $DIR/vec-autoderef-autoref.rs:13:1
    |
 LL | trait MyIter {
    | ^^^^^^^^^^^^
@@ -14,40 +14,40 @@ help: there is a method `get_mut` with a similar name, but with different argume
   --> $SRC_DIR/core/src/slice/mod.rs:LL:COL
 
 error[E0599]: no method named `test` found for struct `Vec<{integer}>` in the current scope
-  --> $DIR/auto-ref-slice-plus-ref.rs:8:7
+  --> $DIR/vec-autoderef-autoref.rs:7:7
    |
 LL |     a.test();
    |       ^^^^ method not found in `Vec<{integer}>`
    |
    = help: items from traits can only be used if the trait is implemented and in scope
 note: `MyIter` defines an item `test`, perhaps you need to implement it
-  --> $DIR/auto-ref-slice-plus-ref.rs:14:1
+  --> $DIR/vec-autoderef-autoref.rs:13:1
    |
 LL | trait MyIter {
    | ^^^^^^^^^^^^
 
 error[E0599]: no method named `test` found for array `[{integer}; 1]` in the current scope
-  --> $DIR/auto-ref-slice-plus-ref.rs:10:11
+  --> $DIR/vec-autoderef-autoref.rs:9:11
    |
 LL |     ([1]).test();
    |           ^^^^ method not found in `[{integer}; 1]`
    |
    = help: items from traits can only be used if the trait is implemented and in scope
 note: `MyIter` defines an item `test`, perhaps you need to implement it
-  --> $DIR/auto-ref-slice-plus-ref.rs:14:1
+  --> $DIR/vec-autoderef-autoref.rs:13:1
    |
 LL | trait MyIter {
    | ^^^^^^^^^^^^
 
 error[E0599]: no method named `test` found for reference `&[{integer}; 1]` in the current scope
-  --> $DIR/auto-ref-slice-plus-ref.rs:11:12
+  --> $DIR/vec-autoderef-autoref.rs:10:12
    |
 LL |     (&[1]).test();
    |            ^^^^ method not found in `&[{integer}; 1]`
    |
    = help: items from traits can only be used if the trait is implemented and in scope
 note: `MyIter` defines an item `test`, perhaps you need to implement it
-  --> $DIR/auto-ref-slice-plus-ref.rs:14:1
+  --> $DIR/vec-autoderef-autoref.rs:13:1
    |
 LL | trait MyIter {
    | ^^^^^^^^^^^^
diff --git a/tests/ui/bare-static-string.rs b/tests/ui/str/str-static-literal.rs
index b71cf38cfe8..61630f0f22b 100644
--- a/tests/ui/bare-static-string.rs
+++ b/tests/ui/str/str-static-literal.rs
@@ -1,3 +1,5 @@
+//! Check that a bare string literal is typed as a `&'static str` and is usable.
+
 //@ run-pass
 
 pub fn main() {