Auto merge of #54757 - nikomatsakis:nll-issue-54573-user-annot, r=pnkfelix
user annotations in patterns Fixes https://github.com/rust-lang/rust/issues/54573 r? @pnkfelix
This commit is contained in:
commit
e1643a8968
18 changed files with 387 additions and 77 deletions
|
|
@ -0,0 +1,24 @@
|
|||
#![feature(nll)]
|
||||
|
||||
enum Foo<'a> {
|
||||
Bar { field: &'a u32 }
|
||||
}
|
||||
|
||||
fn in_let() {
|
||||
let y = 22;
|
||||
let foo = Foo::Bar { field: &y };
|
||||
//~^ ERROR `y` does not live long enough
|
||||
let Foo::Bar::<'static> { field: _z } = foo;
|
||||
}
|
||||
|
||||
fn in_match() {
|
||||
let y = 22;
|
||||
let foo = Foo::Bar { field: &y };
|
||||
//~^ ERROR `y` does not live long enough
|
||||
match foo {
|
||||
Foo::Bar::<'static> { field: _z } => {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() { }
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
error[E0597]: `y` does not live long enough
|
||||
--> $DIR/pattern_substs_on_brace_enum_variant.rs:9:33
|
||||
|
|
||||
LL | let foo = Foo::Bar { field: &y };
|
||||
| ^^ borrowed value does not live long enough
|
||||
...
|
||||
LL | }
|
||||
| - `y` dropped here while still borrowed
|
||||
|
|
||||
= note: borrowed value must be valid for the static lifetime...
|
||||
|
||||
error[E0597]: `y` does not live long enough
|
||||
--> $DIR/pattern_substs_on_brace_enum_variant.rs:16:33
|
||||
|
|
||||
LL | let foo = Foo::Bar { field: &y };
|
||||
| ^^ borrowed value does not live long enough
|
||||
...
|
||||
LL | }
|
||||
| - `y` dropped here while still borrowed
|
||||
|
|
||||
= note: borrowed value must be valid for the static lifetime...
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0597`.
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
#![feature(nll)]
|
||||
|
||||
struct Foo<'a> { field: &'a u32 }
|
||||
|
||||
fn in_let() {
|
||||
let y = 22;
|
||||
let foo = Foo { field: &y };
|
||||
//~^ ERROR `y` does not live long enough
|
||||
let Foo::<'static> { field: _z } = foo;
|
||||
}
|
||||
|
||||
fn in_main() {
|
||||
let y = 22;
|
||||
let foo = Foo { field: &y };
|
||||
//~^ ERROR `y` does not live long enough
|
||||
match foo {
|
||||
Foo::<'static> { field: _z } => {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() { }
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
error[E0597]: `y` does not live long enough
|
||||
--> $DIR/pattern_substs_on_brace_struct.rs:7:28
|
||||
|
|
||||
LL | let foo = Foo { field: &y };
|
||||
| ^^ borrowed value does not live long enough
|
||||
...
|
||||
LL | }
|
||||
| - `y` dropped here while still borrowed
|
||||
|
|
||||
= note: borrowed value must be valid for the static lifetime...
|
||||
|
||||
error[E0597]: `y` does not live long enough
|
||||
--> $DIR/pattern_substs_on_brace_struct.rs:14:28
|
||||
|
|
||||
LL | let foo = Foo { field: &y };
|
||||
| ^^ borrowed value does not live long enough
|
||||
...
|
||||
LL | }
|
||||
| - `y` dropped here while still borrowed
|
||||
|
|
||||
= note: borrowed value must be valid for the static lifetime...
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0597`.
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
#![feature(nll)]
|
||||
|
||||
enum Foo<'a> {
|
||||
Bar(&'a u32)
|
||||
}
|
||||
|
||||
fn in_let() {
|
||||
let y = 22;
|
||||
let foo = Foo::Bar(&y);
|
||||
//~^ ERROR `y` does not live long enough
|
||||
let Foo::Bar::<'static>(_z) = foo;
|
||||
}
|
||||
|
||||
fn in_match() {
|
||||
let y = 22;
|
||||
let foo = Foo::Bar(&y);
|
||||
//~^ ERROR `y` does not live long enough
|
||||
match foo {
|
||||
Foo::Bar::<'static>(_z) => {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() { }
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
error[E0597]: `y` does not live long enough
|
||||
--> $DIR/pattern_substs_on_tuple_enum_variant.rs:9:24
|
||||
|
|
||||
LL | let foo = Foo::Bar(&y);
|
||||
| ^^ borrowed value does not live long enough
|
||||
...
|
||||
LL | }
|
||||
| - `y` dropped here while still borrowed
|
||||
|
|
||||
= note: borrowed value must be valid for the static lifetime...
|
||||
|
||||
error[E0597]: `y` does not live long enough
|
||||
--> $DIR/pattern_substs_on_tuple_enum_variant.rs:16:24
|
||||
|
|
||||
LL | let foo = Foo::Bar(&y);
|
||||
| ^^ borrowed value does not live long enough
|
||||
...
|
||||
LL | }
|
||||
| - `y` dropped here while still borrowed
|
||||
|
|
||||
= note: borrowed value must be valid for the static lifetime...
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0597`.
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
#![feature(nll)]
|
||||
|
||||
struct Foo<'a>(&'a u32);
|
||||
|
||||
fn in_let() {
|
||||
let y = 22;
|
||||
let foo = Foo(&y);
|
||||
//~^ ERROR `y` does not live long enough
|
||||
let Foo::<'static>(_z) = foo;
|
||||
}
|
||||
|
||||
fn in_match() {
|
||||
let y = 22;
|
||||
let foo = Foo(&y);
|
||||
//~^ ERROR `y` does not live long enough
|
||||
match foo {
|
||||
Foo::<'static>(_z) => {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() { }
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
error[E0597]: `y` does not live long enough
|
||||
--> $DIR/pattern_substs_on_tuple_struct.rs:7:19
|
||||
|
|
||||
LL | let foo = Foo(&y);
|
||||
| ^^ borrowed value does not live long enough
|
||||
...
|
||||
LL | }
|
||||
| - `y` dropped here while still borrowed
|
||||
|
|
||||
= note: borrowed value must be valid for the static lifetime...
|
||||
|
||||
error[E0597]: `y` does not live long enough
|
||||
--> $DIR/pattern_substs_on_tuple_struct.rs:14:19
|
||||
|
|
||||
LL | let foo = Foo(&y);
|
||||
| ^^ borrowed value does not live long enough
|
||||
...
|
||||
LL | }
|
||||
| - `y` dropped here while still borrowed
|
||||
|
|
||||
= note: borrowed value must be valid for the static lifetime...
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0597`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue