Skip to content

Commit fae463d

Browse files
committed
cleaned up some tests
1 parent 5e46cfb commit fae463d

28 files changed

+363
-110
lines changed

tests/ui/auxiliary/svh-a-base.rs

Lines changed: 0 additions & 25 deletions
This file was deleted.

tests/ui/auxiliary/svh-b.rs

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
error[E0506]: cannot assign to `x` because it is borrowed
2+
--> $DIR/super-let-lifetime-and-drop.rs:30:28
3+
|
4+
LL | super let b = DropMe(&mut x);
5+
| ------ `x` is borrowed here
6+
...
7+
LL | #[cfg(borrowck)] { x = true; }
8+
| ^^^^^^^^ `x` is assigned to here but it was already borrowed
9+
...
10+
LL | }
11+
| - borrow might be used here, when `b` is dropped and runs the `Drop` code for type `DropMe`
12+
13+
error[E0506]: cannot assign to `x` because it is borrowed
14+
--> $DIR/super-let-lifetime-and-drop.rs:46:28
15+
|
16+
LL | super let b = &DropMe(&mut x);
17+
| --------------
18+
| | |
19+
| | `x` is borrowed here
20+
| a temporary with access to the borrow is created here ...
21+
...
22+
LL | #[cfg(borrowck)] { x = true; }
23+
| ^^^^^^^^ `x` is assigned to here but it was already borrowed
24+
...
25+
LL | }
26+
| - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `DropMe`
27+
28+
error[E0506]: cannot assign to `x` because it is borrowed
29+
--> $DIR/super-let-lifetime-and-drop.rs:64:32
30+
|
31+
LL | super let b = identity(&DropMe(&mut x));
32+
| --------------
33+
| | |
34+
| | `x` is borrowed here
35+
| a temporary with access to the borrow is created here ...
36+
LL | #[cfg(borrowck)] { x = true; }
37+
| ^^^^^^^^ `x` is assigned to here but it was already borrowed
38+
...
39+
LL | };
40+
| - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `DropMe`
41+
42+
error[E0506]: cannot assign to `x` because it is borrowed
43+
--> $DIR/super-let-lifetime-and-drop.rs:87:36
44+
|
45+
LL | super let b = identity(&DropMe(&mut x));
46+
| --------------
47+
| | |
48+
| | `x` is borrowed here
49+
| a temporary with access to the borrow is created here ...
50+
...
51+
LL | #[cfg(borrowck)] { x = true; }
52+
| ^^^^^^^^ `x` is assigned to here but it was already borrowed
53+
...
54+
LL | ));
55+
| - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `DropMe`
56+
57+
error[E0506]: cannot assign to `x` because it is borrowed
58+
--> $DIR/super-let-lifetime-and-drop.rs:107:28
59+
|
60+
LL | super let b = DropMe(&mut x);
61+
| ------ `x` is borrowed here
62+
...
63+
LL | #[cfg(borrowck)] { x = true; }
64+
| ^^^^^^^^ `x` is assigned to here but it was already borrowed
65+
...
66+
LL | }
67+
| - borrow might be used here, when `b` is dropped and runs the `Drop` code for type `DropMe`
68+
69+
error[E0506]: cannot assign to `x` because it is borrowed
70+
--> $DIR/super-let-lifetime-and-drop.rs:125:28
71+
|
72+
LL | super let b = DropMe(&mut x);
73+
| ------ `x` is borrowed here
74+
...
75+
LL | #[cfg(borrowck)] { x = true; }
76+
| ^^^^^^^^ `x` is assigned to here but it was already borrowed
77+
...
78+
LL | }
79+
| - borrow might be used here, when `b` is dropped and runs the `Drop` code for type `DropMe`
80+
81+
error[E0506]: cannot assign to `x` because it is borrowed
82+
--> $DIR/super-let-lifetime-and-drop.rs:143:28
83+
|
84+
LL | super let b = DropMe(&mut x);
85+
| ------ `x` is borrowed here
86+
...
87+
LL | #[cfg(borrowck)] { x = true; }
88+
| ^^^^^^^^ `x` is assigned to here but it was already borrowed
89+
...
90+
LL | }
91+
| - borrow might be used here, when `b` is dropped and runs the `Drop` code for type `DropMe`
92+
93+
error[E0506]: cannot assign to `x` because it is borrowed
94+
--> $DIR/super-let-lifetime-and-drop.rs:159:28
95+
|
96+
LL | b = DropMe(&mut x);
97+
| ------ `x` is borrowed here
98+
...
99+
LL | #[cfg(borrowck)] { x = true; }
100+
| ^^^^^^^^ `x` is assigned to here but it was already borrowed
101+
LL | drop(a);
102+
| - borrow later used here
103+
104+
error[E0716]: temporary value dropped while borrowed
105+
--> $DIR/super-let-lifetime-and-drop.rs:172:33
106+
|
107+
LL | #[cfg(borrowck)] { a = &String::from("asdf"); };
108+
| ^^^^^^^^^^^^^^^^^^^^- temporary value is freed at the end of this statement
109+
| |
110+
| creates a temporary value which is freed while still in use
111+
...
112+
LL | let _ = a;
113+
| - borrow later used here
114+
|
115+
= note: consider using a `let` binding to create a longer lived value
116+
117+
error[E0506]: cannot assign to `x` because it is borrowed
118+
--> $DIR/super-let-lifetime-and-drop.rs:206:28
119+
|
120+
LL | super let d = &DropMe(&mut x);
121+
| --------------
122+
| | |
123+
| | `x` is borrowed here
124+
| a temporary with access to the borrow is created here ...
125+
...
126+
LL | #[cfg(borrowck)] { x = true; }
127+
| ^^^^^^^^ `x` is assigned to here but it was already borrowed
128+
...
129+
LL | }
130+
| - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `DropMe`
131+
132+
error[E0506]: cannot assign to `x` because it is borrowed
133+
--> $DIR/super-let-lifetime-and-drop.rs:227:32
134+
|
135+
LL | super let d = identity(&DropMe(&mut x));
136+
| --------------
137+
| | |
138+
| | `x` is borrowed here
139+
| a temporary with access to the borrow is created here ...
140+
...
141+
LL | #[cfg(borrowck)] { x = true; }
142+
| ^^^^^^^^ `x` is assigned to here but it was already borrowed
143+
...
144+
LL | };
145+
| - ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `DropMe`
146+
147+
error[E0506]: cannot assign to `x` because it is borrowed
148+
--> $DIR/super-let-lifetime-and-drop.rs:246:28
149+
|
150+
LL | super let b = DropMe(&mut x);
151+
| ------ `x` is borrowed here
152+
...
153+
LL | #[cfg(borrowck)] { x = true; }
154+
| ^^^^^^^^ `x` is assigned to here but it was already borrowed
155+
...
156+
LL | }
157+
| - borrow might be used here, when `b` is dropped and runs the `Drop` code for type `DropMe`
158+
159+
error[E0506]: cannot assign to `x` because it is borrowed
160+
--> $DIR/super-let-lifetime-and-drop.rs:263:28
161+
|
162+
LL | let dropme = Some(DropMe(&mut x));
163+
| ------ `x` is borrowed here
164+
...
165+
LL | #[cfg(borrowck)] { x = true; }
166+
| ^^^^^^^^ `x` is assigned to here but it was already borrowed
167+
...
168+
LL | }
169+
| - borrow might be used here, when `x` is dropped and runs the `Drop` code for type `DropMe`
170+
171+
error: aborting due to 13 previous errors
172+
173+
Some errors have detailed explanations: E0506, E0716.
174+
For more information about an error, try `rustc --explain E0506`.

tests/ui/cast/cast-enum-to-primitive-error.fixed

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1+
//! This test verifies that a direct non-primitive cast from an enum to an integer type
2+
//! is correctly disallowed, even when a `From` implementation exists for that enum.
3+
//! It specifically checks for the `E0605` error ("non-primitive cast: `Enum` as `Primitive`")
4+
//! and confirms that `rustfix` can suggest an appropriate correction (e.g., using `into()`).
5+
16
//@ run-rustfix
7+
28
#![allow(dead_code, unused_variables)]
9+
310
enum NonNullary {
411
Nullary,
512
Other(isize),

tests/ui/cast/cast-enum-to-primitive-error.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1+
//! This test verifies that a direct non-primitive cast from an enum to an integer type
2+
//! is correctly disallowed, even when a `From` implementation exists for that enum.
3+
//! It specifically checks for the `E0605` error ("non-primitive cast: `Enum` as `Primitive`")
4+
//! and confirms that `rustfix` can suggest an appropriate correction (e.g., using `into()`).
5+
16
//@ run-rustfix
7+
28
#![allow(dead_code, unused_variables)]
9+
310
enum NonNullary {
411
Nullary,
512
Other(isize),

tests/ui/cast/cast-enum-to-primitive-error.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0605]: non-primitive cast: `NonNullary` as `isize`
2-
--> $DIR/tag-variant-cast-non-nullary.rs:19:15
2+
--> $DIR/cast-enum-to-primitive-error.rs:26:15
33
|
44
LL | let val = v as isize;
55
| ^^^^^^^^^^ an `as` expression can be used to convert enum types to numeric types only if the enum type is unit-only or field-less

tests/ui/cast/coercion-as-explicit-cast.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
//! This test checks that various forms of "trivial" casts and coercions
2+
//! can be explicitly performed using the `as` keyword without compilation errors.
3+
14
//@ run-pass
2-
// Test that all coercions can actually be done using casts (modulo the lints).
35

46
#![allow(trivial_casts, trivial_numeric_casts)]
57

tests/ui/cast/coercion-as-explicit-cast.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
warning: method `foo` is never used
2-
--> $DIR/trivial_casts-rpass.rs:7:8
2+
--> $DIR/coercion-as-explicit-cast.rs:9:8
33
|
44
LL | trait Foo {
55
| --- method in this trait
Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
1-
enum Quux<T> { Bar }
2-
//~^ ERROR: parameter `T` is never used
1+
//! This test checks two common compilation errors related to generic enums
32
4-
fn foo(c: Quux) { assert!((false)); } //~ ERROR missing generics for enum `Quux`
3+
enum Quux<T> {
4+
//~^ ERROR: parameter `T` is never used
5+
Bar,
6+
}
57

6-
fn main() { panic!(); }
8+
fn foo(c: Quux) {
9+
//~^ ERROR missing generics for enum `Quux`
10+
assert!((false));
11+
}
12+
13+
fn main() {
14+
panic!();
15+
}

tests/ui/generics/generic-enum-errors.stderr

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
error[E0392]: type parameter `T` is never used
2-
--> $DIR/tag-type-args.rs:1:11
2+
--> $DIR/generic-enum-errors.rs:3:11
33
|
4-
LL | enum Quux<T> { Bar }
4+
LL | enum Quux<T> {
55
| ^ unused type parameter
66
|
77
= help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData`
88
= help: if you intended `T` to be a const parameter, use `const T: /* Type */` instead
99

1010
error[E0107]: missing generics for enum `Quux`
11-
--> $DIR/tag-type-args.rs:4:11
11+
--> $DIR/generic-enum-errors.rs:8:11
1212
|
13-
LL | fn foo(c: Quux) { assert!((false)); }
13+
LL | fn foo(c: Quux) {
1414
| ^^^^ expected 1 generic argument
1515
|
1616
note: enum defined here, with 1 generic parameter: `T`
17-
--> $DIR/tag-type-args.rs:1:6
17+
--> $DIR/generic-enum-errors.rs:3:6
1818
|
19-
LL | enum Quux<T> { Bar }
19+
LL | enum Quux<T> {
2020
| ^^^^ -
2121
help: add missing generic argument
2222
|
23-
LL | fn foo(c: Quux<T>) { assert!((false)); }
23+
LL | fn foo(c: Quux<T>) {
2424
| +++
2525

2626
error: aborting due to 2 previous errors

0 commit comments

Comments
 (0)