Skip to content

Commit 46967bd

Browse files
committed
Mention both release *and* edition breakage for never type lints
1 parent db07404 commit 46967bd

23 files changed

+86
-62
lines changed

compiler/rustc_lint_defs/src/builtin.rs

+2-2
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::FutureReleaseSemanticsChange,
4188+
reason: FutureIncompatibilityReason::EditionAndFutureReleaseError(Edition::Edition2024),
41894189
reference: "issue #123748 <https://github.com/rust-lang/rust/issues/123748>",
41904190
};
41914191
@edition Edition2024 => Deny;
@@ -4239,7 +4239,7 @@ declare_lint! {
42394239
Warn,
42404240
"never type fallback affecting unsafe function calls",
42414241
@future_incompatible = FutureIncompatibleInfo {
4242-
reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
4242+
reason: FutureIncompatibilityReason::EditionAndFutureReleaseError(Edition::Edition2024),
42434243
reference: "issue #123748 <https://github.com/rust-lang/rust/issues/123748>",
42444244
};
42454245
report_in_external_macro

compiler/rustc_lint_defs/src/lib.rs

+21-3
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,8 @@ pub enum FutureIncompatibilityReason {
381381
/// hard errors (and the lint removed). Preferably when there is some
382382
/// confidence that the number of impacted projects is very small (few
383383
/// should have a broken dependency in their dependency tree).
384+
///
385+
/// [`EditionAndFutureReleaseError`]: FutureIncompatibilityReason::EditionAndFutureReleaseError
384386
FutureReleaseErrorReportInDeps,
385387
/// Code that changes meaning in some way in a
386388
/// future release.
@@ -419,6 +421,17 @@ pub enum FutureIncompatibilityReason {
419421
/// slightly changes the text of the diagnostic, but is otherwise the
420422
/// same.
421423
EditionSemanticsChange(Edition),
424+
/// This will be an error in the provided edition *and* in a future
425+
/// release.
426+
///
427+
/// This variant a combination of [`FutureReleaseErrorDontReportInDeps`]
428+
/// and [`EditionError`]. This is useful in rare cases when we
429+
/// want to have "preview" of a breaking change in an edition, but do a
430+
/// breaking change later on all editions anyway.
431+
///
432+
/// [`EditionError`]: FutureIncompatibilityReason::EditionError
433+
/// [`FutureReleaseErrorDontReportInDeps`]: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps
434+
EditionAndFutureReleaseError(Edition),
422435
/// A custom reason.
423436
///
424437
/// Choose this variant if the built-in text of the diagnostic of the
@@ -431,9 +444,14 @@ pub enum FutureIncompatibilityReason {
431444
impl FutureIncompatibilityReason {
432445
pub fn edition(self) -> Option<Edition> {
433446
match self {
434-
Self::EditionError(e) => Some(e),
435-
Self::EditionSemanticsChange(e) => Some(e),
436-
_ => None,
447+
Self::EditionError(e)
448+
| Self::EditionSemanticsChange(e)
449+
| Self::EditionAndFutureReleaseError(e) => Some(e),
450+
451+
FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps
452+
| FutureIncompatibilityReason::FutureReleaseErrorReportInDeps
453+
| FutureIncompatibilityReason::FutureReleaseSemanticsChange
454+
| FutureIncompatibilityReason::Custom(_) => None,
437455
}
438456
}
439457
}

compiler/rustc_middle/src/lint.rs

+6
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,12 @@ pub fn lint_level(
382382
FutureIncompatibilityReason::EditionSemanticsChange(edition) => {
383383
format!("this changes meaning in Rust {edition}")
384384
}
385+
FutureIncompatibilityReason::EditionAndFutureReleaseError(edition) => {
386+
format!(
387+
"this was previously accepted by the compiler but is being phased out; \
388+
it will become a hard error in Rust {edition} and in a future release in all editions!"
389+
)
390+
}
385391
FutureIncompatibilityReason::Custom(reason) => reason.to_owned(),
386392
};
387393

tests/ui/editions/never-type-fallback-breaking.e2021.fixed

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ fn main() {
1616

1717
fn m() {
1818
//[e2021]~^ this function depends on never type fallback being `()`
19-
//[e2021]~| this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
19+
//[e2021]~| 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!
2020
let x: () = match true {
2121
true => Default::default(),
2222
//[e2024]~^ error: the trait bound `!: Default` is not satisfied
@@ -28,7 +28,7 @@ fn m() {
2828

2929
fn q() -> Option<()> {
3030
//[e2021]~^ this function depends on never type fallback being `()`
31-
//[e2021]~| this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
31+
//[e2021]~| 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!
3232
fn deserialize<T: Default>() -> Option<T> {
3333
Some(T::default())
3434
}
@@ -45,7 +45,7 @@ fn help<'a: 'a, T: Into<()>, U>(_: U) -> Result<T, ()> {
4545
}
4646
fn meow() -> Result<(), ()> {
4747
//[e2021]~^ this function depends on never type fallback being `()`
48-
//[e2021]~| this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
48+
//[e2021]~| 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!
4949
help::<(), _>(1)?;
5050
//[e2024]~^ error: the trait bound `(): From<!>` is not satisfied
5151
Ok(())

tests/ui/editions/never-type-fallback-breaking.e2021.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ warning: this function depends on never type fallback being `()`
44
LL | fn m() {
55
| ^^^^^^
66
|
7-
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
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!
88
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748>
99
= help: specify the types explicitly
1010
note: in edition 2024, the requirement `!: Default` will fail
@@ -24,7 +24,7 @@ warning: this function depends on never type fallback being `()`
2424
LL | fn q() -> Option<()> {
2525
| ^^^^^^^^^^^^^^^^^^^^
2626
|
27-
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
27+
= 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!
2828
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748>
2929
= help: specify the types explicitly
3030
note: in edition 2024, the requirement `!: Default` will fail
@@ -43,7 +43,7 @@ warning: this function depends on never type fallback being `()`
4343
LL | fn meow() -> Result<(), ()> {
4444
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
4545
|
46-
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
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!
4747
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748>
4848
= help: specify the types explicitly
4949
note: in edition 2024, the requirement `(): From<!>` will fail

tests/ui/editions/never-type-fallback-breaking.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ fn main() {
1616

1717
fn m() {
1818
//[e2021]~^ this function depends on never type fallback being `()`
19-
//[e2021]~| this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
19+
//[e2021]~| 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!
2020
let x = match true {
2121
true => Default::default(),
2222
//[e2024]~^ error: the trait bound `!: Default` is not satisfied
@@ -28,7 +28,7 @@ fn m() {
2828

2929
fn q() -> Option<()> {
3030
//[e2021]~^ this function depends on never type fallback being `()`
31-
//[e2021]~| this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
31+
//[e2021]~| 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!
3232
fn deserialize<T: Default>() -> Option<T> {
3333
Some(T::default())
3434
}
@@ -45,7 +45,7 @@ fn help<'a: 'a, T: Into<()>, U>(_: U) -> Result<T, ()> {
4545
}
4646
fn meow() -> Result<(), ()> {
4747
//[e2021]~^ this function depends on never type fallback being `()`
48-
//[e2021]~| this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
48+
//[e2021]~| 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!
4949
help(1)?;
5050
//[e2024]~^ error: the trait bound `(): From<!>` is not satisfied
5151
Ok(())

tests/ui/never_type/defaulted-never-note.nofallback.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ warning: this function depends on never type fallback being `()`
44
LL | fn smeg() {
55
| ^^^^^^^^^
66
|
7-
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
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!
88
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748>
99
= help: specify the types explicitly
1010
note: in edition 2024, the requirement `!: ImplementedForUnitButNotNever` will fail

tests/ui/never_type/defaulted-never-note.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ fn foo<T: ImplementedForUnitButNotNever>(_t: T) {}
2727
//[fallback]~| NOTE required by a bound in `foo`
2828
fn smeg() {
2929
//[nofallback]~^ warn: this function depends on never type fallback being `()`
30-
//[nofallback]~| warn: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
30+
//[nofallback]~| warn: 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!
3131
let _x = return;
3232
foo(_x);
3333
//[fallback]~^ ERROR the trait bound

tests/ui/never_type/dependency-on-fallback-to-unit.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ fn main() {
77

88
fn def() {
99
//~^ warn: this function depends on never type fallback being `()`
10-
//~| warn: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
10+
//~| warn: 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!
1111
match true {
1212
false => <_>::default(),
1313
true => return,
@@ -18,7 +18,7 @@ fn def() {
1818
// <https://github.com/rust-lang/rust/issues/39216>
1919
fn question_mark() -> Result<(), ()> {
2020
//~^ warn: this function depends on never type fallback being `()`
21-
//~| warn: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
21+
//~| warn: 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!
2222
deserialize()?;
2323
Ok(())
2424
}

tests/ui/never_type/dependency-on-fallback-to-unit.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ warning: this function depends on never type fallback being `()`
44
LL | fn def() {
55
| ^^^^^^^^
66
|
7-
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
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!
88
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748>
99
= help: specify the types explicitly
1010
note: in edition 2024, the requirement `!: Default` will fail
@@ -24,7 +24,7 @@ warning: this function depends on never type fallback being `()`
2424
LL | fn question_mark() -> Result<(), ()> {
2525
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2626
|
27-
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
27+
= 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!
2828
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748>
2929
= help: specify the types explicitly
3030
note: in edition 2024, the requirement `!: Default` will fail

tests/ui/never_type/diverging-fallback-control-flow.nofallback.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ warning: this function depends on never type fallback being `()`
44
LL | fn assignment() {
55
| ^^^^^^^^^^^^^^^
66
|
7-
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
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!
88
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748>
99
= help: specify the types explicitly
1010
note: in edition 2024, the requirement `!: UnitDefault` will fail
@@ -24,7 +24,7 @@ warning: this function depends on never type fallback being `()`
2424
LL | fn assignment_rev() {
2525
| ^^^^^^^^^^^^^^^^^^^
2626
|
27-
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
27+
= 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!
2828
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748>
2929
= help: specify the types explicitly
3030
note: in edition 2024, the requirement `!: UnitDefault` will fail

tests/ui/never_type/diverging-fallback-control-flow.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ impl UnitDefault for () {
2929

3030
fn assignment() {
3131
//[nofallback]~^ warn: this function depends on never type fallback being `()`
32-
//[nofallback]~| warn: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
32+
//[nofallback]~| warn: 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!
3333
let x;
3434

3535
if true {
@@ -41,7 +41,7 @@ fn assignment() {
4141

4242
fn assignment_rev() {
4343
//[nofallback]~^ warn: this function depends on never type fallback being `()`
44-
//[nofallback]~| warn: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
44+
//[nofallback]~| warn: 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!
4545
let x;
4646

4747
if true {

tests/ui/never_type/diverging-fallback-no-leak.nofallback.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ warning: this function depends on never type fallback being `()`
44
LL | fn main() {
55
| ^^^^^^^^^
66
|
7-
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
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!
88
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748>
99
= help: specify the types explicitly
1010
note: in edition 2024, the requirement `!: Test` will fail

tests/ui/never_type/diverging-fallback-no-leak.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ fn unconstrained_arg<T: Test>(_: T) {}
1313

1414
fn main() {
1515
//[nofallback]~^ warn: this function depends on never type fallback being `()`
16-
//[nofallback]~| warn: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
16+
//[nofallback]~| warn: 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!
1717

1818
// Here the type variable falls back to `!`,
1919
// and hence we get a type error.

tests/ui/never_type/diverging-fallback-unconstrained-return.nofallback.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ warning: this function depends on never type fallback being `()`
44
LL | fn main() {
55
| ^^^^^^^^^
66
|
7-
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
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!
88
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748>
99
= help: specify the types explicitly
1010
note: in edition 2024, the requirement `!: UnitReturn` will fail

tests/ui/never_type/diverging-fallback-unconstrained-return.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ fn unconstrained_return<T: UnitReturn>() -> T {
2727

2828
fn main() {
2929
//[nofallback]~^ warn: this function depends on never type fallback being `()`
30-
//[nofallback]~| warn: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
30+
//[nofallback]~| warn: 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!
3131

3232
// In Ye Olde Days, the `T` parameter of `unconstrained_return`
3333
// winds up "entangled" with the `!` type that results from

tests/ui/never_type/fallback-closure-ret.nofallback.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ warning: this function depends on never type fallback being `()`
44
LL | fn main() {
55
| ^^^^^^^^^
66
|
7-
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
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!
88
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748>
99
= help: specify the types explicitly
1010
note: in edition 2024, the requirement `!: Bar` will fail

tests/ui/never_type/fallback-closure-ret.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ fn foo<R: Bar>(_: impl Fn() -> R) {}
2020

2121
fn main() {
2222
//[nofallback]~^ warn: this function depends on never type fallback being `()`
23-
//[nofallback]~| warn: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
23+
//[nofallback]~| warn: 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!
2424
foo(|| panic!());
2525
}

tests/ui/never_type/impl_trait_fallback.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ impl T for () {}
77

88
fn should_ret_unit() -> impl T {
99
//~^ warn: this function depends on never type fallback being `()`
10-
//~| warn: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
10+
//~| warn: 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!
1111
panic!()
1212
}

tests/ui/never_type/impl_trait_fallback.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ warning: this function depends on never type fallback being `()`
44
LL | fn should_ret_unit() -> impl T {
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
7-
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
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!
88
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748>
99
= help: specify the types explicitly
1010
note: in edition 2024, the requirement `!: T` will fail

0 commit comments

Comments
 (0)