Skip to content

Commit 673bb5e

Browse files
committed
Mark never_type_fallback_flowing_into_unsafe as a semantic change
...rather than a future error
1 parent 46967bd commit 673bb5e

6 files changed

+49
-32
lines changed

Diff for: compiler/rustc_lint_defs/src/builtin.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4185,7 +4185,7 @@ declare_lint! {
41854185
Warn,
41864186
"never type fallback affecting unsafe function calls",
41874187
@future_incompatible = FutureIncompatibleInfo {
4188-
reason: FutureIncompatibilityReason::EditionAndFutureReleaseError(Edition::Edition2024),
4188+
reason: FutureIncompatibilityReason::EditionAndFutureReleaseSemanticsChange(Edition::Edition2024),
41894189
reference: "issue #123748 <https://github.com/rust-lang/rust/issues/123748>",
41904190
};
41914191
@edition Edition2024 => Deny;

Diff for: compiler/rustc_lint_defs/src/lib.rs

+13-1
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,17 @@ pub enum FutureIncompatibilityReason {
432432
/// [`EditionError`]: FutureIncompatibilityReason::EditionError
433433
/// [`FutureReleaseErrorDontReportInDeps`]: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps
434434
EditionAndFutureReleaseError(Edition),
435+
/// This will change meaning in the provided edition *and* in a future
436+
/// release.
437+
///
438+
/// This variant a combination of [`FutureReleaseSemanticsChange`]
439+
/// and [`EditionSemanticsChange`]. This is useful in rare cases when we
440+
/// want to have "preview" of a breaking change in an edition, but do a
441+
/// breaking change later on all editions anyway.
442+
///
443+
/// [`EditionSemanticsChange`]: FutureIncompatibilityReason::EditionSemanticsChange
444+
/// [`FutureReleaseSemanticsChange`]: FutureIncompatibilityReason::FutureReleaseSemanticsChange
445+
EditionAndFutureReleaseSemanticsChange(Edition),
435446
/// A custom reason.
436447
///
437448
/// Choose this variant if the built-in text of the diagnostic of the
@@ -446,7 +457,8 @@ impl FutureIncompatibilityReason {
446457
match self {
447458
Self::EditionError(e)
448459
| Self::EditionSemanticsChange(e)
449-
| Self::EditionAndFutureReleaseError(e) => Some(e),
460+
| Self::EditionAndFutureReleaseError(e)
461+
| Self::EditionAndFutureReleaseSemanticsChange(e) => Some(e),
450462

451463
FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps
452464
| FutureIncompatibilityReason::FutureReleaseErrorReportInDeps

Diff for: compiler/rustc_middle/src/lint.rs

+5
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,11 @@ pub fn lint_level(
388388
it will become a hard error in Rust {edition} and in a future release in all editions!"
389389
)
390390
}
391+
FutureIncompatibilityReason::EditionAndFutureReleaseSemanticsChange(edition) => {
392+
format!(
393+
"this changes meaning in Rust {edition} and in a future release in all editions!"
394+
)
395+
}
391396
FutureIncompatibilityReason::Custom(reason) => reason.to_owned(),
392397
};
393398

Diff for: tests/ui/never_type/lint-never-type-fallback-flowing-into-unsafe.e2015.stderr

+10-10
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ warning: never type fallback affects this call to an `unsafe` function
44
LL | unsafe { mem::zeroed() }
55
| ^^^^^^^^^^^^^
66
|
7-
= 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!
7+
= warning: this changes meaning in Rust 2024 and in a future release in all editions!
88
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748>
99
= help: specify the type explicitly
1010
= note: `#[warn(never_type_fallback_flowing_into_unsafe)]` on by default
@@ -19,7 +19,7 @@ warning: never type fallback affects this call to an `unsafe` function
1919
LL | core::mem::transmute(Zst)
2020
| ^^^^^^^^^^^^^^^^^^^^^^^^^
2121
|
22-
= 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!
22+
= warning: this changes meaning in Rust 2024 and in a future release in all editions!
2323
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748>
2424
= help: specify the type explicitly
2525
help: use `()` annotations to avoid fallback changes
@@ -33,7 +33,7 @@ warning: never type fallback affects this union access
3333
LL | unsafe { Union { a: () }.b }
3434
| ^^^^^^^^^^^^^^^^^
3535
|
36-
= 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!
36+
= warning: this changes meaning in Rust 2024 and in a future release in all editions!
3737
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748>
3838
= help: specify the type explicitly
3939

@@ -43,7 +43,7 @@ warning: never type fallback affects this raw pointer dereference
4343
LL | unsafe { *ptr::from_ref(&()).cast() }
4444
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
4545
|
46-
= 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!
46+
= warning: this changes meaning in Rust 2024 and in a future release in all editions!
4747
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748>
4848
= help: specify the type explicitly
4949
help: use `()` annotations to avoid fallback changes
@@ -57,7 +57,7 @@ warning: never type fallback affects this call to an `unsafe` function
5757
LL | unsafe { internally_create(x) }
5858
| ^^^^^^^^^^^^^^^^^^^^
5959
|
60-
= 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!
60+
= warning: this changes meaning in Rust 2024 and in a future release in all editions!
6161
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748>
6262
= help: specify the type explicitly
6363
help: use `()` annotations to avoid fallback changes
@@ -71,7 +71,7 @@ warning: never type fallback affects this call to an `unsafe` function
7171
LL | unsafe { zeroed() }
7272
| ^^^^^^^^
7373
|
74-
= 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!
74+
= warning: this changes meaning in Rust 2024 and in a future release in all editions!
7575
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748>
7676
= help: specify the type explicitly
7777
help: use `()` annotations to avoid fallback changes
@@ -85,7 +85,7 @@ warning: never type fallback affects this `unsafe` function
8585
LL | let zeroed = mem::zeroed;
8686
| ^^^^^^^^^^^
8787
|
88-
= 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!
88+
= warning: this changes meaning in Rust 2024 and in a future release in all editions!
8989
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748>
9090
= help: specify the type explicitly
9191
help: use `()` annotations to avoid fallback changes
@@ -99,7 +99,7 @@ warning: never type fallback affects this `unsafe` function
9999
LL | let f = internally_create;
100100
| ^^^^^^^^^^^^^^^^^
101101
|
102-
= 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!
102+
= warning: this changes meaning in Rust 2024 and in a future release in all editions!
103103
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748>
104104
= help: specify the type explicitly
105105
help: use `()` annotations to avoid fallback changes
@@ -113,7 +113,7 @@ warning: never type fallback affects this call to an `unsafe` method
113113
LL | S(marker::PhantomData).create_out_of_thin_air()
114114
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
115115
|
116-
= 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!
116+
= warning: this changes meaning in Rust 2024 and in a future release in all editions!
117117
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748>
118118
= help: specify the type explicitly
119119

@@ -126,7 +126,7 @@ LL | match send_message::<_ /* ?0 */>() {
126126
LL | msg_send!();
127127
| ----------- in this macro invocation
128128
|
129-
= 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!
129+
= warning: this changes meaning in Rust 2024 and in a future release in all editions!
130130
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748>
131131
= help: specify the type explicitly
132132
= note: this warning originates in the macro `msg_send` (in Nightly builds, run with -Z macro-backtrace for more info)

Diff for: tests/ui/never_type/lint-never-type-fallback-flowing-into-unsafe.e2024.stderr

+10-10
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error: never type fallback affects this call to an `unsafe` function
44
LL | unsafe { mem::zeroed() }
55
| ^^^^^^^^^^^^^
66
|
7-
= 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!
7+
= warning: this changes meaning in Rust 2024 and in a future release in all editions!
88
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748>
99
= help: specify the type explicitly
1010
= note: `#[deny(never_type_fallback_flowing_into_unsafe)]` on by default
@@ -19,7 +19,7 @@ error: never type fallback affects this call to an `unsafe` function
1919
LL | core::mem::transmute(Zst)
2020
| ^^^^^^^^^^^^^^^^^^^^^^^^^
2121
|
22-
= 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!
22+
= warning: this changes meaning in Rust 2024 and in a future release in all editions!
2323
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748>
2424
= help: specify the type explicitly
2525
help: use `()` annotations to avoid fallback changes
@@ -33,7 +33,7 @@ error: never type fallback affects this union access
3333
LL | unsafe { Union { a: () }.b }
3434
| ^^^^^^^^^^^^^^^^^
3535
|
36-
= 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!
36+
= warning: this changes meaning in Rust 2024 and in a future release in all editions!
3737
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748>
3838
= help: specify the type explicitly
3939

@@ -43,7 +43,7 @@ error: never type fallback affects this raw pointer dereference
4343
LL | unsafe { *ptr::from_ref(&()).cast() }
4444
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
4545
|
46-
= 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!
46+
= warning: this changes meaning in Rust 2024 and in a future release in all editions!
4747
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748>
4848
= help: specify the type explicitly
4949
help: use `()` annotations to avoid fallback changes
@@ -57,7 +57,7 @@ error: never type fallback affects this call to an `unsafe` function
5757
LL | unsafe { internally_create(x) }
5858
| ^^^^^^^^^^^^^^^^^^^^
5959
|
60-
= 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!
60+
= warning: this changes meaning in Rust 2024 and in a future release in all editions!
6161
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748>
6262
= help: specify the type explicitly
6363
help: use `()` annotations to avoid fallback changes
@@ -71,7 +71,7 @@ error: never type fallback affects this call to an `unsafe` function
7171
LL | unsafe { zeroed() }
7272
| ^^^^^^^^
7373
|
74-
= 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!
74+
= warning: this changes meaning in Rust 2024 and in a future release in all editions!
7575
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748>
7676
= help: specify the type explicitly
7777
help: use `()` annotations to avoid fallback changes
@@ -85,7 +85,7 @@ error: never type fallback affects this `unsafe` function
8585
LL | let zeroed = mem::zeroed;
8686
| ^^^^^^^^^^^
8787
|
88-
= 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!
88+
= warning: this changes meaning in Rust 2024 and in a future release in all editions!
8989
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748>
9090
= help: specify the type explicitly
9191
help: use `()` annotations to avoid fallback changes
@@ -99,7 +99,7 @@ error: never type fallback affects this `unsafe` function
9999
LL | let f = internally_create;
100100
| ^^^^^^^^^^^^^^^^^
101101
|
102-
= 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!
102+
= warning: this changes meaning in Rust 2024 and in a future release in all editions!
103103
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748>
104104
= help: specify the type explicitly
105105
help: use `()` annotations to avoid fallback changes
@@ -113,7 +113,7 @@ error: never type fallback affects this call to an `unsafe` method
113113
LL | S(marker::PhantomData).create_out_of_thin_air()
114114
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
115115
|
116-
= 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!
116+
= warning: this changes meaning in Rust 2024 and in a future release in all editions!
117117
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748>
118118
= help: specify the type explicitly
119119

@@ -126,7 +126,7 @@ LL | match send_message::<_ /* ?0 */>() {
126126
LL | msg_send!();
127127
| ----------- in this macro invocation
128128
|
129-
= 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!
129+
= warning: this changes meaning in Rust 2024 and in a future release in all editions!
130130
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748>
131131
= help: specify the type explicitly
132132
= note: this error originates in the macro `msg_send` (in Nightly builds, run with -Z macro-backtrace for more info)

0 commit comments

Comments
 (0)