Skip to content

Commit f6bfed8

Browse files
authored
Unrolled build for #141793
Rollup merge of #141793 - Kivooeo:test-reform, r=jieyouxu `tests/ui`: A New Order [1/N] not sure if i should say something about changes here, just part of #133895 but this is my very first time doing something like this, id love to keep contributing in this area later on, so any feedback is appreciated also should say that im going to squash it after agreement on changes r? `@jieyouxu` mind if i name this PR series like "`tests/ui`: A New Order [N/N]", im not sure if it fits the project tone, so id like your approval first — but i think it sounds really neat (Star Wars reference) this could be a first part :)
2 parents 852f15c + afc6424 commit f6bfed8

File tree

8 files changed

+57
-40
lines changed

8 files changed

+57
-40
lines changed

tests/ui/autoderef-full-lval.rs

Lines changed: 0 additions & 25 deletions
This file was deleted.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
//! Tests that auto-dereferencing does not allow addition of `Box<isize>` values.
2+
//!
3+
//! This test ensures that `Box<isize>` fields in structs (`Clam` and `Fish`) are not
4+
//! automatically dereferenced to `isize` during addition operations, as `Box<isize>`
5+
//! does not implement the `Add` trait.
6+
7+
struct Clam {
8+
x: Box<isize>,
9+
y: Box<isize>,
10+
}
11+
12+
struct Fish {
13+
a: Box<isize>,
14+
}
15+
16+
fn main() {
17+
let a: Clam = Clam {
18+
x: Box::new(1),
19+
y: Box::new(2),
20+
};
21+
let b: Clam = Clam {
22+
x: Box::new(10),
23+
y: Box::new(20),
24+
};
25+
let z: isize = a.x + b.y;
26+
//~^ ERROR cannot add `Box<isize>` to `Box<isize>`
27+
println!("{}", z);
28+
assert_eq!(z, 21);
29+
let forty: Fish = Fish { a: Box::new(40) };
30+
let two: Fish = Fish { a: Box::new(2) };
31+
let answer: isize = forty.a + two.a;
32+
//~^ ERROR cannot add `Box<isize>` to `Box<isize>`
33+
println!("{}", answer);
34+
assert_eq!(answer, 42);
35+
}

tests/ui/autoderef-full-lval.stderr renamed to tests/ui/autoref-autoderef/autoderef-box-no-add.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0369]: cannot add `Box<isize>` to `Box<isize>`
2-
--> $DIR/autoderef-full-lval.rs:15:24
2+
--> $DIR/autoderef-box-no-add.rs:25:24
33
|
44
LL | let z: isize = a.x + b.y;
55
| --- ^ --- Box<isize>
@@ -13,7 +13,7 @@ note: the foreign item type `Box<isize>` doesn't implement `Add`
1313
= note: not implement `Add`
1414

1515
error[E0369]: cannot add `Box<isize>` to `Box<isize>`
16-
--> $DIR/autoderef-full-lval.rs:21:33
16+
--> $DIR/autoderef-box-no-add.rs:31:33
1717
|
1818
LL | let answer: isize = forty.a + two.a;
1919
| ------- ^ ----- Box<isize>

tests/ui/bare-fn-implements-fn-mut.rs renamed to tests/ui/functions-closures/bare-fn-implements-fn-mut.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
//! Tests that bare functions implement the `FnMut` trait.
2+
//!
3+
//! See <https://github.com/rust-lang/rust/issues/15448>.
4+
15
//@ run-pass
26

37
fn call_f<F:FnMut()>(mut f: F) {

tests/ui/big-literals.rs renamed to tests/ui/lint/overflowing-literals-valid.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
//! Test that valid large numeric literals do not trigger the `overflowing_literals` lint.
2+
13
//@ run-pass
2-
// Catch mistakes in the overflowing literals lint.
4+
35
#![deny(overflowing_literals)]
46

57
pub fn main() {

tests/ui/auto-ref-slice-plus-ref.rs renamed to tests/ui/methods/vec-autoderef-autoref.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
fn main() {
2-
3-
// Testing that method lookup does not automatically borrow
4-
// vectors to slices then automatically create a self reference.
1+
//! Test that method resolution does not autoderef `Vec`
2+
//! into a slice or perform additional autorefs.
53
4+
fn main() {
65
let mut a = vec![0];
76
a.test_mut(); //~ ERROR no method named `test_mut` found
87
a.test(); //~ ERROR no method named `test` found

tests/ui/auto-ref-slice-plus-ref.stderr renamed to tests/ui/methods/vec-autoderef-autoref.stderr

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,53 @@
11
error[E0599]: no method named `test_mut` found for struct `Vec<{integer}>` in the current scope
2-
--> $DIR/auto-ref-slice-plus-ref.rs:7:7
2+
--> $DIR/vec-autoderef-autoref.rs:6:7
33
|
44
LL | a.test_mut();
55
| ^^^^^^^^
66
|
77
= help: items from traits can only be used if the trait is implemented and in scope
88
note: `MyIter` defines an item `test_mut`, perhaps you need to implement it
9-
--> $DIR/auto-ref-slice-plus-ref.rs:14:1
9+
--> $DIR/vec-autoderef-autoref.rs:13:1
1010
|
1111
LL | trait MyIter {
1212
| ^^^^^^^^^^^^
1313
help: there is a method `get_mut` with a similar name, but with different arguments
1414
--> $SRC_DIR/core/src/slice/mod.rs:LL:COL
1515

1616
error[E0599]: no method named `test` found for struct `Vec<{integer}>` in the current scope
17-
--> $DIR/auto-ref-slice-plus-ref.rs:8:7
17+
--> $DIR/vec-autoderef-autoref.rs:7:7
1818
|
1919
LL | a.test();
2020
| ^^^^ method not found in `Vec<{integer}>`
2121
|
2222
= help: items from traits can only be used if the trait is implemented and in scope
2323
note: `MyIter` defines an item `test`, perhaps you need to implement it
24-
--> $DIR/auto-ref-slice-plus-ref.rs:14:1
24+
--> $DIR/vec-autoderef-autoref.rs:13:1
2525
|
2626
LL | trait MyIter {
2727
| ^^^^^^^^^^^^
2828

2929
error[E0599]: no method named `test` found for array `[{integer}; 1]` in the current scope
30-
--> $DIR/auto-ref-slice-plus-ref.rs:10:11
30+
--> $DIR/vec-autoderef-autoref.rs:9:11
3131
|
3232
LL | ([1]).test();
3333
| ^^^^ method not found in `[{integer}; 1]`
3434
|
3535
= help: items from traits can only be used if the trait is implemented and in scope
3636
note: `MyIter` defines an item `test`, perhaps you need to implement it
37-
--> $DIR/auto-ref-slice-plus-ref.rs:14:1
37+
--> $DIR/vec-autoderef-autoref.rs:13:1
3838
|
3939
LL | trait MyIter {
4040
| ^^^^^^^^^^^^
4141

4242
error[E0599]: no method named `test` found for reference `&[{integer}; 1]` in the current scope
43-
--> $DIR/auto-ref-slice-plus-ref.rs:11:12
43+
--> $DIR/vec-autoderef-autoref.rs:10:12
4444
|
4545
LL | (&[1]).test();
4646
| ^^^^ method not found in `&[{integer}; 1]`
4747
|
4848
= help: items from traits can only be used if the trait is implemented and in scope
4949
note: `MyIter` defines an item `test`, perhaps you need to implement it
50-
--> $DIR/auto-ref-slice-plus-ref.rs:14:1
50+
--> $DIR/vec-autoderef-autoref.rs:13:1
5151
|
5252
LL | trait MyIter {
5353
| ^^^^^^^^^^^^

tests/ui/bare-static-string.rs renamed to tests/ui/str/str-static-literal.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Check that a bare string literal is typed as a `&'static str` and is usable.
2+
13
//@ run-pass
24

35
pub fn main() {

0 commit comments

Comments
 (0)