Skip to content

Commit dd912ec

Browse files
committed
report never type lints in deps
1 parent e04270f commit dd912ec

13 files changed

+647
-0
lines changed

compiler/rustc_lint_defs/src/builtin.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4131,6 +4131,7 @@ declare_lint! {
41314131
@future_incompatible = FutureIncompatibleInfo {
41324132
reason: FutureIncompatibilityReason::EditionAndFutureReleaseSemanticsChange(Edition::Edition2024),
41334133
reference: "<https://doc.rust-lang.org/nightly/edition-guide/rust-2024/never-type-fallback.html>",
4134+
report_in_deps: true,
41344135
};
41354136
@edition Edition2024 => Deny;
41364137
report_in_external_macro
@@ -4185,6 +4186,7 @@ declare_lint! {
41854186
@future_incompatible = FutureIncompatibleInfo {
41864187
reason: FutureIncompatibilityReason::EditionAndFutureReleaseError(Edition::Edition2024),
41874188
reference: "<https://doc.rust-lang.org/nightly/edition-guide/rust-2024/never-type-fallback.html>",
4189+
report_in_deps: true,
41884190
};
41894191
report_in_external_macro
41904192
}

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

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,108 @@ LL | takes_apit2(mk::<()>()?);
9696

9797
warning: 5 warnings emitted
9898

99+
Future incompatibility report: Future breakage diagnostic:
100+
warning: this function depends on never type fallback being `()`
101+
--> $DIR/never-type-fallback-breaking.rs:18:1
102+
|
103+
LL | fn m() {
104+
| ^^^^^^
105+
|
106+
= 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!
107+
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/never-type-fallback.html>
108+
= help: specify the types explicitly
109+
note: in edition 2024, the requirement `!: Default` will fail
110+
--> $DIR/never-type-fallback-breaking.rs:22:17
111+
|
112+
LL | true => Default::default(),
113+
| ^^^^^^^^^^^^^^^^^^
114+
= note: `#[warn(dependency_on_unit_never_type_fallback)]` on by default
115+
help: use `()` annotations to avoid fallback changes
116+
|
117+
LL | let x: () = match true {
118+
| ++++
119+
120+
Future breakage diagnostic:
121+
warning: this function depends on never type fallback being `()`
122+
--> $DIR/never-type-fallback-breaking.rs:30:1
123+
|
124+
LL | fn q() -> Option<()> {
125+
| ^^^^^^^^^^^^^^^^^^^^
126+
|
127+
= 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!
128+
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/never-type-fallback.html>
129+
= help: specify the types explicitly
130+
note: in edition 2024, the requirement `!: Default` will fail
131+
--> $DIR/never-type-fallback-breaking.rs:37:5
132+
|
133+
LL | deserialize()?;
134+
| ^^^^^^^^^^^^^
135+
= note: `#[warn(dependency_on_unit_never_type_fallback)]` on by default
136+
help: use `()` annotations to avoid fallback changes
137+
|
138+
LL | deserialize::<()>()?;
139+
| ++++++
140+
141+
Future breakage diagnostic:
142+
warning: this function depends on never type fallback being `()`
143+
--> $DIR/never-type-fallback-breaking.rs:47:1
144+
|
145+
LL | fn meow() -> Result<(), ()> {
146+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
147+
|
148+
= 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!
149+
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/never-type-fallback.html>
150+
= help: specify the types explicitly
151+
note: in edition 2024, the requirement `(): From<!>` will fail
152+
--> $DIR/never-type-fallback-breaking.rs:50:5
153+
|
154+
LL | help(1)?;
155+
| ^^^^^^^
156+
= note: `#[warn(dependency_on_unit_never_type_fallback)]` on by default
157+
help: use `()` annotations to avoid fallback changes
158+
|
159+
LL | help::<(), _>(1)?;
160+
| +++++++++
161+
162+
Future breakage diagnostic:
163+
warning: this function depends on never type fallback being `()`
164+
--> $DIR/never-type-fallback-breaking.rs:59:1
165+
|
166+
LL | pub fn fallback_return() -> Result<(), ()> {
167+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
168+
|
169+
= 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!
170+
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/never-type-fallback.html>
171+
= help: specify the types explicitly
172+
note: in edition 2024, the requirement `!: Default` will fail
173+
--> $DIR/never-type-fallback-breaking.rs:62:19
174+
|
175+
LL | takes_apit(|| Default::default())?;
176+
| ^^^^^^^^^^^^^^^^^^
177+
= note: `#[warn(dependency_on_unit_never_type_fallback)]` on by default
178+
help: use `()` annotations to avoid fallback changes
179+
|
180+
LL | takes_apit::<()>(|| Default::default())?;
181+
| ++++++
182+
183+
Future breakage diagnostic:
184+
warning: this function depends on never type fallback being `()`
185+
--> $DIR/never-type-fallback-breaking.rs:73:1
186+
|
187+
LL | fn fully_apit() -> Result<(), ()> {
188+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
189+
|
190+
= 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!
191+
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/never-type-fallback.html>
192+
= help: specify the types explicitly
193+
note: in edition 2024, the requirement `!: Default` will fail
194+
--> $DIR/never-type-fallback-breaking.rs:76:17
195+
|
196+
LL | takes_apit2(mk()?);
197+
| ^^^^^
198+
= note: `#[warn(dependency_on_unit_never_type_fallback)]` on by default
199+
help: use `()` annotations to avoid fallback changes
200+
|
201+
LL | takes_apit2(mk::<()>()?);
202+
| ++++++
203+

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,24 @@ LL | let _x: () = return;
2020

2121
warning: 1 warning emitted
2222

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

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

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,46 @@ LL | deserialize::<()>()?;
4040

4141
warning: 2 warnings emitted
4242

43+
Future incompatibility report: Future breakage diagnostic:
44+
warning: this function depends on never type fallback being `()`
45+
--> $DIR/dependency-on-fallback-to-unit.rs:8:1
46+
|
47+
LL | fn def() {
48+
| ^^^^^^^^
49+
|
50+
= 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!
51+
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/never-type-fallback.html>
52+
= help: specify the types explicitly
53+
note: in edition 2024, the requirement `!: Default` will fail
54+
--> $DIR/dependency-on-fallback-to-unit.rs:12:19
55+
|
56+
LL | false => <_>::default(),
57+
| ^
58+
= note: `#[warn(dependency_on_unit_never_type_fallback)]` on by default
59+
help: use `()` annotations to avoid fallback changes
60+
|
61+
LL - false => <_>::default(),
62+
LL + false => <()>::default(),
63+
|
64+
65+
Future breakage diagnostic:
66+
warning: this function depends on never type fallback being `()`
67+
--> $DIR/dependency-on-fallback-to-unit.rs:19:1
68+
|
69+
LL | fn question_mark() -> Result<(), ()> {
70+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
71+
|
72+
= 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!
73+
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/never-type-fallback.html>
74+
= help: specify the types explicitly
75+
note: in edition 2024, the requirement `!: Default` will fail
76+
--> $DIR/dependency-on-fallback-to-unit.rs:22:5
77+
|
78+
LL | deserialize()?;
79+
| ^^^^^^^^^^^^^
80+
= note: `#[warn(dependency_on_unit_never_type_fallback)]` on by default
81+
help: use `()` annotations to avoid fallback changes
82+
|
83+
LL | deserialize::<()>()?;
84+
| ++++++
85+

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

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,45 @@ LL | let x: ();
3939

4040
warning: 2 warnings emitted
4141

42+
Future incompatibility report: Future breakage diagnostic:
43+
warning: this function depends on never type fallback being `()`
44+
--> $DIR/diverging-fallback-control-flow.rs:30:1
45+
|
46+
LL | fn assignment() {
47+
| ^^^^^^^^^^^^^^^
48+
|
49+
= 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!
50+
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/never-type-fallback.html>
51+
= help: specify the types explicitly
52+
note: in edition 2024, the requirement `!: UnitDefault` will fail
53+
--> $DIR/diverging-fallback-control-flow.rs:36:13
54+
|
55+
LL | x = UnitDefault::default();
56+
| ^^^^^^^^^^^^^^^^^^^^^^
57+
= note: `#[warn(dependency_on_unit_never_type_fallback)]` on by default
58+
help: use `()` annotations to avoid fallback changes
59+
|
60+
LL | let x: ();
61+
| ++++
62+
63+
Future breakage diagnostic:
64+
warning: this function depends on never type fallback being `()`
65+
--> $DIR/diverging-fallback-control-flow.rs:42:1
66+
|
67+
LL | fn assignment_rev() {
68+
| ^^^^^^^^^^^^^^^^^^^
69+
|
70+
= 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!
71+
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/never-type-fallback.html>
72+
= help: specify the types explicitly
73+
note: in edition 2024, the requirement `!: UnitDefault` will fail
74+
--> $DIR/diverging-fallback-control-flow.rs:50:13
75+
|
76+
LL | x = UnitDefault::default();
77+
| ^^^^^^^^^^^^^^^^^^^^^^
78+
= note: `#[warn(dependency_on_unit_never_type_fallback)]` on by default
79+
help: use `()` annotations to avoid fallback changes
80+
|
81+
LL | let x: ();
82+
| ++++
83+

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,24 @@ LL | unconstrained_arg::<()>(return);
2020

2121
warning: 1 warning emitted
2222

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

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,24 @@ LL | let _: () = if true { unconstrained_return() } else { panic!() };
2020

2121
warning: 1 warning emitted
2222

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

tests/ui/never_type/dont-suggest-turbofish-from-expansion.stderr

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,28 @@ LL | let created: () = create_ok_default()?;
2424

2525
error: aborting due to 1 previous error
2626

27+
Future incompatibility report: Future breakage diagnostic:
28+
error: this function depends on never type fallback being `()`
29+
--> $DIR/dont-suggest-turbofish-from-expansion.rs:10:1
30+
|
31+
LL | fn main() -> Result<(), ()> {
32+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
33+
|
34+
= 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!
35+
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/never-type-fallback.html>
36+
= help: specify the types explicitly
37+
note: in edition 2024, the requirement `!: Default` will fail
38+
--> $DIR/dont-suggest-turbofish-from-expansion.rs:14:23
39+
|
40+
LL | let created = create_ok_default()?;
41+
| ^^^^^^^^^^^^^^^^^^^
42+
note: the lint level is defined here
43+
--> $DIR/dont-suggest-turbofish-from-expansion.rs:1:9
44+
|
45+
LL | #![deny(dependency_on_unit_never_type_fallback)]
46+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
47+
help: use `()` annotations to avoid fallback changes
48+
|
49+
LL | let created: () = create_ok_default()?;
50+
| ++++
51+

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,24 @@ LL | foo::<()>(|| panic!());
2020

2121
warning: 1 warning emitted
2222

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

tests/ui/never_type/impl_trait_fallback.stderr

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,20 @@ LL | fn should_ret_unit() -> impl T {
1616

1717
warning: 1 warning emitted
1818

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

tests/ui/never_type/lint-breaking-2024-assign-underscore.stderr

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,28 @@ LL | _ = foo::<()>()?;
2424

2525
error: aborting due to 1 previous error
2626

27+
Future incompatibility report: Future breakage diagnostic:
28+
error: this function depends on never type fallback being `()`
29+
--> $DIR/lint-breaking-2024-assign-underscore.rs:10:1
30+
|
31+
LL | fn test() -> Result<(), ()> {
32+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
33+
|
34+
= 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!
35+
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/never-type-fallback.html>
36+
= help: specify the types explicitly
37+
note: in edition 2024, the requirement `!: Default` will fail
38+
--> $DIR/lint-breaking-2024-assign-underscore.rs:13:9
39+
|
40+
LL | _ = foo()?;
41+
| ^^^^^
42+
note: the lint level is defined here
43+
--> $DIR/lint-breaking-2024-assign-underscore.rs:4:9
44+
|
45+
LL | #![deny(dependency_on_unit_never_type_fallback)]
46+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
47+
help: use `()` annotations to avoid fallback changes
48+
|
49+
LL | _ = foo::<()>()?;
50+
| ++++++
51+

0 commit comments

Comments
 (0)