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
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`.
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`.
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+
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+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
error[E0506]: cannot assign to `i` because it is borrowed
2+
--> $DIR/try-block-maybe-bad-lifetime.rs:27:9
3+
|
4+
LL | &i
5+
| -- borrow of `i` occurs here
6+
LL | };
7+
LL | i = 0; //~ ERROR cannot assign to `i` because it is borrowed
8+
| ^^^^^ assignment to borrowed `i` occurs here
9+
LL | let _ = i;
10+
LL | do_something_with(x);
11+
| - borrow later used here
12+
13+
error[E0382]: borrow of moved value: `x`
14+
--> $DIR/try-block-maybe-bad-lifetime.rs:38:24
15+
|
16+
LL | ::std::mem::drop(x);
17+
| - value moved here
18+
LL | };
19+
LL | println!("{}", x); //~ ERROR borrow of moved value: `x`
20+
| ^ value borrowed here after move
21+
|
22+
= note: move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait
23+
24+
error[E0506]: cannot assign to `i` because it is borrowed
25+
--> $DIR/try-block-maybe-bad-lifetime.rs:50:9
26+
|
27+
LL | j = &i;
28+
| -- borrow of `i` occurs here
29+
LL | };
30+
LL | i = 0; //~ ERROR cannot assign to `i` because it is borrowed
31+
| ^^^^^ assignment to borrowed `i` occurs here
32+
LL | let _ = i;
33+
LL | do_something_with(j);
34+
| - borrow later used here
35+
36+
error: aborting due to 3 previous errors
37+
38+
Some errors occurred: E0382, E0506.
39+
For more information about an error, try `rustc --explain E0382`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error[E0381]: borrow of possibly uninitialized variable: `cfg_res`
2+
--> $DIR/try-block-opt-init.rs:25:5
3+
|
4+
LL | assert_eq!(cfg_res, 5); //~ ERROR borrow of possibly uninitialized variable: `cfg_res`
5+
| ^^^^^^^^^^^^^^^^^^^^^^^ use of possibly uninitialized `cfg_res`
6+
|
7+
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
8+
9+
error: aborting due to previous error
10+
11+
For more information about this error, try `rustc --explain E0381`.

0 commit comments

Comments
 (0)