Skip to content

Report never type lints in dependencies #141937

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions compiler/rustc_lint_defs/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4131,6 +4131,7 @@ declare_lint! {
@future_incompatible = FutureIncompatibleInfo {
reason: FutureIncompatibilityReason::EditionAndFutureReleaseSemanticsChange(Edition::Edition2024),
reference: "<https://doc.rust-lang.org/nightly/edition-guide/rust-2024/never-type-fallback.html>",
report_in_deps: true,
};
@edition Edition2024 => Deny;
report_in_external_macro
Expand Down Expand Up @@ -4185,6 +4186,7 @@ declare_lint! {
@future_incompatible = FutureIncompatibleInfo {
reason: FutureIncompatibilityReason::EditionAndFutureReleaseError(Edition::Edition2024),
reference: "<https://doc.rust-lang.org/nightly/edition-guide/rust-2024/never-type-fallback.html>",
report_in_deps: true,
};
report_in_external_macro
}
Expand Down
105 changes: 105 additions & 0 deletions tests/ui/editions/never-type-fallback-breaking.e2021.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,108 @@ LL | takes_apit2(mk::<()>()?);

warning: 5 warnings emitted

Future incompatibility report: Future breakage diagnostic:
warning: this function depends on never type fallback being `()`
--> $DIR/never-type-fallback-breaking.rs:18:1
|
LL | fn m() {
| ^^^^^^
|
= 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!
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/never-type-fallback.html>
= help: specify the types explicitly
note: in edition 2024, the requirement `!: Default` will fail
--> $DIR/never-type-fallback-breaking.rs:22:17
|
LL | true => Default::default(),
| ^^^^^^^^^^^^^^^^^^
= note: `#[warn(dependency_on_unit_never_type_fallback)]` on by default
help: use `()` annotations to avoid fallback changes
|
LL | let x: () = match true {
| ++++

Future breakage diagnostic:
warning: this function depends on never type fallback being `()`
--> $DIR/never-type-fallback-breaking.rs:30:1
|
LL | fn q() -> Option<()> {
| ^^^^^^^^^^^^^^^^^^^^
|
= 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!
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/never-type-fallback.html>
= help: specify the types explicitly
note: in edition 2024, the requirement `!: Default` will fail
--> $DIR/never-type-fallback-breaking.rs:37:5
|
LL | deserialize()?;
| ^^^^^^^^^^^^^
= note: `#[warn(dependency_on_unit_never_type_fallback)]` on by default
help: use `()` annotations to avoid fallback changes
|
LL | deserialize::<()>()?;
| ++++++

Future breakage diagnostic:
warning: this function depends on never type fallback being `()`
--> $DIR/never-type-fallback-breaking.rs:47:1
|
LL | fn meow() -> Result<(), ()> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= 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!
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/never-type-fallback.html>
= help: specify the types explicitly
note: in edition 2024, the requirement `(): From<!>` will fail
--> $DIR/never-type-fallback-breaking.rs:50:5
|
LL | help(1)?;
| ^^^^^^^
= note: `#[warn(dependency_on_unit_never_type_fallback)]` on by default
help: use `()` annotations to avoid fallback changes
|
LL | help::<(), _>(1)?;
| +++++++++

Future breakage diagnostic:
warning: this function depends on never type fallback being `()`
--> $DIR/never-type-fallback-breaking.rs:59:1
|
LL | pub fn fallback_return() -> Result<(), ()> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= 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!
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/never-type-fallback.html>
= help: specify the types explicitly
note: in edition 2024, the requirement `!: Default` will fail
--> $DIR/never-type-fallback-breaking.rs:62:19
|
LL | takes_apit(|| Default::default())?;
| ^^^^^^^^^^^^^^^^^^
= note: `#[warn(dependency_on_unit_never_type_fallback)]` on by default
help: use `()` annotations to avoid fallback changes
|
LL | takes_apit::<()>(|| Default::default())?;
| ++++++

Future breakage diagnostic:
warning: this function depends on never type fallback being `()`
--> $DIR/never-type-fallback-breaking.rs:73:1
|
LL | fn fully_apit() -> Result<(), ()> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= 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!
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/never-type-fallback.html>
= help: specify the types explicitly
note: in edition 2024, the requirement `!: Default` will fail
--> $DIR/never-type-fallback-breaking.rs:76:17
|
LL | takes_apit2(mk()?);
| ^^^^^
= note: `#[warn(dependency_on_unit_never_type_fallback)]` on by default
help: use `()` annotations to avoid fallback changes
|
LL | takes_apit2(mk::<()>()?);
| ++++++

21 changes: 21 additions & 0 deletions tests/ui/never_type/defaulted-never-note.nofallback.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,24 @@ LL | let _x: () = return;

warning: 1 warning emitted

Future incompatibility report: Future breakage diagnostic:
warning: this function depends on never type fallback being `()`
--> $DIR/defaulted-never-note.rs:28:1
|
LL | fn smeg() {
| ^^^^^^^^^
|
= 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!
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/never-type-fallback.html>
= help: specify the types explicitly
note: in edition 2024, the requirement `!: ImplementedForUnitButNotNever` will fail
--> $DIR/defaulted-never-note.rs:32:9
|
LL | foo(_x);
| ^^
= note: `#[warn(dependency_on_unit_never_type_fallback)]` on by default
help: use `()` annotations to avoid fallback changes
|
LL | let _x: () = return;
| ++++

43 changes: 43 additions & 0 deletions tests/ui/never_type/dependency-on-fallback-to-unit.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,46 @@ LL | deserialize::<()>()?;

warning: 2 warnings emitted

Future incompatibility report: Future breakage diagnostic:
warning: this function depends on never type fallback being `()`
--> $DIR/dependency-on-fallback-to-unit.rs:8:1
|
LL | fn def() {
| ^^^^^^^^
|
= 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!
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/never-type-fallback.html>
= help: specify the types explicitly
note: in edition 2024, the requirement `!: Default` will fail
--> $DIR/dependency-on-fallback-to-unit.rs:12:19
|
LL | false => <_>::default(),
| ^
= note: `#[warn(dependency_on_unit_never_type_fallback)]` on by default
help: use `()` annotations to avoid fallback changes
|
LL - false => <_>::default(),
LL + false => <()>::default(),
|

Future breakage diagnostic:
warning: this function depends on never type fallback being `()`
--> $DIR/dependency-on-fallback-to-unit.rs:19:1
|
LL | fn question_mark() -> Result<(), ()> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= 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!
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/never-type-fallback.html>
= help: specify the types explicitly
note: in edition 2024, the requirement `!: Default` will fail
--> $DIR/dependency-on-fallback-to-unit.rs:22:5
|
LL | deserialize()?;
| ^^^^^^^^^^^^^
= note: `#[warn(dependency_on_unit_never_type_fallback)]` on by default
help: use `()` annotations to avoid fallback changes
|
LL | deserialize::<()>()?;
| ++++++

Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,45 @@ LL | let x: ();

warning: 2 warnings emitted

Future incompatibility report: Future breakage diagnostic:
warning: this function depends on never type fallback being `()`
--> $DIR/diverging-fallback-control-flow.rs:30:1
|
LL | fn assignment() {
| ^^^^^^^^^^^^^^^
|
= 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!
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/never-type-fallback.html>
= help: specify the types explicitly
note: in edition 2024, the requirement `!: UnitDefault` will fail
--> $DIR/diverging-fallback-control-flow.rs:36:13
|
LL | x = UnitDefault::default();
| ^^^^^^^^^^^^^^^^^^^^^^
= note: `#[warn(dependency_on_unit_never_type_fallback)]` on by default
help: use `()` annotations to avoid fallback changes
|
LL | let x: ();
| ++++

Future breakage diagnostic:
warning: this function depends on never type fallback being `()`
--> $DIR/diverging-fallback-control-flow.rs:42:1
|
LL | fn assignment_rev() {
| ^^^^^^^^^^^^^^^^^^^
|
= 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!
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/never-type-fallback.html>
= help: specify the types explicitly
note: in edition 2024, the requirement `!: UnitDefault` will fail
--> $DIR/diverging-fallback-control-flow.rs:50:13
|
LL | x = UnitDefault::default();
| ^^^^^^^^^^^^^^^^^^^^^^
= note: `#[warn(dependency_on_unit_never_type_fallback)]` on by default
help: use `()` annotations to avoid fallback changes
|
LL | let x: ();
| ++++

21 changes: 21 additions & 0 deletions tests/ui/never_type/diverging-fallback-no-leak.nofallback.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,24 @@ LL | unconstrained_arg::<()>(return);

warning: 1 warning emitted

Future incompatibility report: Future breakage diagnostic:
warning: this function depends on never type fallback being `()`
--> $DIR/diverging-fallback-no-leak.rs:14:1
|
LL | fn main() {
| ^^^^^^^^^
|
= 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!
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/never-type-fallback.html>
= help: specify the types explicitly
note: in edition 2024, the requirement `!: Test` will fail
--> $DIR/diverging-fallback-no-leak.rs:20:23
|
LL | unconstrained_arg(return);
| ^^^^^^
= note: `#[warn(dependency_on_unit_never_type_fallback)]` on by default
help: use `()` annotations to avoid fallback changes
|
LL | unconstrained_arg::<()>(return);
| ++++++

Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,24 @@ LL | let _: () = if true { unconstrained_return() } else { panic!() };

warning: 1 warning emitted

Future incompatibility report: Future breakage diagnostic:
warning: this function depends on never type fallback being `()`
--> $DIR/diverging-fallback-unconstrained-return.rs:28:1
|
LL | fn main() {
| ^^^^^^^^^
|
= 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!
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/never-type-fallback.html>
= help: specify the types explicitly
note: in edition 2024, the requirement `!: UnitReturn` will fail
--> $DIR/diverging-fallback-unconstrained-return.rs:39:23
|
LL | let _ = if true { unconstrained_return() } else { panic!() };
| ^^^^^^^^^^^^^^^^^^^^^^
= note: `#[warn(dependency_on_unit_never_type_fallback)]` on by default
help: use `()` annotations to avoid fallback changes
|
LL | let _: () = if true { unconstrained_return() } else { panic!() };
| ++++

25 changes: 25 additions & 0 deletions tests/ui/never_type/dont-suggest-turbofish-from-expansion.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,28 @@ LL | let created: () = create_ok_default()?;

error: aborting due to 1 previous error

Future incompatibility report: Future breakage diagnostic:
error: this function depends on never type fallback being `()`
--> $DIR/dont-suggest-turbofish-from-expansion.rs:10:1
|
LL | fn main() -> Result<(), ()> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= 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!
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/never-type-fallback.html>
= help: specify the types explicitly
note: in edition 2024, the requirement `!: Default` will fail
--> $DIR/dont-suggest-turbofish-from-expansion.rs:14:23
|
LL | let created = create_ok_default()?;
| ^^^^^^^^^^^^^^^^^^^
note: the lint level is defined here
--> $DIR/dont-suggest-turbofish-from-expansion.rs:1:9
|
LL | #![deny(dependency_on_unit_never_type_fallback)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: use `()` annotations to avoid fallback changes
|
LL | let created: () = create_ok_default()?;
| ++++

21 changes: 21 additions & 0 deletions tests/ui/never_type/fallback-closure-ret.nofallback.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,24 @@ LL | foo::<()>(|| panic!());

warning: 1 warning emitted

Future incompatibility report: Future breakage diagnostic:
warning: this function depends on never type fallback being `()`
--> $DIR/fallback-closure-ret.rs:21:1
|
LL | fn main() {
| ^^^^^^^^^
|
= 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!
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/never-type-fallback.html>
= help: specify the types explicitly
note: in edition 2024, the requirement `!: Bar` will fail
--> $DIR/fallback-closure-ret.rs:24:5
|
LL | foo(|| panic!());
| ^^^^^^^^^^^^^^^^
= note: `#[warn(dependency_on_unit_never_type_fallback)]` on by default
help: use `()` annotations to avoid fallback changes
|
LL | foo::<()>(|| panic!());
| ++++++

17 changes: 17 additions & 0 deletions tests/ui/never_type/impl_trait_fallback.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,20 @@ LL | fn should_ret_unit() -> impl T {

warning: 1 warning emitted

Future incompatibility report: Future breakage diagnostic:
warning: this function depends on never type fallback being `()`
--> $DIR/impl_trait_fallback.rs:8:1
|
LL | fn should_ret_unit() -> impl T {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= 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!
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/never-type-fallback.html>
= help: specify the types explicitly
note: in edition 2024, the requirement `!: T` will fail
--> $DIR/impl_trait_fallback.rs:8:25
|
LL | fn should_ret_unit() -> impl T {
| ^^^^^^
= note: `#[warn(dependency_on_unit_never_type_fallback)]` on by default

25 changes: 25 additions & 0 deletions tests/ui/never_type/lint-breaking-2024-assign-underscore.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,28 @@ LL | _ = foo::<()>()?;

error: aborting due to 1 previous error

Future incompatibility report: Future breakage diagnostic:
error: this function depends on never type fallback being `()`
--> $DIR/lint-breaking-2024-assign-underscore.rs:10:1
|
LL | fn test() -> Result<(), ()> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= 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!
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/never-type-fallback.html>
= help: specify the types explicitly
note: in edition 2024, the requirement `!: Default` will fail
--> $DIR/lint-breaking-2024-assign-underscore.rs:13:9
|
LL | _ = foo()?;
| ^^^^^
note: the lint level is defined here
--> $DIR/lint-breaking-2024-assign-underscore.rs:4:9
|
LL | #![deny(dependency_on_unit_never_type_fallback)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: use `()` annotations to avoid fallback changes
|
LL | _ = foo::<()>()?;
| ++++++

Loading
Loading