Skip to content

Commit

Permalink
Mark never_type_fallback_flowing_into_unsafe as a semantic change
Browse files Browse the repository at this point in the history
...rather than a future error
  • Loading branch information
WaffleLapkin committed Nov 14, 2024
1 parent 46967bd commit 5aa873b
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 32 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 @@ -4185,7 +4185,7 @@ declare_lint! {
Warn,
"never type fallback affecting unsafe function calls",
@future_incompatible = FutureIncompatibleInfo {
reason: FutureIncompatibilityReason::EditionAndFutureReleaseError(Edition::Edition2024),
reason: FutureIncompatibilityReason::EditionAndFutureReleaseSemanticChange(Edition::Edition2024),
reference: "issue #123748 <https://github.com/rust-lang/rust/issues/123748>",
};
@edition Edition2024 => Deny;
Expand Down
14 changes: 13 additions & 1 deletion compiler/rustc_lint_defs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,17 @@ pub enum FutureIncompatibilityReason {
/// [`EditionError`]: FutureIncompatibilityReason::EditionError
/// [`FutureReleaseErrorDontReportInDeps`]: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps
EditionAndFutureReleaseError(Edition),
/// This will change meaning in the provided edition *and* in a future
/// release.
///
/// This variant a combination of [`FutureReleaseSemanticChange`]
/// and [`EditionSemanticsChange`]. This is useful in rare cases when we
/// want to have "preview" of a breaking change in an edition, but do a
/// breaking change later on all editions anyway.
///
/// [`EditionSemanticsChange`]: FutureIncompatibilityReason::EditionSemanticsChange
/// [`FutureReleaseSemanticChange`]: FutureIncompatibilityReason::FutureReleaseSemanticChange
EditionAndFutureReleaseSemanticChange(Edition),
/// A custom reason.
///
/// Choose this variant if the built-in text of the diagnostic of the
Expand All @@ -446,7 +457,8 @@ impl FutureIncompatibilityReason {
match self {
Self::EditionError(e)
| Self::EditionSemanticsChange(e)
| Self::EditionAndFutureReleaseError(e) => Some(e),
| Self::EditionAndFutureReleaseError(e)
| Self::EditionAndFutureReleaseSemanticChange(e) => Some(e),

FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps
| FutureIncompatibilityReason::FutureReleaseErrorReportInDeps
Expand Down
5 changes: 5 additions & 0 deletions compiler/rustc_middle/src/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,11 @@ pub fn lint_level(
it will become a hard error in Rust {edition} and in a future release in all editions!"
)
}
FutureIncompatibilityReason::EditionAndFutureReleaseSemanticChange(edition) => {
format!(
"this changes meaning in Rust {edition} and in a future release in all editions!"
)
}
FutureIncompatibilityReason::Custom(reason) => reason.to_owned(),
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ warning: never type fallback affects this call to an `unsafe` function
LL | unsafe { mem::zeroed() }
| ^^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in Rust 2024 and in a future release in all editions!
= warning: this changes meaning in Rust 2024 and in a future release in all editions!
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748>
= help: specify the type explicitly
= note: `#[warn(never_type_fallback_flowing_into_unsafe)]` on by default
Expand All @@ -19,7 +19,7 @@ warning: never type fallback affects this call to an `unsafe` function
LL | core::mem::transmute(Zst)
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in Rust 2024 and in a future release in all editions!
= warning: this changes meaning in Rust 2024 and in a future release in all editions!
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748>
= help: specify the type explicitly
help: use `()` annotations to avoid fallback changes
Expand All @@ -33,7 +33,7 @@ warning: never type fallback affects this union access
LL | unsafe { Union { a: () }.b }
| ^^^^^^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in Rust 2024 and in a future release in all editions!
= warning: this changes meaning in Rust 2024 and in a future release in all editions!
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748>
= help: specify the type explicitly

Expand All @@ -43,7 +43,7 @@ warning: never type fallback affects this raw pointer dereference
LL | unsafe { *ptr::from_ref(&()).cast() }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in Rust 2024 and in a future release in all editions!
= warning: this changes meaning in Rust 2024 and in a future release in all editions!
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748>
= help: specify the type explicitly
help: use `()` annotations to avoid fallback changes
Expand All @@ -57,7 +57,7 @@ warning: never type fallback affects this call to an `unsafe` function
LL | unsafe { internally_create(x) }
| ^^^^^^^^^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in Rust 2024 and in a future release in all editions!
= warning: this changes meaning in Rust 2024 and in a future release in all editions!
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748>
= help: specify the type explicitly
help: use `()` annotations to avoid fallback changes
Expand All @@ -71,7 +71,7 @@ warning: never type fallback affects this call to an `unsafe` function
LL | unsafe { zeroed() }
| ^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in Rust 2024 and in a future release in all editions!
= warning: this changes meaning in Rust 2024 and in a future release in all editions!
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748>
= help: specify the type explicitly
help: use `()` annotations to avoid fallback changes
Expand All @@ -85,7 +85,7 @@ warning: never type fallback affects this `unsafe` function
LL | let zeroed = mem::zeroed;
| ^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in Rust 2024 and in a future release in all editions!
= warning: this changes meaning in Rust 2024 and in a future release in all editions!
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748>
= help: specify the type explicitly
help: use `()` annotations to avoid fallback changes
Expand All @@ -99,7 +99,7 @@ warning: never type fallback affects this `unsafe` function
LL | let f = internally_create;
| ^^^^^^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in Rust 2024 and in a future release in all editions!
= warning: this changes meaning in Rust 2024 and in a future release in all editions!
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748>
= help: specify the type explicitly
help: use `()` annotations to avoid fallback changes
Expand All @@ -113,7 +113,7 @@ warning: never type fallback affects this call to an `unsafe` method
LL | S(marker::PhantomData).create_out_of_thin_air()
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in Rust 2024 and in a future release in all editions!
= warning: this changes meaning in Rust 2024 and in a future release in all editions!
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748>
= help: specify the type explicitly

Expand All @@ -126,7 +126,7 @@ LL | match send_message::<_ /* ?0 */>() {
LL | msg_send!();
| ----------- in this macro invocation
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in Rust 2024 and in a future release in all editions!
= warning: this changes meaning in Rust 2024 and in a future release in all editions!
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748>
= help: specify the type explicitly
= note: this warning originates in the macro `msg_send` (in Nightly builds, run with -Z macro-backtrace for more info)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ error: never type fallback affects this call to an `unsafe` function
LL | unsafe { mem::zeroed() }
| ^^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in Rust 2024 and in a future release in all editions!
= warning: this changes meaning in Rust 2024 and in a future release in all editions!
= 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
Expand All @@ -19,7 +19,7 @@ error: never type fallback affects this call to an `unsafe` function
LL | core::mem::transmute(Zst)
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in Rust 2024 and in a future release in all editions!
= warning: this changes meaning in Rust 2024 and in a future release in all editions!
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748>
= help: specify the type explicitly
help: use `()` annotations to avoid fallback changes
Expand All @@ -33,7 +33,7 @@ error: never type fallback affects this union access
LL | unsafe { Union { a: () }.b }
| ^^^^^^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in Rust 2024 and in a future release in all editions!
= warning: this changes meaning in Rust 2024 and in a future release in all editions!
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748>
= help: specify the type explicitly

Expand All @@ -43,7 +43,7 @@ error: never type fallback affects this raw pointer dereference
LL | unsafe { *ptr::from_ref(&()).cast() }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in Rust 2024 and in a future release in all editions!
= warning: this changes meaning in Rust 2024 and in a future release in all editions!
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748>
= help: specify the type explicitly
help: use `()` annotations to avoid fallback changes
Expand All @@ -57,7 +57,7 @@ error: never type fallback affects this call to an `unsafe` function
LL | unsafe { internally_create(x) }
| ^^^^^^^^^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in Rust 2024 and in a future release in all editions!
= warning: this changes meaning in Rust 2024 and in a future release in all editions!
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748>
= help: specify the type explicitly
help: use `()` annotations to avoid fallback changes
Expand All @@ -71,7 +71,7 @@ error: never type fallback affects this call to an `unsafe` function
LL | unsafe { zeroed() }
| ^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in Rust 2024 and in a future release in all editions!
= warning: this changes meaning in Rust 2024 and in a future release in all editions!
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748>
= help: specify the type explicitly
help: use `()` annotations to avoid fallback changes
Expand All @@ -85,7 +85,7 @@ error: never type fallback affects this `unsafe` function
LL | let zeroed = mem::zeroed;
| ^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in Rust 2024 and in a future release in all editions!
= warning: this changes meaning in Rust 2024 and in a future release in all editions!
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748>
= help: specify the type explicitly
help: use `()` annotations to avoid fallback changes
Expand All @@ -99,7 +99,7 @@ error: never type fallback affects this `unsafe` function
LL | let f = internally_create;
| ^^^^^^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in Rust 2024 and in a future release in all editions!
= warning: this changes meaning in Rust 2024 and in a future release in all editions!
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748>
= help: specify the type explicitly
help: use `()` annotations to avoid fallback changes
Expand All @@ -113,7 +113,7 @@ error: never type fallback affects this call to an `unsafe` method
LL | S(marker::PhantomData).create_out_of_thin_air()
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in Rust 2024 and in a future release in all editions!
= warning: this changes meaning in Rust 2024 and in a future release in all editions!
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748>
= help: specify the type explicitly

Expand All @@ -126,7 +126,7 @@ LL | match send_message::<_ /* ?0 */>() {
LL | msg_send!();
| ----------- in this macro invocation
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in Rust 2024 and in a future release in all editions!
= warning: this changes meaning in Rust 2024 and in a future release in all editions!
= 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)
Expand Down
Loading

0 comments on commit 5aa873b

Please sign in to comment.