Skip to content

Commit a6e7f26

Browse files
committed
Update tests.
1 parent 3b9e214 commit a6e7f26

File tree

5 files changed

+120
-63
lines changed

5 files changed

+120
-63
lines changed

src/test/ui/suggestions/missing-lifetime-specifier.rs

+2
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,15 @@ thread_local! {
4545
//~| ERROR this union takes 2 lifetime arguments but 1 lifetime argument was supplied
4646
//~| ERROR this union takes 2 lifetime arguments but 1 lifetime argument was supplied
4747
//~| ERROR this union takes 2 lifetime arguments but 1 lifetime argument was supplied
48+
//~| ERROR this union takes 2 lifetime arguments but 1 lifetime argument was supplied
4849
}
4950
thread_local! {
5051
static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, i32>>>>> = RefCell::new(HashMap::new());
5152
//~^ ERROR this trait takes 2 lifetime arguments but 1 lifetime argument was supplied
5253
//~| ERROR this trait takes 2 lifetime arguments but 1 lifetime argument was supplied
5354
//~| ERROR this trait takes 2 lifetime arguments but 1 lifetime argument was supplied
5455
//~| ERROR this trait takes 2 lifetime arguments but 1 lifetime argument was supplied
56+
//~| ERROR this trait takes 2 lifetime arguments but 1 lifetime argument was supplied
5557
//~| ERROR missing lifetime
5658
//~| ERROR missing lifetime
5759
}

src/test/ui/suggestions/missing-lifetime-specifier.stderr

+111-58
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@ LL | static a: RefCell<HashMap<i32, Vec<Vec<Foo<'static, 'static>>>>> = RefC
1313
error[E0106]: missing lifetime specifiers
1414
--> $DIR/missing-lifetime-specifier.rs:18:44
1515
|
16-
LL | static a: RefCell<HashMap<i32, Vec<Vec<Foo>>>> = RefCell::new(HashMap::new());
17-
| ^^^ expected 2 lifetime parameters
18-
|
19-
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
20-
help: consider using the `'static` lifetime
21-
|
22-
LL | static a: RefCell<HashMap<i32, Vec<Vec<Foo<'static, 'static>>>>> = RefCell::new(HashMap::new());
23-
| ~~~~~~~~~~~~~~~~~~~~~
16+
LL | / thread_local! {
17+
LL | | static a: RefCell<HashMap<i32, Vec<Vec<Foo>>>> = RefCell::new(HashMap::new());
18+
| | ^^^ expected 2 lifetime parameters
19+
LL | |
20+
LL | |
21+
LL | | }
22+
| |_-
23+
|
24+
= help: this function's return type contains a borrowed value, but the signature does not say which one of `init`'s 3 lifetimes it is borrowed from
2425

2526
error[E0106]: missing lifetime specifier
2627
--> $DIR/missing-lifetime-specifier.rs:23:44
@@ -49,26 +50,32 @@ LL | static b: RefCell<HashMap<i32, Vec<Vec<&Bar<'static, 'static>>>>> = Ref
4950
error[E0106]: missing lifetime specifier
5051
--> $DIR/missing-lifetime-specifier.rs:23:44
5152
|
52-
LL | static b: RefCell<HashMap<i32, Vec<Vec<&Bar>>>> = RefCell::new(HashMap::new());
53-
| ^ expected named lifetime parameter
54-
|
55-
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
56-
help: consider using the `'static` lifetime
57-
|
58-
LL | static b: RefCell<HashMap<i32, Vec<Vec<&'static Bar>>>> = RefCell::new(HashMap::new());
59-
| ~~~~~~~~
53+
LL | / thread_local! {
54+
LL | | static b: RefCell<HashMap<i32, Vec<Vec<&Bar>>>> = RefCell::new(HashMap::new());
55+
| | ^ expected named lifetime parameter
56+
LL | |
57+
LL | |
58+
LL | |
59+
LL | |
60+
LL | | }
61+
| |_-
62+
|
63+
= help: this function's return type contains a borrowed value, but the signature does not say which one of `init`'s 4 lifetimes it is borrowed from
6064

6165
error[E0106]: missing lifetime specifiers
6266
--> $DIR/missing-lifetime-specifier.rs:23:45
6367
|
64-
LL | static b: RefCell<HashMap<i32, Vec<Vec<&Bar>>>> = RefCell::new(HashMap::new());
65-
| ^^^ expected 2 lifetime parameters
66-
|
67-
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
68-
help: consider using the `'static` lifetime
69-
|
70-
LL | static b: RefCell<HashMap<i32, Vec<Vec<&Bar<'static, 'static>>>>> = RefCell::new(HashMap::new());
71-
| ~~~~~~~~~~~~~~~~~~~~~
68+
LL | / thread_local! {
69+
LL | | static b: RefCell<HashMap<i32, Vec<Vec<&Bar>>>> = RefCell::new(HashMap::new());
70+
| | ^^^ expected 2 lifetime parameters
71+
LL | |
72+
LL | |
73+
LL | |
74+
LL | |
75+
LL | | }
76+
| |_-
77+
|
78+
= help: this function's return type contains a borrowed value, but the signature does not say which one of `init`'s 4 lifetimes it is borrowed from
7279

7380
error[E0106]: missing lifetime specifiers
7481
--> $DIR/missing-lifetime-specifier.rs:30:48
@@ -85,14 +92,15 @@ LL | static c: RefCell<HashMap<i32, Vec<Vec<Qux<'static, 'static, i32>>>>> =
8592
error[E0106]: missing lifetime specifiers
8693
--> $DIR/missing-lifetime-specifier.rs:30:48
8794
|
88-
LL | static c: RefCell<HashMap<i32, Vec<Vec<Qux<i32>>>>> = RefCell::new(HashMap::new());
89-
| ^ expected 2 lifetime parameters
90-
|
91-
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
92-
help: consider using the `'static` lifetime
95+
LL | / thread_local! {
96+
LL | | static c: RefCell<HashMap<i32, Vec<Vec<Qux<i32>>>>> = RefCell::new(HashMap::new());
97+
| | ^ expected 2 lifetime parameters
98+
LL | |
99+
LL | |
100+
LL | | }
101+
| |_-
93102
|
94-
LL | static c: RefCell<HashMap<i32, Vec<Vec<Qux<'static, 'static, i32>>>>> = RefCell::new(HashMap::new());
95-
| +++++++++++++++++
103+
= help: this function's return type contains a borrowed value, but the signature does not say which one of `init`'s 3 lifetimes it is borrowed from
96104

97105
error[E0106]: missing lifetime specifier
98106
--> $DIR/missing-lifetime-specifier.rs:35:44
@@ -121,26 +129,50 @@ LL | static d: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, 'static, i32>>>>>
121129
error[E0106]: missing lifetime specifier
122130
--> $DIR/missing-lifetime-specifier.rs:35:44
123131
|
124-
LL | static d: RefCell<HashMap<i32, Vec<Vec<&Tar<i32>>>>> = RefCell::new(HashMap::new());
125-
| ^ expected named lifetime parameter
126-
|
127-
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
128-
help: consider using the `'static` lifetime
129-
|
130-
LL | static d: RefCell<HashMap<i32, Vec<Vec<&'static Tar<i32>>>>> = RefCell::new(HashMap::new());
131-
| ~~~~~~~~
132+
LL | / thread_local! {
133+
LL | | static d: RefCell<HashMap<i32, Vec<Vec<&Tar<i32>>>>> = RefCell::new(HashMap::new());
134+
| | ^ expected named lifetime parameter
135+
LL | |
136+
LL | |
137+
LL | |
138+
LL | |
139+
LL | | }
140+
| |_-
141+
|
142+
= help: this function's return type contains a borrowed value, but the signature does not say which one of `init`'s 4 lifetimes it is borrowed from
132143

133144
error[E0106]: missing lifetime specifiers
134145
--> $DIR/missing-lifetime-specifier.rs:35:49
135146
|
136-
LL | static d: RefCell<HashMap<i32, Vec<Vec<&Tar<i32>>>>> = RefCell::new(HashMap::new());
137-
| ^ expected 2 lifetime parameters
147+
LL | / thread_local! {
148+
LL | | static d: RefCell<HashMap<i32, Vec<Vec<&Tar<i32>>>>> = RefCell::new(HashMap::new());
149+
| | ^ expected 2 lifetime parameters
150+
LL | |
151+
LL | |
152+
LL | |
153+
LL | |
154+
LL | | }
155+
| |_-
156+
|
157+
= help: this function's return type contains a borrowed value, but the signature does not say which one of `init`'s 4 lifetimes it is borrowed from
158+
159+
error[E0107]: this union takes 2 lifetime arguments but 1 lifetime argument was supplied
160+
--> $DIR/missing-lifetime-specifier.rs:43:44
138161
|
139-
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
140-
help: consider using the `'static` lifetime
162+
LL | static e: RefCell<HashMap<i32, Vec<Vec<Qux<'static, i32>>>>> = RefCell::new(HashMap::new());
163+
| ^^^ ------- supplied 1 lifetime argument
164+
| |
165+
| expected 2 lifetime arguments
141166
|
142-
LL | static d: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, 'static, i32>>>>> = RefCell::new(HashMap::new());
143-
| +++++++++++++++++
167+
note: union defined here, with 2 lifetime parameters: `'t`, `'k`
168+
--> $DIR/missing-lifetime-specifier.rs:11:11
169+
|
170+
LL | pub union Qux<'t, 'k, I> {
171+
| ^^^ -- --
172+
help: add missing lifetime argument
173+
|
174+
LL | static e: RefCell<HashMap<i32, Vec<Vec<Qux<'static, '_, i32>>>>> = RefCell::new(HashMap::new());
175+
| ++++
144176

145177
error[E0107]: this union takes 2 lifetime arguments but 1 lifetime argument was supplied
146178
--> $DIR/missing-lifetime-specifier.rs:43:44
@@ -157,7 +189,7 @@ LL | pub union Qux<'t, 'k, I> {
157189
| ^^^ -- --
158190
help: add missing lifetime argument
159191
|
160-
LL | static e: RefCell<HashMap<i32, Vec<Vec<Qux<'static, '_, i32>>>>> = RefCell::new(HashMap::new());
192+
LL | static e: RefCell<HashMap<i32, Vec<Vec<Qux<'static, 'k, i32>>>>> = RefCell::new(HashMap::new());
161193
| ++++
162194

163195
error[E0107]: this union takes 2 lifetime arguments but 1 lifetime argument was supplied
@@ -215,7 +247,7 @@ LL | static e: RefCell<HashMap<i32, Vec<Vec<Qux<'static, '_, i32>>>>> = RefC
215247
| ++++
216248

217249
error[E0107]: this trait takes 2 lifetime arguments but 1 lifetime argument was supplied
218-
--> $DIR/missing-lifetime-specifier.rs:50:45
250+
--> $DIR/missing-lifetime-specifier.rs:51:45
219251
|
220252
LL | static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, i32>>>>> = RefCell::new(HashMap::new());
221253
| ^^^ ------- supplied 1 lifetime argument
@@ -233,7 +265,7 @@ LL | static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, '_, i32>>>>> = Ref
233265
| ++++
234266

235267
error[E0106]: missing lifetime specifier
236-
--> $DIR/missing-lifetime-specifier.rs:50:44
268+
--> $DIR/missing-lifetime-specifier.rs:51:44
237269
|
238270
LL | static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, i32>>>>> = RefCell::new(HashMap::new());
239271
| ^ expected named lifetime parameter
@@ -245,7 +277,7 @@ LL | static f: RefCell<HashMap<i32, Vec<Vec<&'static Tar<'static, i32>>>>> =
245277
| ~~~~~~~~
246278

247279
error[E0107]: this trait takes 2 lifetime arguments but 1 lifetime argument was supplied
248-
--> $DIR/missing-lifetime-specifier.rs:50:45
280+
--> $DIR/missing-lifetime-specifier.rs:51:45
249281
|
250282
LL | static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, i32>>>>> = RefCell::new(HashMap::new());
251283
| ^^^ ------- supplied 1 lifetime argument
@@ -263,19 +295,40 @@ LL | static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, 'k, i32>>>>> = Ref
263295
| ++++
264296

265297
error[E0106]: missing lifetime specifier
266-
--> $DIR/missing-lifetime-specifier.rs:50:44
298+
--> $DIR/missing-lifetime-specifier.rs:51:44
299+
|
300+
LL | / thread_local! {
301+
LL | | static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, i32>>>>> = RefCell::new(HashMap::new());
302+
| | ^ expected named lifetime parameter
303+
LL | |
304+
LL | |
305+
... |
306+
LL | |
307+
LL | | }
308+
| |_-
309+
|
310+
= help: this function's return type contains a borrowed value, but the signature does not say which one of `init`'s 3 lifetimes it is borrowed from
311+
312+
error[E0107]: this trait takes 2 lifetime arguments but 1 lifetime argument was supplied
313+
--> $DIR/missing-lifetime-specifier.rs:51:45
267314
|
268315
LL | static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, i32>>>>> = RefCell::new(HashMap::new());
269-
| ^ expected named lifetime parameter
316+
| ^^^ ------- supplied 1 lifetime argument
317+
| |
318+
| expected 2 lifetime arguments
270319
|
271-
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
272-
help: consider using the `'static` lifetime
320+
note: trait defined here, with 2 lifetime parameters: `'t`, `'k`
321+
--> $DIR/missing-lifetime-specifier.rs:15:7
273322
|
274-
LL | static f: RefCell<HashMap<i32, Vec<Vec<&'static Tar<'static, i32>>>>> = RefCell::new(HashMap::new());
275-
| ~~~~~~~~
323+
LL | trait Tar<'t, 'k, I> {}
324+
| ^^^ -- --
325+
help: add missing lifetime argument
326+
|
327+
LL | static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, 'k, i32>>>>> = RefCell::new(HashMap::new());
328+
| ++++
276329

277330
error[E0107]: this trait takes 2 lifetime arguments but 1 lifetime argument was supplied
278-
--> $DIR/missing-lifetime-specifier.rs:50:45
331+
--> $DIR/missing-lifetime-specifier.rs:51:45
279332
|
280333
LL | static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, i32>>>>> = RefCell::new(HashMap::new());
281334
| ^^^ ------- supplied 1 lifetime argument
@@ -293,7 +346,7 @@ LL | static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, 'k, i32>>>>> = Ref
293346
| ++++
294347

295348
error[E0107]: this trait takes 2 lifetime arguments but 1 lifetime argument was supplied
296-
--> $DIR/missing-lifetime-specifier.rs:50:45
349+
--> $DIR/missing-lifetime-specifier.rs:51:45
297350
|
298351
LL | static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, i32>>>>> = RefCell::new(HashMap::new());
299352
| ^^^ ------- supplied 1 lifetime argument
@@ -310,7 +363,7 @@ help: add missing lifetime argument
310363
LL | static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, '_, i32>>>>> = RefCell::new(HashMap::new());
311364
| ++++
312365

313-
error: aborting due to 22 previous errors
366+
error: aborting due to 24 previous errors
314367

315368
Some errors have detailed explanations: E0106, E0107.
316369
For more information about an error, try `rustc --explain E0106`.

src/test/ui/threads-sendsync/issue-43733.mir.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
2-
--> $DIR/issue-43733.rs:17:5
2+
--> $DIR/issue-43733.rs:19:5
33
|
44
LL | __KEY.get(Default::default)
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
66
|
77
= note: consult the function's documentation for information on how to avoid undefined behavior
88

99
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
10-
--> $DIR/issue-43733.rs:20:42
10+
--> $DIR/issue-43733.rs:22:42
1111
|
1212
LL | static FOO: std::thread::LocalKey<Foo> = std::thread::LocalKey::new(__getit);
1313
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function

src/test/ui/threads-sendsync/issue-43733.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
#![feature(thread_local)]
55
#![feature(cfg_target_thread_local, thread_local_internals)]
66

7+
use std::cell::RefCell;
8+
79
type Foo = std::cell::RefCell<String>;
810

911
#[cfg(target_thread_local)]
@@ -13,7 +15,7 @@ static __KEY: std::thread::__FastLocalKeyInner<Foo> = std::thread::__FastLocalKe
1315
#[cfg(not(target_thread_local))]
1416
static __KEY: std::thread::__OsLocalKeyInner<Foo> = std::thread::__OsLocalKeyInner::new();
1517

16-
fn __getit() -> std::option::Option<&'static Foo> {
18+
fn __getit(_: Option<&mut Option<RefCell<String>>>) -> std::option::Option<&'static Foo> {
1719
__KEY.get(Default::default) //~ ERROR call to unsafe function is unsafe
1820
}
1921

src/test/ui/threads-sendsync/issue-43733.thir.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
2-
--> $DIR/issue-43733.rs:17:5
2+
--> $DIR/issue-43733.rs:19:5
33
|
44
LL | __KEY.get(Default::default)
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
66
|
77
= note: consult the function's documentation for information on how to avoid undefined behavior
88

99
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
10-
--> $DIR/issue-43733.rs:20:42
10+
--> $DIR/issue-43733.rs:22:42
1111
|
1212
LL | static FOO: std::thread::LocalKey<Foo> = std::thread::LocalKey::new(__getit);
1313
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function

0 commit comments

Comments
 (0)