-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Stabilize
anonymous_lifetime_in_impl_trait
- Loading branch information
Showing
16 changed files
with
202 additions
and
259 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
#![feature(anonymous_lifetime_in_impl_trait)] | ||
|
||
trait Foo<T> { | ||
fn bar(self, baz: T); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
trait Foo<T> { | ||
fn foo(&self, _: T) { } | ||
} | ||
|
||
mod foo { | ||
fn fun(t: impl crate::Foo<&u32>, n: u32) { | ||
t.foo(&n); | ||
//~^ ERROR `n` does not live long enough | ||
} | ||
} | ||
|
||
mod fun { | ||
fn fun(t: impl Fn(&u32), n: u32) { | ||
t(&n); | ||
} | ||
} | ||
|
||
mod iterator_fun { | ||
fn fun(t: impl Iterator<Item = impl Fn(&u32)>, n: u32) { | ||
for elem in t { | ||
elem(&n); | ||
} | ||
} | ||
} | ||
|
||
mod iterator_foo { | ||
fn fun(t: impl Iterator<Item = impl crate::Foo<&u32>>, n: u32) { | ||
for elem in t { | ||
elem.foo(&n); | ||
//~^ ERROR `n` does not live long enough | ||
} | ||
} | ||
} | ||
|
||
mod placeholder { | ||
trait Placeholder<'a> { | ||
fn foo(&self, _: &'a u32) {} | ||
} | ||
|
||
fn fun(t: impl Placeholder<'_>, n: u32) { | ||
t.foo(&n); | ||
//~^ ERROR `n` does not live long enough | ||
} | ||
} | ||
|
||
fn main() { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
error[E0597]: `n` does not live long enough | ||
--> $DIR/impl-trait-lifetimes.rs:7:15 | ||
| | ||
LL | fn fun(t: impl crate::Foo<&u32>, n: u32) { | ||
| - has type `t` - binding `n` declared here | ||
LL | t.foo(&n); | ||
| ------^^- | ||
| | | | ||
| | borrowed value does not live long enough | ||
| argument requires that `n` is borrowed for `'1` | ||
LL | | ||
LL | } | ||
| - `n` dropped here while still borrowed | ||
|
||
error[E0597]: `n` does not live long enough | ||
--> $DIR/impl-trait-lifetimes.rs:29:22 | ||
| | ||
LL | fn fun(t: impl Iterator<Item = impl crate::Foo<&u32>>, n: u32) { | ||
| - binding `n` declared here | ||
LL | for elem in t { | ||
LL | elem.foo(&n); | ||
| ^^ borrowed value does not live long enough | ||
... | ||
LL | } | ||
| - `n` dropped here while still borrowed | ||
|
||
error[E0597]: `n` does not live long enough | ||
--> $DIR/impl-trait-lifetimes.rs:41:15 | ||
| | ||
LL | fn fun(t: impl Placeholder<'_>, n: u32) { | ||
| - has type `t` - binding `n` declared here | ||
LL | t.foo(&n); | ||
| ------^^- | ||
| | | | ||
| | borrowed value does not live long enough | ||
| argument requires that `n` is borrowed for `'1` | ||
LL | | ||
LL | } | ||
| - `n` dropped here while still borrowed | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0597`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.