Skip to content

Commit

Permalink
Update former compile-fail tests
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewjasper committed Aug 14, 2018
1 parent 3c8eb4e commit a19db49
Show file tree
Hide file tree
Showing 46 changed files with 105 additions and 94 deletions.
Expand Up @@ -18,7 +18,7 @@ LL | fn transmute<'a,'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) {
| |
| lifetime `'a` defined here
LL | let a = bar(foo, y);
| ^^^^^^^^^^^ argument requires that `'b` must outlive `'a`
| ^^^^^^^^^^^ assignment requires that `'b` must outlive `'a`

error: unsatisfied lifetime constraints
--> $DIR/project-fn-ret-contravariant.rs:54:12
Expand All @@ -29,7 +29,7 @@ LL | fn transmute<'a,'b>(x: &'a u32, y: &'b u32) -> (&'a u32, &'b u32) {
| lifetime `'a` defined here
LL | let a = bar(foo, y);
LL | let b = bar(foo, x);
| ^^^^^^^^^^^ argument requires that `'a` must outlive `'b`
| ^^^^^^^^^^^ assignment requires that `'a` must outlive `'b`

error: aborting due to 2 previous errors

Expand Up @@ -4,13 +4,13 @@ warning: not reporting region error due to nll
LL | bar(foo, x) //[transmute]~ ERROR E0495
| ^^^

error: borrowed data escapes outside of function
error: unsatisfied lifetime constraints
--> $DIR/project-fn-ret-contravariant.rs:48:4
|
LL | fn baz<'a,'b>(x: &'a u32) -> &'static u32 {
| - `x` is a reference that is only valid in the function body
| -- lifetime `'a` defined here
LL | bar(foo, x) //[transmute]~ ERROR E0495
| ^^^^^^^^^^^ `x` escapes the function body here
| ^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static`

error: aborting due to previous error

Expand Up @@ -18,7 +18,7 @@ LL | fn transmute<'a,'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) {
| |
| lifetime `'a` defined here
LL | let a = bar(foo, y); //[krisskross]~ ERROR E0623
| ^^^^^^^^^^^ argument requires that `'b` must outlive `'a`
| ^^^^^^^^^^^ assignment requires that `'b` must outlive `'a`

error: unsatisfied lifetime constraints
--> $DIR/project-fn-ret-invariant.rs:64:12
Expand All @@ -29,7 +29,7 @@ LL | fn transmute<'a,'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) {
| lifetime `'a` defined here
LL | let a = bar(foo, y); //[krisskross]~ ERROR E0623
LL | let b = bar(foo, x);
| ^^^^^^^^^^^ argument requires that `'a` must outlive `'b`
| ^^^^^^^^^^^ assignment requires that `'a` must outlive `'b`

error: aborting due to 2 previous errors

Expand Up @@ -4,14 +4,14 @@ warning: not reporting region error due to nll
LL | bar(foo, x) //[transmute]~ ERROR E0495
| ^^^

error: borrowed data escapes outside of function
error: unsatisfied lifetime constraints
--> $DIR/project-fn-ret-invariant.rs:58:4
|
LL | fn baz<'a,'b>(x: Type<'a>) -> Type<'static> {
| - `x` is a reference that is only valid in the function body
| -- lifetime `'a` defined here
...
LL | bar(foo, x) //[transmute]~ ERROR E0495
| ^^^^^^^^^^^ `x` escapes the function body here
| ^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static`

error: aborting due to previous error

Expand Up @@ -35,7 +35,7 @@ LL | | //[mir]~^ ERROR cannot borrow `x` as mutable more than
LL | | *y = 1;
LL | | drop(y);
LL | | }
| |_________________^ requires that `'1` must outlive `'2`
| |_________________^ returning this value requires that `'1` must outlive `'2`
|
= note: closure implements `FnMut`, so references to captured variables can't escape the closure

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/borrowck/borrowck-describe-lvalue.mir.stderr
Expand Up @@ -35,7 +35,7 @@ LL | | //[mir]~^ ERROR cannot borrow `x` as mutable more than
LL | | *y = 1;
LL | | drop(y);
LL | | }
| |_________________^ requires that `'1` must outlive `'2`
| |_________________^ returning this value requires that `'1` must outlive `'2`
|
= note: closure implements `FnMut`, so references to captured variables can't escape the closure

Expand Down
Expand Up @@ -5,14 +5,14 @@ LL | S { pointer: &mut *p.pointer }
| ^^^^^^^^^^^^^^^

error: unsatisfied lifetime constraints
--> $DIR/borrowck-reborrow-from-shorter-lived-andmut.rs:19:18
--> $DIR/borrowck-reborrow-from-shorter-lived-andmut.rs:19:5
|
LL | fn copy_borrowed_ptr<'a,'b>(p: &'a mut S<'b>) -> S<'b> {
| -- -- lifetime `'b` defined here
| |
| lifetime `'a` defined here
LL | S { pointer: &mut *p.pointer }
| ^^^^^^^^^^^^^^^ requires that `'a` must outlive `'b`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a`

error: aborting due to previous error

Expand Up @@ -40,13 +40,13 @@ error: unsatisfied lifetime constraints
--> $DIR/must_outlive_least_region_or_bound.rs:16:44
|
LL | fn explicit<'a>(x: &'a i32) -> impl Copy { x }
| -- lifetime `'a` defined here ^ return requires that `'a` must outlive `'static`
| -- lifetime `'a` defined here ^ returning this value requires that `'a` must outlive `'static`

error: unsatisfied lifetime constraints
--> $DIR/must_outlive_least_region_or_bound.rs:22:69
|
LL | fn with_bound<'a>(x: &'a i32) -> impl LifetimeTrait<'a> + 'static { x }
| -- lifetime `'a` defined here ^ return requires that `'a` must outlive `'static`
| -- lifetime `'a` defined here ^ returning this value requires that `'a` must outlive `'static`

error: unsatisfied lifetime constraints
--> $DIR/must_outlive_least_region_or_bound.rs:29:5
Expand All @@ -57,7 +57,7 @@ LL | fn move_lifetime_into_fn<'a, 'b>(x: &'a u32, y: &'b u32) -> impl Fn(&'a u32
| lifetime `'a` defined here
LL | //~^ ERROR lifetime mismatch
LL | move |_| println!("{}", y)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'b`

error[E0310]: the parameter type `T` may not live long enough
--> $DIR/must_outlive_least_region_or_bound.rs:34:5
Expand Down
14 changes: 8 additions & 6 deletions src/test/ui/lub-if.nll.stderr
Expand Up @@ -11,20 +11,22 @@ LL | s //~ ERROR E0312
| ^

error: unsatisfied lifetime constraints
--> $DIR/lub-if.rs:34:8
--> $DIR/lub-if.rs:38:9
|
LL | pub fn opt_str2<'a>(maybestr: &'a Option<String>) -> &'static str {
| -- lifetime `'a` defined here
LL | if maybestr.is_none() {
| ^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static`
...
LL | s //~ ERROR E0312
| ^ returning this value requires that `'a` must outlive `'static`

error: unsatisfied lifetime constraints
--> $DIR/lub-if.rs:43:8
--> $DIR/lub-if.rs:45:9
|
LL | pub fn opt_str3<'a>(maybestr: &'a Option<String>) -> &'static str {
| -- lifetime `'a` defined here
LL | if maybestr.is_some() {
| ^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static`
...
LL | s //~ ERROR E0312
| ^ returning this value requires that `'a` must outlive `'static`

error: aborting due to 2 previous errors

14 changes: 8 additions & 6 deletions src/test/ui/lub-match.nll.stderr
Expand Up @@ -11,20 +11,22 @@ LL | s //~ ERROR E0312
| ^

error: unsatisfied lifetime constraints
--> $DIR/lub-match.rs:36:11
--> $DIR/lub-match.rs:40:13
|
LL | pub fn opt_str2<'a>(maybestr: &'a Option<String>) -> &'static str {
| -- lifetime `'a` defined here
LL | match *maybestr {
| ^^^^^^^^^ requires that `'a` must outlive `'static`
...
LL | s //~ ERROR E0312
| ^ returning this value requires that `'a` must outlive `'static`

error: unsatisfied lifetime constraints
--> $DIR/lub-match.rs:46:11
--> $DIR/lub-match.rs:49:13
|
LL | pub fn opt_str3<'a>(maybestr: &'a Option<String>) -> &'static str {
| -- lifetime `'a` defined here
LL | match *maybestr {
| ^^^^^^^^^ requires that `'a` must outlive `'static`
...
LL | s //~ ERROR E0312
| ^ returning this value requires that `'a` must outlive `'static`

error: aborting due to 2 previous errors

2 changes: 1 addition & 1 deletion src/test/ui/match/match-ref-mut-invariance.nll.stderr
Expand Up @@ -15,7 +15,7 @@ LL | fn bar<'a>(&'a mut self) -> &'a mut &'a i32 {
| | lifetime `'a` defined here
LL | | match self.0 { ref mut x => x } //~ ERROR mismatched types
LL | | }
| |_____^ requires that `'a` must outlive `'b`
| |_____^ returning this value requires that `'a` must outlive `'b`

error: aborting due to previous error

2 changes: 1 addition & 1 deletion src/test/ui/match/match-ref-mut-let-invariance.nll.stderr
Expand Up @@ -16,7 +16,7 @@ LL | fn bar<'a>(&'a mut self) -> &'a mut &'a i32 {
LL | | let ref mut x = self.0;
LL | | x //~ ERROR mismatched types
LL | | }
| |_____^ requires that `'a` must outlive `'b`
| |_____^ returning this value requires that `'a` must outlive `'b`

error: aborting due to previous error

Expand Up @@ -18,7 +18,7 @@ LL | | // for<'a,'b,'c>fn(&'a (SomeTrait+'c)) -> &'b (SomeTrait+'a)
... |
LL | | //~| ERROR cannot infer
LL | | }
| |_^ return requires that `'a` must outlive `'b`
| |_^ returning this value requires that `'a` must outlive `'b`

error: aborting due to previous error

Expand Up @@ -19,7 +19,7 @@ LL | fn load1<'a,'b>(a: &'a MyBox<SomeTrait>,
| lifetime `'a` defined here
...
LL | a //~ ERROR lifetime mismatch
| ^ function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'b`
| ^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a`

error: borrowed data escapes outside of function
--> $DIR/object-lifetime-default-mybox.rs:41:5
Expand Down
8 changes: 5 additions & 3 deletions src/test/ui/regions/region-object-lifetime-2.nll.stderr
Expand Up @@ -4,13 +4,15 @@ warning: not reporting region error due to nll
LL | x.borrowed() //~ ERROR cannot infer
| ^^^^^^^^

error: borrowed data escapes outside of function
error: unsatisfied lifetime constraints
--> $DIR/region-object-lifetime-2.rs:20:5
|
LL | fn borrowed_receiver_different_lifetimes<'a,'b>(x: &'a Foo) -> &'b () {
| - `x` is a reference that is only valid in the function body
| -- -- lifetime `'b` defined here
| |
| lifetime `'a` defined here
LL | x.borrowed() //~ ERROR cannot infer
| ^^^^^^^^^^^^ `x` escapes the function body here
| ^^^^^^^^^^^^ returning this value requires that `'a` must outlive `'b`

error: aborting due to previous error

Expand Up @@ -67,7 +67,7 @@ LL | fn d<'a,'b>(v: &'a [u8]) -> Box<Foo+'b> {
LL | | Box::new(v)
LL | | //~^ ERROR cannot infer an appropriate lifetime due to conflicting
LL | | }
| |_^ return requires that `'a` must outlive `'b`
| |_^ returning this value requires that `'a` must outlive `'b`

error: aborting due to 4 previous errors

Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/regions/regions-bounds.nll.stderr
Expand Up @@ -18,7 +18,7 @@ LL | fn a_fn1<'a,'b>(e: an_enum<'a>) -> an_enum<'b> {
| |
| lifetime `'a` defined here
LL | return e; //~ ERROR mismatched types
| ^ return requires that `'a` must outlive `'b`
| ^ returning this value requires that `'a` must outlive `'b`

error: unsatisfied lifetime constraints
--> $DIR/regions-bounds.rs:23:12
Expand All @@ -28,7 +28,7 @@ LL | fn a_fn3<'a,'b>(e: a_class<'a>) -> a_class<'b> {
| |
| lifetime `'a` defined here
LL | return e; //~ ERROR mismatched types
| ^ return requires that `'a` must outlive `'b`
| ^ returning this value requires that `'a` must outlive `'b`

error: aborting due to 2 previous errors

Expand Up @@ -13,7 +13,7 @@ LL | fn g<'a, T: 'static>(v: Box<A<T>+'a>) -> Box<X+'static> {
| | lifetime `'a` defined here
LL | | box B(&*v) as Box<X> //~ ERROR cannot infer
LL | | }
| |_^ return requires that `'a` must outlive `'static`
| |_^ returning this value requires that `'a` must outlive `'static`

error[E0597]: `*v` does not live long enough
--> $DIR/regions-close-object-into-object-2.rs:20:11
Expand Down
Expand Up @@ -37,7 +37,7 @@ LL | fn i<'a, T, U>(v: Box<A<U>+'a>) -> Box<X+'static> {
| | lifetime `'a` defined here
LL | | box B(&*v) as Box<X> //~ ERROR cannot infer
LL | | }
| |_^ return requires that `'a` must outlive `'static`
| |_^ returning this value requires that `'a` must outlive `'static`

error[E0310]: the parameter type `U` may not live long enough
--> $DIR/regions-close-object-into-object-4.rs:20:5
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/regions/regions-creating-enums3.nll.stderr
Expand Up @@ -5,14 +5,14 @@ LL | ast::add(x, y) //~ ERROR 17:5: 17:19: lifetime mismatch [E0623]
| ^^^^^^^^

error: unsatisfied lifetime constraints
--> $DIR/regions-creating-enums3.rs:17:14
--> $DIR/regions-creating-enums3.rs:17:5
|
LL | fn mk_add_bad1<'a,'b>(x: &'a ast<'a>, y: &'b ast<'b>) -> ast<'a> {
| -- -- lifetime `'b` defined here
| |
| lifetime `'a` defined here
LL | ast::add(x, y) //~ ERROR 17:5: 17:19: lifetime mismatch [E0623]
| ^ requires that `'b` must outlive `'a`
| ^^^^^^^^^^^^^^ function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'b`

error: aborting due to previous error

4 changes: 2 additions & 2 deletions src/test/ui/regions/regions-creating-enums4.nll.stderr
Expand Up @@ -5,14 +5,14 @@ LL | ast::add(x, y) //~ ERROR cannot infer
| ^^^^^^^^

error: unsatisfied lifetime constraints
--> $DIR/regions-creating-enums4.rs:17:14
--> $DIR/regions-creating-enums4.rs:17:5
|
LL | fn mk_add_bad2<'a,'b>(x: &'a ast<'a>, y: &'a ast<'a>, z: &ast) -> ast<'b> {
| -- -- lifetime `'b` defined here
| |
| lifetime `'a` defined here
LL | ast::add(x, y) //~ ERROR cannot infer
| ^ requires that `'a` must outlive `'b`
| ^^^^^^^^^^^^^^ returning this value requires that `'a` must outlive `'b`

error: aborting due to previous error

Expand Up @@ -12,7 +12,7 @@ LL | impl<'a> Box<'a> {
LL | fn or<'b,G:GetRef<'b>>(&self, g2: G) -> &'a isize {
| -- lifetime `'b` defined here
LL | g2.get()
| ^^^^^^^^ argument requires that `'b` must outlive `'a`
| ^^^^^^^^ returning this value requires that `'b` must outlive `'a`

error: aborting due to previous error

2 changes: 1 addition & 1 deletion src/test/ui/regions/regions-early-bound-error.nll.stderr
Expand Up @@ -12,7 +12,7 @@ LL | fn get<'a,'b,G:GetRef<'a, isize>>(g1: G, b: &'b isize) -> &'b isize {
| |
| lifetime `'a` defined here
LL | g1.get()
| ^^^^^^^^ argument requires that `'a` must outlive `'b`
| ^^^^^^^^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a`

error: aborting due to previous error

2 changes: 1 addition & 1 deletion src/test/ui/regions/regions-escape-method.nll.stderr
Expand Up @@ -8,7 +8,7 @@ error: unsatisfied lifetime constraints
--> $DIR/regions-escape-method.rs:25:13
|
LL | s.f(|p| p) //~ ERROR cannot infer
| -- ^ return requires that `'1` must outlive `'2`
| -- ^ returning this value requires that `'1` must outlive `'2`
| ||
| |return type of closure is &'2 i32
| has type `&'1 i32`
Expand Down
Expand Up @@ -8,7 +8,7 @@ error: unsatisfied lifetime constraints
--> $DIR/regions-escape-via-trait-or-not.rs:28:14
|
LL | with(|o| o) //~ ERROR cannot infer
| -- ^ return requires that `'1` must outlive `'2`
| -- ^ returning this value requires that `'1` must outlive `'2`
| ||
| |return type of closure is &'2 isize
| has type `&'1 isize`
Expand Down
Expand Up @@ -19,7 +19,7 @@ LL | fn ordering2<'a, 'b>(x: &'a &'b usize, y: &'a usize) -> &'b usize {
| lifetime `'a` defined here
LL | // However, it is not safe to assume that 'b <= 'a
LL | &*y //~ ERROR 23:5: 23:8: lifetime mismatch [E0623]
| ^^^ requires that `'a` must outlive `'b`
| ^^^ function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a`

error: unsatisfied lifetime constraints
--> $DIR/regions-free-region-ordering-callee.rs:28:24
Expand Down
Expand Up @@ -15,7 +15,7 @@ LL | / match self.next {
LL | | Some(ref next) => next.get(),
LL | | None => &self.val //~ ERROR cannot infer
LL | | }
| |_____^ requires that `'a` must outlive `'b`
| |_____^ returning this value requires that `'a` must outlive `'b`

error: aborting due to previous error

0 comments on commit a19db49

Please sign in to comment.