Skip to content

Commit

Permalink
Change suspicious auto trait lint message to has potentially surprisi…
Browse files Browse the repository at this point in the history
…ng behavior
  • Loading branch information
spastorino committed Feb 8, 2024
1 parent 9584f78 commit b306762
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 34 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_lint_defs/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4061,7 +4061,7 @@ declare_lint! {
Warn,
"the rules governing auto traits have recently changed resulting in potential breakage",
@future_incompatible = FutureIncompatibleInfo {
reason: FutureIncompatibilityReason::FutureReleaseSemanticsChange,
reason: FutureIncompatibilityReason::Custom("has potentially surprising behavior"),
reference: "issue #93367 <https://github.com/rust-lang/rust/issues/93367>",
};
}
Expand Down
10 changes: 5 additions & 5 deletions tests/ui/auto-traits/suspicious-impls-lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ unsafe impl<T: Send> Send for MayImplementSendOk<T> {} // ok
struct MayImplementSendErr<T>(T);
unsafe impl<T: Send> Send for MayImplementSendErr<&T> {}
//~^ ERROR
//~| WARNING this will change its meaning
//~| WARNING has potentially surprising behavior

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

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

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

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

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

fn main() {}
10 changes: 5 additions & 5 deletions tests/ui/auto-traits/suspicious-impls-lint.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ error: cross-crate traits with a default impl, like `Send`, should not be specia
LL | unsafe impl<T: Send> Send for MayImplementSendErr<&T> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= warning: this will change its meaning in a future release!
= warning: has potentially surprising behavior
= note: for more information, see issue #93367 <https://github.com/rust-lang/rust/issues/93367>
= note: `&T` is not a generic parameter
note: try using the same sequence of generic parameters as the struct definition
Expand All @@ -24,7 +24,7 @@ error: cross-crate traits with a default impl, like `Send`, should not be specia
LL | unsafe impl Send for ContainsVec<i32> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= warning: this will change its meaning in a future release!
= warning: has potentially surprising behavior
= note: for more information, see issue #93367 <https://github.com/rust-lang/rust/issues/93367>
= note: `i32` is not a generic parameter
note: try using the same sequence of generic parameters as the struct definition
Expand All @@ -39,7 +39,7 @@ error: cross-crate traits with a default impl, like `Send`, should not be specia
LL | unsafe impl<T: Send> Send for TwoParamsSame<T, T> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= warning: this will change its meaning in a future release!
= warning: has potentially surprising behavior
= note: for more information, see issue #93367 <https://github.com/rust-lang/rust/issues/93367>
= note: `T` is mentioned multiple times
note: try using the same sequence of generic parameters as the struct definition
Expand All @@ -54,7 +54,7 @@ error: cross-crate traits with a default impl, like `Send`, should not be specia
LL | unsafe impl<T> Send for WithPhantomDataSend<*const T, i8> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= warning: this will change its meaning in a future release!
= warning: has potentially surprising behavior
= note: for more information, see issue #93367 <https://github.com/rust-lang/rust/issues/93367>
= note: `*const T` is not a generic parameter
note: try using the same sequence of generic parameters as the struct definition
Expand All @@ -69,7 +69,7 @@ error: cross-crate traits with a default impl, like `Sync`, should not be specia
LL | unsafe impl<T> Sync for WithLifetime<'static, Vec<T>> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= warning: this will change its meaning in a future release!
= warning: has potentially surprising behavior
= note: for more information, see issue #93367 <https://github.com/rust-lang/rust/issues/93367>
= note: `Vec<T>` is not a generic parameter
note: try using the same sequence of generic parameters as the struct definition
Expand Down
6 changes: 3 additions & 3 deletions tests/ui/auto-traits/suspicious-negative-impls-lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ use std::marker::PhantomData;
struct ContainsVec<T>(Vec<T>);
impl !Send for ContainsVec<u32> {}
//~^ ERROR
//~| WARNING this will change its meaning
//~| WARNING has potentially surprising behavior

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

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

fn main() {}
6 changes: 3 additions & 3 deletions tests/ui/auto-traits/suspicious-negative-impls-lint.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ error: cross-crate traits with a default impl, like `Send`, should not be specia
LL | impl !Send for ContainsVec<u32> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= warning: this will change its meaning in a future release!
= warning: has potentially surprising behavior
= note: for more information, see issue #93367 <https://github.com/rust-lang/rust/issues/93367>
= note: `u32` is not a generic parameter
note: try using the same sequence of generic parameters as the struct definition
Expand All @@ -24,7 +24,7 @@ error: cross-crate traits with a default impl, like `Send`, should not be specia
LL | impl<T> !Send for WithPhantomDataSend<*const T, u8> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= warning: this will change its meaning in a future release!
= warning: has potentially surprising behavior
= note: for more information, see issue #93367 <https://github.com/rust-lang/rust/issues/93367>
= note: `*const T` is not a generic parameter
note: try using the same sequence of generic parameters as the struct definition
Expand All @@ -39,7 +39,7 @@ error: cross-crate traits with a default impl, like `Sync`, should not be specia
LL | impl<T> !Sync for WithLifetime<'static, Option<T>> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= warning: this will change its meaning in a future release!
= warning: has potentially surprising behavior
= note: for more information, see issue #93367 <https://github.com/rust-lang/rust/issues/93367>
= note: `Option<T>` is not a generic parameter
note: try using the same sequence of generic parameters as the struct definition
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ unsafe impl<T: 'static> Send for TestType<T> {} //~ ERROR conflicting implementa

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

fn main() {}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ warning: cross-crate traits with a default impl, like `Send`, should not be spec
LL | impl !Send for TestType<i32> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= warning: this will change its meaning in a future release!
= warning: has potentially surprising behavior
= note: for more information, see issue #93367 <https://github.com/rust-lang/rust/issues/93367>
= note: `i32` is not a generic parameter
note: try using the same sequence of generic parameters as the struct definition
Expand Down
12 changes: 6 additions & 6 deletions tests/ui/coherence/coherence-orphan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ use lib::TheTrait;

struct TheType;

impl TheTrait<usize> for isize { }
impl TheTrait<usize> for isize {}
//~^ ERROR E0117
//~| ERROR not all trait items implemented

impl TheTrait<TheType> for isize { }
impl TheTrait<TheType> for isize {}
//~^ ERROR not all trait items implemented

impl TheTrait<isize> for TheType { }
impl TheTrait<isize> for TheType {}
//~^ ERROR not all trait items implemented

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

fn main() { }
fn main() {}
14 changes: 7 additions & 7 deletions tests/ui/coherence/coherence-orphan.stderr
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
error[E0117]: only traits defined in the current crate can be implemented for primitive types
--> $DIR/coherence-orphan.rs:10:1
|
LL | impl TheTrait<usize> for isize { }
LL | impl TheTrait<usize> for isize {}
| ^^^^^---------------^^^^^-----
| | | |
| | | `isize` is not defined in the current crate
Expand All @@ -13,7 +13,7 @@ LL | impl TheTrait<usize> for isize { }
error[E0117]: only traits defined in the current crate can be implemented for types defined outside of the crate
--> $DIR/coherence-orphan.rs:20:1
|
LL | impl !Send for Vec<isize> { }
LL | impl !Send for Vec<isize> {}
| ^^^^^^^^^^^^^^^----------
| | |
| | `Vec` is not defined in the current crate
Expand All @@ -24,10 +24,10 @@ LL | impl !Send for Vec<isize> { }
warning: cross-crate traits with a default impl, like `Send`, should not be specialized
--> $DIR/coherence-orphan.rs:20:1
|
LL | impl !Send for Vec<isize> { }
LL | impl !Send for Vec<isize> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
= warning: this will change its meaning in a future release!
= warning: has potentially surprising behavior
= note: for more information, see issue #93367 <https://github.com/rust-lang/rust/issues/93367>
= note: `isize` is not a generic parameter
note: try using the same sequence of generic parameters as the struct definition
Expand All @@ -37,23 +37,23 @@ note: try using the same sequence of generic parameters as the struct definition
error[E0046]: not all trait items implemented, missing: `the_fn`
--> $DIR/coherence-orphan.rs:10:1
|
LL | impl TheTrait<usize> for isize { }
LL | impl TheTrait<usize> for isize {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `the_fn` in implementation
|
= help: implement the missing item: `fn the_fn(&self) { todo!() }`

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

error[E0046]: not all trait items implemented, missing: `the_fn`
--> $DIR/coherence-orphan.rs:17:1
|
LL | impl TheTrait<isize> for TheType { }
LL | impl TheTrait<isize> for TheType {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `the_fn` in implementation
|
= help: implement the missing item: `fn the_fn(&self) { todo!() }`
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/issues/issue-106755.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ unsafe impl<T: 'static> Send for TestType<T> {} //~ ERROR conflicting implementa

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

fn main() {}
2 changes: 1 addition & 1 deletion tests/ui/issues/issue-106755.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ warning: cross-crate traits with a default impl, like `Send`, should not be spec
LL | impl !Send for TestType<i32> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= warning: this will change its meaning in a future release!
= warning: has potentially surprising behavior
= note: for more information, see issue #93367 <https://github.com/rust-lang/rust/issues/93367>
= note: `i32` is not a generic parameter
note: try using the same sequence of generic parameters as the struct definition
Expand Down

0 comments on commit b306762

Please sign in to comment.