File tree Expand file tree Collapse file tree 2 files changed +5
-5
lines changed
src/test/ui/never-fallback Expand file tree Collapse file tree 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> {
1010}
1111
1212fn 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
1515 Ok ( x) => x, // `x` has type `_`, which is unconstrained
1616 Err ( s) => panic ! ( s) , // … except for unifying with the type of `panic!()`
1717 // so that both `match` arms have the same type.
1818 // Therefore `_` resolves to `!` and we "return" an `Ok(!)` value.
1919 }
2020 } ;
21-
21+
2222 let cast: & dyn FnOnce ( ) -> _ = & a;
2323 println ! ( "Return type: {:?}" , get_type( cast) ) ;
2424}
Original file line number Diff line number Diff line change @@ -10,15 +10,15 @@ fn unconstrained_return<T>() -> Result<T, String> {
1010}
1111
1212fn foo ( ) {
13- let a = || {
13+ let a = || {
1414 match unconstrained_return ( ) { //~ ERROR Fallback to `!` may introduce undefined behavior
1515 Ok ( x) => x, // `x` has type `_`, which is unconstrained
1616 Err ( s) => panic ! ( s) , // … except for unifying with the type of `panic!()`
1717 // so that both `match` arms have the same type.
1818 // Therefore `_` resolves to `!` and we "return" an `Ok(!)` value.
1919 }
2020 } ;
21-
21+
2222 let cast: & dyn FnOnce ( ) -> _ = & a;
2323 println ! ( "Return type: {:?}" , get_type( cast) ) ;
2424}
You can’t perform that action at this time.
0 commit comments