File tree 2 files changed +5
-5
lines changed
src/test/ui/never-fallback
2 files changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -10,15 +10,15 @@ fn unconstrained_return<T>() -> Result<T, String> {
10
10
}
11
11
12
12
fn foo ( ) {
13
- let a = || {
14
- match unconstrained_return :: < _ > ( ) { //~ ERROR Fallback to `!` may introduce undefined behavior
13
+ let a = || {
14
+ match unconstrained_return :: < _ > ( ) { //~ ERROR Fallback to `!` may introduce undefined
15
15
Ok ( x) => x, // `x` has type `_`, which is unconstrained
16
16
Err ( s) => panic ! ( s) , // … except for unifying with the type of `panic!()`
17
17
// so that both `match` arms have the same type.
18
18
// Therefore `_` resolves to `!` and we "return" an `Ok(!)` value.
19
19
}
20
20
} ;
21
-
21
+
22
22
let cast: & dyn FnOnce ( ) -> _ = & a;
23
23
println ! ( "Return type: {:?}" , get_type( cast) ) ;
24
24
}
Original file line number Diff line number Diff line change @@ -10,15 +10,15 @@ fn unconstrained_return<T>() -> Result<T, String> {
10
10
}
11
11
12
12
fn foo ( ) {
13
- let a = || {
13
+ let a = || {
14
14
match unconstrained_return ( ) { //~ ERROR Fallback to `!` may introduce undefined behavior
15
15
Ok ( x) => x, // `x` has type `_`, which is unconstrained
16
16
Err ( s) => panic ! ( s) , // … except for unifying with the type of `panic!()`
17
17
// so that both `match` arms have the same type.
18
18
// Therefore `_` resolves to `!` and we "return" an `Ok(!)` value.
19
19
}
20
20
} ;
21
-
21
+
22
22
let cast: & dyn FnOnce ( ) -> _ = & a;
23
23
println ! ( "Return type: {:?}" , get_type( cast) ) ;
24
24
}
You can’t perform that action at this time.
0 commit comments