forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#126881 - WaffleLapkin:unsafe-code-affected-by-fallback-hard-in-2024, r=compiler-errors Make `NEVER_TYPE_FALLBACK_FLOWING_INTO_UNSAFE` a deny-by-default lint in edition 2024 I don't actually really care about this, but ``@traviscross`` asked me to do this, because lang team briefly discussed this before. (TC here:) Specifically, our original FCPed plan included this step: - Add a lint against fallback affecting a generic that is passed to an `unsafe` function. - Perhaps make this lint `deny-by-default` or a hard error in Rust 2024. That is, we had left as an open question strengthening this in Rust 2024, and had marked it as an open question on the tracking issue. We're nominating here to address the open question. (Closing the remaining open question helps us to fully mark this off for Rust 2024.) r? ``@compiler-errors`` Tracking: - rust-lang#123748
- Loading branch information
Showing
4 changed files
with
160 additions
and
23 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
116 changes: 116 additions & 0 deletions
116
tests/ui/never_type/lint-never-type-fallback-flowing-into-unsafe.e2024.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,116 @@ | ||
error: never type fallback affects this call to an `unsafe` function | ||
--> $DIR/lint-never-type-fallback-flowing-into-unsafe.rs:13:18 | ||
| | ||
LL | unsafe { mem::zeroed() } | ||
| ^^^^^^^^^^^^^ | ||
| | ||
= warning: this will change its meaning in a future release! | ||
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748> | ||
= help: specify the type explicitly | ||
= note: `#[deny(never_type_fallback_flowing_into_unsafe)]` on by default | ||
|
||
error: never type fallback affects this call to an `unsafe` function | ||
--> $DIR/lint-never-type-fallback-flowing-into-unsafe.rs:30:13 | ||
| | ||
LL | core::mem::transmute(Zst) | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= warning: this will change its meaning in a future release! | ||
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748> | ||
= help: specify the type explicitly | ||
|
||
error: never type fallback affects this union access | ||
--> $DIR/lint-never-type-fallback-flowing-into-unsafe.rs:47:18 | ||
| | ||
LL | unsafe { Union { a: () }.b } | ||
| ^^^^^^^^^^^^^^^^^ | ||
| | ||
= warning: this will change its meaning in a future release! | ||
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748> | ||
= help: specify the type explicitly | ||
|
||
error: never type fallback affects this raw pointer dereference | ||
--> $DIR/lint-never-type-fallback-flowing-into-unsafe.rs:58:18 | ||
| | ||
LL | unsafe { *ptr::from_ref(&()).cast() } | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= warning: this will change its meaning in a future release! | ||
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748> | ||
= help: specify the type explicitly | ||
|
||
error: never type fallback affects this call to an `unsafe` function | ||
--> $DIR/lint-never-type-fallback-flowing-into-unsafe.rs:79:18 | ||
| | ||
LL | unsafe { internally_create(x) } | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= warning: this will change its meaning in a future release! | ||
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748> | ||
= help: specify the type explicitly | ||
|
||
error: never type fallback affects this call to an `unsafe` function | ||
--> $DIR/lint-never-type-fallback-flowing-into-unsafe.rs:97:18 | ||
| | ||
LL | unsafe { zeroed() } | ||
| ^^^^^^^^ | ||
| | ||
= warning: this will change its meaning in a future release! | ||
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748> | ||
= help: specify the type explicitly | ||
|
||
error: never type fallback affects this `unsafe` function | ||
--> $DIR/lint-never-type-fallback-flowing-into-unsafe.rs:92:22 | ||
| | ||
LL | let zeroed = mem::zeroed; | ||
| ^^^^^^^^^^^ | ||
| | ||
= warning: this will change its meaning in a future release! | ||
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748> | ||
= help: specify the type explicitly | ||
|
||
error: never type fallback affects this `unsafe` function | ||
--> $DIR/lint-never-type-fallback-flowing-into-unsafe.rs:115:17 | ||
| | ||
LL | let f = internally_create; | ||
| ^^^^^^^^^^^^^^^^^ | ||
| | ||
= warning: this will change its meaning in a future release! | ||
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748> | ||
= help: specify the type explicitly | ||
|
||
error: never type fallback affects this call to an `unsafe` method | ||
--> $DIR/lint-never-type-fallback-flowing-into-unsafe.rs:140:13 | ||
| | ||
LL | S(marker::PhantomData).create_out_of_thin_air() | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= warning: this will change its meaning in a future release! | ||
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748> | ||
= help: specify the type explicitly | ||
|
||
error: never type fallback affects this call to an `unsafe` function | ||
--> $DIR/lint-never-type-fallback-flowing-into-unsafe.rs:158:19 | ||
| | ||
LL | match send_message::<_ /* ?0 */>() { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
... | ||
LL | msg_send!(); | ||
| ----------- in this macro invocation | ||
| | ||
= warning: this will change its meaning in a future release! | ||
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748> | ||
= help: specify the type explicitly | ||
= note: this error originates in the macro `msg_send` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
warning: the type `!` does not permit zero-initialization | ||
--> $DIR/lint-never-type-fallback-flowing-into-unsafe.rs:13:18 | ||
| | ||
LL | unsafe { mem::zeroed() } | ||
| ^^^^^^^^^^^^^ this code causes undefined behavior when executed | ||
| | ||
= note: the `!` type has no valid value | ||
= note: `#[warn(invalid_value)]` on by default | ||
|
||
error: aborting due to 10 previous errors; 1 warning emitted | ||
|
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