File tree 6 files changed +20
-12
lines changed
6 files changed +20
-12
lines changed Original file line number Diff line number Diff line change 1
1
// -*- rust -*-
2
2
// Tests that a function with a ! annotation always actually fails
3
- // error-pattern: some control paths may return
4
3
5
- fn bad_bang ( i : uint ) -> ! { ret 7 u; }
4
+ fn bad_bang ( i : uint ) -> ! {
5
+ ret 7 u;
6
+ //!^ ERROR expected `_|_` but found `uint` (types differ)
7
+ }
6
8
7
9
fn main ( ) { bad_bang ( 5 u) ; }
Original file line number Diff line number Diff line change 1
1
// -*- rust -*-
2
2
// Tests that a function with a ! annotation always actually fails
3
- // error-pattern: may return to the caller
4
3
5
- fn bad_bang ( i : uint ) -> ! { if i < 0 u { } else { fail; } }
4
+ fn bad_bang ( i : uint ) -> ! {
5
+ if i < 0 u { } else { fail; }
6
+ //!^ ERROR expected `_|_` but found `()` (types differ)
7
+ }
6
8
7
9
fn main ( ) { bad_bang ( 5 u) ; }
Original file line number Diff line number Diff line change 1
- // error-pattern: some control paths may return
2
- fn f ( ) -> ! { 3 }
1
+ fn f ( ) -> ! {
2
+ 3 //! ERROR expected `_|_` but found `int` (types differ)
3
+ }
3
4
fn main ( ) { }
Original file line number Diff line number Diff line change 1
- // error-pattern:in non-returning function f, some control paths may return
2
1
fn g ( ) -> ! { fail; }
3
- fn f ( ) -> ! { ret 42 ; g ( ) ; }
2
+ fn f ( ) -> ! {
3
+ ret 42 ; //! ERROR expected `_|_` but found `int` (types differ)
4
+ g ( ) ; //! WARNING unreachable statement
5
+ }
4
6
fn main ( ) { }
Original file line number Diff line number Diff line change 1
- // error-pattern:in non-returning function f, some control paths may return
2
- fn f ( ) -> ! { ret 42 ; fail; }
1
+ fn f ( ) -> ! {
2
+ ret 42 ; //! ERROR expected `_|_` but found `int` (types differ)
3
+ fail; //! WARNING unreachable statement
4
+ }
3
5
fn main ( ) { }
Original file line number Diff line number Diff line change 1
- // error-pattern:some control paths may return
2
1
/* Make sure a loop{} with a break in it can't be
3
2
the tailexpr in the body of a diverging function */
4
3
fn forever ( ) -> ! {
5
4
loop {
6
5
break ;
7
6
}
8
- ret 42 ;
7
+ ret 42 ; //! ERROR expected `_|_` but found `int` (types differ)
9
8
}
10
9
11
10
fn main ( ) {
You can’t perform that action at this time.
0 commit comments