From 687f2526fb7f558cd3425d107cf92b88898ad331 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Thu, 26 Jul 2018 08:21:35 +0300 Subject: [PATCH] move mir_check_* to ui tests, add adjusted references --- .../nll}/mir_check_cast_closure.rs | 0 src/test/ui/nll/mir_check_cast_closure.stderr | 14 ++++++++++++++ .../nll}/mir_check_cast_reify.rs | 2 +- src/test/ui/nll/mir_check_cast_reify.stderr | 17 +++++++++++++++++ .../nll}/mir_check_cast_unsafe_fn.rs | 2 +- .../ui/nll/mir_check_cast_unsafe_fn.stderr | 17 +++++++++++++++++ .../nll}/mir_check_cast_unsize.rs | 3 ++- src/test/ui/nll/mir_check_cast_unsize.stderr | 19 +++++++++++++++++++ 8 files changed, 71 insertions(+), 3 deletions(-) rename src/test/{compile-fail => ui/nll}/mir_check_cast_closure.rs (100%) create mode 100644 src/test/ui/nll/mir_check_cast_closure.stderr rename src/test/{compile-fail => ui/nll}/mir_check_cast_reify.rs (97%) create mode 100644 src/test/ui/nll/mir_check_cast_reify.stderr rename src/test/{compile-fail => ui/nll}/mir_check_cast_unsafe_fn.rs (94%) create mode 100644 src/test/ui/nll/mir_check_cast_unsafe_fn.stderr rename src/test/{compile-fail => ui/nll}/mir_check_cast_unsize.rs (92%) create mode 100644 src/test/ui/nll/mir_check_cast_unsize.stderr diff --git a/src/test/compile-fail/mir_check_cast_closure.rs b/src/test/ui/nll/mir_check_cast_closure.rs similarity index 100% rename from src/test/compile-fail/mir_check_cast_closure.rs rename to src/test/ui/nll/mir_check_cast_closure.rs diff --git a/src/test/ui/nll/mir_check_cast_closure.stderr b/src/test/ui/nll/mir_check_cast_closure.stderr new file mode 100644 index 00000000000..fc2a3c43f75 --- /dev/null +++ b/src/test/ui/nll/mir_check_cast_closure.stderr @@ -0,0 +1,14 @@ +warning: not reporting region error due to nll + --> $DIR/mir_check_cast_closure.rs:18:5 + | +LL | g + | ^ + +error: unsatisfied lifetime constraints + --> $DIR/mir_check_cast_closure.rs:16:28 + | +LL | let g: fn(_, _) -> _ = |_x, y| y; + | ^^^^^^^^^ cast requires that `'b` must outlive `'a` + +error: aborting due to previous error + diff --git a/src/test/compile-fail/mir_check_cast_reify.rs b/src/test/ui/nll/mir_check_cast_reify.rs similarity index 97% rename from src/test/compile-fail/mir_check_cast_reify.rs rename to src/test/ui/nll/mir_check_cast_reify.rs index f85104dff86..3a530c1e747 100644 --- a/src/test/compile-fail/mir_check_cast_reify.rs +++ b/src/test/ui/nll/mir_check_cast_reify.rs @@ -45,8 +45,8 @@ fn bar<'a>(x: &'a u32) -> &'static u32 { // as part of checking the `ReifyFnPointer`. let f: fn(_) -> _ = foo; //~^ WARNING not reporting region error due to nll - //~| ERROR unsatisfied lifetime constraints f(x) + //~^ ERROR } fn main() {} diff --git a/src/test/ui/nll/mir_check_cast_reify.stderr b/src/test/ui/nll/mir_check_cast_reify.stderr new file mode 100644 index 00000000000..13f90e1f159 --- /dev/null +++ b/src/test/ui/nll/mir_check_cast_reify.stderr @@ -0,0 +1,17 @@ +warning: not reporting region error due to nll + --> $DIR/mir_check_cast_reify.rs:46:25 + | +LL | let f: fn(_) -> _ = foo; + | ^^^ + +error: borrowed data escapes outside of closure + --> $DIR/mir_check_cast_reify.rs:48:5 + | +LL | fn bar<'a>(x: &'a u32) -> &'static u32 { + | - `x` is a reference that is only valid in the closure body +... +LL | f(x) + | ^^^^ `x` escapes the closure body here + +error: aborting due to previous error + diff --git a/src/test/compile-fail/mir_check_cast_unsafe_fn.rs b/src/test/ui/nll/mir_check_cast_unsafe_fn.rs similarity index 94% rename from src/test/compile-fail/mir_check_cast_unsafe_fn.rs rename to src/test/ui/nll/mir_check_cast_unsafe_fn.rs index e90242f3f87..4a840da028d 100644 --- a/src/test/compile-fail/mir_check_cast_unsafe_fn.rs +++ b/src/test/ui/nll/mir_check_cast_unsafe_fn.rs @@ -17,8 +17,8 @@ fn bar<'a>(input: &'a u32, f: fn(&'a u32) -> &'a u32) -> &'static u32 { // in `g`. These are related via the `UnsafeFnPointer` cast. let g: unsafe fn(_) -> _ = f; //~^ WARNING not reporting region error due to nll - //~| ERROR unsatisfied lifetime constraints unsafe { g(input) } + //~^ ERROR } fn main() {} diff --git a/src/test/ui/nll/mir_check_cast_unsafe_fn.stderr b/src/test/ui/nll/mir_check_cast_unsafe_fn.stderr new file mode 100644 index 00000000000..b08c6f32e6b --- /dev/null +++ b/src/test/ui/nll/mir_check_cast_unsafe_fn.stderr @@ -0,0 +1,17 @@ +warning: not reporting region error due to nll + --> $DIR/mir_check_cast_unsafe_fn.rs:18:32 + | +LL | let g: unsafe fn(_) -> _ = f; + | ^ + +error: borrowed data escapes outside of closure + --> $DIR/mir_check_cast_unsafe_fn.rs:20:14 + | +LL | fn bar<'a>(input: &'a u32, f: fn(&'a u32) -> &'a u32) -> &'static u32 { + | ----- `input` is a reference that is only valid in the closure body +... +LL | unsafe { g(input) } + | ^^^^^^^^ `input` escapes the closure body here + +error: aborting due to previous error + diff --git a/src/test/compile-fail/mir_check_cast_unsize.rs b/src/test/ui/nll/mir_check_cast_unsize.rs similarity index 92% rename from src/test/compile-fail/mir_check_cast_unsize.rs rename to src/test/ui/nll/mir_check_cast_unsize.rs index d242186a6f7..695dddbf7e9 100644 --- a/src/test/compile-fail/mir_check_cast_unsize.rs +++ b/src/test/ui/nll/mir_check_cast_unsize.rs @@ -15,7 +15,8 @@ use std::fmt::Debug; fn bar<'a>(x: &'a u32) -> &'static dyn Debug { - x //~ ERROR unsatisfied lifetime constraints + //~^ ERROR unsatisfied lifetime constraints + x //~^ WARNING not reporting region error due to nll } diff --git a/src/test/ui/nll/mir_check_cast_unsize.stderr b/src/test/ui/nll/mir_check_cast_unsize.stderr new file mode 100644 index 00000000000..7bd0595f3b5 --- /dev/null +++ b/src/test/ui/nll/mir_check_cast_unsize.stderr @@ -0,0 +1,19 @@ +warning: not reporting region error due to nll + --> $DIR/mir_check_cast_unsize.rs:19:5 + | +LL | x + | ^ + +error: unsatisfied lifetime constraints + --> $DIR/mir_check_cast_unsize.rs:17:46 + | +LL | fn bar<'a>(x: &'a u32) -> &'static dyn Debug { + | ______________________________________________^ +LL | | //~^ ERROR unsatisfied lifetime constraints +LL | | x +LL | | //~^ WARNING not reporting region error due to nll +LL | | } + | |_^ return requires that `'a` must outlive `'static` + +error: aborting due to previous error +