From e4280852ae8ff32494c1ca6e4fe76e9e4a15dd31 Mon Sep 17 00:00:00 2001 From: Scott McMurray Date: Sun, 12 Aug 2018 20:05:29 -0700 Subject: [PATCH] Make a try-blocks folder for all the try{} UI tests --- .../try-block}/try-block-bad-lifetime.rs | 0 .../try-block/try-block-bad-lifetime.stderr | 50 ++++++++++++++++++ .../try-block}/try-block-bad-type.rs | 0 .../ui/try-block/try-block-bad-type.stderr | 52 +++++++++++++++++++ .../try-block-in-edition2015.rs | 0 .../try-block-in-edition2015.stderr | 0 .../try-block}/try-block-in-match.rs | 0 .../ui/try-block/try-block-in-match.stderr | 8 +++ .../try-block}/try-block-in-while.rs | 0 .../ui/try-block/try-block-in-while.stderr | 8 +++ .../try-block-maybe-bad-lifetime.rs | 0 .../try-block-maybe-bad-lifetime.stderr | 39 ++++++++++++++ .../try-block}/try-block-opt-init.rs | 0 .../ui/try-block/try-block-opt-init.stderr | 11 ++++ .../{ => try-block}/try-block-type-error.rs | 0 .../try-block-type-error.stderr | 0 16 files changed, 168 insertions(+) rename src/test/{compile-fail => ui/try-block}/try-block-bad-lifetime.rs (100%) create mode 100644 src/test/ui/try-block/try-block-bad-lifetime.stderr rename src/test/{compile-fail => ui/try-block}/try-block-bad-type.rs (100%) create mode 100644 src/test/ui/try-block/try-block-bad-type.stderr rename src/test/ui/{ => try-block}/try-block-in-edition2015.rs (100%) rename src/test/ui/{ => try-block}/try-block-in-edition2015.stderr (100%) rename src/test/{compile-fail => ui/try-block}/try-block-in-match.rs (100%) create mode 100644 src/test/ui/try-block/try-block-in-match.stderr rename src/test/{compile-fail => ui/try-block}/try-block-in-while.rs (100%) create mode 100644 src/test/ui/try-block/try-block-in-while.stderr rename src/test/{compile-fail => ui/try-block}/try-block-maybe-bad-lifetime.rs (100%) create mode 100644 src/test/ui/try-block/try-block-maybe-bad-lifetime.stderr rename src/test/{compile-fail => ui/try-block}/try-block-opt-init.rs (100%) create mode 100644 src/test/ui/try-block/try-block-opt-init.stderr rename src/test/ui/{ => try-block}/try-block-type-error.rs (100%) rename src/test/ui/{ => try-block}/try-block-type-error.stderr (100%) diff --git a/src/test/compile-fail/try-block-bad-lifetime.rs b/src/test/ui/try-block/try-block-bad-lifetime.rs similarity index 100% rename from src/test/compile-fail/try-block-bad-lifetime.rs rename to src/test/ui/try-block/try-block-bad-lifetime.rs diff --git a/src/test/ui/try-block/try-block-bad-lifetime.stderr b/src/test/ui/try-block/try-block-bad-lifetime.stderr new file mode 100644 index 000000000000..36c89faf5a2c --- /dev/null +++ b/src/test/ui/try-block/try-block-bad-lifetime.stderr @@ -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`. diff --git a/src/test/compile-fail/try-block-bad-type.rs b/src/test/ui/try-block/try-block-bad-type.rs similarity index 100% rename from src/test/compile-fail/try-block-bad-type.rs rename to src/test/ui/try-block/try-block-bad-type.rs diff --git a/src/test/ui/try-block/try-block-bad-type.stderr b/src/test/ui/try-block/try-block-bad-type.stderr new file mode 100644 index 000000000000..159e43e13e40 --- /dev/null +++ b/src/test/ui/try-block/try-block-bad-type.stderr @@ -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: + > + > + > + > + > + = note: required by `std::convert::From::from` + +error[E0271]: type mismatch resolving ` 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 ` as std::ops::Try>::Ok == ()` + --> $DIR/try-block-bad-type.rs:25:39 + | +LL | let res: Result = 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`. diff --git a/src/test/ui/try-block-in-edition2015.rs b/src/test/ui/try-block/try-block-in-edition2015.rs similarity index 100% rename from src/test/ui/try-block-in-edition2015.rs rename to src/test/ui/try-block/try-block-in-edition2015.rs diff --git a/src/test/ui/try-block-in-edition2015.stderr b/src/test/ui/try-block/try-block-in-edition2015.stderr similarity index 100% rename from src/test/ui/try-block-in-edition2015.stderr rename to src/test/ui/try-block/try-block-in-edition2015.stderr diff --git a/src/test/compile-fail/try-block-in-match.rs b/src/test/ui/try-block/try-block-in-match.rs similarity index 100% rename from src/test/compile-fail/try-block-in-match.rs rename to src/test/ui/try-block/try-block-in-match.rs diff --git a/src/test/ui/try-block/try-block-in-match.stderr b/src/test/ui/try-block/try-block-in-match.stderr new file mode 100644 index 000000000000..f07d23885aca --- /dev/null +++ b/src/test/ui/try-block/try-block-in-match.stderr @@ -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 + diff --git a/src/test/compile-fail/try-block-in-while.rs b/src/test/ui/try-block/try-block-in-while.rs similarity index 100% rename from src/test/compile-fail/try-block-in-while.rs rename to src/test/ui/try-block/try-block-in-while.rs diff --git a/src/test/ui/try-block/try-block-in-while.stderr b/src/test/ui/try-block/try-block-in-while.stderr new file mode 100644 index 000000000000..36577d784b83 --- /dev/null +++ b/src/test/ui/try-block/try-block-in-while.stderr @@ -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 + diff --git a/src/test/compile-fail/try-block-maybe-bad-lifetime.rs b/src/test/ui/try-block/try-block-maybe-bad-lifetime.rs similarity index 100% rename from src/test/compile-fail/try-block-maybe-bad-lifetime.rs rename to src/test/ui/try-block/try-block-maybe-bad-lifetime.rs diff --git a/src/test/ui/try-block/try-block-maybe-bad-lifetime.stderr b/src/test/ui/try-block/try-block-maybe-bad-lifetime.stderr new file mode 100644 index 000000000000..366a8da4b6e8 --- /dev/null +++ b/src/test/ui/try-block/try-block-maybe-bad-lifetime.stderr @@ -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`. diff --git a/src/test/compile-fail/try-block-opt-init.rs b/src/test/ui/try-block/try-block-opt-init.rs similarity index 100% rename from src/test/compile-fail/try-block-opt-init.rs rename to src/test/ui/try-block/try-block-opt-init.rs diff --git a/src/test/ui/try-block/try-block-opt-init.stderr b/src/test/ui/try-block/try-block-opt-init.stderr new file mode 100644 index 000000000000..3ebcb7dc37af --- /dev/null +++ b/src/test/ui/try-block/try-block-opt-init.stderr @@ -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`. diff --git a/src/test/ui/try-block-type-error.rs b/src/test/ui/try-block/try-block-type-error.rs similarity index 100% rename from src/test/ui/try-block-type-error.rs rename to src/test/ui/try-block/try-block-type-error.rs diff --git a/src/test/ui/try-block-type-error.stderr b/src/test/ui/try-block/try-block-type-error.stderr similarity index 100% rename from src/test/ui/try-block-type-error.stderr rename to src/test/ui/try-block/try-block-type-error.stderr