-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #108821 - matthiaskrgr:rollup-cmkbgpr, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #107801 (const_eval: `implies_by` in `rustc_const_unstable`) - #108750 (Fix `ObligationCtxt::sub`) - #108780 (Add regression tests for issue 70919) - #108786 (Check for free regions in MIR validation) - #108790 (Do not ICE when interpreting a cast between non-monomorphic types) - #108803 (Do not ICE when failing to normalize in ConstProp.) - #108807 (Emit the suspicious_auto_trait_impls for negative impls as well) - #108812 (Add regression test for #98444) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
- Loading branch information
Showing
33 changed files
with
443 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#![feature(negative_impls)] | ||
#![deny(suspicious_auto_trait_impls)] | ||
|
||
use std::marker::PhantomData; | ||
|
||
struct ContainsVec<T>(Vec<T>); | ||
impl !Send for ContainsVec<u32> {} | ||
//~^ ERROR | ||
//~| WARNING this will change its meaning | ||
|
||
pub struct WithPhantomDataSend<T, U>(PhantomData<T>, U); | ||
impl<T> !Send for WithPhantomDataSend<*const T, u8> {} | ||
//~^ ERROR | ||
//~| WARNING this will change its meaning | ||
|
||
pub struct WithLifetime<'a, T>(&'a (), T); | ||
impl<T> !Sync for WithLifetime<'static, Option<T>> {} | ||
//~^ ERROR | ||
//~| WARNING this will change its meaning | ||
|
||
fn main() {} |
52 changes: 52 additions & 0 deletions
52
tests/ui/auto-traits/suspicious-negative-impls-lint.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
error: cross-crate traits with a default impl, like `Send`, should not be specialized | ||
--> $DIR/suspicious-negative-impls-lint.rs:7:1 | ||
| | ||
LL | impl !Send for ContainsVec<u32> {} | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= warning: this will change its meaning in a future release! | ||
= 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 | ||
--> $DIR/suspicious-negative-impls-lint.rs:6:1 | ||
| | ||
LL | struct ContainsVec<T>(Vec<T>); | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
note: the lint level is defined here | ||
--> $DIR/suspicious-negative-impls-lint.rs:2:9 | ||
| | ||
LL | #![deny(suspicious_auto_trait_impls)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: cross-crate traits with a default impl, like `Send`, should not be specialized | ||
--> $DIR/suspicious-negative-impls-lint.rs:12:1 | ||
| | ||
LL | impl<T> !Send for WithPhantomDataSend<*const T, u8> {} | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= warning: this will change its meaning in a future release! | ||
= 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 | ||
--> $DIR/suspicious-negative-impls-lint.rs:11:1 | ||
| | ||
LL | pub struct WithPhantomDataSend<T, U>(PhantomData<T>, U); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: cross-crate traits with a default impl, like `Sync`, should not be specialized | ||
--> $DIR/suspicious-negative-impls-lint.rs:17:1 | ||
| | ||
LL | impl<T> !Sync for WithLifetime<'static, Option<T>> {} | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= warning: this will change its meaning in a future release! | ||
= 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 | ||
--> $DIR/suspicious-negative-impls-lint.rs:16:1 | ||
| | ||
LL | pub struct WithLifetime<'a, T>(&'a (), T); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 3 previous errors | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// A version of `issue-70919-drop-in-loop`, but without | ||
// the necessary `drop` call. | ||
// | ||
// This should fail to compile, since the `Drop` impl | ||
// for `WrapperWithDrop` could observe the changed | ||
// `base` value. | ||
|
||
struct WrapperWithDrop<'a>(&'a mut bool); | ||
impl<'a> Drop for WrapperWithDrop<'a> { | ||
fn drop(&mut self) { | ||
} | ||
} | ||
|
||
fn drop_in_loop() { | ||
let mut base = true; | ||
let mut wrapper = WrapperWithDrop(&mut base); | ||
loop { | ||
base = false; //~ ERROR: cannot assign to `base` | ||
wrapper = WrapperWithDrop(&mut base); | ||
} | ||
} | ||
|
||
fn main() { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
error[E0506]: cannot assign to `base` because it is borrowed | ||
--> $DIR/drop-in-loop.rs:18:9 | ||
| | ||
LL | let mut wrapper = WrapperWithDrop(&mut base); | ||
| --------- `base` is borrowed here | ||
LL | loop { | ||
LL | base = false; | ||
| ^^^^^^^^^^^^ `base` is assigned to here but it was already borrowed | ||
LL | wrapper = WrapperWithDrop(&mut base); | ||
| ------- borrow might be used here, when `wrapper` is dropped and runs the `Drop` code for type `WrapperWithDrop` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0506`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Regression test for issue #70919 | ||
// Tests that we don't emit a spurious "borrow might be used" error | ||
// when we have an explicit `drop` in a loop | ||
|
||
// check-pass | ||
|
||
struct WrapperWithDrop<'a>(&'a mut bool); | ||
impl<'a> Drop for WrapperWithDrop<'a> { | ||
fn drop(&mut self) { | ||
} | ||
} | ||
|
||
fn drop_in_loop() { | ||
let mut base = true; | ||
let mut wrapper = WrapperWithDrop(&mut base); | ||
loop { | ||
drop(wrapper); | ||
|
||
base = false; | ||
wrapper = WrapperWithDrop(&mut base); | ||
} | ||
} | ||
|
||
fn main() { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.