Skip to content

Commit a777d96

Browse files
committed
Update tests.
1 parent c324043 commit a777d96

12 files changed

+65
-116
lines changed

tests/ui/consts/const-mut-refs/mut_ref_in_final.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const B: *mut i32 = &mut 4; //~ ERROR mutable references are not allowed
1818
const B2: Option<&mut i32> = None;
1919

2020
// Not ok, can't prove that no mutable allocation ends up in final value
21-
const B3: Option<&mut i32> = Some(&mut 42); //~ ERROR temporary value dropped while borrowed
21+
const B3: Option<&mut i32> = Some(&mut 42); //~ ERROR mutable references are not allowed
2222

2323
const fn helper(x: &mut i32) -> Option<&mut i32> { Some(x) }
2424
const B4: Option<&mut i32> = helper(&mut 42); //~ ERROR temporary value dropped while borrowed

tests/ui/consts/const-mut-refs/mut_ref_in_final.stderr

+3-7
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,11 @@ error[E0764]: mutable references are not allowed in the final value of constants
44
LL | const B: *mut i32 = &mut 4;
55
| ^^^^^^
66

7-
error[E0716]: temporary value dropped while borrowed
8-
--> $DIR/mut_ref_in_final.rs:21:40
7+
error[E0764]: mutable references are not allowed in the final value of constants
8+
--> $DIR/mut_ref_in_final.rs:21:35
99
|
1010
LL | const B3: Option<&mut i32> = Some(&mut 42);
11-
| ----------^^-
12-
| | | |
13-
| | | temporary value is freed at the end of this statement
14-
| | creates a temporary value which is freed while still in use
15-
| using this value as a constant requires that borrow lasts for `'static`
11+
| ^^^^^^^
1612

1713
error[E0716]: temporary value dropped while borrowed
1814
--> $DIR/mut_ref_in_final.rs:24:42

tests/ui/consts/issue-54224.rs

-12
This file was deleted.

tests/ui/consts/promote-not.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
use std::cell::Cell;
66
use std::mem::ManuallyDrop;
77

8-
// We do not promote mutable references.
9-
static mut TEST1: Option<&mut [i32]> = Some(&mut [1, 2, 3]); //~ ERROR temporary value dropped while borrowed
8+
static mut TEST1: Option<&mut [i32]> = Some(&mut [1, 2, 3]);
109

1110
static mut TEST2: &'static mut [i32] = {
1211
let x = &mut [1,2,3]; //~ ERROR temporary value dropped while borrowed

tests/ui/consts/promote-not.stderr

+27-37
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,5 @@
11
error[E0716]: temporary value dropped while borrowed
2-
--> $DIR/promote-not.rs:9:50
3-
|
4-
LL | static mut TEST1: Option<&mut [i32]> = Some(&mut [1, 2, 3]);
5-
| ----------^^^^^^^^^-
6-
| | | |
7-
| | | temporary value is freed at the end of this statement
8-
| | creates a temporary value which is freed while still in use
9-
| using this value as a static requires that borrow lasts for `'static`
10-
11-
error[E0716]: temporary value dropped while borrowed
12-
--> $DIR/promote-not.rs:12:18
2+
--> $DIR/promote-not.rs:11:18
133
|
144
LL | let x = &mut [1,2,3];
155
| ^^^^^^^ creates a temporary value which is freed while still in use
@@ -19,7 +9,7 @@ LL | };
199
| - temporary value is freed at the end of this statement
2010

2111
error[E0716]: temporary value dropped while borrowed
22-
--> $DIR/promote-not.rs:34:29
12+
--> $DIR/promote-not.rs:33:29
2313
|
2414
LL | let _x: &'static i32 = &unsafe { U { x: 0 }.x };
2515
| ------------ ^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use
@@ -29,7 +19,7 @@ LL | };
2919
| - temporary value is freed at the end of this statement
3020

3121
error[E0716]: temporary value dropped while borrowed
32-
--> $DIR/promote-not.rs:40:29
22+
--> $DIR/promote-not.rs:39:29
3323
|
3424
LL | let _val: &'static _ = &(Cell::new(1), 2).1;
3525
| ---------- ^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use
@@ -39,7 +29,7 @@ LL | };
3929
| - temporary value is freed at the end of this statement
4030

4131
error[E0493]: destructor of `String` cannot be evaluated at compile-time
42-
--> $DIR/promote-not.rs:47:14
32+
--> $DIR/promote-not.rs:46:14
4333
|
4434
LL | let x = &String::new();
4535
| ^^^^^^^^^^^^^ the destructor for this type cannot be evaluated in constants
@@ -48,7 +38,7 @@ LL | };
4838
| - value is dropped here
4939

5040
error[E0716]: temporary value dropped while borrowed
51-
--> $DIR/promote-not.rs:59:33
41+
--> $DIR/promote-not.rs:58:33
5242
|
5343
LL | let _x: &'static u32 = &mk_panic();
5444
| ------------ ^^^^^^^^^^ creates a temporary value which is freed while still in use
@@ -58,7 +48,7 @@ LL | }
5848
| - temporary value is freed at the end of this statement
5949

6050
error[E0716]: temporary value dropped while borrowed
61-
--> $DIR/promote-not.rs:21:32
51+
--> $DIR/promote-not.rs:20:32
6252
|
6353
LL | let _x: &'static () = &foo();
6454
| ----------- ^^^^^ creates a temporary value which is freed while still in use
@@ -68,7 +58,7 @@ LL | }
6858
| - temporary value is freed at the end of this statement
6959

7060
error[E0716]: temporary value dropped while borrowed
71-
--> $DIR/promote-not.rs:29:29
61+
--> $DIR/promote-not.rs:28:29
7262
|
7363
LL | let _x: &'static i32 = &unsafe { U { x: 0 }.x };
7464
| ------------ ^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use
@@ -78,7 +68,7 @@ LL | }
7868
| - temporary value is freed at the end of this statement
7969

8070
error[E0716]: temporary value dropped while borrowed
81-
--> $DIR/promote-not.rs:65:29
71+
--> $DIR/promote-not.rs:64:29
8272
|
8373
LL | let _val: &'static _ = &(Cell::new(1), 2).0;
8474
| ---------- ^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use
@@ -89,7 +79,7 @@ LL | }
8979
| - temporary value is freed at the end of this statement
9080

9181
error[E0716]: temporary value dropped while borrowed
92-
--> $DIR/promote-not.rs:66:29
82+
--> $DIR/promote-not.rs:65:29
9383
|
9484
LL | let _val: &'static _ = &(Cell::new(1), 2).1;
9585
| ---------- ^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use
@@ -100,7 +90,7 @@ LL | }
10090
| - temporary value is freed at the end of this statement
10191

10292
error[E0716]: temporary value dropped while borrowed
103-
--> $DIR/promote-not.rs:69:29
93+
--> $DIR/promote-not.rs:68:29
10494
|
10595
LL | let _val: &'static _ = &(1/0);
10696
| ---------- ^^^^^ creates a temporary value which is freed while still in use
@@ -111,7 +101,7 @@ LL | }
111101
| - temporary value is freed at the end of this statement
112102

113103
error[E0716]: temporary value dropped while borrowed
114-
--> $DIR/promote-not.rs:70:29
104+
--> $DIR/promote-not.rs:69:29
115105
|
116106
LL | let _val: &'static _ = &(1/(1-1));
117107
| ---------- ^^^^^^^^^ creates a temporary value which is freed while still in use
@@ -122,7 +112,7 @@ LL | }
122112
| - temporary value is freed at the end of this statement
123113

124114
error[E0716]: temporary value dropped while borrowed
125-
--> $DIR/promote-not.rs:71:29
115+
--> $DIR/promote-not.rs:70:29
126116
|
127117
LL | let _val: &'static _ = &((1+1)/(1-1));
128118
| ---------- ^^^^^^^^^^^^^ creates a temporary value which is freed while still in use
@@ -133,7 +123,7 @@ LL | }
133123
| - temporary value is freed at the end of this statement
134124

135125
error[E0716]: temporary value dropped while borrowed
136-
--> $DIR/promote-not.rs:72:29
126+
--> $DIR/promote-not.rs:71:29
137127
|
138128
LL | let _val: &'static _ = &(i32::MIN/-1);
139129
| ---------- ^^^^^^^^^^^^^ creates a temporary value which is freed while still in use
@@ -144,7 +134,7 @@ LL | }
144134
| - temporary value is freed at the end of this statement
145135

146136
error[E0716]: temporary value dropped while borrowed
147-
--> $DIR/promote-not.rs:73:29
137+
--> $DIR/promote-not.rs:72:29
148138
|
149139
LL | let _val: &'static _ = &(i32::MIN/(0-1));
150140
| ---------- ^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use
@@ -155,7 +145,7 @@ LL | }
155145
| - temporary value is freed at the end of this statement
156146

157147
error[E0716]: temporary value dropped while borrowed
158-
--> $DIR/promote-not.rs:74:29
148+
--> $DIR/promote-not.rs:73:29
159149
|
160150
LL | let _val: &'static _ = &(-128i8/-1);
161151
| ---------- ^^^^^^^^^^^ creates a temporary value which is freed while still in use
@@ -166,7 +156,7 @@ LL | }
166156
| - temporary value is freed at the end of this statement
167157

168158
error[E0716]: temporary value dropped while borrowed
169-
--> $DIR/promote-not.rs:75:29
159+
--> $DIR/promote-not.rs:74:29
170160
|
171161
LL | let _val: &'static _ = &(1%0);
172162
| ---------- ^^^^^ creates a temporary value which is freed while still in use
@@ -177,7 +167,7 @@ LL | }
177167
| - temporary value is freed at the end of this statement
178168

179169
error[E0716]: temporary value dropped while borrowed
180-
--> $DIR/promote-not.rs:76:29
170+
--> $DIR/promote-not.rs:75:29
181171
|
182172
LL | let _val: &'static _ = &(1%(1-1));
183173
| ---------- ^^^^^^^^^ creates a temporary value which is freed while still in use
@@ -188,7 +178,7 @@ LL | }
188178
| - temporary value is freed at the end of this statement
189179

190180
error[E0716]: temporary value dropped while borrowed
191-
--> $DIR/promote-not.rs:77:29
181+
--> $DIR/promote-not.rs:76:29
192182
|
193183
LL | let _val: &'static _ = &([1,2,3][4]+1);
194184
| ---------- ^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use
@@ -199,7 +189,7 @@ LL | }
199189
| - temporary value is freed at the end of this statement
200190

201191
error[E0716]: temporary value dropped while borrowed
202-
--> $DIR/promote-not.rs:81:29
192+
--> $DIR/promote-not.rs:80:29
203193
|
204194
LL | let _val: &'static _ = &TEST_DROP;
205195
| ---------- ^^^^^^^^^ creates a temporary value which is freed while still in use
@@ -210,7 +200,7 @@ LL | }
210200
| - temporary value is freed at the end of this statement
211201

212202
error[E0716]: temporary value dropped while borrowed
213-
--> $DIR/promote-not.rs:83:29
203+
--> $DIR/promote-not.rs:82:29
214204
|
215205
LL | let _val: &'static _ = &&TEST_DROP;
216206
| ---------- ^^^^^^^^^^ creates a temporary value which is freed while still in use
@@ -221,7 +211,7 @@ LL | }
221211
| - temporary value is freed at the end of this statement
222212

223213
error[E0716]: temporary value dropped while borrowed
224-
--> $DIR/promote-not.rs:83:30
214+
--> $DIR/promote-not.rs:82:30
225215
|
226216
LL | let _val: &'static _ = &&TEST_DROP;
227217
| ---------- ^^^^^^^^^ creates a temporary value which is freed while still in use
@@ -232,7 +222,7 @@ LL | }
232222
| - temporary value is freed at the end of this statement
233223

234224
error[E0716]: temporary value dropped while borrowed
235-
--> $DIR/promote-not.rs:86:29
225+
--> $DIR/promote-not.rs:85:29
236226
|
237227
LL | let _val: &'static _ = &(&TEST_DROP,);
238228
| ---------- ^^^^^^^^^^^^^ creates a temporary value which is freed while still in use
@@ -243,7 +233,7 @@ LL | }
243233
| - temporary value is freed at the end of this statement
244234

245235
error[E0716]: temporary value dropped while borrowed
246-
--> $DIR/promote-not.rs:86:31
236+
--> $DIR/promote-not.rs:85:31
247237
|
248238
LL | let _val: &'static _ = &(&TEST_DROP,);
249239
| ---------- ^^^^^^^^^ creates a temporary value which is freed while still in use
@@ -254,7 +244,7 @@ LL | }
254244
| - temporary value is freed at the end of this statement
255245

256246
error[E0716]: temporary value dropped while borrowed
257-
--> $DIR/promote-not.rs:89:29
247+
--> $DIR/promote-not.rs:88:29
258248
|
259249
LL | let _val: &'static _ = &[&TEST_DROP; 1];
260250
| ---------- ^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use
@@ -265,7 +255,7 @@ LL | }
265255
| - temporary value is freed at the end of this statement
266256

267257
error[E0716]: temporary value dropped while borrowed
268-
--> $DIR/promote-not.rs:89:31
258+
--> $DIR/promote-not.rs:88:31
269259
|
270260
LL | let _val: &'static _ = &[&TEST_DROP; 1];
271261
| ---------- ^^^^^^^^^ - temporary value is freed at the end of this statement
@@ -274,7 +264,7 @@ LL | let _val: &'static _ = &[&TEST_DROP; 1];
274264
| type annotation requires that borrow lasts for `'static`
275265

276266
error[E0716]: temporary value dropped while borrowed
277-
--> $DIR/promote-not.rs:98:26
267+
--> $DIR/promote-not.rs:97:26
278268
|
279269
LL | let x: &'static _ = &UnionWithCell { f1: 0 };
280270
| ---------- ^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use
@@ -284,7 +274,7 @@ LL |
284274
LL | }
285275
| - temporary value is freed at the end of this statement
286276

287-
error: aborting due to 27 previous errors
277+
error: aborting due to 26 previous errors
288278

289279
Some errors have detailed explanations: E0493, E0716.
290280
For more information about an error, try `rustc --explain E0493`.

tests/ui/coroutine/auto-trait-regions.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ fn main() {
4343
// Disallow impls which relates lifetimes in the coroutine interior
4444
let gen = #[coroutine] move || {
4545
let a = A(&mut true, &mut true, No);
46-
//~^ ERROR temporary value dropped while borrowed
47-
//~| ERROR temporary value dropped while borrowed
46+
//~^ ERROR borrow may still be in use when coroutine yields
47+
//~| ERROR borrow may still be in use when coroutine yields
4848
yield;
4949
assert_foo(a);
5050
};
+21-23
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,34 @@
1-
error[E0716]: temporary value dropped while borrowed
2-
--> $DIR/auto-trait-regions.rs:45:24
1+
error[E0626]: borrow may still be in use when coroutine yields
2+
--> $DIR/auto-trait-regions.rs:45:19
33
|
4+
LL | let gen = #[coroutine] move || {
5+
| ------- within this coroutine
46
LL | let a = A(&mut true, &mut true, No);
5-
| ^^^^ - temporary value is freed at the end of this statement
6-
| |
7-
| creates a temporary value which is freed while still in use
7+
| ^^^^^^^^^
88
...
9-
LL | assert_foo(a);
10-
| - borrow later used here
9+
LL | yield;
10+
| ----- possible yield occurs here
1111
|
12-
help: consider using a `let` binding to create a longer lived value
13-
|
14-
LL ~ let binding = true;
15-
LL ~ let a = A(&mut binding, &mut true, No);
12+
help: add `static` to mark this coroutine as unmovable
1613
|
14+
LL | let gen = #[coroutine] static move || {
15+
| ++++++
1716

18-
error[E0716]: temporary value dropped while borrowed
19-
--> $DIR/auto-trait-regions.rs:45:35
17+
error[E0626]: borrow may still be in use when coroutine yields
18+
--> $DIR/auto-trait-regions.rs:45:30
2019
|
20+
LL | let gen = #[coroutine] move || {
21+
| ------- within this coroutine
2122
LL | let a = A(&mut true, &mut true, No);
22-
| ^^^^ - temporary value is freed at the end of this statement
23-
| |
24-
| creates a temporary value which is freed while still in use
23+
| ^^^^^^^^^
2524
...
26-
LL | assert_foo(a);
27-
| - borrow later used here
28-
|
29-
help: consider using a `let` binding to create a longer lived value
25+
LL | yield;
26+
| ----- possible yield occurs here
3027
|
31-
LL ~ let binding = true;
32-
LL ~ let a = A(&mut true, &mut binding, No);
28+
help: add `static` to mark this coroutine as unmovable
3329
|
30+
LL | let gen = #[coroutine] static move || {
31+
| ++++++
3432

3533
error: implementation of `Foo` is not general enough
3634
--> $DIR/auto-trait-regions.rs:31:5
@@ -52,4 +50,4 @@ LL | assert_foo(gen);
5250

5351
error: aborting due to 4 previous errors
5452

55-
For more information about this error, try `rustc --explain E0716`.
53+
For more information about this error, try `rustc --explain E0626`.
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
("Hello", 1) [(("Hello", 1),)] "Hello" "Hello" "Hello" ("Hello", 1) ("Hello", 1) ("Hello", 1)
1+
("Hello", 1) [(("Hello", 1),)] Some("Hello") "Hello" "Hello" ("Hello", 1) ("Hello", 1) ("Hello", 1)
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
("Hello", 1) [(("Hello", 1),)] "Hello" "Hello" "Hello" ("Hello", 1) ("Hello", 1) ("Hello", 1)
1+
("Hello", 1) [(("Hello", 1),)] Some("Hello") "Hello" "Hello" ("Hello", 1) ("Hello", 1) ("Hello", 1)

tests/ui/lifetimes/temporary-lifetime-extension.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ fn temp() -> (String, i32) {
2323
fn main() {
2424
let a = &temp();
2525
let b = [(&temp(),)];
26-
let c = &temp().0;
26+
let c = Some(&temp().0);
2727
let d = &temp().0[..];
2828
let e = {
2929
let _ = 123;

0 commit comments

Comments
 (0)