-
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 #129199 - RalfJung:writes_through_immutable_pointer, r=…
…<try> make writes_through_immutable_pointer a hard error This turns the lint added in #118324 into a hard error. This has been reported in cargo's future-compat reports since Rust 1.76 (released in February). Given that const_mut_refs is still unstable, it should be impossible to even hit this error on stable: we did accidentally stabilize some functions that can cause this error, but that got reverted in #117905. Still, let's do a crater run just to be sure. Given that this should only affect unstable code, I don't think it needs an FCP, but let's Cc `@rust-lang/lang` anyway -- any objection to making this unambiguous UB into a hard error during const-eval? This can be viewed as part of #129195 which is already nominated for discussion.
- Loading branch information
Showing
7 changed files
with
23 additions
and
102 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
54 changes: 7 additions & 47 deletions
54
tests/ui/consts/const-eval/ub-write-through-immutable.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 |
---|---|---|
@@ -1,55 +1,15 @@ | ||
error: writing through a pointer that was derived from a shared (immutable) reference | ||
--> $DIR/ub-write-through-immutable.rs:12:5 | ||
error[E0080]: evaluation of constant value failed | ||
--> $DIR/ub-write-through-immutable.rs:11:5 | ||
| | ||
LL | *ptr = 0; | ||
| ^^^^^^^^ | ||
| | ||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | ||
= note: for more information, see issue #X <https://github.com/rust-lang/rust/issues/X> | ||
note: the lint level is defined here | ||
--> $DIR/ub-write-through-immutable.rs:3:9 | ||
| | ||
LL | #![deny(writes_through_immutable_pointer)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| ^^^^^^^^ writing through a pointer that was derived from a shared (immutable) reference | ||
|
||
error: writing through a pointer that was derived from a shared (immutable) reference | ||
--> $DIR/ub-write-through-immutable.rs:19:5 | ||
error[E0080]: evaluation of constant value failed | ||
--> $DIR/ub-write-through-immutable.rs:18:5 | ||
| | ||
LL | *ptr = 0; | ||
| ^^^^^^^^ | ||
| | ||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | ||
= note: for more information, see issue #X <https://github.com/rust-lang/rust/issues/X> | ||
| ^^^^^^^^ writing through a pointer that was derived from a shared (immutable) reference | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
Future incompatibility report: Future breakage diagnostic: | ||
error: writing through a pointer that was derived from a shared (immutable) reference | ||
--> $DIR/ub-write-through-immutable.rs:12:5 | ||
| | ||
LL | *ptr = 0; | ||
| ^^^^^^^^ | ||
| | ||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | ||
= note: for more information, see issue #X <https://github.com/rust-lang/rust/issues/X> | ||
note: the lint level is defined here | ||
--> $DIR/ub-write-through-immutable.rs:3:9 | ||
| | ||
LL | #![deny(writes_through_immutable_pointer)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
Future breakage diagnostic: | ||
error: writing through a pointer that was derived from a shared (immutable) reference | ||
--> $DIR/ub-write-through-immutable.rs:19:5 | ||
| | ||
LL | *ptr = 0; | ||
| ^^^^^^^^ | ||
| | ||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | ||
= note: for more information, see issue #X <https://github.com/rust-lang/rust/issues/X> | ||
note: the lint level is defined here | ||
--> $DIR/ub-write-through-immutable.rs:3:9 | ||
| | ||
LL | #![deny(writes_through_immutable_pointer)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
For more information about this error, try `rustc --explain E0080`. |