Skip to content

Commit b306762

Browse files
committed
Change suspicious auto trait lint message to has potentially surprising behavior
1 parent 9584f78 commit b306762

11 files changed

+34
-34
lines changed

compiler/rustc_lint_defs/src/builtin.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4061,7 +4061,7 @@ declare_lint! {
40614061
Warn,
40624062
"the rules governing auto traits have recently changed resulting in potential breakage",
40634063
@future_incompatible = FutureIncompatibleInfo {
4064-
reason: FutureIncompatibilityReason::FutureReleaseSemanticsChange,
4064+
reason: FutureIncompatibilityReason::Custom("has potentially surprising behavior"),
40654065
reference: "issue #93367 <https://github.com/rust-lang/rust/issues/93367>",
40664066
};
40674067
}

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

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ unsafe impl<T: Send> Send for MayImplementSendOk<T> {} // ok
88
struct MayImplementSendErr<T>(T);
99
unsafe impl<T: Send> Send for MayImplementSendErr<&T> {}
1010
//~^ ERROR
11-
//~| WARNING this will change its meaning
11+
//~| WARNING has potentially surprising behavior
1212

1313
struct ContainsNonSendDirect<T>(*const T);
1414
unsafe impl<T: Send> Send for ContainsNonSendDirect<&T> {} // ok
@@ -20,7 +20,7 @@ unsafe impl<T: Send> Send for ContainsIndirectNonSend<&T> {} // ok
2020
struct ContainsVec<T>(Vec<T>);
2121
unsafe impl Send for ContainsVec<i32> {}
2222
//~^ ERROR
23-
//~| WARNING this will change its meaning
23+
//~| WARNING has potentially surprising behavior
2424

2525
struct TwoParams<T, U>(T, U);
2626
unsafe impl<T: Send, U: Send> Send for TwoParams<T, U> {} // ok
@@ -31,20 +31,20 @@ unsafe impl<T: Send, U: Send> Send for TwoParamsFlipped<U, T> {} // ok
3131
struct TwoParamsSame<T, U>(T, U);
3232
unsafe impl<T: Send> Send for TwoParamsSame<T, T> {}
3333
//~^ ERROR
34-
//~| WARNING this will change its meaning
34+
//~| WARNING has potentially surprising behavior
3535

3636
pub struct WithPhantomDataNonSend<T, U>(PhantomData<*const T>, U);
3737
unsafe impl<T> Send for WithPhantomDataNonSend<T, i8> {} // ok
3838

3939
pub struct WithPhantomDataSend<T, U>(PhantomData<T>, U);
4040
unsafe impl<T> Send for WithPhantomDataSend<*const T, i8> {}
4141
//~^ ERROR
42-
//~| WARNING this will change its meaning
42+
//~| WARNING has potentially surprising behavior
4343

4444
pub struct WithLifetime<'a, T>(&'a (), T);
4545
unsafe impl<T> Send for WithLifetime<'static, T> {} // ok
4646
unsafe impl<T> Sync for WithLifetime<'static, Vec<T>> {}
4747
//~^ ERROR
48-
//~| WARNING this will change its meaning
48+
//~| WARNING has potentially surprising behavior
4949

5050
fn main() {}

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

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error: cross-crate traits with a default impl, like `Send`, should not be specia
44
LL | unsafe impl<T: Send> Send for MayImplementSendErr<&T> {}
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
7-
= warning: this will change its meaning in a future release!
7+
= warning: has potentially surprising behavior
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
@@ -24,7 +24,7 @@ error: cross-crate traits with a default impl, like `Send`, should not be specia
2424
LL | unsafe impl Send for ContainsVec<i32> {}
2525
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2626
|
27-
= warning: this will change its meaning in a future release!
27+
= warning: has potentially surprising behavior
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
@@ -39,7 +39,7 @@ error: cross-crate traits with a default impl, like `Send`, should not be specia
3939
LL | unsafe impl<T: Send> Send for TwoParamsSame<T, T> {}
4040
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4141
|
42-
= warning: this will change its meaning in a future release!
42+
= warning: has potentially surprising behavior
4343
= note: for more information, see issue #93367 <https://github.com/rust-lang/rust/issues/93367>
4444
= note: `T` is mentioned multiple times
4545
note: try using the same sequence of generic parameters as the struct definition
@@ -54,7 +54,7 @@ error: cross-crate traits with a default impl, like `Send`, should not be specia
5454
LL | unsafe impl<T> Send for WithPhantomDataSend<*const T, i8> {}
5555
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5656
|
57-
= warning: this will change its meaning in a future release!
57+
= warning: has potentially surprising behavior
5858
= note: for more information, see issue #93367 <https://github.com/rust-lang/rust/issues/93367>
5959
= note: `*const T` is not a generic parameter
6060
note: try using the same sequence of generic parameters as the struct definition
@@ -69,7 +69,7 @@ error: cross-crate traits with a default impl, like `Sync`, should not be specia
6969
LL | unsafe impl<T> Sync for WithLifetime<'static, Vec<T>> {}
7070
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
7171
|
72-
= warning: this will change its meaning in a future release!
72+
= warning: has potentially surprising behavior
7373
= note: for more information, see issue #93367 <https://github.com/rust-lang/rust/issues/93367>
7474
= note: `Vec<T>` is not a generic parameter
7575
note: try using the same sequence of generic parameters as the struct definition

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ use std::marker::PhantomData;
66
struct ContainsVec<T>(Vec<T>);
77
impl !Send for ContainsVec<u32> {}
88
//~^ ERROR
9-
//~| WARNING this will change its meaning
9+
//~| WARNING has potentially surprising behavior
1010

1111
pub struct WithPhantomDataSend<T, U>(PhantomData<T>, U);
1212
impl<T> !Send for WithPhantomDataSend<*const T, u8> {}
1313
//~^ ERROR
14-
//~| WARNING this will change its meaning
14+
//~| WARNING has potentially surprising behavior
1515

1616
pub struct WithLifetime<'a, T>(&'a (), T);
1717
impl<T> !Sync for WithLifetime<'static, Option<T>> {}
1818
//~^ ERROR
19-
//~| WARNING this will change its meaning
19+
//~| WARNING has potentially surprising behavior
2020

2121
fn main() {}

tests/ui/auto-traits/suspicious-negative-impls-lint.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error: cross-crate traits with a default impl, like `Send`, should not be specia
44
LL | impl !Send for ContainsVec<u32> {}
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
7-
= warning: this will change its meaning in a future release!
7+
= warning: has potentially surprising behavior
88
= note: for more information, see issue #93367 <https://github.com/rust-lang/rust/issues/93367>
99
= note: `u32` is not a generic parameter
1010
note: try using the same sequence of generic parameters as the struct definition
@@ -24,7 +24,7 @@ error: cross-crate traits with a default impl, like `Send`, should not be specia
2424
LL | impl<T> !Send for WithPhantomDataSend<*const T, u8> {}
2525
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2626
|
27-
= warning: this will change its meaning in a future release!
27+
= warning: has potentially surprising behavior
2828
= note: for more information, see issue #93367 <https://github.com/rust-lang/rust/issues/93367>
2929
= note: `*const T` is not a generic parameter
3030
note: try using the same sequence of generic parameters as the struct definition
@@ -39,7 +39,7 @@ error: cross-crate traits with a default impl, like `Sync`, should not be specia
3939
LL | impl<T> !Sync for WithLifetime<'static, Option<T>> {}
4040
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4141
|
42-
= warning: this will change its meaning in a future release!
42+
= warning: has potentially surprising behavior
4343
= note: for more information, see issue #93367 <https://github.com/rust-lang/rust/issues/93367>
4444
= note: `Option<T>` is not a generic parameter
4545
note: try using the same sequence of generic parameters as the struct definition

tests/ui/coherence/coherence-conflicting-negative-trait-impl.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ unsafe impl<T: 'static> Send for TestType<T> {} //~ ERROR conflicting implementa
1414

1515
impl !Send for TestType<i32> {}
1616
//~^ WARNING
17-
//~| WARNING this will change its meaning
17+
//~| WARNING has potentially surprising behavior
1818

1919
fn main() {}

tests/ui/coherence/coherence-conflicting-negative-trait-impl.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ warning: cross-crate traits with a default impl, like `Send`, should not be spec
2222
LL | impl !Send for TestType<i32> {}
2323
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2424
|
25-
= warning: this will change its meaning in a future release!
25+
= warning: has potentially surprising behavior
2626
= note: for more information, see issue #93367 <https://github.com/rust-lang/rust/issues/93367>
2727
= note: `i32` is not a generic parameter
2828
note: try using the same sequence of generic parameters as the struct definition

tests/ui/coherence/coherence-orphan.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@ use lib::TheTrait;
77

88
struct TheType;
99

10-
impl TheTrait<usize> for isize { }
10+
impl TheTrait<usize> for isize {}
1111
//~^ ERROR E0117
1212
//~| ERROR not all trait items implemented
1313

14-
impl TheTrait<TheType> for isize { }
14+
impl TheTrait<TheType> for isize {}
1515
//~^ ERROR not all trait items implemented
1616

17-
impl TheTrait<isize> for TheType { }
17+
impl TheTrait<isize> for TheType {}
1818
//~^ ERROR not all trait items implemented
1919

20-
impl !Send for Vec<isize> { } //~ ERROR E0117
20+
impl !Send for Vec<isize> {} //~ ERROR E0117
2121
//~^ WARNING
22-
//~| WARNING this will change its meaning
22+
//~| WARNING has potentially surprising behavior
2323

24-
fn main() { }
24+
fn main() {}

tests/ui/coherence/coherence-orphan.stderr

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
error[E0117]: only traits defined in the current crate can be implemented for primitive types
22
--> $DIR/coherence-orphan.rs:10:1
33
|
4-
LL | impl TheTrait<usize> for isize { }
4+
LL | impl TheTrait<usize> for isize {}
55
| ^^^^^---------------^^^^^-----
66
| | | |
77
| | | `isize` is not defined in the current crate
@@ -13,7 +13,7 @@ LL | impl TheTrait<usize> for isize { }
1313
error[E0117]: only traits defined in the current crate can be implemented for types defined outside of the crate
1414
--> $DIR/coherence-orphan.rs:20:1
1515
|
16-
LL | impl !Send for Vec<isize> { }
16+
LL | impl !Send for Vec<isize> {}
1717
| ^^^^^^^^^^^^^^^----------
1818
| | |
1919
| | `Vec` is not defined in the current crate
@@ -24,10 +24,10 @@ LL | impl !Send for Vec<isize> { }
2424
warning: cross-crate traits with a default impl, like `Send`, should not be specialized
2525
--> $DIR/coherence-orphan.rs:20:1
2626
|
27-
LL | impl !Send for Vec<isize> { }
27+
LL | impl !Send for Vec<isize> {}
2828
| ^^^^^^^^^^^^^^^^^^^^^^^^^
2929
|
30-
= warning: this will change its meaning in a future release!
30+
= warning: has potentially surprising behavior
3131
= note: for more information, see issue #93367 <https://github.com/rust-lang/rust/issues/93367>
3232
= note: `isize` is not a generic parameter
3333
note: try using the same sequence of generic parameters as the struct definition
@@ -37,23 +37,23 @@ note: try using the same sequence of generic parameters as the struct definition
3737
error[E0046]: not all trait items implemented, missing: `the_fn`
3838
--> $DIR/coherence-orphan.rs:10:1
3939
|
40-
LL | impl TheTrait<usize> for isize { }
40+
LL | impl TheTrait<usize> for isize {}
4141
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `the_fn` in implementation
4242
|
4343
= help: implement the missing item: `fn the_fn(&self) { todo!() }`
4444

4545
error[E0046]: not all trait items implemented, missing: `the_fn`
4646
--> $DIR/coherence-orphan.rs:14:1
4747
|
48-
LL | impl TheTrait<TheType> for isize { }
48+
LL | impl TheTrait<TheType> for isize {}
4949
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `the_fn` in implementation
5050
|
5151
= help: implement the missing item: `fn the_fn(&self) { todo!() }`
5252

5353
error[E0046]: not all trait items implemented, missing: `the_fn`
5454
--> $DIR/coherence-orphan.rs:17:1
5555
|
56-
LL | impl TheTrait<isize> for TheType { }
56+
LL | impl TheTrait<isize> for TheType {}
5757
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `the_fn` in implementation
5858
|
5959
= help: implement the missing item: `fn the_fn(&self) { todo!() }`

tests/ui/issues/issue-106755.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ unsafe impl<T: 'static> Send for TestType<T> {} //~ ERROR conflicting implementa
1616

1717
impl !Send for TestType<i32> {}
1818
//~^ WARNING
19-
//~| WARNING this will change its meaning
19+
//~| WARNING has potentially surprising behavior
2020

2121
fn main() {}

tests/ui/issues/issue-106755.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ warning: cross-crate traits with a default impl, like `Send`, should not be spec
2222
LL | impl !Send for TestType<i32> {}
2323
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2424
|
25-
= warning: this will change its meaning in a future release!
25+
= warning: has potentially surprising behavior
2626
= note: for more information, see issue #93367 <https://github.com/rust-lang/rust/issues/93367>
2727
= note: `i32` is not a generic parameter
2828
note: try using the same sequence of generic parameters as the struct definition

0 commit comments

Comments
 (0)