Skip to content

Commit cb5318d

Browse files
committed
stop using "nofallback" revision terminology
1 parent 3f606fa commit cb5318d

5 files changed

+93
-12
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
error: this function depends on never type fallback being `()`
2+
--> $DIR/diverging-fallback-unconstrained-return.rs:26:1
3+
|
4+
LL | fn main() {
5+
| ^^^^^^^^^
6+
|
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!
8+
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2024/never-type-fallback.html>
9+
= help: specify the types explicitly
10+
note: in edition 2024, the requirement `!: UnitReturn` will fail
11+
--> $DIR/diverging-fallback-unconstrained-return.rs:37:23
12+
|
13+
LL | let _ = if true { unconstrained_return() } else { panic!() };
14+
| ^^^^^^^^^^^^^^^^^^^^^^
15+
= note: `#[deny(dependency_on_unit_never_type_fallback)]` (part of `#[deny(rust_2024_compatibility)]`) on by default
16+
help: use `()` annotations to avoid fallback changes
17+
|
18+
LL | let _: () = if true { unconstrained_return() } else { panic!() };
19+
| ++++
20+
21+
error: aborting due to 1 previous error
22+
23+
Future incompatibility report: Future breakage diagnostic:
24+
error: this function depends on never type fallback being `()`
25+
--> $DIR/diverging-fallback-unconstrained-return.rs:26: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/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:37:23
35+
|
36+
LL | let _ = if true { unconstrained_return() } else { panic!() };
37+
| ^^^^^^^^^^^^^^^^^^^^^^
38+
= note: `#[deny(dependency_on_unit_never_type_fallback)]` (part of `#[deny(rust_2024_compatibility)]`) on by default
39+
help: use `()` annotations to avoid fallback changes
40+
|
41+
LL | let _: () = if true { unconstrained_return() } else { panic!() };
42+
| ++++
43+
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
error[E0277]: the trait bound `!: UnitReturn` is not satisfied
2+
--> $DIR/diverging-fallback-unconstrained-return.rs:37:23
3+
|
4+
LL | let _ = if true { unconstrained_return() } else { panic!() };
5+
| ^^^^^^^^^^^^^^^^^^^^^^ the trait `UnitReturn` is not implemented for `!`
6+
|
7+
help: the following other types implement trait `UnitReturn`
8+
--> $DIR/diverging-fallback-unconstrained-return.rs:15:1
9+
|
10+
LL | impl UnitReturn for i32 {}
11+
| ^^^^^^^^^^^^^^^^^^^^^^^ `i32`
12+
LL | impl UnitReturn for () {}
13+
| ^^^^^^^^^^^^^^^^^^^^^^ `()`
14+
= note: this error might have been caused by changes to Rust's type-inference algorithm (see issue #148922 <https://github.com/rust-lang/rust/issues/148922> for more information)
15+
= help: you might have intended to use the type `()` here instead
16+
note: required by a bound in `unconstrained_return`
17+
--> $DIR/diverging-fallback-unconstrained-return.rs:18:28
18+
|
19+
LL | fn unconstrained_return<T: UnitReturn>() -> T {
20+
| ^^^^^^^^^^ required by this bound in `unconstrained_return`
21+
22+
error: aborting due to 1 previous error
23+
24+
For more information about this error, try `rustc --explain E0277`.

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
// in the objc crate, where changing the fallback from `!` to `()`
55
// resulted in unsoundness.
66
//
7-
//@ revisions: nofallback fallback
8-
//@[fallback] edition: 2024
7+
//@ revisions: e2021 e2024
8+
//@[e2024] edition: 2024
99

1010
#![expect(unit_bindings)]
1111

@@ -24,8 +24,8 @@ fn unconstrained_return<T: UnitReturn>() -> T {
2424
}
2525

2626
fn main() {
27-
//[nofallback]~^ error: this function depends on never type fallback being `()`
28-
//[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!
27+
//[e2021]~^ error: this function depends on never type fallback being `()`
28+
//[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!
2929

3030
// In Ye Olde Days, the `T` parameter of `unconstrained_return`
3131
// winds up "entangled" with the `!` type that results from
@@ -34,5 +34,5 @@ fn main() {
3434
// idea was to change that fallback to `!`, but that would have resulted
3535
// in this code no longer compiling (or worse, in some cases it injected
3636
// unsound results).
37-
let _ = if true { unconstrained_return() } else { panic!() }; //[fallback]~ error: the trait bound `!: UnitReturn` is not satisfied
37+
let _ = if true { unconstrained_return() } else { panic!() }; //[e2024]~ error: the trait bound `!: UnitReturn` is not satisfied
3838
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error[E0271]: expected `{closure@fallback-closure-wrap.rs:16:40}` to return `()`, but it returns `!`
2+
--> $DIR/fallback-closure-wrap.rs:17:9
3+
|
4+
LL | let error = Closure::wrap(Box::new(move || {
5+
| ------- this closure
6+
LL | panic!("Can't connect to server.");
7+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found `!`
8+
|
9+
= note: expected unit type `()`
10+
found type `!`
11+
= note: required for the cast from `Box<{closure@$DIR/fallback-closure-wrap.rs:16:40: 16:47}>` to `Box<dyn FnMut()>`
12+
13+
error: aborting due to 1 previous error
14+
15+
For more information about this error, try `rustc --explain E0271`.

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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
11
// This is a minified example from Crater breakage observed when attempting to
22
// stabilize never type, nstoddard/webgl-gui @ 22f0169f.
33
//
4-
// This particular test case currently fails as the inference to `()` rather
5-
// than `!` happens as a result of an `as` cast, which is not currently tracked.
64
// Crater did not find many cases of this occurring, but it is included for
75
// awareness.
86
//
9-
//@ revisions: nofallback fallback
10-
//@[fallback] edition: 2024
11-
//@[nofallback] check-pass
12-
//@[fallback] check-fail
7+
//@ revisions: e2021 e2024
8+
//@[e2021] edition: 2021
9+
//@[e2024] edition: 2024
10+
//
11+
//@[e2021] check-pass
1312

1413
use std::marker::PhantomData;
1514

1615
fn main() {
1716
let error = Closure::wrap(Box::new(move || {
1817
panic!("Can't connect to server.");
19-
//[fallback]~^ ERROR to return `()`, but it returns `!`
18+
//[e2024]~^ ERROR to return `()`, but it returns `!`
2019
}) as Box<dyn FnMut()>);
2120
}
2221

0 commit comments

Comments
 (0)