mirror of https://github.com/rust-lang/rust.git
Use revisions instead of nll compare mode for `/regions/` ui tests
This commit is contained in:
parent
5cdab3a8db
commit
e10aa1586d
|
@ -1,16 +1,16 @@
|
|||
error[E0478]: lifetime bound not satisfied
|
||||
--> $DIR/issue-28848.rs:10:5
|
||||
--> $DIR/issue-28848.rs:14:5
|
||||
|
|
||||
LL | Foo::<'a, 'b>::xmute(u)
|
||||
| ^^^^^^^^^^^^^
|
||||
|
|
||||
note: lifetime parameter instantiated with the lifetime `'b` as defined here
|
||||
--> $DIR/issue-28848.rs:9:16
|
||||
--> $DIR/issue-28848.rs:13:16
|
||||
|
|
||||
LL | pub fn foo<'a, 'b>(u: &'b ()) -> &'a () {
|
||||
| ^^
|
||||
note: but lifetime parameter must outlive the lifetime `'a` as defined here
|
||||
--> $DIR/issue-28848.rs:9:12
|
||||
--> $DIR/issue-28848.rs:13:12
|
||||
|
|
||||
LL | pub fn foo<'a, 'b>(u: &'b ()) -> &'a () {
|
||||
| ^^
|
|
@ -1,5 +1,5 @@
|
|||
error: lifetime may not live long enough
|
||||
--> $DIR/issue-28848.rs:10:5
|
||||
--> $DIR/issue-28848.rs:14:5
|
||||
|
|
||||
LL | pub fn foo<'a, 'b>(u: &'b ()) -> &'a () {
|
||||
| -- -- lifetime `'b` defined here
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
// revisions: base nll
|
||||
// ignore-compare-mode-nll
|
||||
//[nll] compile-flags: -Z borrowck=mir
|
||||
|
||||
struct Foo<'a, 'b: 'a>(&'a &'b ());
|
||||
|
||||
impl<'a, 'b> Foo<'a, 'b> {
|
||||
|
@ -7,7 +11,9 @@ impl<'a, 'b> Foo<'a, 'b> {
|
|||
}
|
||||
|
||||
pub fn foo<'a, 'b>(u: &'b ()) -> &'a () {
|
||||
Foo::<'a, 'b>::xmute(u) //~ ERROR lifetime bound not satisfied
|
||||
Foo::<'a, 'b>::xmute(u)
|
||||
//[base]~^ ERROR lifetime bound not satisfied
|
||||
//[nll]~^^ ERROR lifetime may not live long enough
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error[E0308]: `if` and `else` have incompatible types
|
||||
--> $DIR/region-invariant-static-error-reporting.rs:17:9
|
||||
--> $DIR/region-invariant-static-error-reporting.rs:21:9
|
||||
|
|
||||
LL | let bad = if x.is_some() {
|
||||
| _______________-
|
||||
|
@ -14,7 +14,7 @@ LL | | };
|
|||
= note: expected struct `Invariant<'a>`
|
||||
found struct `Invariant<'static>`
|
||||
note: the lifetime `'a` as defined here...
|
||||
--> $DIR/region-invariant-static-error-reporting.rs:13:10
|
||||
--> $DIR/region-invariant-static-error-reporting.rs:17:10
|
||||
|
|
||||
LL | fn unify<'a>(x: Option<Invariant<'a>>, f: fn(Invariant<'a>)) {
|
||||
| ^^
|
|
@ -1,5 +1,5 @@
|
|||
error[E0521]: borrowed data escapes outside of function
|
||||
--> $DIR/region-invariant-static-error-reporting.rs:15:9
|
||||
--> $DIR/region-invariant-static-error-reporting.rs:19:9
|
||||
|
|
||||
LL | fn unify<'a>(x: Option<Invariant<'a>>, f: fn(Invariant<'a>)) {
|
||||
| -- - `x` is a reference that is only valid in the function body
|
||||
|
|
|
@ -3,8 +3,12 @@
|
|||
// over time, but this test used to exhibit some pretty bogus messages
|
||||
// that were not remotely helpful.
|
||||
|
||||
// error-pattern:the lifetime `'a`
|
||||
// error-pattern:the static lifetime
|
||||
// revisions: base nll
|
||||
// ignore-compare-mode-nll
|
||||
//[base] error-pattern:the lifetime `'a`
|
||||
//[base] error-pattern:the static lifetime
|
||||
//[nll] compile-flags: -Z borrowck=mir
|
||||
//[nll] error-pattern:argument requires that `'a` must outlive `'static`
|
||||
|
||||
struct Invariant<'a>(Option<&'a mut &'a mut ()>);
|
||||
|
||||
|
@ -12,9 +16,9 @@ fn mk_static() -> Invariant<'static> { Invariant(None) }
|
|||
|
||||
fn unify<'a>(x: Option<Invariant<'a>>, f: fn(Invariant<'a>)) {
|
||||
let bad = if x.is_some() {
|
||||
x.unwrap()
|
||||
x.unwrap() //[nll]~ ERROR borrowed data escapes outside of function [E0521]
|
||||
} else {
|
||||
mk_static()
|
||||
mk_static() //[base]~ ERROR `if` and `else` have incompatible types [E0308]
|
||||
};
|
||||
f(bad);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:8:10
|
||||
--> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:12:10
|
||||
|
|
||||
LL | fn b<'a, 'b>(x: &mut &'a isize, y: &mut &'b isize) {
|
||||
| --------- --------- these two types are declared with different lifetimes...
|
||||
|
@ -8,7 +8,7 @@ LL | *x = *y;
|
|||
| ^^ ...but data from `y` flows into `x` here
|
||||
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:14:7
|
||||
--> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:20:7
|
||||
|
|
||||
LL | fn c<'a,'b>(x: &mut &'a isize, y: &mut &'b isize) {
|
||||
| --------- --------- these two types are declared with different lifetimes...
|
||||
|
@ -17,7 +17,7 @@ LL | a(x, y);
|
|||
| ^ ...but data from `y` flows into `x` here
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:20:43
|
||||
--> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:28:43
|
||||
|
|
||||
LL | let _: fn(&mut &isize, &mut &isize) = a;
|
||||
| ^ one type is more general than the other
|
|
@ -1,5 +1,5 @@
|
|||
error: lifetime may not live long enough
|
||||
--> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:8:5
|
||||
--> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:12:5
|
||||
|
|
||||
LL | fn b<'a, 'b>(x: &mut &'a isize, y: &mut &'b isize) {
|
||||
| -- -- lifetime `'b` defined here
|
||||
|
@ -12,7 +12,7 @@ LL | *x = *y;
|
|||
= help: consider adding the following bound: `'b: 'a`
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:14:5
|
||||
--> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:20:5
|
||||
|
|
||||
LL | fn c<'a,'b>(x: &mut &'a isize, y: &mut &'b isize) {
|
||||
| -- -- lifetime `'b` defined here
|
||||
|
@ -28,7 +28,7 @@ LL | a(x, y);
|
|||
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:20:12
|
||||
--> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:28:12
|
||||
|
|
||||
LL | let _: fn(&mut &isize, &mut &isize) = a;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
|
||||
|
@ -37,7 +37,7 @@ LL | let _: fn(&mut &isize, &mut &isize) = a;
|
|||
found fn pointer `for<'r, 's> fn(&'r mut &isize, &'s mut &isize)`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:20:12
|
||||
--> $DIR/region-lifetime-bounds-on-fns-where-clause.rs:28:12
|
||||
|
|
||||
LL | let _: fn(&mut &isize, &mut &isize) = a;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
// revisions: base nll
|
||||
// ignore-compare-mode-nll
|
||||
//[nll] compile-flags: -Z borrowck=mir
|
||||
|
||||
fn a<'a, 'b>(x: &mut &'a isize, y: &mut &'b isize) where 'b: 'a {
|
||||
// Note: this is legal because of the `'b:'a` declaration.
|
||||
*x = *y;
|
||||
|
@ -5,19 +9,25 @@ fn a<'a, 'b>(x: &mut &'a isize, y: &mut &'b isize) where 'b: 'a {
|
|||
|
||||
fn b<'a, 'b>(x: &mut &'a isize, y: &mut &'b isize) {
|
||||
// Illegal now because there is no `'b:'a` declaration.
|
||||
*x = *y; //~ ERROR E0623
|
||||
*x = *y;
|
||||
//[base]~^ ERROR E0623
|
||||
//[nll]~^^ ERROR lifetime may not live long enough
|
||||
}
|
||||
|
||||
fn c<'a,'b>(x: &mut &'a isize, y: &mut &'b isize) {
|
||||
// Here we try to call `foo` but do not know that `'a` and `'b` are
|
||||
// related as required.
|
||||
a(x, y); //~ ERROR lifetime mismatch [E0623]
|
||||
a(x, y);
|
||||
//[base]~^ ERROR lifetime mismatch [E0623]
|
||||
//[nll]~^^ ERROR lifetime may not live long enough
|
||||
}
|
||||
|
||||
fn d() {
|
||||
// 'a and 'b are early bound in the function `a` because they appear
|
||||
// inconstraints:
|
||||
let _: fn(&mut &isize, &mut &isize) = a; //~ ERROR mismatched types
|
||||
let _: fn(&mut &isize, &mut &isize) = a;
|
||||
//~^ ERROR mismatched types [E0308]
|
||||
//[nll]~^^ ERROR mismatched types [E0308]
|
||||
}
|
||||
|
||||
fn e() {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:9:10
|
||||
--> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:13:10
|
||||
|
|
||||
LL | fn b<'a, 'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) {
|
||||
| --------- --------- these two types are declared with different lifetimes...
|
||||
|
@ -8,7 +8,7 @@ LL | *x = *y;
|
|||
| ^^ ...but data from `y` flows into `x` here
|
||||
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:10:10
|
||||
--> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:16:10
|
||||
|
|
||||
LL | fn b<'a, 'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) {
|
||||
| --------- ---------
|
||||
|
@ -19,7 +19,7 @@ LL | *z = *y;
|
|||
| ^^ ...but data from `y` flows into `z` here
|
||||
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:16:7
|
||||
--> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:22:7
|
||||
|
|
||||
LL | fn c<'a,'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) {
|
||||
| --------- --------- these two types are declared with different lifetimes...
|
||||
|
@ -28,7 +28,7 @@ LL | a(x, y, z);
|
|||
| ^ ...but data from `y` flows into `x` here
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:22:56
|
||||
--> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:30:56
|
||||
|
|
||||
LL | let _: fn(&mut &isize, &mut &isize, &mut &isize) = a;
|
||||
| ^ one type is more general than the other
|
|
@ -1,5 +1,5 @@
|
|||
error: lifetime may not live long enough
|
||||
--> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:9:5
|
||||
--> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:13:5
|
||||
|
|
||||
LL | fn b<'a, 'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) {
|
||||
| -- -- lifetime `'b` defined here
|
||||
|
@ -12,7 +12,7 @@ LL | *x = *y;
|
|||
= help: consider adding the following bound: `'b: 'a`
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:16:5
|
||||
--> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:22:5
|
||||
|
|
||||
LL | fn c<'a,'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) {
|
||||
| -- -- lifetime `'b` defined here
|
||||
|
@ -28,7 +28,7 @@ LL | a(x, y, z);
|
|||
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:22:12
|
||||
--> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:30:12
|
||||
|
|
||||
LL | let _: fn(&mut &isize, &mut &isize, &mut &isize) = a;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
|
||||
|
@ -37,7 +37,7 @@ LL | let _: fn(&mut &isize, &mut &isize, &mut &isize) = a;
|
|||
found fn pointer `for<'r, 's, 't0> fn(&'r mut &isize, &'s mut &isize, &'t0 mut &isize)`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:22:12
|
||||
--> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:30:12
|
||||
|
|
||||
LL | let _: fn(&mut &isize, &mut &isize, &mut &isize) = a;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
|
||||
|
@ -46,7 +46,7 @@ LL | let _: fn(&mut &isize, &mut &isize, &mut &isize) = a;
|
|||
found fn pointer `for<'r, 's, 't0> fn(&'r mut &isize, &'s mut &isize, &'t0 mut &isize)`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:22:12
|
||||
--> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:30:12
|
||||
|
|
||||
LL | let _: fn(&mut &isize, &mut &isize, &mut &isize) = a;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
|
||||
|
|
|
@ -1,82 +0,0 @@
|
|||
error: lifetime may not live long enough
|
||||
--> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:9:5
|
||||
|
|
||||
LL | fn b<'a, 'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) {
|
||||
| -- -- lifetime `'b` defined here
|
||||
| |
|
||||
| lifetime `'a` defined here
|
||||
LL | // Illegal now because there is no `'b:'a` declaration.
|
||||
LL | *x = *y;
|
||||
| ^^^^^^^ assignment requires that `'b` must outlive `'a`
|
||||
|
|
||||
= help: consider adding the following bound: `'b: 'a`
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:10:5
|
||||
|
|
||||
LL | fn b<'a, 'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) {
|
||||
| -- -- lifetime `'c` defined here
|
||||
| |
|
||||
| lifetime `'b` defined here
|
||||
...
|
||||
LL | *z = *y;
|
||||
| ^^^^^^^ assignment requires that `'b` must outlive `'c`
|
||||
|
|
||||
= help: consider adding the following bound: `'b: 'c`
|
||||
|
||||
help: add bound `'b: 'a + 'c`
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:16:5
|
||||
|
|
||||
LL | fn c<'a,'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) {
|
||||
| -- -- lifetime `'b` defined here
|
||||
| |
|
||||
| lifetime `'a` defined here
|
||||
...
|
||||
LL | a(x, y, z);
|
||||
| ^^^^^^^^^^ argument requires that `'b` must outlive `'a`
|
||||
|
|
||||
= help: consider adding the following bound: `'b: 'a`
|
||||
= note: requirement occurs because of a mutable reference to &isize
|
||||
= note: mutable references are invariant over their type parameter
|
||||
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:16:5
|
||||
|
|
||||
LL | fn c<'a,'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) {
|
||||
| -- -- lifetime `'c` defined here
|
||||
| |
|
||||
| lifetime `'b` defined here
|
||||
...
|
||||
LL | a(x, y, z);
|
||||
| ^^^^^^^^^^ argument requires that `'b` must outlive `'c`
|
||||
|
|
||||
= help: consider adding the following bound: `'b: 'c`
|
||||
= note: requirement occurs because of a mutable reference to &isize
|
||||
= note: mutable references are invariant over their type parameter
|
||||
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
|
||||
|
||||
help: add bound `'b: 'a + 'c`
|
||||
|
||||
error: higher-ranked subtype error
|
||||
--> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:22:12
|
||||
|
|
||||
LL | let _: fn(&mut &isize, &mut &isize, &mut &isize) = a;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: higher-ranked subtype error
|
||||
--> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:22:12
|
||||
|
|
||||
LL | let _: fn(&mut &isize, &mut &isize, &mut &isize) = a;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: higher-ranked subtype error
|
||||
--> $DIR/region-multiple-lifetime-bounds-on-fns-where-clause.rs:22:12
|
||||
|
|
||||
LL | let _: fn(&mut &isize, &mut &isize, &mut &isize) = a;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 7 previous errors
|
||||
|
|
@ -1,3 +1,7 @@
|
|||
// revisions: base nll
|
||||
// ignore-compare-mode-nll
|
||||
//[nll] compile-flags: -Z borrowck=mir
|
||||
|
||||
fn a<'a, 'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) where 'b: 'a + 'c {
|
||||
// Note: this is legal because of the `'b:'a` declaration.
|
||||
*x = *y;
|
||||
|
@ -6,20 +10,27 @@ fn a<'a, 'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) where
|
|||
|
||||
fn b<'a, 'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) {
|
||||
// Illegal now because there is no `'b:'a` declaration.
|
||||
*x = *y; //~ ERROR E0623
|
||||
*z = *y; //~ ERROR E0623
|
||||
*x = *y;
|
||||
//[base]~^ ERROR E0623
|
||||
//[nll]~^^ ERROR lifetime may not live long enough
|
||||
*z = *y; //[base]~ ERROR E0623
|
||||
}
|
||||
|
||||
fn c<'a,'b, 'c>(x: &mut &'a isize, y: &mut &'b isize, z: &mut &'c isize) {
|
||||
// Here we try to call `foo` but do not know that `'a` and `'b` are
|
||||
// related as required.
|
||||
a(x, y, z); //~ ERROR lifetime mismatch [E0623]
|
||||
a(x, y, z);
|
||||
//[base]~^ ERROR lifetime mismatch [E0623]
|
||||
//[nll]~^^ ERROR lifetime may not live long enough
|
||||
}
|
||||
|
||||
fn d() {
|
||||
// 'a and 'b are early bound in the function `a` because they appear
|
||||
// inconstraints:
|
||||
let _: fn(&mut &isize, &mut &isize, &mut &isize) = a; //~ ERROR E0308
|
||||
let _: fn(&mut &isize, &mut &isize, &mut &isize) = a;
|
||||
//~^ ERROR E0308
|
||||
//[nll]~^^ ERROR mismatched types [E0308]
|
||||
//[nll]~| ERROR mismatched types [E0308]
|
||||
}
|
||||
|
||||
fn e() {
|
||||
|
|
|
@ -1,26 +1,26 @@
|
|||
error[E0495]: cannot infer an appropriate lifetime for autoref due to conflicting requirements
|
||||
--> $DIR/region-object-lifetime-2.rs:10:7
|
||||
--> $DIR/region-object-lifetime-2.rs:14:7
|
||||
|
|
||||
LL | x.borrowed()
|
||||
| ^^^^^^^^
|
||||
|
|
||||
note: first, the lifetime cannot outlive the lifetime `'a` as defined here...
|
||||
--> $DIR/region-object-lifetime-2.rs:9:42
|
||||
--> $DIR/region-object-lifetime-2.rs:13:42
|
||||
|
|
||||
LL | fn borrowed_receiver_different_lifetimes<'a,'b>(x: &'a dyn Foo) -> &'b () {
|
||||
| ^^
|
||||
note: ...so that reference does not outlive borrowed content
|
||||
--> $DIR/region-object-lifetime-2.rs:10:5
|
||||
--> $DIR/region-object-lifetime-2.rs:14:5
|
||||
|
|
||||
LL | x.borrowed()
|
||||
| ^
|
||||
note: but, the lifetime must be valid for the lifetime `'b` as defined here...
|
||||
--> $DIR/region-object-lifetime-2.rs:9:45
|
||||
--> $DIR/region-object-lifetime-2.rs:13:45
|
||||
|
|
||||
LL | fn borrowed_receiver_different_lifetimes<'a,'b>(x: &'a dyn Foo) -> &'b () {
|
||||
| ^^
|
||||
note: ...so that reference does not outlive borrowed content
|
||||
--> $DIR/region-object-lifetime-2.rs:10:5
|
||||
--> $DIR/region-object-lifetime-2.rs:14:5
|
||||
|
|
||||
LL | x.borrowed()
|
||||
| ^^^^^^^^^^^^
|
|
@ -1,5 +1,5 @@
|
|||
error: lifetime may not live long enough
|
||||
--> $DIR/region-object-lifetime-2.rs:10:5
|
||||
--> $DIR/region-object-lifetime-2.rs:14:5
|
||||
|
|
||||
LL | fn borrowed_receiver_different_lifetimes<'a,'b>(x: &'a dyn Foo) -> &'b () {
|
||||
| -- -- lifetime `'b` defined here
|
||||
|
|
|
@ -1,13 +1,19 @@
|
|||
// Various tests related to testing how region inference works
|
||||
// with respect to the object receivers.
|
||||
|
||||
// revisions: base nll
|
||||
// ignore-compare-mode-nll
|
||||
//[nll] compile-flags: -Z borrowck=mir
|
||||
|
||||
trait Foo {
|
||||
fn borrowed<'a>(&'a self) -> &'a ();
|
||||
}
|
||||
|
||||
// Borrowed receiver but two distinct lifetimes, we get an error.
|
||||
fn borrowed_receiver_different_lifetimes<'a,'b>(x: &'a dyn Foo) -> &'b () {
|
||||
x.borrowed() //~ ERROR cannot infer
|
||||
x.borrowed()
|
||||
//[base]~^ ERROR cannot infer
|
||||
//[nll]~^^ ERROR lifetime may not live long enough
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -1,26 +1,26 @@
|
|||
error[E0495]: cannot infer an appropriate lifetime for autoref due to conflicting requirements
|
||||
--> $DIR/region-object-lifetime-4.rs:12:7
|
||||
--> $DIR/region-object-lifetime-4.rs:16:7
|
||||
|
|
||||
LL | x.borrowed()
|
||||
| ^^^^^^^^
|
||||
|
|
||||
note: first, the lifetime cannot outlive the lifetime `'a` as defined here...
|
||||
--> $DIR/region-object-lifetime-4.rs:11:41
|
||||
--> $DIR/region-object-lifetime-4.rs:15:41
|
||||
|
|
||||
LL | fn borrowed_receiver_related_lifetimes2<'a,'b>(x: &'a (dyn Foo + 'b)) -> &'b () {
|
||||
| ^^
|
||||
note: ...so that reference does not outlive borrowed content
|
||||
--> $DIR/region-object-lifetime-4.rs:12:5
|
||||
--> $DIR/region-object-lifetime-4.rs:16:5
|
||||
|
|
||||
LL | x.borrowed()
|
||||
| ^
|
||||
note: but, the lifetime must be valid for the lifetime `'b` as defined here...
|
||||
--> $DIR/region-object-lifetime-4.rs:11:44
|
||||
--> $DIR/region-object-lifetime-4.rs:15:44
|
||||
|
|
||||
LL | fn borrowed_receiver_related_lifetimes2<'a,'b>(x: &'a (dyn Foo + 'b)) -> &'b () {
|
||||
| ^^
|
||||
note: ...so that reference does not outlive borrowed content
|
||||
--> $DIR/region-object-lifetime-4.rs:12:5
|
||||
--> $DIR/region-object-lifetime-4.rs:16:5
|
||||
|
|
||||
LL | x.borrowed()
|
||||
| ^^^^^^^^^^^^
|
|
@ -1,5 +1,5 @@
|
|||
error: lifetime may not live long enough
|
||||
--> $DIR/region-object-lifetime-4.rs:12:5
|
||||
--> $DIR/region-object-lifetime-4.rs:16:5
|
||||
|
|
||||
LL | fn borrowed_receiver_related_lifetimes2<'a,'b>(x: &'a (dyn Foo + 'b)) -> &'b () {
|
||||
| -- -- lifetime `'b` defined here
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
// Various tests related to testing how region inference works
|
||||
// with respect to the object receivers.
|
||||
|
||||
// revisions: base nll
|
||||
// ignore-compare-mode-nll
|
||||
//[nll] compile-flags: -Z borrowck=mir
|
||||
|
||||
trait Foo {
|
||||
fn borrowed<'a>(&'a self) -> &'a ();
|
||||
}
|
||||
|
@ -9,7 +13,9 @@ trait Foo {
|
|||
// with the longer lifetime when (from the signature) we only know
|
||||
// that it lives as long as the shorter lifetime. Therefore, error.
|
||||
fn borrowed_receiver_related_lifetimes2<'a,'b>(x: &'a (dyn Foo + 'b)) -> &'b () {
|
||||
x.borrowed() //~ ERROR cannot infer
|
||||
x.borrowed()
|
||||
//[base]~^ ERROR cannot infer
|
||||
//[nll]~^^ ERROR lifetime may not live long enough
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error[E0759]: `v` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement
|
||||
--> $DIR/region-object-lifetime-in-coercion.rs:8:46
|
||||
--> $DIR/region-object-lifetime-in-coercion.rs:12:46
|
||||
|
|
||||
LL | fn a(v: &[u8]) -> Box<dyn Foo + 'static> {
|
||||
| ----- this data with an anonymous lifetime `'_`...
|
||||
|
@ -16,7 +16,7 @@ LL | fn a(v: &'static [u8]) -> Box<dyn Foo + 'static> {
|
|||
| ~~~~~~~~~~~~~
|
||||
|
||||
error[E0759]: `v` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement
|
||||
--> $DIR/region-object-lifetime-in-coercion.rs:13:14
|
||||
--> $DIR/region-object-lifetime-in-coercion.rs:19:14
|
||||
|
|
||||
LL | fn b(v: &[u8]) -> Box<dyn Foo + 'static> {
|
||||
| ----- this data with an anonymous lifetime `'_`...
|
||||
|
@ -24,7 +24,7 @@ LL | Box::new(v)
|
|||
| ^ ...is used and required to live as long as `'static` here
|
||||
|
|
||||
note: `'static` lifetime requirement introduced by the return type
|
||||
--> $DIR/region-object-lifetime-in-coercion.rs:12:33
|
||||
--> $DIR/region-object-lifetime-in-coercion.rs:18:33
|
||||
|
|
||||
LL | fn b(v: &[u8]) -> Box<dyn Foo + 'static> {
|
||||
| ^^^^^^^ `'static` requirement introduced here
|
||||
|
@ -40,7 +40,7 @@ LL | fn b(v: &'static [u8]) -> Box<dyn Foo + 'static> {
|
|||
| ~~~~~~~~~~~~~
|
||||
|
||||
error[E0759]: `v` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement
|
||||
--> $DIR/region-object-lifetime-in-coercion.rs:19:14
|
||||
--> $DIR/region-object-lifetime-in-coercion.rs:27:14
|
||||
|
|
||||
LL | fn c(v: &[u8]) -> Box<dyn Foo> {
|
||||
| ----- this data with an anonymous lifetime `'_`...
|
||||
|
@ -49,7 +49,7 @@ LL | Box::new(v)
|
|||
| ^ ...is used and required to live as long as `'static` here
|
||||
|
|
||||
note: `'static` lifetime requirement introduced by the return type
|
||||
--> $DIR/region-object-lifetime-in-coercion.rs:16:23
|
||||
--> $DIR/region-object-lifetime-in-coercion.rs:24:23
|
||||
|
|
||||
LL | fn c(v: &[u8]) -> Box<dyn Foo> {
|
||||
| ^^^^^^^ `'static` requirement introduced here
|
||||
|
@ -62,30 +62,30 @@ LL | fn c(v: &[u8]) -> Box<dyn Foo + '_> {
|
|||
| ++++
|
||||
|
||||
error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements
|
||||
--> $DIR/region-object-lifetime-in-coercion.rs:23:14
|
||||
--> $DIR/region-object-lifetime-in-coercion.rs:33:14
|
||||
|
|
||||
LL | Box::new(v)
|
||||
| ^
|
||||
|
|
||||
note: first, the lifetime cannot outlive the lifetime `'a` as defined here...
|
||||
--> $DIR/region-object-lifetime-in-coercion.rs:22:6
|
||||
--> $DIR/region-object-lifetime-in-coercion.rs:32:6
|
||||
|
|
||||
LL | fn d<'a,'b>(v: &'a [u8]) -> Box<dyn Foo+'b> {
|
||||
| ^^
|
||||
note: ...so that the expression is assignable
|
||||
--> $DIR/region-object-lifetime-in-coercion.rs:23:14
|
||||
--> $DIR/region-object-lifetime-in-coercion.rs:33:14
|
||||
|
|
||||
LL | Box::new(v)
|
||||
| ^
|
||||
= note: expected `&[u8]`
|
||||
found `&'a [u8]`
|
||||
note: but, the lifetime must be valid for the lifetime `'b` as defined here...
|
||||
--> $DIR/region-object-lifetime-in-coercion.rs:22:9
|
||||
--> $DIR/region-object-lifetime-in-coercion.rs:32:9
|
||||
|
|
||||
LL | fn d<'a,'b>(v: &'a [u8]) -> Box<dyn Foo+'b> {
|
||||
| ^^
|
||||
note: ...so that the types are compatible
|
||||
--> $DIR/region-object-lifetime-in-coercion.rs:23:5
|
||||
--> $DIR/region-object-lifetime-in-coercion.rs:33:5
|
||||
|
|
||||
LL | Box::new(v)
|
||||
| ^^^^^^^^^^^
|
|
@ -1,5 +1,5 @@
|
|||
error: lifetime may not live long enough
|
||||
--> $DIR/region-object-lifetime-in-coercion.rs:8:12
|
||||
--> $DIR/region-object-lifetime-in-coercion.rs:12:12
|
||||
|
|
||||
LL | fn a(v: &[u8]) -> Box<dyn Foo + 'static> {
|
||||
| - let's call the lifetime of this reference `'1`
|
||||
|
@ -7,7 +7,7 @@ LL | let x: Box<dyn Foo + 'static> = Box::new(v);
|
|||
| ^^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'1` must outlive `'static`
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/region-object-lifetime-in-coercion.rs:13:5
|
||||
--> $DIR/region-object-lifetime-in-coercion.rs:19:5
|
||||
|
|
||||
LL | fn b(v: &[u8]) -> Box<dyn Foo + 'static> {
|
||||
| - let's call the lifetime of this reference `'1`
|
||||
|
@ -15,7 +15,7 @@ LL | Box::new(v)
|
|||
| ^^^^^^^^^^^ returning this value requires that `'1` must outlive `'static`
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/region-object-lifetime-in-coercion.rs:19:5
|
||||
--> $DIR/region-object-lifetime-in-coercion.rs:27:5
|
||||
|
|
||||
LL | fn c(v: &[u8]) -> Box<dyn Foo> {
|
||||
| - let's call the lifetime of this reference `'1`
|
||||
|
@ -24,7 +24,7 @@ LL | Box::new(v)
|
|||
| ^^^^^^^^^^^ returning this value requires that `'1` must outlive `'static`
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/region-object-lifetime-in-coercion.rs:23:5
|
||||
--> $DIR/region-object-lifetime-in-coercion.rs:33:5
|
||||
|
|
||||
LL | fn d<'a,'b>(v: &'a [u8]) -> Box<dyn Foo+'b> {
|
||||
| -- -- lifetime `'b` defined here
|
||||
|
|
|
@ -1,26 +1,38 @@
|
|||
// Test that attempts to implicitly coerce a value into an
|
||||
// object respect the lifetime bound on the object type.
|
||||
|
||||
// revisions: base nll
|
||||
// ignore-compare-mode-nll
|
||||
//[nll] compile-flags: -Z borrowck=mir
|
||||
|
||||
trait Foo {}
|
||||
impl<'a> Foo for &'a [u8] {}
|
||||
|
||||
fn a(v: &[u8]) -> Box<dyn Foo + 'static> {
|
||||
let x: Box<dyn Foo + 'static> = Box::new(v); //~ ERROR E0759
|
||||
let x: Box<dyn Foo + 'static> = Box::new(v);
|
||||
//[base]~^ ERROR E0759
|
||||
//[nll]~^^ ERROR lifetime may not live long enough
|
||||
x
|
||||
}
|
||||
|
||||
fn b(v: &[u8]) -> Box<dyn Foo + 'static> {
|
||||
Box::new(v) //~ ERROR E0759
|
||||
Box::new(v)
|
||||
//[base]~^ ERROR E0759
|
||||
//[nll]~^^ ERROR lifetime may not live long enough
|
||||
}
|
||||
|
||||
fn c(v: &[u8]) -> Box<dyn Foo> {
|
||||
// same as previous case due to RFC 599
|
||||
|
||||
Box::new(v) //~ ERROR E0759
|
||||
Box::new(v)
|
||||
//[base]~^ ERROR E0759
|
||||
//[nll]~^^ ERROR lifetime may not live long enough
|
||||
}
|
||||
|
||||
fn d<'a,'b>(v: &'a [u8]) -> Box<dyn Foo+'b> {
|
||||
Box::new(v) //~ ERROR cannot infer an appropriate lifetime due to conflicting
|
||||
Box::new(v)
|
||||
//[base]~^ ERROR cannot infer an appropriate lifetime due to conflicting
|
||||
//[nll]~^^ ERROR lifetime may not live long enough
|
||||
}
|
||||
|
||||
fn e<'a:'b,'b>(v: &'a [u8]) -> Box<dyn Foo+'b> {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error[E0759]: `self` has an anonymous lifetime `'_` but it needs to satisfy a `'static` lifetime requirement
|
||||
--> $DIR/regions-addr-of-self.rs:7:37
|
||||
--> $DIR/regions-addr-of-self.rs:11:37
|
||||
|
|
||||
LL | pub fn chase_cat(&mut self) {
|
||||
| --------- this data with an anonymous lifetime `'_`...
|
|
@ -1,5 +1,5 @@
|
|||
error: lifetime may not live long enough
|
||||
--> $DIR/regions-addr-of-self.rs:7:16
|
||||
--> $DIR/regions-addr-of-self.rs:11:16
|
||||
|
|
||||
LL | pub fn chase_cat(&mut self) {
|
||||
| - let's call the lifetime of this reference `'1`
|
||||
|
|
|
@ -1,10 +1,16 @@
|
|||
// revisions: base nll
|
||||
// ignore-compare-mode-nll
|
||||
//[nll] compile-flags: -Z borrowck=mir
|
||||
|
||||
struct Dog {
|
||||
cats_chased: usize,
|
||||
}
|
||||
|
||||
impl Dog {
|
||||
pub fn chase_cat(&mut self) {
|
||||
let p: &'static mut usize = &mut self.cats_chased; //~ ERROR E0759
|
||||
let p: &'static mut usize = &mut self.cats_chased;
|
||||
//[base]~^ ERROR E0759
|
||||
//[nll]~^^ ERROR lifetime may not live long enough
|
||||
*p += 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
error[E0495]: cannot infer an appropriate lifetime for borrow expression due to conflicting requirements
|
||||
--> $DIR/regions-addr-of-upvar-self.rs:8:41
|
||||
--> $DIR/regions-addr-of-upvar-self.rs:12:41
|
||||
|
|
||||
LL | let p: &'static mut usize = &mut self.food;
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
note: first, the lifetime cannot outlive the lifetime `'_` as defined here...
|
||||
--> $DIR/regions-addr-of-upvar-self.rs:7:18
|
||||
--> $DIR/regions-addr-of-upvar-self.rs:11:18
|
||||
|
|
||||
LL | let _f = || {
|
||||
| ^^
|
||||
note: ...so that closure can access `self`
|
||||
--> $DIR/regions-addr-of-upvar-self.rs:8:41
|
||||
--> $DIR/regions-addr-of-upvar-self.rs:12:41
|
||||
|
|
||||
LL | let p: &'static mut usize = &mut self.food;
|
||||
| ^^^^^^^^^^^^^^
|
||||
= note: but, the lifetime must be valid for the static lifetime...
|
||||
note: ...so that reference does not outlive borrowed content
|
||||
--> $DIR/regions-addr-of-upvar-self.rs:8:41
|
||||
--> $DIR/regions-addr-of-upvar-self.rs:12:41
|
||||
|
|
||||
LL | let p: &'static mut usize = &mut self.food;
|
||||
| ^^^^^^^^^^^^^^
|
|
@ -1,5 +1,5 @@
|
|||
error: lifetime may not live long enough
|
||||
--> $DIR/regions-addr-of-upvar-self.rs:8:20
|
||||
--> $DIR/regions-addr-of-upvar-self.rs:12:20
|
||||
|
|
||||
LL | let _f = || {
|
||||
| -- lifetime `'1` represents this closure's body
|
||||
|
@ -9,7 +9,7 @@ LL | let p: &'static mut usize = &mut self.food;
|
|||
= note: closure implements `FnMut`, so references to captured variables can't escape the closure
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/regions-addr-of-upvar-self.rs:8:20
|
||||
--> $DIR/regions-addr-of-upvar-self.rs:12:20
|
||||
|
|
||||
LL | pub fn chase_cat(&mut self) {
|
||||
| - let's call the lifetime of this reference `'1`
|
||||
|
@ -18,7 +18,7 @@ LL | let p: &'static mut usize = &mut self.food;
|
|||
| ^^^^^^^^^^^^^^^^^^ type annotation requires that `'1` must outlive `'static`
|
||||
|
||||
error[E0597]: `self` does not live long enough
|
||||
--> $DIR/regions-addr-of-upvar-self.rs:8:46
|
||||
--> $DIR/regions-addr-of-upvar-self.rs:12:46
|
||||
|
|
||||
LL | let _f = || {
|
||||
| -- value captured here
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
// revisions: base nll
|
||||
// ignore-compare-mode-nll
|
||||
//[nll] compile-flags: -Z borrowck=mir
|
||||
|
||||
struct Dog {
|
||||
food: usize,
|
||||
}
|
||||
|
@ -5,7 +9,11 @@ struct Dog {
|
|||
impl Dog {
|
||||
pub fn chase_cat(&mut self) {
|
||||
let _f = || {
|
||||
let p: &'static mut usize = &mut self.food; //~ ERROR cannot infer
|
||||
let p: &'static mut usize = &mut self.food;
|
||||
//[base]~^ ERROR cannot infer
|
||||
//[nll]~^^ ERROR lifetime may not live long enough
|
||||
//[nll]~^^^ ERROR lifetime may not live long enough
|
||||
//[nll]~^^^^ ERROR E0597
|
||||
*p = 3;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,71 +1,71 @@
|
|||
error[E0477]: the type `&'a isize` does not fulfill the required lifetime
|
||||
--> $DIR/regions-bounded-by-trait-requiring-static.rs:22:5
|
||||
--> $DIR/regions-bounded-by-trait-requiring-static.rs:26:5
|
||||
|
|
||||
LL | assert_send::<&'a isize>();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: type must satisfy the static lifetime as required by this binding
|
||||
--> $DIR/regions-bounded-by-trait-requiring-static.rs:6:18
|
||||
--> $DIR/regions-bounded-by-trait-requiring-static.rs:10:18
|
||||
|
|
||||
LL | fn assert_send<T:'static>() { }
|
||||
| ^^^^^^^
|
||||
|
||||
error[E0477]: the type `&'a str` does not fulfill the required lifetime
|
||||
--> $DIR/regions-bounded-by-trait-requiring-static.rs:26:5
|
||||
--> $DIR/regions-bounded-by-trait-requiring-static.rs:32:5
|
||||
|
|
||||
LL | assert_send::<&'a str>();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: type must satisfy the static lifetime as required by this binding
|
||||
--> $DIR/regions-bounded-by-trait-requiring-static.rs:6:18
|
||||
--> $DIR/regions-bounded-by-trait-requiring-static.rs:10:18
|
||||
|
|
||||
LL | fn assert_send<T:'static>() { }
|
||||
| ^^^^^^^
|
||||
|
||||
error[E0477]: the type `&'a [isize]` does not fulfill the required lifetime
|
||||
--> $DIR/regions-bounded-by-trait-requiring-static.rs:30:5
|
||||
--> $DIR/regions-bounded-by-trait-requiring-static.rs:38:5
|
||||
|
|
||||
LL | assert_send::<&'a [isize]>();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: type must satisfy the static lifetime as required by this binding
|
||||
--> $DIR/regions-bounded-by-trait-requiring-static.rs:6:18
|
||||
--> $DIR/regions-bounded-by-trait-requiring-static.rs:10:18
|
||||
|
|
||||
LL | fn assert_send<T:'static>() { }
|
||||
| ^^^^^^^
|
||||
|
||||
error[E0477]: the type `Box<&'a isize>` does not fulfill the required lifetime
|
||||
--> $DIR/regions-bounded-by-trait-requiring-static.rs:44:5
|
||||
--> $DIR/regions-bounded-by-trait-requiring-static.rs:54:5
|
||||
|
|
||||
LL | assert_send::<Box<&'a isize>>();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: type must satisfy the static lifetime as required by this binding
|
||||
--> $DIR/regions-bounded-by-trait-requiring-static.rs:6:18
|
||||
--> $DIR/regions-bounded-by-trait-requiring-static.rs:10:18
|
||||
|
|
||||
LL | fn assert_send<T:'static>() { }
|
||||
| ^^^^^^^
|
||||
|
||||
error[E0477]: the type `*const &'a isize` does not fulfill the required lifetime
|
||||
--> $DIR/regions-bounded-by-trait-requiring-static.rs:55:5
|
||||
--> $DIR/regions-bounded-by-trait-requiring-static.rs:67:5
|
||||
|
|
||||
LL | assert_send::<*const &'a isize>();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: type must satisfy the static lifetime as required by this binding
|
||||
--> $DIR/regions-bounded-by-trait-requiring-static.rs:6:18
|
||||
--> $DIR/regions-bounded-by-trait-requiring-static.rs:10:18
|
||||
|
|
||||
LL | fn assert_send<T:'static>() { }
|
||||
| ^^^^^^^
|
||||
|
||||
error[E0477]: the type `*mut &'a isize` does not fulfill the required lifetime
|
||||
--> $DIR/regions-bounded-by-trait-requiring-static.rs:59:5
|
||||
--> $DIR/regions-bounded-by-trait-requiring-static.rs:73:5
|
||||
|
|
||||
LL | assert_send::<*mut &'a isize>();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: type must satisfy the static lifetime as required by this binding
|
||||
--> $DIR/regions-bounded-by-trait-requiring-static.rs:6:18
|
||||
--> $DIR/regions-bounded-by-trait-requiring-static.rs:10:18
|
||||
|
|
||||
LL | fn assert_send<T:'static>() { }
|
||||
| ^^^^^^^
|
|
@ -1,5 +1,5 @@
|
|||
error: lifetime may not live long enough
|
||||
--> $DIR/regions-bounded-by-trait-requiring-static.rs:22:5
|
||||
--> $DIR/regions-bounded-by-trait-requiring-static.rs:26:5
|
||||
|
|
||||
LL | fn param_not_ok<'a>(x: &'a isize) {
|
||||
| -- lifetime `'a` defined here
|
||||
|
@ -7,7 +7,7 @@ LL | assert_send::<&'a isize>();
|
|||
| ^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static`
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/regions-bounded-by-trait-requiring-static.rs:26:5
|
||||
--> $DIR/regions-bounded-by-trait-requiring-static.rs:32:5
|
||||
|
|
||||
LL | fn param_not_ok1<'a>(_: &'a isize) {
|
||||
| -- lifetime `'a` defined here
|
||||
|
@ -15,7 +15,7 @@ LL | assert_send::<&'a str>();
|
|||
| ^^^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static`
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/regions-bounded-by-trait-requiring-static.rs:30:5
|
||||
--> $DIR/regions-bounded-by-trait-requiring-static.rs:38:5
|
||||
|
|
||||
LL | fn param_not_ok2<'a>(_: &'a isize) {
|
||||
| -- lifetime `'a` defined here
|
||||
|
@ -23,7 +23,7 @@ LL | assert_send::<&'a [isize]>();
|
|||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static`
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/regions-bounded-by-trait-requiring-static.rs:44:5
|
||||
--> $DIR/regions-bounded-by-trait-requiring-static.rs:54:5
|
||||
|
|
||||
LL | fn box_with_region_not_ok<'a>() {
|
||||
| -- lifetime `'a` defined here
|
||||
|
@ -31,7 +31,7 @@ LL | assert_send::<Box<&'a isize>>();
|
|||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static`
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/regions-bounded-by-trait-requiring-static.rs:55:5
|
||||
--> $DIR/regions-bounded-by-trait-requiring-static.rs:67:5
|
||||
|
|
||||
LL | fn unsafe_ok2<'a>(_: &'a isize) {
|
||||
| -- lifetime `'a` defined here
|
||||
|
@ -39,7 +39,7 @@ LL | assert_send::<*const &'a isize>();
|
|||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static`
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/regions-bounded-by-trait-requiring-static.rs:59:5
|
||||
--> $DIR/regions-bounded-by-trait-requiring-static.rs:73:5
|
||||
|
|
||||
LL | fn unsafe_ok3<'a>(_: &'a isize) {
|
||||
| -- lifetime `'a` defined here
|
||||
|
|
|
@ -2,6 +2,10 @@
|
|||
// in this file all test region bound and lifetime violations that are
|
||||
// detected during type check.
|
||||
|
||||
// revisions: base nll
|
||||
// ignore-compare-mode-nll
|
||||
//[nll] compile-flags: -Z borrowck=mir
|
||||
|
||||
trait Dummy : 'static { }
|
||||
fn assert_send<T:'static>() { }
|
||||
|
||||
|
@ -19,15 +23,21 @@ fn static_lifime_ok<'a,T,U:Send>(_: &'a isize) {
|
|||
// otherwise lifetime pointers are not ok
|
||||
|
||||
fn param_not_ok<'a>(x: &'a isize) {
|
||||
assert_send::<&'a isize>(); //~ ERROR does not fulfill the required lifetime
|
||||
assert_send::<&'a isize>();
|
||||
//[base]~^ ERROR does not fulfill the required lifetime
|
||||
//[nll]~^^ ERROR lifetime may not live long enough
|
||||
}
|
||||
|
||||
fn param_not_ok1<'a>(_: &'a isize) {
|
||||
assert_send::<&'a str>(); //~ ERROR does not fulfill the required lifetime
|
||||
assert_send::<&'a str>();
|
||||
//[base]~^ ERROR does not fulfill the required lifetime
|
||||
//[nll]~^^ ERROR lifetime may not live long enough
|
||||
}
|
||||
|
||||
fn param_not_ok2<'a>(_: &'a isize) {
|
||||
assert_send::<&'a [isize]>(); //~ ERROR does not fulfill the required lifetime
|
||||
assert_send::<&'a [isize]>();
|
||||
//[base]~^ ERROR does not fulfill the required lifetime
|
||||
//[nll]~^^ ERROR lifetime may not live long enough
|
||||
}
|
||||
|
||||
// boxes are ok
|
||||
|
@ -41,7 +51,9 @@ fn box_ok() {
|
|||
// but not if they own a bad thing
|
||||
|
||||
fn box_with_region_not_ok<'a>() {
|
||||
assert_send::<Box<&'a isize>>(); //~ ERROR does not fulfill the required lifetime
|
||||
assert_send::<Box<&'a isize>>();
|
||||
//[base]~^ ERROR does not fulfill the required lifetime
|
||||
//[nll]~^^ ERROR lifetime may not live long enough
|
||||
}
|
||||
|
||||
// raw pointers are ok unless they point at unsendable things
|
||||
|
@ -52,11 +64,15 @@ fn unsafe_ok1<'a>(_: &'a isize) {
|
|||
}
|
||||
|
||||
fn unsafe_ok2<'a>(_: &'a isize) {
|
||||
assert_send::<*const &'a isize>(); //~ ERROR does not fulfill the required lifetime
|
||||
assert_send::<*const &'a isize>();
|
||||
//[base]~^ ERROR does not fulfill the required lifetime
|
||||
//[nll]~^^ ERROR lifetime may not live long enough
|
||||
}
|
||||
|
||||
fn unsafe_ok3<'a>(_: &'a isize) {
|
||||
assert_send::<*mut &'a isize>(); //~ ERROR does not fulfill the required lifetime
|
||||
assert_send::<*mut &'a isize>();
|
||||
//[base]~^ ERROR does not fulfill the required lifetime
|
||||
//[nll]~^^ ERROR lifetime may not live long enough
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/regions-bounded-method-type-parameters-cross-crate.rs:20:7
|
||||
--> $DIR/regions-bounded-method-type-parameters-cross-crate.rs:23:7
|
||||
|
|
||||
LL | fn call_bigger_region<'x, 'y>(a: Inv<'x>, b: Inv<'y>) {
|
||||
| ------- ------- these two types are declared with different lifetimes...
|
|
@ -1,5 +1,5 @@
|
|||
error: lifetime may not live long enough
|
||||
--> $DIR/regions-bounded-method-type-parameters-cross-crate.rs:20:5
|
||||
--> $DIR/regions-bounded-method-type-parameters-cross-crate.rs:23:5
|
||||
|
|
||||
LL | fn call_bigger_region<'x, 'y>(a: Inv<'x>, b: Inv<'y>) {
|
||||
| -- -- lifetime `'y` defined here
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
// aux-build:rbmtp_cross_crate_lib.rs
|
||||
// revisions: base nll
|
||||
// ignore-compare-mode-nll
|
||||
//[nll] compile-flags: -Z borrowck=mir
|
||||
|
||||
// Check explicit region bounds on methods in the cross crate case.
|
||||
|
||||
|
@ -17,7 +20,9 @@ fn call_into_maybe_owned<'x,F:IntoMaybeOwned<'x>>(f: F) {
|
|||
|
||||
fn call_bigger_region<'x, 'y>(a: Inv<'x>, b: Inv<'y>) {
|
||||
// Here the value provided for 'y is 'y, and hence 'y:'x does not hold.
|
||||
a.bigger_region(b) //~ ERROR lifetime mismatch [E0623]
|
||||
a.bigger_region(b)
|
||||
//[base]~^ ERROR lifetime mismatch [E0623]
|
||||
//[nll]~^^ ERROR lifetime may not live long enough
|
||||
}
|
||||
|
||||
fn main() { }
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/regions-bounded-method-type-parameters-trait-bound.rs:20:7
|
||||
--> $DIR/regions-bounded-method-type-parameters-trait-bound.rs:24:7
|
||||
|
|
||||
LL | fn caller2<'a,'b,F:Foo<'a>>(a: Inv<'a>, b: Inv<'b>, f: F) {
|
||||
| ------- ------- these two types are declared with different lifetimes...
|
|
@ -1,5 +1,5 @@
|
|||
error: lifetime may not live long enough
|
||||
--> $DIR/regions-bounded-method-type-parameters-trait-bound.rs:20:5
|
||||
--> $DIR/regions-bounded-method-type-parameters-trait-bound.rs:24:5
|
||||
|
|
||||
LL | fn caller2<'a,'b,F:Foo<'a>>(a: Inv<'a>, b: Inv<'b>, f: F) {
|
||||
| -- -- lifetime `'b` defined here
|
||||
|
|
|
@ -2,6 +2,10 @@
|
|||
// nominal types (but not on other types) and that they are type
|
||||
// checked.
|
||||
|
||||
// revisions: base nll
|
||||
// ignore-compare-mode-nll
|
||||
//[nll] compile-flags: -Z borrowck=mir
|
||||
|
||||
struct Inv<'a> { // invariant w/r/t 'a
|
||||
x: &'a mut &'a isize
|
||||
}
|
||||
|
@ -17,7 +21,9 @@ fn caller1<'a,'b,F:Foo<'a>>(a: Inv<'a>, b: Inv<'b>, f: F) {
|
|||
|
||||
fn caller2<'a,'b,F:Foo<'a>>(a: Inv<'a>, b: Inv<'b>, f: F) {
|
||||
// Here the value provided for 'y is 'b, and hence 'b:'a does not hold.
|
||||
f.method(b); //~ ERROR lifetime mismatch [E0623]
|
||||
f.method(b);
|
||||
//[base]~^ ERROR lifetime mismatch [E0623]
|
||||
//[nll]~^^ ERROR lifetime may not live long enough
|
||||
}
|
||||
|
||||
fn caller3<'a,'b:'a,F:Foo<'a>>(a: Inv<'a>, b: Inv<'b>, f: F) {
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
error[E0477]: the type `&'a isize` does not fulfill the required lifetime
|
||||
--> $DIR/regions-bounded-method-type-parameters.rs:12:9
|
||||
--> $DIR/regions-bounded-method-type-parameters.rs:16:9
|
||||
|
|
||||
LL | Foo.some_method::<&'a isize>();
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
note: type must satisfy the static lifetime as required by this binding
|
||||
--> $DIR/regions-bounded-method-type-parameters.rs:8:22
|
||||
--> $DIR/regions-bounded-method-type-parameters.rs:12:22
|
||||
|
|
||||
LL | fn some_method<A:'static>(self) { }
|
||||
| ^^^^^^^
|
|
@ -1,5 +1,5 @@
|
|||
error: lifetime may not live long enough
|
||||
--> $DIR/regions-bounded-method-type-parameters.rs:12:9
|
||||
--> $DIR/regions-bounded-method-type-parameters.rs:16:9
|
||||
|
|
||||
LL | fn caller<'a>(x: &isize) {
|
||||
| -- lifetime `'a` defined here
|
||||
|
|
|
@ -2,6 +2,10 @@
|
|||
// nominal types (but not on other types) and that they are type
|
||||
// checked.
|
||||
|
||||
// revisions: base nll
|
||||
// ignore-compare-mode-nll
|
||||
//[nll] compile-flags: -Z borrowck=mir
|
||||
|
||||
struct Foo;
|
||||
|
||||
impl Foo {
|
||||
|
@ -10,7 +14,8 @@ impl Foo {
|
|||
|
||||
fn caller<'a>(x: &isize) {
|
||||
Foo.some_method::<&'a isize>();
|
||||
//~^ ERROR does not fulfill the required lifetime
|
||||
//[base]~^ ERROR does not fulfill the required lifetime
|
||||
//[nll]~^^ ERROR lifetime may not live long enough
|
||||
}
|
||||
|
||||
fn main() { }
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/regions-bounds.rs:9:12
|
||||
--> $DIR/regions-bounds.rs:13:12
|
||||
|
|
||||
LL | return e;
|
||||
| ^ lifetime mismatch
|
||||
|
@ -7,18 +7,18 @@ LL | return e;
|
|||
= note: expected struct `TupleStruct<'b>`
|
||||
found struct `TupleStruct<'a>`
|
||||
note: the lifetime `'a` as defined here...
|
||||
--> $DIR/regions-bounds.rs:8:10
|
||||
--> $DIR/regions-bounds.rs:12:10
|
||||
|
|
||||
LL | fn a_fn1<'a,'b>(e: TupleStruct<'a>) -> TupleStruct<'b> {
|
||||
| ^^
|
||||
note: ...does not necessarily outlive the lifetime `'b` as defined here
|
||||
--> $DIR/regions-bounds.rs:8:13
|
||||
--> $DIR/regions-bounds.rs:12:13
|
||||
|
|
||||
LL | fn a_fn1<'a,'b>(e: TupleStruct<'a>) -> TupleStruct<'b> {
|
||||
| ^^
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/regions-bounds.rs:13:12
|
||||
--> $DIR/regions-bounds.rs:19:12
|
||||
|
|
||||
LL | return e;
|
||||
| ^ lifetime mismatch
|
||||
|
@ -26,12 +26,12 @@ LL | return e;
|
|||
= note: expected struct `Struct<'b>`
|
||||
found struct `Struct<'a>`
|
||||
note: the lifetime `'a` as defined here...
|
||||
--> $DIR/regions-bounds.rs:12:10
|
||||
--> $DIR/regions-bounds.rs:18:10
|
||||
|
|
||||
LL | fn a_fn3<'a,'b>(e: Struct<'a>) -> Struct<'b> {
|
||||
| ^^
|
||||
note: ...does not necessarily outlive the lifetime `'b` as defined here
|
||||
--> $DIR/regions-bounds.rs:12:13
|
||||
--> $DIR/regions-bounds.rs:18:13
|
||||
|
|
||||
LL | fn a_fn3<'a,'b>(e: Struct<'a>) -> Struct<'b> {
|
||||
| ^^
|
|
@ -1,5 +1,5 @@
|
|||
error: lifetime may not live long enough
|
||||
--> $DIR/regions-bounds.rs:9:12
|
||||
--> $DIR/regions-bounds.rs:13:12
|
||||
|
|
||||
LL | fn a_fn1<'a,'b>(e: TupleStruct<'a>) -> TupleStruct<'b> {
|
||||
| -- -- lifetime `'b` defined here
|
||||
|
@ -11,7 +11,7 @@ LL | return e;
|
|||
= help: consider adding the following bound: `'a: 'b`
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/regions-bounds.rs:13:12
|
||||
--> $DIR/regions-bounds.rs:19:12
|
||||
|
|
||||
LL | fn a_fn3<'a,'b>(e: Struct<'a>) -> Struct<'b> {
|
||||
| -- -- lifetime `'b` defined here
|
||||
|
|
|
@ -2,15 +2,23 @@
|
|||
// nominal types (but not on other types) and that they are type
|
||||
// checked.
|
||||
|
||||
// revisions: base nll
|
||||
// ignore-compare-mode-nll
|
||||
//[nll] compile-flags: -Z borrowck=mir
|
||||
|
||||
struct TupleStruct<'a>(&'a isize);
|
||||
struct Struct<'a> { x:&'a isize }
|
||||
|
||||
fn a_fn1<'a,'b>(e: TupleStruct<'a>) -> TupleStruct<'b> {
|
||||
return e; //~ ERROR mismatched types
|
||||
return e;
|
||||
//[base]~^ ERROR mismatched types
|
||||
//[nll]~^^ ERROR lifetime may not live long enough
|
||||
}
|
||||
|
||||
fn a_fn3<'a,'b>(e: Struct<'a>) -> Struct<'b> {
|
||||
return e; //~ ERROR mismatched types
|
||||
return e;
|
||||
//[base]~^ ERROR mismatched types
|
||||
//[nll]~^^ ERROR lifetime may not live long enough
|
||||
}
|
||||
|
||||
fn main() { }
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error[E0310]: the associated type `<T as Iter>::Item` may not live long enough
|
||||
--> $DIR/regions-close-associated-type-into-object.rs:15:5
|
||||
--> $DIR/regions-close-associated-type-into-object.rs:19:5
|
||||
|
|
||||
LL | Box::new(item)
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
@ -8,7 +8,7 @@ LL | Box::new(item)
|
|||
= note: ...so that the type `<T as Iter>::Item` will meet its required lifetime bounds
|
||||
|
||||
error[E0310]: the associated type `<T as Iter>::Item` may not live long enough
|
||||
--> $DIR/regions-close-associated-type-into-object.rs:22:5
|
||||
--> $DIR/regions-close-associated-type-into-object.rs:26:5
|
||||
|
|
||||
LL | Box::new(item)
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
@ -17,7 +17,7 @@ LL | Box::new(item)
|
|||
= note: ...so that the type `Box<<T as Iter>::Item>` will meet its required lifetime bounds
|
||||
|
||||
error[E0309]: the associated type `<T as Iter>::Item` may not live long enough
|
||||
--> $DIR/regions-close-associated-type-into-object.rs:28:5
|
||||
--> $DIR/regions-close-associated-type-into-object.rs:32:5
|
||||
|
|
||||
LL | Box::new(item)
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
@ -26,7 +26,7 @@ LL | Box::new(item)
|
|||
= note: ...so that the type `<T as Iter>::Item` will meet its required lifetime bounds
|
||||
|
||||
error[E0309]: the associated type `<T as Iter>::Item` may not live long enough
|
||||
--> $DIR/regions-close-associated-type-into-object.rs:35:5
|
||||
--> $DIR/regions-close-associated-type-into-object.rs:39:5
|
||||
|
|
||||
LL | Box::new(item)
|
||||
| ^^^^^^^^^^^^^^
|
|
@ -1,5 +1,5 @@
|
|||
error[E0310]: the associated type `<T as Iter>::Item` may not live long enough
|
||||
--> $DIR/regions-close-associated-type-into-object.rs:15:5
|
||||
--> $DIR/regions-close-associated-type-into-object.rs:19:5
|
||||
|
|
||||
LL | Box::new(item)
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
@ -8,7 +8,7 @@ LL | Box::new(item)
|
|||
= note: ...so that the type `<T as Iter>::Item` will meet its required lifetime bounds
|
||||
|
||||
error[E0310]: the associated type `<T as Iter>::Item` may not live long enough
|
||||
--> $DIR/regions-close-associated-type-into-object.rs:22:5
|
||||
--> $DIR/regions-close-associated-type-into-object.rs:26:5
|
||||
|
|
||||
LL | Box::new(item)
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
@ -17,7 +17,7 @@ LL | Box::new(item)
|
|||
= note: ...so that the type `<T as Iter>::Item` will meet its required lifetime bounds
|
||||
|
||||
error[E0309]: the associated type `<T as Iter>::Item` may not live long enough
|
||||
--> $DIR/regions-close-associated-type-into-object.rs:28:5
|
||||
--> $DIR/regions-close-associated-type-into-object.rs:32:5
|
||||
|
|
||||
LL | Box::new(item)
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
@ -26,7 +26,7 @@ LL | Box::new(item)
|
|||
= note: ...so that the type `<T as Iter>::Item` will meet its required lifetime bounds
|
||||
|
||||
error[E0309]: the associated type `<T as Iter>::Item` may not live long enough
|
||||
--> $DIR/regions-close-associated-type-into-object.rs:35:5
|
||||
--> $DIR/regions-close-associated-type-into-object.rs:39:5
|
||||
|
|
||||
LL | Box::new(item)
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
// revisions: base nll
|
||||
// ignore-compare-mode-nll
|
||||
//[nll] compile-flags: -Z borrowck=mir
|
||||
|
||||
trait X {}
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error[E0759]: `v` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement
|
||||
--> $DIR/regions-close-object-into-object-2.rs:9:16
|
||||
--> $DIR/regions-close-object-into-object-2.rs:13:16
|
||||
|
|
||||
LL | fn g<'a, T: 'static>(v: Box<dyn A<T> + 'a>) -> Box<dyn X + 'static> {
|
||||
| ------------------ this data with lifetime `'a`...
|
||||
|
@ -7,7 +7,7 @@ LL | Box::new(B(&*v)) as Box<dyn X>
|
|||
| ^^^ ...is used and required to live as long as `'static` here
|
||||
|
|
||||
note: `'static` lifetime requirement introduced by the return type
|
||||
--> $DIR/regions-close-object-into-object-2.rs:8:60
|
||||
--> $DIR/regions-close-object-into-object-2.rs:12:60
|
||||
|
|
||||
LL | fn g<'a, T: 'static>(v: Box<dyn A<T> + 'a>) -> Box<dyn X + 'static> {
|
||||
| ^^^^^^^ `'static` requirement introduced here
|
|
@ -1,5 +1,5 @@
|
|||
error: lifetime may not live long enough
|
||||
--> $DIR/regions-close-object-into-object-2.rs:9:5
|
||||
--> $DIR/regions-close-object-into-object-2.rs:13:5
|
||||
|
|
||||
LL | fn g<'a, T: 'static>(v: Box<dyn A<T> + 'a>) -> Box<dyn X + 'static> {
|
||||
| -- lifetime `'a` defined here
|
||||
|
@ -7,7 +7,7 @@ LL | Box::new(B(&*v)) as Box<dyn X>
|
|||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static`
|
||||
|
||||
error[E0515]: cannot return value referencing local data `*v`
|
||||
--> $DIR/regions-close-object-into-object-2.rs:9:5
|
||||
--> $DIR/regions-close-object-into-object-2.rs:13:5
|
||||
|
|
||||
LL | Box::new(B(&*v)) as Box<dyn X>
|
||||
| ^^^^^^^^^^^---^^^^^^^^^^^^^^^^
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
// revisions: base nll
|
||||
// ignore-compare-mode-nll
|
||||
//[nll] compile-flags: -Z borrowck=mir
|
||||
|
||||
trait A<T> { }
|
||||
|
||||
struct B<'a, T:'a>(&'a (dyn A<T> + 'a));
|
||||
|
@ -6,7 +10,10 @@ trait X { }
|
|||
impl<'a, T> X for B<'a, T> {}
|
||||
|
||||
fn g<'a, T: 'static>(v: Box<dyn A<T> + 'a>) -> Box<dyn X + 'static> {
|
||||
Box::new(B(&*v)) as Box<dyn X> //~ ERROR E0759
|
||||
Box::new(B(&*v)) as Box<dyn X>
|
||||
//[base]~^ ERROR E0759
|
||||
//[nll]~^^ ERROR lifetime may not live long enough
|
||||
//[nll]~| ERROR cannot return value referencing local data `*v` [E0515]
|
||||
}
|
||||
|
||||
fn main() { }
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error[E0759]: `v` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement
|
||||
--> $DIR/regions-close-object-into-object-4.rs:9:16
|
||||
--> $DIR/regions-close-object-into-object-4.rs:13:16
|
||||
|
|
||||
LL | fn i<'a, T, U>(v: Box<dyn A<U>+'a>) -> Box<dyn X + 'static> {
|
||||
| ---------------- this data with lifetime `'a`...
|
||||
|
@ -7,7 +7,7 @@ LL | Box::new(B(&*v)) as Box<dyn X>
|
|||
| ^^^ ...is used and required to live as long as `'static` here
|
||||
|
|
||||
note: `'static` lifetime requirement introduced by the return type
|
||||
--> $DIR/regions-close-object-into-object-4.rs:8:52
|
||||
--> $DIR/regions-close-object-into-object-4.rs:12:52
|
||||
|
|
||||
LL | fn i<'a, T, U>(v: Box<dyn A<U>+'a>) -> Box<dyn X + 'static> {
|
||||
| ^^^^^^^ `'static` requirement introduced here
|
|
@ -1,5 +1,5 @@
|
|||
error[E0310]: the parameter type `U` may not live long enough
|
||||
--> $DIR/regions-close-object-into-object-4.rs:9:5
|
||||
--> $DIR/regions-close-object-into-object-4.rs:13:5
|
||||
|
|
||||
LL | fn i<'a, T, U>(v: Box<dyn A<U>+'a>) -> Box<dyn X + 'static> {
|
||||
| - help: consider adding an explicit lifetime bound...: `U: 'static`
|
||||
|
@ -7,7 +7,7 @@ LL | Box::new(B(&*v)) as Box<dyn X>
|
|||
| ^^^^^^^^ ...so that the type `U` will meet its required lifetime bounds
|
||||
|
||||
error[E0310]: the parameter type `U` may not live long enough
|
||||
--> $DIR/regions-close-object-into-object-4.rs:9:5
|
||||
--> $DIR/regions-close-object-into-object-4.rs:13:5
|
||||
|
|
||||
LL | fn i<'a, T, U>(v: Box<dyn A<U>+'a>) -> Box<dyn X + 'static> {
|
||||
| - help: consider adding an explicit lifetime bound...: `U: 'static`
|
||||
|
@ -15,7 +15,7 @@ LL | Box::new(B(&*v)) as Box<dyn X>
|
|||
| ^^^^^^^^^^^^^^^^ ...so that the type `U` will meet its required lifetime bounds
|
||||
|
||||
error[E0310]: the parameter type `U` may not live long enough
|
||||
--> $DIR/regions-close-object-into-object-4.rs:9:5
|
||||
--> $DIR/regions-close-object-into-object-4.rs:13:5
|
||||
|
|
||||
LL | fn i<'a, T, U>(v: Box<dyn A<U>+'a>) -> Box<dyn X + 'static> {
|
||||
| - help: consider adding an explicit lifetime bound...: `U: 'static`
|
||||
|
@ -23,7 +23,7 @@ LL | Box::new(B(&*v)) as Box<dyn X>
|
|||
| ^^^^^^^^^^^^^^^^ ...so that the type `U` will meet its required lifetime bounds
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/regions-close-object-into-object-4.rs:9:5
|
||||
--> $DIR/regions-close-object-into-object-4.rs:13:5
|
||||
|
|
||||
LL | fn i<'a, T, U>(v: Box<dyn A<U>+'a>) -> Box<dyn X + 'static> {
|
||||
| -- lifetime `'a` defined here
|
||||
|
@ -31,7 +31,7 @@ LL | Box::new(B(&*v)) as Box<dyn X>
|
|||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static`
|
||||
|
||||
error[E0515]: cannot return value referencing local data `*v`
|
||||
--> $DIR/regions-close-object-into-object-4.rs:9:5
|
||||
--> $DIR/regions-close-object-into-object-4.rs:13:5
|
||||
|
|
||||
LL | Box::new(B(&*v)) as Box<dyn X>
|
||||
| ^^^^^^^^^^^---^^^^^^^^^^^^^^^^
|
||||
|
@ -40,7 +40,7 @@ LL | Box::new(B(&*v)) as Box<dyn X>
|
|||
| returns a value referencing data owned by the current function
|
||||
|
||||
error[E0310]: the parameter type `U` may not live long enough
|
||||
--> $DIR/regions-close-object-into-object-4.rs:9:14
|
||||
--> $DIR/regions-close-object-into-object-4.rs:13:14
|
||||
|
|
||||
LL | fn i<'a, T, U>(v: Box<dyn A<U>+'a>) -> Box<dyn X + 'static> {
|
||||
| - help: consider adding an explicit lifetime bound...: `U: 'static`
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
// revisions: base nll
|
||||
// ignore-compare-mode-nll
|
||||
//[nll] compile-flags: -Z borrowck=mir
|
||||
|
||||
trait A<T> { }
|
||||
|
||||
struct B<'a, T:'a>(&'a (dyn A<T> + 'a));
|
||||
|
@ -6,7 +10,15 @@ trait X { }
|
|||
impl<'a, T> X for B<'a, T> {}
|
||||
|
||||
fn i<'a, T, U>(v: Box<dyn A<U>+'a>) -> Box<dyn X + 'static> {
|
||||
Box::new(B(&*v)) as Box<dyn X> //~ ERROR E0759
|
||||
Box::new(B(&*v)) as Box<dyn X>
|
||||
//[base]~^ ERROR E0759
|
||||
//[nll]~^^ ERROR the parameter type `U` may not live long enough [E0310]
|
||||
//[nll]~| ERROR the parameter type `U` may not live long enough [E0310]
|
||||
//[nll]~| ERROR the parameter type `U` may not live long enough [E0310]
|
||||
//[nll]~| ERROR lifetime may not live long enough
|
||||
//[nll]~| ERROR cannot return value referencing local data `*v` [E0515]
|
||||
//[nll]~| ERROR the parameter type `U` may not live long enough [E0310]
|
||||
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error[E0310]: the parameter type `T` may not live long enough
|
||||
--> $DIR/regions-close-object-into-object-5.rs:17:5
|
||||
--> $DIR/regions-close-object-into-object-5.rs:21:5
|
||||
|
|
||||
LL | fn f<'a, T, U>(v: Box<A<T> + 'static>) -> Box<X + 'static> {
|
||||
| - help: consider adding an explicit lifetime bound...: `T: 'static`
|
||||
|
@ -8,13 +8,13 @@ LL | Box::new(B(&*v)) as Box<dyn X>
|
|||
| ^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds...
|
||||
|
|
||||
note: ...that is required by this bound
|
||||
--> $DIR/regions-close-object-into-object-5.rs:9:17
|
||||
--> $DIR/regions-close-object-into-object-5.rs:13:17
|
||||
|
|
||||
LL | struct B<'a, T: 'a>(&'a (A<T> + 'a));
|
||||
| ^^
|
||||
|
||||
error[E0310]: the parameter type `T` may not live long enough
|
||||
--> $DIR/regions-close-object-into-object-5.rs:17:5
|
||||
--> $DIR/regions-close-object-into-object-5.rs:21:5
|
||||
|
|
||||
LL | fn f<'a, T, U>(v: Box<A<T> + 'static>) -> Box<X + 'static> {
|
||||
| - help: consider adding an explicit lifetime bound...: `T: 'static`
|
||||
|
@ -23,7 +23,7 @@ LL | Box::new(B(&*v)) as Box<dyn X>
|
|||
| ^^^^^^^^^^^^^^^^ ...so that the type `B<'_, T>` will meet its required lifetime bounds
|
||||
|
||||
error[E0310]: the parameter type `T` may not live long enough
|
||||
--> $DIR/regions-close-object-into-object-5.rs:17:14
|
||||
--> $DIR/regions-close-object-into-object-5.rs:21:14
|
||||
|
|
||||
LL | fn f<'a, T, U>(v: Box<A<T> + 'static>) -> Box<X + 'static> {
|
||||
| - help: consider adding an explicit lifetime bound...: `T: 'static`
|
||||
|
@ -32,13 +32,13 @@ LL | Box::new(B(&*v)) as Box<dyn X>
|
|||
| ^ ...so that the type `T` will meet its required lifetime bounds...
|
||||
|
|
||||
note: ...that is required by this bound
|
||||
--> $DIR/regions-close-object-into-object-5.rs:9:17
|
||||
--> $DIR/regions-close-object-into-object-5.rs:13:17
|
||||
|
|
||||
LL | struct B<'a, T: 'a>(&'a (A<T> + 'a));
|
||||
| ^^
|
||||
|
||||
error[E0310]: the parameter type `T` may not live long enough
|
||||
--> $DIR/regions-close-object-into-object-5.rs:17:14
|
||||
--> $DIR/regions-close-object-into-object-5.rs:21:14
|
||||
|
|
||||
LL | fn f<'a, T, U>(v: Box<A<T> + 'static>) -> Box<X + 'static> {
|
||||
| - help: consider adding an explicit lifetime bound...: `T: 'static`
|
||||
|
@ -47,13 +47,13 @@ LL | Box::new(B(&*v)) as Box<dyn X>
|
|||
| ^^^^^^ ...so that the type `T` will meet its required lifetime bounds...
|
||||
|
|
||||
note: ...that is required by this bound
|
||||
--> $DIR/regions-close-object-into-object-5.rs:9:17
|
||||
--> $DIR/regions-close-object-into-object-5.rs:13:17
|
||||
|
|
||||
LL | struct B<'a, T: 'a>(&'a (A<T> + 'a));
|
||||
| ^^
|
||||
|
||||
error[E0310]: the parameter type `T` may not live long enough
|
||||
--> $DIR/regions-close-object-into-object-5.rs:17:16
|
||||
--> $DIR/regions-close-object-into-object-5.rs:21:16
|
||||
|
|
||||
LL | fn f<'a, T, U>(v: Box<A<T> + 'static>) -> Box<X + 'static> {
|
||||
| - help: consider adding an explicit lifetime bound...: `T: 'static`
|
||||
|
@ -62,7 +62,7 @@ LL | Box::new(B(&*v)) as Box<dyn X>
|
|||
| ^^^ ...so that the reference type `&dyn A<T>` does not outlive the data it points at
|
||||
|
||||
error[E0310]: the parameter type `T` may not live long enough
|
||||
--> $DIR/regions-close-object-into-object-5.rs:17:16
|
||||
--> $DIR/regions-close-object-into-object-5.rs:21:16
|
||||
|
|
||||
LL | fn f<'a, T, U>(v: Box<A<T> + 'static>) -> Box<X + 'static> {
|
||||
| - help: consider adding an explicit lifetime bound...: `T: 'static`
|
||||
|
@ -71,7 +71,7 @@ LL | Box::new(B(&*v)) as Box<dyn X>
|
|||
| ^^^ ...so that the type `(dyn A<T> + 'static)` is not borrowed for too long
|
||||
|
||||
error[E0310]: the parameter type `T` may not live long enough
|
||||
--> $DIR/regions-close-object-into-object-5.rs:17:16
|
||||
--> $DIR/regions-close-object-into-object-5.rs:21:16
|
||||
|
|
||||
LL | fn f<'a, T, U>(v: Box<A<T> + 'static>) -> Box<X + 'static> {
|
||||
| - help: consider adding an explicit lifetime bound...: `T: 'static`
|
|
@ -1,5 +1,5 @@
|
|||
error[E0310]: the parameter type `T` may not live long enough
|
||||
--> $DIR/regions-close-object-into-object-5.rs:17:5
|
||||
--> $DIR/regions-close-object-into-object-5.rs:21:5
|
||||
|
|
||||
LL | fn f<'a, T, U>(v: Box<A<T> + 'static>) -> Box<X + 'static> {
|
||||
| - help: consider adding an explicit lifetime bound...: `T: 'static`
|
||||
|
@ -8,7 +8,7 @@ LL | Box::new(B(&*v)) as Box<dyn X>
|
|||
| ^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds
|
||||
|
||||
error[E0310]: the parameter type `T` may not live long enough
|
||||
--> $DIR/regions-close-object-into-object-5.rs:17:5
|
||||
--> $DIR/regions-close-object-into-object-5.rs:21:5
|
||||
|
|
||||
LL | fn f<'a, T, U>(v: Box<A<T> + 'static>) -> Box<X + 'static> {
|
||||
| - help: consider adding an explicit lifetime bound...: `T: 'static`
|
||||
|
@ -17,7 +17,7 @@ LL | Box::new(B(&*v)) as Box<dyn X>
|
|||
| ^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds
|
||||
|
||||
error[E0310]: the parameter type `T` may not live long enough
|
||||
--> $DIR/regions-close-object-into-object-5.rs:17:5
|
||||
--> $DIR/regions-close-object-into-object-5.rs:21:5
|
||||
|
|
||||
LL | fn f<'a, T, U>(v: Box<A<T> + 'static>) -> Box<X + 'static> {
|
||||
| - help: consider adding an explicit lifetime bound...: `T: 'static`
|
||||
|
@ -26,7 +26,7 @@ LL | Box::new(B(&*v)) as Box<dyn X>
|
|||
| ^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds
|
||||
|
||||
error[E0515]: cannot return value referencing local data `*v`
|
||||
--> $DIR/regions-close-object-into-object-5.rs:17:5
|
||||
--> $DIR/regions-close-object-into-object-5.rs:21:5
|
||||
|
|
||||
LL | Box::new(B(&*v)) as Box<dyn X>
|
||||
| ^^^^^^^^^^^---^^^^^^^^^^^^^^^^
|
||||
|
@ -35,7 +35,7 @@ LL | Box::new(B(&*v)) as Box<dyn X>
|
|||
| returns a value referencing data owned by the current function
|
||||
|
||||
error[E0310]: the parameter type `T` may not live long enough
|
||||
--> $DIR/regions-close-object-into-object-5.rs:17:14
|
||||
--> $DIR/regions-close-object-into-object-5.rs:21:14
|
||||
|
|
||||
LL | fn f<'a, T, U>(v: Box<A<T> + 'static>) -> Box<X + 'static> {
|
||||
| - help: consider adding an explicit lifetime bound...: `T: 'static`
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
// revisions: base nll
|
||||
// ignore-compare-mode-nll
|
||||
//[nll] compile-flags: -Z borrowck=mir
|
||||
|
||||
#![allow(warnings)]
|
||||
|
||||
|
||||
|
@ -19,9 +23,10 @@ fn f<'a, T, U>(v: Box<A<T> + 'static>) -> Box<X + 'static> {
|
|||
//~| ERROR the parameter type `T` may not live long enough
|
||||
//~| ERROR the parameter type `T` may not live long enough
|
||||
//~| ERROR the parameter type `T` may not live long enough
|
||||
//~| ERROR the parameter type `T` may not live long enough
|
||||
//~| ERROR the parameter type `T` may not live long enough
|
||||
//~| ERROR the parameter type `T` may not live long enough
|
||||
//[base]~| ERROR the parameter type `T` may not live long enough
|
||||
//[base]~| ERROR the parameter type `T` may not live long enough
|
||||
//[base]~| ERROR the parameter type `T` may not live long enough
|
||||
//[nll]~| ERROR cannot return value referencing local data `*v` [E0515]
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error[E0310]: the parameter type `A` may not live long enough
|
||||
--> $DIR/regions-close-over-type-parameter-1.rs:12:5
|
||||
--> $DIR/regions-close-over-type-parameter-1.rs:15:5
|
||||
|
|
||||
LL | fn make_object1<A: SomeTrait>(v: A) -> Box<dyn SomeTrait + 'static> {
|
||||
| -- help: consider adding an explicit lifetime bound...: `A: 'static +`
|
||||
|
@ -7,7 +7,7 @@ LL | Box::new(v) as Box<dyn SomeTrait + 'static>
|
|||
| ^^^^^^^^^^^ ...so that the type `A` will meet its required lifetime bounds
|
||||
|
||||
error[E0309]: the parameter type `A` may not live long enough
|
||||
--> $DIR/regions-close-over-type-parameter-1.rs:21:5
|
||||
--> $DIR/regions-close-over-type-parameter-1.rs:24:5
|
||||
|
|
||||
LL | fn make_object3<'a, 'b, A: SomeTrait + 'a>(v: A) -> Box<dyn SomeTrait + 'b> {
|
||||
| -- help: consider adding an explicit lifetime bound...: `A: 'b +`
|
|
@ -1,5 +1,5 @@
|
|||
error[E0310]: the parameter type `A` may not live long enough
|
||||
--> $DIR/regions-close-over-type-parameter-1.rs:12:5
|
||||
--> $DIR/regions-close-over-type-parameter-1.rs:15:5
|
||||
|
|
||||
LL | fn make_object1<A: SomeTrait>(v: A) -> Box<dyn SomeTrait + 'static> {
|
||||
| -- help: consider adding an explicit lifetime bound...: `A: 'static +`
|
||||
|
@ -7,7 +7,7 @@ LL | Box::new(v) as Box<dyn SomeTrait + 'static>
|
|||
| ^^^^^^^^^^^ ...so that the type `A` will meet its required lifetime bounds
|
||||
|
||||
error[E0309]: the parameter type `A` may not live long enough
|
||||
--> $DIR/regions-close-over-type-parameter-1.rs:21:5
|
||||
--> $DIR/regions-close-over-type-parameter-1.rs:24:5
|
||||
|
|
||||
LL | fn make_object3<'a, 'b, A: SomeTrait + 'a>(v: A) -> Box<dyn SomeTrait + 'b> {
|
||||
| -- help: consider adding an explicit lifetime bound...: `A: 'b +`
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
// an object. This should yield errors unless `A` (and the object)
|
||||
// both have suitable bounds.
|
||||
|
||||
// revisions: base nll
|
||||
// ignore-compare-mode-nll
|
||||
//[nll] compile-flags: -Z borrowck=mir
|
||||
|
||||
trait SomeTrait {
|
||||
fn get(&self) -> isize;
|
||||
|
|
|
@ -1,26 +1,26 @@
|
|||
error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements
|
||||
--> $DIR/regions-close-over-type-parameter-multiple.rs:20:5
|
||||
--> $DIR/regions-close-over-type-parameter-multiple.rs:23:5
|
||||
|
|
||||
LL | Box::new(v) as Box<dyn SomeTrait + 'a>
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: first, the lifetime cannot outlive the lifetime `'a` as defined here...
|
||||
--> $DIR/regions-close-over-type-parameter-multiple.rs:18:20
|
||||
--> $DIR/regions-close-over-type-parameter-multiple.rs:21:20
|
||||
|
|
||||
LL | fn make_object_bad<'a,'b,'c,A:SomeTrait+'a+'b>(v: A) -> Box<dyn SomeTrait + 'c> {
|
||||
| ^^
|
||||
note: ...so that the declared lifetime parameter bounds are satisfied
|
||||
--> $DIR/regions-close-over-type-parameter-multiple.rs:20:5
|
||||
--> $DIR/regions-close-over-type-parameter-multiple.rs:23:5
|
||||
|
|
||||
LL | Box::new(v) as Box<dyn SomeTrait + 'a>
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
note: but, the lifetime must be valid for the lifetime `'c` as defined here...
|
||||
--> $DIR/regions-close-over-type-parameter-multiple.rs:18:26
|
||||
--> $DIR/regions-close-over-type-parameter-multiple.rs:21:26
|
||||
|
|
||||
LL | fn make_object_bad<'a,'b,'c,A:SomeTrait+'a+'b>(v: A) -> Box<dyn SomeTrait + 'c> {
|
||||
| ^^
|
||||
note: ...so that the types are compatible
|
||||
--> $DIR/regions-close-over-type-parameter-multiple.rs:20:5
|
||||
--> $DIR/regions-close-over-type-parameter-multiple.rs:23:5
|
||||
|
|
||||
LL | Box::new(v) as Box<dyn SomeTrait + 'a>
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
@ -1,5 +1,5 @@
|
|||
error: lifetime may not live long enough
|
||||
--> $DIR/regions-close-over-type-parameter-multiple.rs:20:5
|
||||
--> $DIR/regions-close-over-type-parameter-multiple.rs:23:5
|
||||
|
|
||||
LL | fn make_object_bad<'a,'b,'c,A:SomeTrait+'a+'b>(v: A) -> Box<dyn SomeTrait + 'c> {
|
||||
| -- -- lifetime `'c` defined here
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
// Various tests where we over type parameters with multiple lifetime
|
||||
// bounds.
|
||||
|
||||
// revisions: base nll
|
||||
// ignore-compare-mode-nll
|
||||
//[nll] compile-flags: -Z borrowck=mir
|
||||
|
||||
trait SomeTrait { fn get(&self) -> isize; }
|
||||
|
||||
|
@ -17,7 +20,9 @@ fn make_object_good2<'a,'b,A:SomeTrait+'a+'b>(v: A) -> Box<dyn SomeTrait + 'b> {
|
|||
|
||||
fn make_object_bad<'a,'b,'c,A:SomeTrait+'a+'b>(v: A) -> Box<dyn SomeTrait + 'c> {
|
||||
// A outlives 'a AND 'b...but not 'c.
|
||||
Box::new(v) as Box<dyn SomeTrait + 'a> //~ ERROR cannot infer an appropriate lifetime
|
||||
Box::new(v) as Box<dyn SomeTrait + 'a>
|
||||
//[base]~^ ERROR cannot infer an appropriate lifetime
|
||||
//[nll]~^^ ERROR lifetime may not live long enough
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error[E0310]: the parameter type `T` may not live long enough
|
||||
--> $DIR/regions-close-param-into-object.rs:6:5
|
||||
--> $DIR/regions-close-param-into-object.rs:10:5
|
||||
|
|
||||
LL | fn p1<T>(v: T) -> Box<dyn X + 'static>
|
||||
| - help: consider adding an explicit lifetime bound...: `T: 'static`
|
||||
|
@ -8,7 +8,7 @@ LL | Box::new(v)
|
|||
| ^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds
|
||||
|
||||
error[E0310]: the parameter type `T` may not live long enough
|
||||
--> $DIR/regions-close-param-into-object.rs:12:5
|
||||
--> $DIR/regions-close-param-into-object.rs:16:5
|
||||
|
|
||||
LL | fn p2<T>(v: Box<T>) -> Box<dyn X + 'static>
|
||||
| - help: consider adding an explicit lifetime bound...: `T: 'static`
|
||||
|
@ -17,7 +17,7 @@ LL | Box::new(v)
|
|||
| ^^^^^^^^^^^ ...so that the type `Box<T>` will meet its required lifetime bounds
|
||||
|
||||
error[E0309]: the parameter type `T` may not live long enough
|
||||
--> $DIR/regions-close-param-into-object.rs:18:5
|
||||
--> $DIR/regions-close-param-into-object.rs:22:5
|
||||
|
|
||||
LL | fn p3<'a,T>(v: T) -> Box<dyn X + 'a>
|
||||
| - help: consider adding an explicit lifetime bound...: `T: 'a`
|
||||
|
@ -26,7 +26,7 @@ LL | Box::new(v)
|
|||
| ^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds
|
||||
|
||||
error[E0309]: the parameter type `T` may not live long enough
|
||||
--> $DIR/regions-close-param-into-object.rs:24:5
|
||||
--> $DIR/regions-close-param-into-object.rs:28:5
|
||||
|
|
||||
LL | fn p4<'a,T>(v: Box<T>) -> Box<dyn X + 'a>
|
||||
| - help: consider adding an explicit lifetime bound...: `T: 'a`
|
|
@ -1,5 +1,5 @@
|
|||
error[E0310]: the parameter type `T` may not live long enough
|
||||
--> $DIR/regions-close-param-into-object.rs:6:5
|
||||
--> $DIR/regions-close-param-into-object.rs:10:5
|
||||
|
|
||||
LL | fn p1<T>(v: T) -> Box<dyn X + 'static>
|
||||
| - help: consider adding an explicit lifetime bound...: `T: 'static`
|
||||
|
@ -8,7 +8,7 @@ LL | Box::new(v)
|
|||
| ^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds
|
||||
|
||||
error[E0310]: the parameter type `T` may not live long enough
|
||||
--> $DIR/regions-close-param-into-object.rs:12:5
|
||||
--> $DIR/regions-close-param-into-object.rs:16:5
|
||||
|
|
||||
LL | fn p2<T>(v: Box<T>) -> Box<dyn X + 'static>
|
||||
| - help: consider adding an explicit lifetime bound...: `T: 'static`
|
||||
|
@ -17,7 +17,7 @@ LL | Box::new(v)
|
|||
| ^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds
|
||||
|
||||
error[E0309]: the parameter type `T` may not live long enough
|
||||
--> $DIR/regions-close-param-into-object.rs:18:5
|
||||
--> $DIR/regions-close-param-into-object.rs:22:5
|
||||
|
|
||||
LL | fn p3<'a,T>(v: T) -> Box<dyn X + 'a>
|
||||
| - help: consider adding an explicit lifetime bound...: `T: 'a`
|
||||
|
@ -26,7 +26,7 @@ LL | Box::new(v)
|
|||
| ^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds
|
||||
|
||||
error[E0309]: the parameter type `T` may not live long enough
|
||||
--> $DIR/regions-close-param-into-object.rs:24:5
|
||||
--> $DIR/regions-close-param-into-object.rs:28:5
|
||||
|
|
||||
LL | fn p4<'a,T>(v: Box<T>) -> Box<dyn X + 'a>
|
||||
| - help: consider adding an explicit lifetime bound...: `T: 'a`
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
// revisions: base nll
|
||||
// ignore-compare-mode-nll
|
||||
//[nll] compile-flags: -Z borrowck=mir
|
||||
|
||||
trait X { fn foo(&self) {} }
|
||||
|
||||
fn p1<T>(v: T) -> Box<dyn X + 'static>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/regions-creating-enums3.rs:7:5
|
||||
--> $DIR/regions-creating-enums3.rs:11:5
|
||||
|
|
||||
LL | fn mk_add_bad1<'a,'b>(x: &'a Ast<'a>, y: &'b Ast<'b>) -> Ast<'a> {
|
||||
| ----------- -------
|
|
@ -1,5 +1,5 @@
|
|||
error: lifetime may not live long enough
|
||||
--> $DIR/regions-creating-enums3.rs:7:5
|
||||
--> $DIR/regions-creating-enums3.rs:11:5
|
||||
|
|
||||
LL | fn mk_add_bad1<'a,'b>(x: &'a Ast<'a>, y: &'b Ast<'b>) -> Ast<'a> {
|
||||
| -- -- lifetime `'b` defined here
|
||||
|
|
|
@ -1,10 +1,16 @@
|
|||
// revisions: base nll
|
||||
// ignore-compare-mode-nll
|
||||
//[nll] compile-flags: -Z borrowck=mir
|
||||
|
||||
enum Ast<'a> {
|
||||
Num(usize),
|
||||
Add(&'a Ast<'a>, &'a Ast<'a>)
|
||||
}
|
||||
|
||||
fn mk_add_bad1<'a,'b>(x: &'a Ast<'a>, y: &'b Ast<'b>) -> Ast<'a> {
|
||||
Ast::Add(x, y) //~ ERROR lifetime mismatch [E0623]
|
||||
Ast::Add(x, y)
|
||||
//[base]~^ ERROR lifetime mismatch [E0623]
|
||||
//[nll]~^^ ERROR lifetime may not live long enough
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
@ -1,28 +1,28 @@
|
|||
error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements
|
||||
--> $DIR/regions-creating-enums4.rs:7:5
|
||||
--> $DIR/regions-creating-enums4.rs:11:5
|
||||
|
|
||||
LL | Ast::Add(x, y)
|
||||
| ^^^^^^^^
|
||||
|
|
||||
note: first, the lifetime cannot outlive the lifetime `'a` as defined here...
|
||||
--> $DIR/regions-creating-enums4.rs:6:16
|
||||
--> $DIR/regions-creating-enums4.rs:10:16
|
||||
|
|
||||
LL | fn mk_add_bad2<'a,'b>(x: &'a Ast<'a>, y: &'a Ast<'a>, z: &Ast) -> Ast<'b> {
|
||||
| ^^
|
||||
note: ...so that the expression is assignable
|
||||
--> $DIR/regions-creating-enums4.rs:7:14
|
||||
--> $DIR/regions-creating-enums4.rs:11:14
|
||||
|
|
||||
LL | Ast::Add(x, y)
|
||||
| ^
|
||||
= note: expected `&Ast<'_>`
|
||||
found `&Ast<'a>`
|
||||
note: but, the lifetime must be valid for the lifetime `'b` as defined here...
|
||||
--> $DIR/regions-creating-enums4.rs:6:19
|
||||
--> $DIR/regions-creating-enums4.rs:10:19
|
||||
|
|
||||
LL | fn mk_add_bad2<'a,'b>(x: &'a Ast<'a>, y: &'a Ast<'a>, z: &Ast) -> Ast<'b> {
|
||||
| ^^
|
||||
note: ...so that the types are compatible
|
||||
--> $DIR/regions-creating-enums4.rs:7:5
|
||||
--> $DIR/regions-creating-enums4.rs:11:5
|
||||
|
|
||||
LL | Ast::Add(x, y)
|
||||
| ^^^^^^^^^^^^^^
|
|
@ -1,5 +1,5 @@
|
|||
error: lifetime may not live long enough
|
||||
--> $DIR/regions-creating-enums4.rs:7:5
|
||||
--> $DIR/regions-creating-enums4.rs:11:5
|
||||
|
|
||||
LL | fn mk_add_bad2<'a,'b>(x: &'a Ast<'a>, y: &'a Ast<'a>, z: &Ast) -> Ast<'b> {
|
||||
| -- -- lifetime `'b` defined here
|
||||
|
|
|
@ -1,10 +1,16 @@
|
|||
// revisions: base nll
|
||||
// ignore-compare-mode-nll
|
||||
//[nll] compile-flags: -Z borrowck=mir
|
||||
|
||||
enum Ast<'a> {
|
||||
Num(usize),
|
||||
Add(&'a Ast<'a>, &'a Ast<'a>)
|
||||
}
|
||||
|
||||
fn mk_add_bad2<'a,'b>(x: &'a Ast<'a>, y: &'a Ast<'a>, z: &Ast) -> Ast<'b> {
|
||||
Ast::Add(x, y) //~ ERROR cannot infer
|
||||
Ast::Add(x, y)
|
||||
//[base]~^ ERROR cannot infer
|
||||
//[nll]~^^ ERROR lifetime may not live long enough
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
error[E0312]: lifetime of reference outlives lifetime of borrowed content...
|
||||
--> $DIR/regions-early-bound-error-method.rs:20:9
|
||||
--> $DIR/regions-early-bound-error-method.rs:24:9
|
||||
|
|
||||
LL | g2.get()
|
||||
| ^^^^^^^^
|
||||
|
|
||||
note: ...the reference is valid for the lifetime `'a` as defined here...
|
||||
--> $DIR/regions-early-bound-error-method.rs:18:6
|
||||
--> $DIR/regions-early-bound-error-method.rs:22:6
|
||||
|
|
||||
LL | impl<'a> Box<'a> {
|
||||
| ^^
|
||||
note: ...but the borrowed content is only valid for the lifetime `'b` as defined here
|
||||
--> $DIR/regions-early-bound-error-method.rs:19:11
|
||||
--> $DIR/regions-early-bound-error-method.rs:23:11
|
||||
|
|
||||
LL | fn or<'b,G:GetRef<'b>>(&self, g2: G) -> &'a isize {
|
||||
| ^^
|
|
@ -1,5 +1,5 @@
|
|||
error: lifetime may not live long enough
|
||||
--> $DIR/regions-early-bound-error-method.rs:20:9
|
||||
--> $DIR/regions-early-bound-error-method.rs:24:9
|
||||
|
|
||||
LL | impl<'a> Box<'a> {
|
||||
| -- lifetime `'a` defined here
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
// Tests that you can use a fn lifetime parameter as part of
|
||||
// the value for a type parameter in a bound.
|
||||
|
||||
// revisions: base nll
|
||||
// ignore-compare-mode-nll
|
||||
//[nll] compile-flags: -Z borrowck=mir
|
||||
|
||||
trait GetRef<'a> {
|
||||
fn get(&self) -> &'a isize;
|
||||
}
|
||||
|
@ -18,7 +22,8 @@ impl<'a> GetRef<'a> for Box<'a> {
|
|||
impl<'a> Box<'a> {
|
||||
fn or<'b,G:GetRef<'b>>(&self, g2: G) -> &'a isize {
|
||||
g2.get()
|
||||
//~^ ERROR E0312
|
||||
//[base]~^ ERROR E0312
|
||||
//[nll]~^^ ERROR lifetime may not live long enough
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
error[E0312]: lifetime of reference outlives lifetime of borrowed content...
|
||||
--> $DIR/regions-early-bound-error.rs:19:5
|
||||
--> $DIR/regions-early-bound-error.rs:23:5
|
||||
|
|
||||
LL | g1.get()
|
||||
| ^^^^^^^^
|
||||
|
|
||||
note: ...the reference is valid for the lifetime `'b` as defined here...
|
||||
--> $DIR/regions-early-bound-error.rs:18:11
|
||||
--> $DIR/regions-early-bound-error.rs:22:11
|
||||
|
|
||||
LL | fn get<'a,'b,G:GetRef<'a, isize>>(g1: G, b: &'b isize) -> &'b isize {
|
||||
| ^^
|
||||
note: ...but the borrowed content is only valid for the lifetime `'a` as defined here
|
||||
--> $DIR/regions-early-bound-error.rs:18:8
|
||||
--> $DIR/regions-early-bound-error.rs:22:8
|
||||
|
|
||||
LL | fn get<'a,'b,G:GetRef<'a, isize>>(g1: G, b: &'b isize) -> &'b isize {
|
||||
| ^^
|
|
@ -1,5 +1,5 @@
|
|||
error: lifetime may not live long enough
|
||||
--> $DIR/regions-early-bound-error.rs:19:5
|
||||
--> $DIR/regions-early-bound-error.rs:23:5
|
||||
|
|
||||
LL | fn get<'a,'b,G:GetRef<'a, isize>>(g1: G, b: &'b isize) -> &'b isize {
|
||||
| -- -- lifetime `'b` defined here
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
// Tests that you can use a fn lifetime parameter as part of
|
||||
// the value for a type parameter in a bound.
|
||||
|
||||
// revisions: base nll
|
||||
// ignore-compare-mode-nll
|
||||
//[nll] compile-flags: -Z borrowck=mir
|
||||
|
||||
trait GetRef<'a, T> {
|
||||
fn get(&self) -> &'a T;
|
||||
}
|
||||
|
@ -17,7 +21,8 @@ impl<'a,T:Clone> GetRef<'a,T> for Box<'a,T> {
|
|||
|
||||
fn get<'a,'b,G:GetRef<'a, isize>>(g1: G, b: &'b isize) -> &'b isize {
|
||||
g1.get()
|
||||
//~^ ERROR E0312
|
||||
//[base]~^ ERROR E0312
|
||||
//[nll]~^^ ERROR lifetime may not live long enough
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/regions-fn-subtyping-return-static-fail.rs:48:12
|
||||
--> $DIR/regions-fn-subtyping-return-static-fail.rs:52:12
|
||||
|
|
||||
LL | want_G(baz);
|
||||
| ^^^ one type is more general than the other
|
|
@ -1,5 +1,5 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/regions-fn-subtyping-return-static-fail.rs:48:5
|
||||
--> $DIR/regions-fn-subtyping-return-static-fail.rs:52:5
|
||||
|
|
||||
LL | want_G(baz);
|
||||
| ^^^^^^^^^^^ one type is more general than the other
|
||||
|
|
|
@ -6,6 +6,10 @@
|
|||
// This can safely be considered to be an instance of `F` because all
|
||||
// lifetimes are sublifetimes of 'static.
|
||||
|
||||
// revisions: base nll
|
||||
// ignore-compare-mode-nll
|
||||
//[nll] compile-flags: -Z borrowck=mir
|
||||
|
||||
#![allow(dead_code)]
|
||||
#![allow(unused_variables)]
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/regions-free-region-ordering-callee.rs:13:5
|
||||
--> $DIR/regions-free-region-ordering-callee.rs:17:5
|
||||
|
|
||||
LL | fn ordering2<'a, 'b>(x: &'a &'b usize, y: &'a usize) -> &'b usize {
|
||||
| ------------- ---------
|
||||
|
@ -10,7 +10,7 @@ LL | &*y
|
|||
| ^^^ ...but data from `x` is returned here
|
||||
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/regions-free-region-ordering-callee.rs:18:24
|
||||
--> $DIR/regions-free-region-ordering-callee.rs:24:24
|
||||
|
|
||||
LL | fn ordering3<'a, 'b>(x: &'a usize, y: &'b usize) -> &'a &'b usize {
|
||||
| --------- -------------
|
|
@ -1,5 +1,5 @@
|
|||
error: lifetime may not live long enough
|
||||
--> $DIR/regions-free-region-ordering-callee.rs:13:5
|
||||
--> $DIR/regions-free-region-ordering-callee.rs:17:5
|
||||
|
|
||||
LL | fn ordering2<'a, 'b>(x: &'a &'b usize, y: &'a usize) -> &'b usize {
|
||||
| -- -- lifetime `'b` defined here
|
||||
|
@ -12,7 +12,7 @@ LL | &*y
|
|||
= help: consider adding the following bound: `'a: 'b`
|
||||
|
||||
error: lifetime may not live long enough
|
||||
--> $DIR/regions-free-region-ordering-callee.rs:18:12
|
||||
--> $DIR/regions-free-region-ordering-callee.rs:24:12
|
||||
|
|
||||
LL | fn ordering3<'a, 'b>(x: &'a usize, y: &'b usize) -> &'a &'b usize {
|
||||
| -- -- lifetime `'b` defined here
|
||||
|
|
|
@ -2,6 +2,10 @@
|
|||
// that appear in their parameter list. See also
|
||||
// regions-free-region-ordering-caller.rs
|
||||
|
||||
// revisions: base nll
|
||||
// ignore-compare-mode-nll
|
||||
//[nll] compile-flags: -Z borrowck=mir
|
||||
|
||||
fn ordering1<'a, 'b>(x: &'a &'b usize) -> &'a usize {
|
||||
// It is safe to assume that 'a <= 'b due to the type of x
|
||||
let y: &'b usize = &**x;
|
||||
|
@ -10,13 +14,16 @@ fn ordering1<'a, 'b>(x: &'a &'b usize) -> &'a usize {
|
|||
|
||||
fn ordering2<'a, 'b>(x: &'a &'b usize, y: &'a usize) -> &'b usize {
|
||||
// However, it is not safe to assume that 'b <= 'a
|
||||
&*y //~ ERROR lifetime mismatch [E0623]
|
||||
&*y
|
||||
//[base]~^ ERROR lifetime mismatch [E0623]
|
||||
//[nll]~^^ ERROR lifetime may not live long enough
|
||||
}
|
||||
|
||||
fn ordering3<'a, 'b>(x: &'a usize, y: &'b usize) -> &'a &'b usize {
|
||||
// Do not infer an ordering from the return value.
|
||||
let z: &'b usize = &*x;
|
||||
//~^ ERROR lifetime mismatch [E0623]
|
||||
//[base]~^ ERROR lifetime mismatch [E0623]
|
||||
//[nll]~^^ ERROR lifetime may not live long enough
|
||||
panic!();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,26 +1,26 @@
|
|||
error[E0495]: cannot infer an appropriate lifetime for borrow expression due to conflicting requirements
|
||||
--> $DIR/regions-free-region-ordering-incorrect.rs:17:21
|
||||
--> $DIR/regions-free-region-ordering-incorrect.rs:21:21
|
||||
|
|
||||
LL | None => &self.val
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
note: first, the lifetime cannot outlive the lifetime `'a` as defined here...
|
||||
--> $DIR/regions-free-region-ordering-incorrect.rs:14:12
|
||||
--> $DIR/regions-free-region-ordering-incorrect.rs:18:12
|
||||
|
|
||||
LL | fn get<'a>(&'a self) -> &'b T {
|
||||
| ^^
|
||||
note: ...so that reference does not outlive borrowed content
|
||||
--> $DIR/regions-free-region-ordering-incorrect.rs:17:21
|
||||
--> $DIR/regions-free-region-ordering-incorrect.rs:21:21
|
||||
|
|
||||
LL | None => &self.val
|
||||
| ^^^^^^^^^
|
||||
note: but, the lifetime must be valid for the lifetime `'b` as defined here...
|
||||
--> $DIR/regions-free-region-ordering-incorrect.rs:13:6
|
||||
--> $DIR/regions-free-region-ordering-incorrect.rs:17:6
|
||||
|
|
||||
LL | impl<'b, T> Node<'b, T> {
|
||||
| ^^
|
||||
note: ...so that reference does not outlive borrowed content
|
||||
--> $DIR/regions-free-region-ordering-incorrect.rs:15:9
|
||||
--> $DIR/regions-free-region-ordering-incorrect.rs:19:9
|
||||
|
|
||||
LL | / match self.next {
|
||||
LL | | Some(ref next) => next.get(),
|
|
@ -1,5 +1,5 @@
|
|||
error: lifetime may not live long enough
|
||||
--> $DIR/regions-free-region-ordering-incorrect.rs:15:9
|
||||
--> $DIR/regions-free-region-ordering-incorrect.rs:19:9
|
||||
|
|
||||
LL | impl<'b, T> Node<'b, T> {
|
||||
| -- lifetime `'b` defined here
|
||||
|
|
|
@ -5,6 +5,10 @@
|
|||
//
|
||||
// This test began its life as a test for issue #4325.
|
||||
|
||||
// revisions: base nll
|
||||
// ignore-compare-mode-nll
|
||||
//[nll] compile-flags: -Z borrowck=mir
|
||||
|
||||
struct Node<'b, T: 'b> {
|
||||
val: T,
|
||||
next: Option<&'b Node<'b, T>>
|
||||
|
@ -12,9 +16,9 @@ struct Node<'b, T: 'b> {
|
|||
|
||||
impl<'b, T> Node<'b, T> {
|
||||
fn get<'a>(&'a self) -> &'b T {
|
||||
match self.next {
|
||||
match self.next { //[nll]~ ERROR lifetime may not live long enough
|
||||
Some(ref next) => next.get(),
|
||||
None => &self.val //~ ERROR cannot infer
|
||||
None => &self.val //[base]~ ERROR cannot infer
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error[E0309]: the parameter type `T` may not live long enough
|
||||
--> $DIR/regions-implied-bounds-projection-gap-1.rs:16:10
|
||||
--> $DIR/regions-implied-bounds-projection-gap-1.rs:20:10
|
||||
|
|
||||
LL | fn func<'x, T:Trait1<'x>>(t: &'x T::Foo)
|
||||
| -- help: consider adding an explicit lifetime bound...: `T: 'x +`
|
|
@ -1,5 +1,5 @@
|
|||
error[E0309]: the parameter type `T` may not live long enough
|
||||
--> $DIR/regions-implied-bounds-projection-gap-1.rs:16:5
|
||||
--> $DIR/regions-implied-bounds-projection-gap-1.rs:20:5
|
||||
|
|
||||
LL | fn func<'x, T:Trait1<'x>>(t: &'x T::Foo)
|
||||
| -- help: consider adding an explicit lifetime bound...: `T: 'x +`
|
||||
|
|
|
@ -3,6 +3,10 @@
|
|||
// there might be other ways for the caller of `func` to show that
|
||||
// `T::Foo: 'x` holds (e.g., where-clause).
|
||||
|
||||
// revisions: base nll
|
||||
// ignore-compare-mode-nll
|
||||
//[nll] compile-flags: -Z borrowck=mir
|
||||
|
||||
trait Trait1<'x> {
|
||||
type Foo;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error[E0309]: the parameter type `Self` may not live long enough
|
||||
--> $DIR/regions-infer-bound-from-trait-self.rs:46:9
|
||||
--> $DIR/regions-infer-bound-from-trait-self.rs:50:9
|
||||
|
|
||||
LL | check_bound(x, self)
|
||||
| ^^^^^^^^^^^
|
||||
|
@ -7,7 +7,7 @@ LL | check_bound(x, self)
|
|||
= help: consider adding an explicit lifetime bound `Self: 'a`...
|
||||
= note: ...so that the type `Self` will meet its required lifetime bounds...
|
||||
note: ...that is required by this bound
|
||||
--> $DIR/regions-infer-bound-from-trait-self.rs:12:21
|
||||
--> $DIR/regions-infer-bound-from-trait-self.rs:16:21
|
||||
|
|
||||
LL | fn check_bound<'a,A:'a>(x: Inv<'a>, a: A) { }
|
||||
| ^^
|
|
@ -1,5 +1,5 @@
|
|||
error[E0309]: the parameter type `Self` may not live long enough
|
||||
--> $DIR/regions-infer-bound-from-trait-self.rs:46:9
|
||||
--> $DIR/regions-infer-bound-from-trait-self.rs:50:9
|
||||
|
|
||||
LL | check_bound(x, self)
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
// Test that we can derive lifetime bounds on `Self` from trait
|
||||
// inheritance.
|
||||
|
||||
// revisions: base nll
|
||||
// ignore-compare-mode-nll
|
||||
//[nll] compile-flags: -Z borrowck=mir
|
||||
|
||||
trait Static : 'static { }
|
||||
|
||||
trait Is<'a> : 'a { }
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error[E0309]: the parameter type `A` may not live long enough
|
||||
--> $DIR/regions-infer-bound-from-trait.rs:33:5
|
||||
--> $DIR/regions-infer-bound-from-trait.rs:37:5
|
||||
|
|
||||
LL | fn bar1<'a,A>(x: Inv<'a>, a: A) {
|
||||
| - help: consider adding an explicit lifetime bound...: `A: 'a`
|
||||
|
@ -7,13 +7,13 @@ LL | check_bound(x, a)
|
|||
| ^^^^^^^^^^^ ...so that the type `A` will meet its required lifetime bounds...
|
||||
|
|
||||
note: ...that is required by this bound
|
||||
--> $DIR/regions-infer-bound-from-trait.rs:12:21
|
||||
--> $DIR/regions-infer-bound-from-trait.rs:16:21
|
||||
|
|
||||
LL | fn check_bound<'a,A:'a>(x: Inv<'a>, a: A) { }
|
||||
| ^^
|
||||
|
||||
error[E0309]: the parameter type `A` may not live long enough
|
||||
--> $DIR/regions-infer-bound-from-trait.rs:37:5
|
||||
--> $DIR/regions-infer-bound-from-trait.rs:41:5
|
||||
|
|
||||
LL | fn bar2<'a,'b,A:Is<'b>>(x: Inv<'a>, y: Inv<'b>, a: A) {
|
||||
| -- help: consider adding an explicit lifetime bound...: `A: 'a +`
|
||||
|
@ -21,7 +21,7 @@ LL | check_bound(x, a)
|
|||
| ^^^^^^^^^^^ ...so that the type `A` will meet its required lifetime bounds...
|
||||
|
|
||||
note: ...that is required by this bound
|
||||
--> $DIR/regions-infer-bound-from-trait.rs:12:21
|
||||
--> $DIR/regions-infer-bound-from-trait.rs:16:21
|
||||
|
|
||||
LL | fn check_bound<'a,A:'a>(x: Inv<'a>, a: A) { }
|
||||
| ^^
|
|
@ -1,5 +1,5 @@
|
|||
error[E0309]: the parameter type `A` may not live long enough
|
||||
--> $DIR/regions-infer-bound-from-trait.rs:33:5
|
||||
--> $DIR/regions-infer-bound-from-trait.rs:37:5
|
||||
|
|
||||
LL | fn bar1<'a,A>(x: Inv<'a>, a: A) {
|
||||
| - help: consider adding an explicit lifetime bound...: `A: 'a`
|
||||
|
@ -7,7 +7,7 @@ LL | check_bound(x, a)
|
|||
| ^^^^^^^^^^^^^^^^^ ...so that the type `A` will meet its required lifetime bounds
|
||||
|
||||
error[E0309]: the parameter type `A` may not live long enough
|
||||
--> $DIR/regions-infer-bound-from-trait.rs:37:5
|
||||
--> $DIR/regions-infer-bound-from-trait.rs:41:5
|
||||
|
|
||||
LL | fn bar2<'a,'b,A:Is<'b>>(x: Inv<'a>, y: Inv<'b>, a: A) {
|
||||
| -- help: consider adding an explicit lifetime bound...: `A: 'a +`
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
// Test that we can derive lifetime bounds on type parameters
|
||||
// from trait inheritance.
|
||||
|
||||
// revisions: base nll
|
||||
// ignore-compare-mode-nll
|
||||
//[nll] compile-flags: -Z borrowck=mir
|
||||
|
||||
trait Static : 'static { }
|
||||
|
||||
trait Is<'a> : 'a { }
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/regions-infer-contravariance-due-to-decl.rs:25:35
|
||||
--> $DIR/regions-infer-contravariance-due-to-decl.rs:29:35
|
||||
|
|
||||
LL | fn use_<'short,'long>(c: Contravariant<'short>,
|
||||
| --------------------- these two types are declared with different lifetimes...
|
|
@ -1,5 +1,5 @@
|
|||
error: lifetime may not live long enough
|
||||
--> $DIR/regions-infer-contravariance-due-to-decl.rs:25:12
|
||||
--> $DIR/regions-infer-contravariance-due-to-decl.rs:29:12
|
||||
|
|
||||
LL | fn use_<'short,'long>(c: Contravariant<'short>,
|
||||
| ------ ----- lifetime `'long` defined here
|
||||
|
|
|
@ -4,6 +4,10 @@
|
|||
// Note: see variance-regions-*.rs for the tests that check that the
|
||||
// variance inference works in the first place.
|
||||
|
||||
// revisions: base nll
|
||||
// ignore-compare-mode-nll
|
||||
//[nll] compile-flags: -Z borrowck=mir
|
||||
|
||||
use std::marker;
|
||||
|
||||
// This is contravariant with respect to 'a, meaning that
|
||||
|
@ -22,7 +26,9 @@ fn use_<'short,'long>(c: Contravariant<'short>,
|
|||
// 'short <= 'long, this would be true if the Contravariant type were
|
||||
// covariant with respect to its parameter 'a.
|
||||
|
||||
let _: Contravariant<'long> = c; //~ ERROR E0623
|
||||
let _: Contravariant<'long> = c;
|
||||
//[base]~^ ERROR E0623
|
||||
//[nll]~^^ ERROR lifetime may not live long enough
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/regions-infer-covariance-due-to-decl.rs:22:32
|
||||
--> $DIR/regions-infer-covariance-due-to-decl.rs:26:32
|
||||
|
|
||||
LL | fn use_<'short,'long>(c: Covariant<'long>,
|
||||
| ----------------
|
|
@ -1,5 +1,5 @@
|
|||
error: lifetime may not live long enough
|
||||
--> $DIR/regions-infer-covariance-due-to-decl.rs:22:12
|
||||
--> $DIR/regions-infer-covariance-due-to-decl.rs:26:12
|
||||
|
|
||||
LL | fn use_<'short,'long>(c: Covariant<'long>,
|
||||
| ------ ----- lifetime `'long` defined here
|
||||
|
|
|
@ -4,6 +4,10 @@
|
|||
// Note: see variance-regions-*.rs for the tests that check that the
|
||||
// variance inference works in the first place.
|
||||
|
||||
// revisions: base nll
|
||||
// ignore-compare-mode-nll
|
||||
//[nll] compile-flags: -Z borrowck=mir
|
||||
|
||||
use std::marker;
|
||||
|
||||
struct Covariant<'a> {
|
||||
|
@ -19,7 +23,9 @@ fn use_<'short,'long>(c: Covariant<'long>,
|
|||
// 'short <= 'long, this would be true if the Covariant type were
|
||||
// contravariant with respect to its parameter 'a.
|
||||
|
||||
let _: Covariant<'short> = c; //~ ERROR E0623
|
||||
let _: Covariant<'short> = c;
|
||||
//[base]~^ ERROR E0623
|
||||
//[nll]~^^ ERROR lifetime may not live long enough
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue