-
Notifications
You must be signed in to change notification settings - Fork 12.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
200 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#![feature(generic_associated_types)] | ||
// check-fail | ||
|
||
trait StreamingIter { | ||
type Item<'a> where Self: 'a; | ||
fn next<'a>(&'a mut self) -> Option<Self::Item::<'a>>; | ||
} | ||
|
||
struct StreamingSliceIter<'a, T> { | ||
idx: usize, | ||
data: &'a mut [T], | ||
} | ||
|
||
impl<'b, T: 'b> StreamingIter for StreamingSliceIter<'b, T> { | ||
type Item<'a> = &'a mut T; | ||
//~^ the parameter type | ||
fn next(&mut self) -> Option<&mut T> { | ||
loop {} | ||
} | ||
} | ||
|
||
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,11 @@ | ||
error[E0309]: the parameter type `T` may not live long enough | ||
--> $DIR/issue-84931.rs:15:21 | ||
| | ||
LL | type Item<'a> = &'a mut T; | ||
| - ^^^^^^^^^ ...so that the reference type `&'a mut T` does not outlive the data it points at | ||
| | | ||
| help: consider adding a where clause: `where T: 'a` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0309`. |
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,40 @@ | ||
#![feature(generic_associated_types)] | ||
// check-fail | ||
|
||
enum Either<L, R> { | ||
Left(L), | ||
Right(R), | ||
} | ||
|
||
pub trait HasChildrenOf { | ||
type T; | ||
type TRef<'a>; | ||
|
||
fn ref_children<'a>(&'a self) -> Vec<Self::TRef<'a>>; | ||
fn take_children(self) -> Vec<Self::T>; | ||
} | ||
|
||
impl<Left, Right> HasChildrenOf for Either<Left, Right> | ||
where | ||
Left: HasChildrenOf, | ||
Right: HasChildrenOf, | ||
{ | ||
type T = Either<Left::T, Right::T>; | ||
type TRef<'a> | ||
//~^ the associated type | ||
//~^^ the associated type | ||
where | ||
<Left as HasChildrenOf>::T: 'a, | ||
<Right as HasChildrenOf>::T: 'a | ||
= Either<&'a Left::T, &'a Right::T>; | ||
|
||
fn ref_children<'a>(&'a self) -> Vec<Self::TRef<'a>> { | ||
todo!() | ||
} | ||
|
||
fn take_children(self) -> Vec<Self::T> { | ||
todo!() | ||
} | ||
} | ||
|
||
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,29 @@ | ||
error[E0309]: the associated type `<Left as HasChildrenOf>::T` may not live long enough | ||
--> $DIR/issue-86787.rs:23:5 | ||
| | ||
LL | / type TRef<'a> | ||
LL | | | ||
LL | | | ||
LL | | where | ||
LL | | <Left as HasChildrenOf>::T: 'a, | ||
LL | | <Right as HasChildrenOf>::T: 'a | ||
| | - help: consider adding a where clause: `, <Left as HasChildrenOf>::T: 'a` | ||
LL | | = Either<&'a Left::T, &'a Right::T>; | ||
| |________________________________________^ ...so that the type `<Left as HasChildrenOf>::T` will meet its required lifetime bounds | ||
|
||
error[E0309]: the associated type `<Right as HasChildrenOf>::T` may not live long enough | ||
--> $DIR/issue-86787.rs:23:5 | ||
| | ||
LL | / type TRef<'a> | ||
LL | | | ||
LL | | | ||
LL | | where | ||
LL | | <Left as HasChildrenOf>::T: 'a, | ||
LL | | <Right as HasChildrenOf>::T: 'a | ||
| | - help: consider adding a where clause: `, <Right as HasChildrenOf>::T: 'a` | ||
LL | | = Either<&'a Left::T, &'a Right::T>; | ||
| |________________________________________^ ...so that the type `<Right as HasChildrenOf>::T` will meet its required lifetime bounds | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0309`. |