Skip to content

Commit e428085

Browse files
committed
Make a try-blocks folder for all the try{} UI tests
1 parent 5cf387c commit e428085

16 files changed

+168
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
error[E0597]: `my_string` does not live long enough
2+
--> $DIR/try-block-bad-lifetime.rs:25:33
3+
|
4+
LL | let my_str: & str = & my_string;
5+
| ^^^^^^^^^^^ borrowed value does not live long enough
6+
...
7+
LL | };
8+
| - `my_string` dropped here while still borrowed
9+
LL | do_something_with(result);
10+
| ------ borrow later used here
11+
12+
error[E0506]: cannot assign to `i` because it is borrowed
13+
--> $DIR/try-block-bad-lifetime.rs:39:13
14+
|
15+
LL | let k = &mut i;
16+
| ------ borrow of `i` occurs here
17+
...
18+
LL | i = 10; //~ ERROR cannot assign to `i` because it is borrowed
19+
| ^^^^^^ assignment to borrowed `i` occurs here
20+
LL | };
21+
LL | ::std::mem::drop(k); //~ ERROR use of moved value: `k`
22+
| - borrow later used here
23+
24+
error[E0382]: use of moved value: `k`
25+
--> $DIR/try-block-bad-lifetime.rs:41:26
26+
|
27+
LL | Err(k) ?;
28+
| - value moved here
29+
...
30+
LL | ::std::mem::drop(k); //~ ERROR use of moved value: `k`
31+
| ^ value used here after move
32+
|
33+
= note: move occurs because `k` has type `&mut i32`, which does not implement the `Copy` trait
34+
35+
error[E0506]: cannot assign to `i` because it is borrowed
36+
--> $DIR/try-block-bad-lifetime.rs:42:9
37+
|
38+
LL | let k = &mut i;
39+
| ------ borrow of `i` occurs here
40+
...
41+
LL | i = 40; //~ ERROR cannot assign to `i` because it is borrowed
42+
| ^^^^^^ assignment to borrowed `i` occurs here
43+
LL |
44+
LL | let i_ptr = if let Err(i_ptr) = j { i_ptr } else { panic ! ("") };
45+
| - borrow later used here
46+
47+
error: aborting due to 4 previous errors
48+
49+
Some errors occurred: E0382, E0506, E0597.
50+
For more information about an error, try `rustc --explain E0382`.
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
error[E0277]: the trait bound `i32: std::convert::From<&str>` is not satisfied
2+
--> $DIR/try-block-bad-type.rs:17:9
3+
|
4+
LL | Err("")?; //~ ERROR the trait bound `i32: std::convert::From<&str>` is not satisfied
5+
| ^^^^^^^^ the trait `std::convert::From<&str>` is not implemented for `i32`
6+
|
7+
= help: the following implementations were found:
8+
<i32 as std::convert::From<bool>>
9+
<i32 as std::convert::From<i16>>
10+
<i32 as std::convert::From<i8>>
11+
<i32 as std::convert::From<u16>>
12+
<i32 as std::convert::From<u8>>
13+
= note: required by `std::convert::From::from`
14+
15+
error[E0271]: type mismatch resolving `<std::result::Result<i32, i32> as std::ops::Try>::Ok == &str`
16+
--> $DIR/try-block-bad-type.rs:22:9
17+
|
18+
LL | "" //~ ERROR type mismatch
19+
| ^^ expected i32, found &str
20+
|
21+
= note: expected type `i32`
22+
found type `&str`
23+
24+
error[E0271]: type mismatch resolving `<std::result::Result<i32, i32> as std::ops::Try>::Ok == ()`
25+
--> $DIR/try-block-bad-type.rs:25:39
26+
|
27+
LL | let res: Result<i32, i32> = try { }; //~ ERROR type mismatch
28+
| ^ expected i32, found ()
29+
|
30+
= note: expected type `i32`
31+
found type `()`
32+
33+
error[E0277]: the trait bound `(): std::ops::Try` is not satisfied
34+
--> $DIR/try-block-bad-type.rs:27:23
35+
|
36+
LL | let res: () = try { }; //~ the trait bound `(): std::ops::Try` is not satisfied
37+
| ^^^ the trait `std::ops::Try` is not implemented for `()`
38+
|
39+
= note: required by `std::ops::Try::from_ok`
40+
41+
error[E0277]: the trait bound `i32: std::ops::Try` is not satisfied
42+
--> $DIR/try-block-bad-type.rs:29:24
43+
|
44+
LL | let res: i32 = try { 5 }; //~ ERROR the trait bound `i32: std::ops::Try` is not satisfied
45+
| ^^^^^ the trait `std::ops::Try` is not implemented for `i32`
46+
|
47+
= note: required by `std::ops::Try::from_ok`
48+
49+
error: aborting due to 5 previous errors
50+
51+
Some errors occurred: E0271, E0277.
52+
For more information about an error, try `rustc --explain E0271`.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: expected expression, found reserved keyword `try`
2+
--> $DIR/try-block-in-match.rs:16:11
3+
|
4+
LL | match try { false } { _ => {} } //~ ERROR expected expression, found reserved keyword `try`
5+
| ^^^ expected expression
6+
7+
error: aborting due to previous error
8+
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: expected expression, found reserved keyword `try`
2+
--> $DIR/try-block-in-while.rs:16:11
3+
|
4+
LL | while try { false } {} //~ ERROR expected expression, found reserved keyword `try`
5+
| ^^^ expected expression
6+
7+
error: aborting due to previous error
8+

0 commit comments

Comments
 (0)