Skip to content

Commit 5c0f55d

Browse files
committed
Moves the negative impls into a separate test file
1 parent 2fe288f commit 5c0f55d

File tree

4 files changed

+115
-67
lines changed

4 files changed

+115
-67
lines changed

tests/ui/auto-traits/suspicious-impls-lint.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![feature(negative_impls)]
21
#![deny(suspicious_auto_trait_impls)]
32

43
use std::marker::PhantomData;
@@ -22,9 +21,6 @@ struct ContainsVec<T>(Vec<T>);
2221
unsafe impl Send for ContainsVec<i32> {}
2322
//~^ ERROR
2423
//~| WARNING this will change its meaning
25-
impl !Send for ContainsVec<u32> {}
26-
//~^ ERROR
27-
//~| WARNING this will change its meaning
2824

2925
struct TwoParams<T, U>(T, U);
3026
unsafe impl<T: Send, U: Send> Send for TwoParams<T, U> {} // ok
@@ -44,17 +40,11 @@ pub struct WithPhantomDataSend<T, U>(PhantomData<T>, U);
4440
unsafe impl<T> Send for WithPhantomDataSend<*const T, i8> {}
4541
//~^ ERROR
4642
//~| WARNING this will change its meaning
47-
impl<T> !Send for WithPhantomDataSend<*const T, u8> {}
48-
//~^ ERROR
49-
//~| WARNING this will change its meaning
5043

5144
pub struct WithLifetime<'a, T>(&'a (), T);
5245
unsafe impl<T> Send for WithLifetime<'static, T> {} // ok
5346
unsafe impl<T> Sync for WithLifetime<'static, Vec<T>> {}
5447
//~^ ERROR
5548
//~| WARNING this will change its meaning
56-
impl<T> !Sync for WithLifetime<'static, Option<T>> {}
57-
//~^ ERROR
58-
//~| WARNING this will change its meaning
5949

6050
fn main() {}
Lines changed: 12 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: cross-crate traits with a default impl, like `Send`, should not be specialized
2-
--> $DIR/suspicious-impls-lint.rs:10:1
2+
--> $DIR/suspicious-impls-lint.rs:9:1
33
|
44
LL | unsafe impl<T: Send> Send for MayImplementSendErr<&T> {}
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -8,18 +8,18 @@ LL | unsafe impl<T: Send> Send for MayImplementSendErr<&T> {}
88
= note: for more information, see issue #93367 <https://github.com/rust-lang/rust/issues/93367>
99
= note: `&T` is not a generic parameter
1010
note: try using the same sequence of generic parameters as the struct definition
11-
--> $DIR/suspicious-impls-lint.rs:9:1
11+
--> $DIR/suspicious-impls-lint.rs:8:1
1212
|
1313
LL | struct MayImplementSendErr<T>(T);
1414
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1515
note: the lint level is defined here
16-
--> $DIR/suspicious-impls-lint.rs:2:9
16+
--> $DIR/suspicious-impls-lint.rs:1:9
1717
|
1818
LL | #![deny(suspicious_auto_trait_impls)]
1919
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
2020

2121
error: cross-crate traits with a default impl, like `Send`, should not be specialized
22-
--> $DIR/suspicious-impls-lint.rs:22:1
22+
--> $DIR/suspicious-impls-lint.rs:21:1
2323
|
2424
LL | unsafe impl Send for ContainsVec<i32> {}
2525
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -28,28 +28,13 @@ LL | unsafe impl Send for ContainsVec<i32> {}
2828
= note: for more information, see issue #93367 <https://github.com/rust-lang/rust/issues/93367>
2929
= note: `i32` is not a generic parameter
3030
note: try using the same sequence of generic parameters as the struct definition
31-
--> $DIR/suspicious-impls-lint.rs:21:1
31+
--> $DIR/suspicious-impls-lint.rs:20:1
3232
|
3333
LL | struct ContainsVec<T>(Vec<T>);
3434
| ^^^^^^^^^^^^^^^^^^^^^
3535

3636
error: cross-crate traits with a default impl, like `Send`, should not be specialized
37-
--> $DIR/suspicious-impls-lint.rs:25:1
38-
|
39-
LL | impl !Send for ContainsVec<u32> {}
40-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
41-
|
42-
= warning: this will change its meaning in a future release!
43-
= note: for more information, see issue #93367 <https://github.com/rust-lang/rust/issues/93367>
44-
= note: `u32` is not a generic parameter
45-
note: try using the same sequence of generic parameters as the struct definition
46-
--> $DIR/suspicious-impls-lint.rs:21:1
47-
|
48-
LL | struct ContainsVec<T>(Vec<T>);
49-
| ^^^^^^^^^^^^^^^^^^^^^
50-
51-
error: cross-crate traits with a default impl, like `Send`, should not be specialized
52-
--> $DIR/suspicious-impls-lint.rs:36:1
37+
--> $DIR/suspicious-impls-lint.rs:32:1
5338
|
5439
LL | unsafe impl<T: Send> Send for TwoParamsSame<T, T> {}
5540
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -58,13 +43,13 @@ LL | unsafe impl<T: Send> Send for TwoParamsSame<T, T> {}
5843
= note: for more information, see issue #93367 <https://github.com/rust-lang/rust/issues/93367>
5944
= note: `T` is mentioned multiple times
6045
note: try using the same sequence of generic parameters as the struct definition
61-
--> $DIR/suspicious-impls-lint.rs:35:1
46+
--> $DIR/suspicious-impls-lint.rs:31:1
6247
|
6348
LL | struct TwoParamsSame<T, U>(T, U);
6449
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
6550

6651
error: cross-crate traits with a default impl, like `Send`, should not be specialized
67-
--> $DIR/suspicious-impls-lint.rs:44:1
52+
--> $DIR/suspicious-impls-lint.rs:40:1
6853
|
6954
LL | unsafe impl<T> Send for WithPhantomDataSend<*const T, i8> {}
7055
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -73,28 +58,13 @@ LL | unsafe impl<T> Send for WithPhantomDataSend<*const T, i8> {}
7358
= note: for more information, see issue #93367 <https://github.com/rust-lang/rust/issues/93367>
7459
= note: `*const T` is not a generic parameter
7560
note: try using the same sequence of generic parameters as the struct definition
76-
--> $DIR/suspicious-impls-lint.rs:43:1
77-
|
78-
LL | pub struct WithPhantomDataSend<T, U>(PhantomData<T>, U);
79-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
80-
81-
error: cross-crate traits with a default impl, like `Send`, should not be specialized
82-
--> $DIR/suspicious-impls-lint.rs:47:1
83-
|
84-
LL | impl<T> !Send for WithPhantomDataSend<*const T, u8> {}
85-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
86-
|
87-
= warning: this will change its meaning in a future release!
88-
= note: for more information, see issue #93367 <https://github.com/rust-lang/rust/issues/93367>
89-
= note: `*const T` is not a generic parameter
90-
note: try using the same sequence of generic parameters as the struct definition
91-
--> $DIR/suspicious-impls-lint.rs:43:1
61+
--> $DIR/suspicious-impls-lint.rs:39:1
9262
|
9363
LL | pub struct WithPhantomDataSend<T, U>(PhantomData<T>, U);
9464
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
9565

9666
error: cross-crate traits with a default impl, like `Sync`, should not be specialized
97-
--> $DIR/suspicious-impls-lint.rs:53:1
67+
--> $DIR/suspicious-impls-lint.rs:46:1
9868
|
9969
LL | unsafe impl<T> Sync for WithLifetime<'static, Vec<T>> {}
10070
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -103,25 +73,10 @@ LL | unsafe impl<T> Sync for WithLifetime<'static, Vec<T>> {}
10373
= note: for more information, see issue #93367 <https://github.com/rust-lang/rust/issues/93367>
10474
= note: `Vec<T>` is not a generic parameter
10575
note: try using the same sequence of generic parameters as the struct definition
106-
--> $DIR/suspicious-impls-lint.rs:51:1
107-
|
108-
LL | pub struct WithLifetime<'a, T>(&'a (), T);
109-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
110-
111-
error: cross-crate traits with a default impl, like `Sync`, should not be specialized
112-
--> $DIR/suspicious-impls-lint.rs:56:1
113-
|
114-
LL | impl<T> !Sync for WithLifetime<'static, Option<T>> {}
115-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
116-
|
117-
= warning: this will change its meaning in a future release!
118-
= note: for more information, see issue #93367 <https://github.com/rust-lang/rust/issues/93367>
119-
= note: `Option<T>` is not a generic parameter
120-
note: try using the same sequence of generic parameters as the struct definition
121-
--> $DIR/suspicious-impls-lint.rs:51:1
76+
--> $DIR/suspicious-impls-lint.rs:44:1
12277
|
12378
LL | pub struct WithLifetime<'a, T>(&'a (), T);
12479
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12580

126-
error: aborting due to 8 previous errors
81+
error: aborting due to 5 previous errors
12782

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#![feature(negative_impls)]
2+
#![deny(suspicious_auto_trait_impls)]
3+
4+
use std::marker::PhantomData;
5+
6+
struct ContainsVec<T>(Vec<T>);
7+
impl !Send for ContainsVec<u32> {}
8+
//~^ ERROR
9+
//~| WARNING this will change its meaning
10+
11+
pub struct WithPhantomDataSend<T, U>(PhantomData<T>, U);
12+
impl<T> !Send for WithPhantomDataSend<*const T, u8> {}
13+
//~^ ERROR
14+
//~| WARNING this will change its meaning
15+
16+
pub struct WithLifetime<'a, T>(&'a (), T);
17+
impl<T> !Sync for WithLifetime<'static, Option<T>> {}
18+
//~^ ERROR
19+
//~| WARNING this will change its meaning
20+
21+
fn main() {}
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
error: cross-crate traits with a default impl, like `Send`, should not be specialized
2+
--> $DIR/suspicious-negative-impls-lint.rs:7:1
3+
|
4+
LL | impl !Send for ContainsVec<u32> {}
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= warning: this will change its meaning in a future release!
8+
= note: for more information, see issue #93367 <https://github.com/rust-lang/rust/issues/93367>
9+
= note: `u32` is not a generic parameter
10+
note: try using the same sequence of generic parameters as the struct definition
11+
--> $DIR/suspicious-negative-impls-lint.rs:6:1
12+
|
13+
LL | struct ContainsVec<T>(Vec<T>);
14+
| ^^^^^^^^^^^^^^^^^^^^^
15+
note: the lint level is defined here
16+
--> $DIR/suspicious-negative-impls-lint.rs:2:9
17+
|
18+
LL | #![deny(suspicious_auto_trait_impls)]
19+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
20+
21+
error: cross-crate traits with a default impl, like `Send`, should not be specialized
22+
--> $DIR/suspicious-negative-impls-lint.rs:12:1
23+
|
24+
LL | unsafe impl<T> Send for WithPhantomDataSend<*const T, i8> {}
25+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
26+
|
27+
= warning: this will change its meaning in a future release!
28+
= note: for more information, see issue #93367 <https://github.com/rust-lang/rust/issues/93367>
29+
= note: `*const T` is not a generic parameter
30+
note: try using the same sequence of generic parameters as the struct definition
31+
--> $DIR/suspicious-negative-impls-lint.rs:11:1
32+
|
33+
LL | pub struct WithPhantomDataSend<T, U>(PhantomData<T>, U);
34+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
35+
36+
error: cross-crate traits with a default impl, like `Send`, should not be specialized
37+
--> $DIR/suspicious-negative-impls-lint.rs:15:1
38+
|
39+
LL | impl<T> !Send for WithPhantomDataSend<*const T, u8> {}
40+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
41+
|
42+
= warning: this will change its meaning in a future release!
43+
= note: for more information, see issue #93367 <https://github.com/rust-lang/rust/issues/93367>
44+
= note: `*const T` is not a generic parameter
45+
note: try using the same sequence of generic parameters as the struct definition
46+
--> $DIR/suspicious-negative-impls-lint.rs:11:1
47+
|
48+
LL | pub struct WithPhantomDataSend<T, U>(PhantomData<T>, U);
49+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
50+
51+
error: cross-crate traits with a default impl, like `Sync`, should not be specialized
52+
--> $DIR/suspicious-negative-impls-lint.rs:21:1
53+
|
54+
LL | unsafe impl<T> Sync for WithLifetime<'static, Vec<T>> {}
55+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
56+
|
57+
= warning: this will change its meaning in a future release!
58+
= note: for more information, see issue #93367 <https://github.com/rust-lang/rust/issues/93367>
59+
= note: `Vec<T>` is not a generic parameter
60+
note: try using the same sequence of generic parameters as the struct definition
61+
--> $DIR/suspicious-negative-impls-lint.rs:19:1
62+
|
63+
LL | pub struct WithLifetime<'a, T>(&'a (), T);
64+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
65+
66+
error: cross-crate traits with a default impl, like `Sync`, should not be specialized
67+
--> $DIR/suspicious-negative-impls-lint.rs:24:1
68+
|
69+
LL | impl<T> !Sync for WithLifetime<'static, Option<T>> {}
70+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
71+
|
72+
= warning: this will change its meaning in a future release!
73+
= note: for more information, see issue #93367 <https://github.com/rust-lang/rust/issues/93367>
74+
= note: `Option<T>` is not a generic parameter
75+
note: try using the same sequence of generic parameters as the struct definition
76+
--> $DIR/suspicious-negative-impls-lint.rs:19:1
77+
|
78+
LL | pub struct WithLifetime<'a, T>(&'a (), T);
79+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
80+
81+
error: aborting due to 5 previous errors
82+

0 commit comments

Comments
 (0)