You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rollup merge of #146167 - WaffleLapkin:deny-never-ty-lints, r=lcnr,petrochenkov
Deny-by-default never type lints
In Rust [1.89.0](https://github.com/rust-lang/rust/milestone/133) we started emitting these lints in dependencies. I discussed the future steps with `@lcnr` and we think that before stabilizing the never type (and doing the breaking changes) we should deny the lints for ~4 releases.
This PR marks `never_type_fallback_flowing_into_unsafe` and `dependency_on_unit_never_type_fallback` lints as deny-by-default.
Tracking:
- #35121
Related:
- #141937
/// // return has type `!` which, is some cases, causes never type fallback
@@ -4155,7 +4154,7 @@ declare_lint! {
4155
4154
///
4156
4155
/// See [Tracking Issue for making `!` fall back to `!`](https://github.com/rust-lang/rust/issues/123748).
4157
4156
pubDEPENDENCY_ON_UNIT_NEVER_TYPE_FALLBACK,
4158
-
Warn,
4157
+
Deny,
4159
4158
"never type fallback affecting unsafe function calls",
Copy file name to clipboardExpand all lines: tests/ui/editions/never-type-fallback-breaking.e2021.fixed
+10-12Lines changed: 10 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -3,9 +3,7 @@
3
3
//@[e2021] edition: 2021
4
4
//@[e2024] edition: 2024
5
5
//
6
-
//@[e2021] run-pass
7
6
//@[e2021] run-rustfix
8
-
//@[e2024] check-fail
9
7
10
8
fn main() {
11
9
m();
@@ -16,8 +14,8 @@ fn main() {
16
14
}
17
15
18
16
fn m() {
19
-
//[e2021]~^ WARN this function depends on never type fallback being `()`
20
-
//[e2021]~| 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!
17
+
//[e2021]~^ error: this function depends on never type fallback being `()`
18
+
//[e2021]~| 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!
21
19
let x: () = match true {
22
20
true => Default::default(),
23
21
//[e2024]~^ error: the trait bound `!: Default` is not satisfied
@@ -28,8 +26,8 @@ fn m() {
28
26
}
29
27
30
28
fn q() -> Option<()> {
31
-
//[e2021]~^ WARN this function depends on never type fallback being `()`
32
-
//[e2021]~| 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!
29
+
//[e2021]~^ error: this function depends on never type fallback being `()`
30
+
//[e2021]~| 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!
//[e2021]~^ WARN this function depends on never type fallback being `()`
49
-
//[e2021]~| 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!
46
+
//[e2021]~^ error: this function depends on never type fallback being `()`
47
+
//[e2021]~| 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!
50
48
help::<(), _>(1)?;
51
49
//[e2024]~^ error: the trait bound `(): From<!>` is not satisfied
//[e2021]~^ WARN this function depends on never type fallback being `()`
61
-
//[e2021]~| 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!
58
+
//[e2021]~^ error: this function depends on never type fallback being `()`
59
+
//[e2021]~| 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!
62
60
takes_apit::<()>(|| Default::default())?;
63
61
//[e2024]~^ error: the trait bound `!: Default` is not satisfied
64
62
Ok(())
@@ -71,8 +69,8 @@ fn mk<T>() -> Result<T, ()> {
71
69
fn takes_apit2(_x: impl Default) {}
72
70
73
71
fn fully_apit() -> Result<(), ()> {
74
-
//[e2021]~^ WARN this function depends on never type fallback being `()`
75
-
//[e2021]~| 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!
72
+
//[e2021]~^ error: this function depends on never type fallback being `()`
73
+
//[e2021]~| 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!
76
74
takes_apit2(mk::<()>()?);
77
75
//[e2024]~^ error: the trait bound `!: Default` is not satisfied
Copy file name to clipboardExpand all lines: tests/ui/editions/never-type-fallback-breaking.e2021.stderr
+37-37Lines changed: 37 additions & 37 deletions
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
-
warning: this function depends on never type fallback being `()`
2
-
--> $DIR/never-type-fallback-breaking.rs:18:1
1
+
error: this function depends on never type fallback being `()`
2
+
--> $DIR/never-type-fallback-breaking.rs:16:1
3
3
|
4
4
LL | fn m() {
5
5
| ^^^^^^
@@ -8,18 +8,18 @@ LL | fn m() {
8
8
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/never-type-fallback.html>
9
9
= help: specify the types explicitly
10
10
note: in edition 2024, the requirement `!: Default` will fail
11
-
--> $DIR/never-type-fallback-breaking.rs:22:17
11
+
--> $DIR/never-type-fallback-breaking.rs:20:17
12
12
|
13
13
LL | true => Default::default(),
14
14
| ^^^^^^^^^^^^^^^^^^
15
-
= note: `#[warn(dependency_on_unit_never_type_fallback)]` (part of `#[warn(rust_2024_compatibility)]`) on by default
15
+
= note: `#[deny(dependency_on_unit_never_type_fallback)]` (part of `#[deny(rust_2024_compatibility)]`) on by default
16
16
help: use `()` annotations to avoid fallback changes
17
17
|
18
18
LL | let x: () = match true {
19
19
| ++++
20
20
21
-
warning: this function depends on never type fallback being `()`
22
-
--> $DIR/never-type-fallback-breaking.rs:30:1
21
+
error: this function depends on never type fallback being `()`
22
+
--> $DIR/never-type-fallback-breaking.rs:28:1
23
23
|
24
24
LL | fn q() -> Option<()> {
25
25
| ^^^^^^^^^^^^^^^^^^^^
@@ -28,7 +28,7 @@ LL | fn q() -> Option<()> {
28
28
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/never-type-fallback.html>
29
29
= help: specify the types explicitly
30
30
note: in edition 2024, the requirement `!: Default` will fail
31
-
--> $DIR/never-type-fallback-breaking.rs:37:5
31
+
--> $DIR/never-type-fallback-breaking.rs:35:5
32
32
|
33
33
LL | deserialize()?;
34
34
| ^^^^^^^^^^^^^
@@ -37,8 +37,8 @@ help: use `()` annotations to avoid fallback changes
37
37
LL | deserialize::<()>()?;
38
38
| ++++++
39
39
40
-
warning: this function depends on never type fallback being `()`
41
-
--> $DIR/never-type-fallback-breaking.rs:47:1
40
+
error: this function depends on never type fallback being `()`
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/never-type-fallback.html>
48
48
= help: specify the types explicitly
49
49
note: in edition 2024, the requirement `(): From<!>` will fail
50
-
--> $DIR/never-type-fallback-breaking.rs:50:5
50
+
--> $DIR/never-type-fallback-breaking.rs:48:5
51
51
|
52
52
LL | help(1)?;
53
53
| ^^^^^^^
@@ -56,8 +56,8 @@ help: use `()` annotations to avoid fallback changes
56
56
LL | help::<(), _>(1)?;
57
57
| +++++++++
58
58
59
-
warning: this function depends on never type fallback being `()`
60
-
--> $DIR/never-type-fallback-breaking.rs:59:1
59
+
error: this function depends on never type fallback being `()`
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/never-type-fallback.html>
67
67
= help: specify the types explicitly
68
68
note: in edition 2024, the requirement `!: Default` will fail
69
-
--> $DIR/never-type-fallback-breaking.rs:62:19
69
+
--> $DIR/never-type-fallback-breaking.rs:60:19
70
70
|
71
71
LL | takes_apit(|| Default::default())?;
72
72
| ^^^^^^^^^^^^^^^^^^
@@ -75,8 +75,8 @@ help: use `()` annotations to avoid fallback changes
75
75
LL | takes_apit::<()>(|| Default::default())?;
76
76
| ++++++
77
77
78
-
warning: this function depends on never type fallback being `()`
79
-
--> $DIR/never-type-fallback-breaking.rs:73:1
78
+
error: this function depends on never type fallback being `()`
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/never-type-fallback.html>
86
86
= help: specify the types explicitly
87
87
note: in edition 2024, the requirement `!: Default` will fail
88
-
--> $DIR/never-type-fallback-breaking.rs:76:17
88
+
--> $DIR/never-type-fallback-breaking.rs:74:17
89
89
|
90
90
LL | takes_apit2(mk()?);
91
91
| ^^^^^
@@ -94,11 +94,11 @@ help: use `()` annotations to avoid fallback changes
warning: this function depends on never type fallback being `()`
101
-
--> $DIR/never-type-fallback-breaking.rs:18:1
100
+
error: this function depends on never type fallback being `()`
101
+
--> $DIR/never-type-fallback-breaking.rs:16:1
102
102
|
103
103
LL | fn m() {
104
104
| ^^^^^^
@@ -107,19 +107,19 @@ LL | fn m() {
107
107
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/never-type-fallback.html>
108
108
= help: specify the types explicitly
109
109
note: in edition 2024, the requirement `!: Default` will fail
110
-
--> $DIR/never-type-fallback-breaking.rs:22:17
110
+
--> $DIR/never-type-fallback-breaking.rs:20:17
111
111
|
112
112
LL | true => Default::default(),
113
113
| ^^^^^^^^^^^^^^^^^^
114
-
= note: `#[warn(dependency_on_unit_never_type_fallback)]` (part of `#[warn(rust_2024_compatibility)]`) on by default
114
+
= note: `#[deny(dependency_on_unit_never_type_fallback)]` (part of `#[deny(rust_2024_compatibility)]`) on by default
115
115
help: use `()` annotations to avoid fallback changes
116
116
|
117
117
LL | let x: () = match true {
118
118
| ++++
119
119
120
120
Future breakage diagnostic:
121
-
warning: this function depends on never type fallback being `()`
122
-
--> $DIR/never-type-fallback-breaking.rs:30:1
121
+
error: this function depends on never type fallback being `()`
122
+
--> $DIR/never-type-fallback-breaking.rs:28:1
123
123
|
124
124
LL | fn q() -> Option<()> {
125
125
| ^^^^^^^^^^^^^^^^^^^^
@@ -128,19 +128,19 @@ LL | fn q() -> Option<()> {
128
128
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/never-type-fallback.html>
129
129
= help: specify the types explicitly
130
130
note: in edition 2024, the requirement `!: Default` will fail
131
-
--> $DIR/never-type-fallback-breaking.rs:37:5
131
+
--> $DIR/never-type-fallback-breaking.rs:35:5
132
132
|
133
133
LL | deserialize()?;
134
134
| ^^^^^^^^^^^^^
135
-
= note: `#[warn(dependency_on_unit_never_type_fallback)]` (part of `#[warn(rust_2024_compatibility)]`) on by default
135
+
= note: `#[deny(dependency_on_unit_never_type_fallback)]` (part of `#[deny(rust_2024_compatibility)]`) on by default
136
136
help: use `()` annotations to avoid fallback changes
137
137
|
138
138
LL | deserialize::<()>()?;
139
139
| ++++++
140
140
141
141
Future breakage diagnostic:
142
-
warning: this function depends on never type fallback being `()`
143
-
--> $DIR/never-type-fallback-breaking.rs:47:1
142
+
error: this function depends on never type fallback being `()`
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/never-type-fallback.html>
150
150
= help: specify the types explicitly
151
151
note: in edition 2024, the requirement `(): From<!>` will fail
152
-
--> $DIR/never-type-fallback-breaking.rs:50:5
152
+
--> $DIR/never-type-fallback-breaking.rs:48:5
153
153
|
154
154
LL | help(1)?;
155
155
| ^^^^^^^
156
-
= note: `#[warn(dependency_on_unit_never_type_fallback)]` (part of `#[warn(rust_2024_compatibility)]`) on by default
156
+
= note: `#[deny(dependency_on_unit_never_type_fallback)]` (part of `#[deny(rust_2024_compatibility)]`) on by default
157
157
help: use `()` annotations to avoid fallback changes
158
158
|
159
159
LL | help::<(), _>(1)?;
160
160
| +++++++++
161
161
162
162
Future breakage diagnostic:
163
-
warning: this function depends on never type fallback being `()`
164
-
--> $DIR/never-type-fallback-breaking.rs:59:1
163
+
error: this function depends on never type fallback being `()`
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/never-type-fallback.html>
171
171
= help: specify the types explicitly
172
172
note: in edition 2024, the requirement `!: Default` will fail
173
-
--> $DIR/never-type-fallback-breaking.rs:62:19
173
+
--> $DIR/never-type-fallback-breaking.rs:60:19
174
174
|
175
175
LL | takes_apit(|| Default::default())?;
176
176
| ^^^^^^^^^^^^^^^^^^
177
-
= note: `#[warn(dependency_on_unit_never_type_fallback)]` (part of `#[warn(rust_2024_compatibility)]`) on by default
177
+
= note: `#[deny(dependency_on_unit_never_type_fallback)]` (part of `#[deny(rust_2024_compatibility)]`) on by default
178
178
help: use `()` annotations to avoid fallback changes
179
179
|
180
180
LL | takes_apit::<()>(|| Default::default())?;
181
181
| ++++++
182
182
183
183
Future breakage diagnostic:
184
-
warning: this function depends on never type fallback being `()`
185
-
--> $DIR/never-type-fallback-breaking.rs:73:1
184
+
error: this function depends on never type fallback being `()`
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/never-type-fallback.html>
192
192
= help: specify the types explicitly
193
193
note: in edition 2024, the requirement `!: Default` will fail
194
-
--> $DIR/never-type-fallback-breaking.rs:76:17
194
+
--> $DIR/never-type-fallback-breaking.rs:74:17
195
195
|
196
196
LL | takes_apit2(mk()?);
197
197
| ^^^^^
198
-
= note: `#[warn(dependency_on_unit_never_type_fallback)]` (part of `#[warn(rust_2024_compatibility)]`) on by default
198
+
= note: `#[deny(dependency_on_unit_never_type_fallback)]` (part of `#[deny(rust_2024_compatibility)]`) on by default
199
199
help: use `()` annotations to avoid fallback changes
= help: you might have intended to use the type `()` here instead
9
9
10
10
error[E0277]: the trait bound `!: Default` is not satisfied
11
-
--> $DIR/never-type-fallback-breaking.rs:37:5
11
+
--> $DIR/never-type-fallback-breaking.rs:35:5
12
12
|
13
13
LL | deserialize()?;
14
14
| ^^^^^^^^^^^^^ the trait `Default` is not implemented for `!`
15
15
|
16
16
= note: this error might have been caused by changes to Rust's type-inference algorithm (see issue #48950 <https://github.com/rust-lang/rust/issues/48950> for more information)
17
17
= help: you might have intended to use the type `()` here instead
18
18
note: required by a bound in `deserialize`
19
-
--> $DIR/never-type-fallback-breaking.rs:33:23
19
+
--> $DIR/never-type-fallback-breaking.rs:31:23
20
20
|
21
21
LL | fn deserialize<T: Default>() -> Option<T> {
22
22
| ^^^^^^^ required by this bound in `deserialize`
23
23
24
24
error[E0277]: the trait bound `(): From<!>` is not satisfied
25
-
--> $DIR/never-type-fallback-breaking.rs:50:5
25
+
--> $DIR/never-type-fallback-breaking.rs:48:5
26
26
|
27
27
LL | help(1)?;
28
28
| ^^^^^^^ the trait `From<!>` is not implemented for `()`
= help: you might have intended to use the type `()` here instead
55
55
56
56
error[E0277]: the trait bound `!: Default` is not satisfied
57
-
--> $DIR/never-type-fallback-breaking.rs:76:17
57
+
--> $DIR/never-type-fallback-breaking.rs:74:17
58
58
|
59
59
LL | takes_apit2(mk()?);
60
60
| ----------- ^^^^^ the trait `Default` is not implemented for `!`
@@ -64,7 +64,7 @@ LL | takes_apit2(mk()?);
64
64
= note: this error might have been caused by changes to Rust's type-inference algorithm (see issue #48950 <https://github.com/rust-lang/rust/issues/48950> for more information)
65
65
= help: you might have intended to use the type `()` here instead
0 commit comments