Make a try-blocks folder for all the try{} UI tests

This commit is contained in:
Scott McMurray 2018-08-12 20:05:29 -07:00
parent 5cf387c4f4
commit e4280852ae
16 changed files with 168 additions and 0 deletions

View File

@ -0,0 +1,50 @@
error[E0597]: `my_string` does not live long enough
--> $DIR/try-block-bad-lifetime.rs:25:33
|
LL | let my_str: & str = & my_string;
| ^^^^^^^^^^^ borrowed value does not live long enough
...
LL | };
| - `my_string` dropped here while still borrowed
LL | do_something_with(result);
| ------ borrow later used here
error[E0506]: cannot assign to `i` because it is borrowed
--> $DIR/try-block-bad-lifetime.rs:39:13
|
LL | let k = &mut i;
| ------ borrow of `i` occurs here
...
LL | i = 10; //~ ERROR cannot assign to `i` because it is borrowed
| ^^^^^^ assignment to borrowed `i` occurs here
LL | };
LL | ::std::mem::drop(k); //~ ERROR use of moved value: `k`
| - borrow later used here
error[E0382]: use of moved value: `k`
--> $DIR/try-block-bad-lifetime.rs:41:26
|
LL | Err(k) ?;
| - value moved here
...
LL | ::std::mem::drop(k); //~ ERROR use of moved value: `k`
| ^ value used here after move
|
= note: move occurs because `k` has type `&mut i32`, which does not implement the `Copy` trait
error[E0506]: cannot assign to `i` because it is borrowed
--> $DIR/try-block-bad-lifetime.rs:42:9
|
LL | let k = &mut i;
| ------ borrow of `i` occurs here
...
LL | i = 40; //~ ERROR cannot assign to `i` because it is borrowed
| ^^^^^^ assignment to borrowed `i` occurs here
LL |
LL | let i_ptr = if let Err(i_ptr) = j { i_ptr } else { panic ! ("") };
| - borrow later used here
error: aborting due to 4 previous errors
Some errors occurred: E0382, E0506, E0597.
For more information about an error, try `rustc --explain E0382`.

View File

@ -0,0 +1,52 @@
error[E0277]: the trait bound `i32: std::convert::From<&str>` is not satisfied
--> $DIR/try-block-bad-type.rs:17:9
|
LL | Err("")?; //~ ERROR the trait bound `i32: std::convert::From<&str>` is not satisfied
| ^^^^^^^^ the trait `std::convert::From<&str>` is not implemented for `i32`
|
= help: the following implementations were found:
<i32 as std::convert::From<bool>>
<i32 as std::convert::From<i16>>
<i32 as std::convert::From<i8>>
<i32 as std::convert::From<u16>>
<i32 as std::convert::From<u8>>
= note: required by `std::convert::From::from`
error[E0271]: type mismatch resolving `<std::result::Result<i32, i32> as std::ops::Try>::Ok == &str`
--> $DIR/try-block-bad-type.rs:22:9
|
LL | "" //~ ERROR type mismatch
| ^^ expected i32, found &str
|
= note: expected type `i32`
found type `&str`
error[E0271]: type mismatch resolving `<std::result::Result<i32, i32> as std::ops::Try>::Ok == ()`
--> $DIR/try-block-bad-type.rs:25:39
|
LL | let res: Result<i32, i32> = try { }; //~ ERROR type mismatch
| ^ expected i32, found ()
|
= note: expected type `i32`
found type `()`
error[E0277]: the trait bound `(): std::ops::Try` is not satisfied
--> $DIR/try-block-bad-type.rs:27:23
|
LL | let res: () = try { }; //~ the trait bound `(): std::ops::Try` is not satisfied
| ^^^ the trait `std::ops::Try` is not implemented for `()`
|
= note: required by `std::ops::Try::from_ok`
error[E0277]: the trait bound `i32: std::ops::Try` is not satisfied
--> $DIR/try-block-bad-type.rs:29:24
|
LL | let res: i32 = try { 5 }; //~ ERROR the trait bound `i32: std::ops::Try` is not satisfied
| ^^^^^ the trait `std::ops::Try` is not implemented for `i32`
|
= note: required by `std::ops::Try::from_ok`
error: aborting due to 5 previous errors
Some errors occurred: E0271, E0277.
For more information about an error, try `rustc --explain E0271`.

View File

@ -0,0 +1,8 @@
error: expected expression, found reserved keyword `try`
--> $DIR/try-block-in-match.rs:16:11
|
LL | match try { false } { _ => {} } //~ ERROR expected expression, found reserved keyword `try`
| ^^^ expected expression
error: aborting due to previous error

View File

@ -0,0 +1,8 @@
error: expected expression, found reserved keyword `try`
--> $DIR/try-block-in-while.rs:16:11
|
LL | while try { false } {} //~ ERROR expected expression, found reserved keyword `try`
| ^^^ expected expression
error: aborting due to previous error

View File

@ -0,0 +1,39 @@
error[E0506]: cannot assign to `i` because it is borrowed
--> $DIR/try-block-maybe-bad-lifetime.rs:27:9
|
LL | &i
| -- borrow of `i` occurs here
LL | };
LL | i = 0; //~ ERROR cannot assign to `i` because it is borrowed
| ^^^^^ assignment to borrowed `i` occurs here
LL | let _ = i;
LL | do_something_with(x);
| - borrow later used here
error[E0382]: borrow of moved value: `x`
--> $DIR/try-block-maybe-bad-lifetime.rs:38:24
|
LL | ::std::mem::drop(x);
| - value moved here
LL | };
LL | println!("{}", x); //~ ERROR borrow of moved value: `x`
| ^ value borrowed here after move
|
= note: move occurs because `x` has type `std::string::String`, which does not implement the `Copy` trait
error[E0506]: cannot assign to `i` because it is borrowed
--> $DIR/try-block-maybe-bad-lifetime.rs:50:9
|
LL | j = &i;
| -- borrow of `i` occurs here
LL | };
LL | i = 0; //~ ERROR cannot assign to `i` because it is borrowed
| ^^^^^ assignment to borrowed `i` occurs here
LL | let _ = i;
LL | do_something_with(j);
| - borrow later used here
error: aborting due to 3 previous errors
Some errors occurred: E0382, E0506.
For more information about an error, try `rustc --explain E0382`.

View File

@ -0,0 +1,11 @@
error[E0381]: borrow of possibly uninitialized variable: `cfg_res`
--> $DIR/try-block-opt-init.rs:25:5
|
LL | assert_eq!(cfg_res, 5); //~ ERROR borrow of possibly uninitialized variable: `cfg_res`
| ^^^^^^^^^^^^^^^^^^^^^^^ use of possibly uninitialized `cfg_res`
|
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error: aborting due to previous error
For more information about this error, try `rustc --explain E0381`.