forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnever-type-fallback-breaking.e2021.fixed
52 lines (45 loc) · 1.6 KB
/
never-type-fallback-breaking.e2021.fixed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//@ revisions: e2021 e2024
//
//@[e2021] edition: 2021
//@[e2024] edition: 2024
//@[e2024] compile-flags: -Zunstable-options
//
//@[e2021] run-pass
//@[e2021] run-rustfix
//@[e2024] check-fail
fn main() {
m();
q();
let _ = meow();
}
fn m() {
//[e2021]~^ this function depends on never type fallback being `()`
//[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!
let x: () = match true {
true => Default::default(),
//[e2024]~^ error: the trait bound `!: Default` is not satisfied
false => panic!("..."),
};
dbg!(x);
}
fn q() -> Option<()> {
//[e2021]~^ this function depends on never type fallback being `()`
//[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!
fn deserialize<T: Default>() -> Option<T> {
Some(T::default())
}
deserialize::<()>()?;
//[e2024]~^ error: the trait bound `!: Default` is not satisfied
None
}
// Make sure we turbofish the right argument
fn help<'a: 'a, T: Into<()>, U>(_: U) -> Result<T, ()> {
Err(())
}
fn meow() -> Result<(), ()> {
//[e2021]~^ this function depends on never type fallback being `()`
//[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!
help::<(), _>(1)?;
//[e2024]~^ error: the trait bound `(): From<!>` is not satisfied
Ok(())
}