-
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.
Rollup merge of #92683 - jackh726:issue-92033, r=estebank
Suggest copying trait associated type bounds on lifetime error Closes #92033 Kind of the most simple suggestion to make - we don't try to be fancy. Turns out, it's still pretty useful (the couple existing tests that trigger this error end up fixed - for this error - upon applying the fix). r? ``@estebank`` cc ``@nikomatsakis``
- Loading branch information
Showing
12 changed files
with
163 additions
and
28 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
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#![feature(generic_associated_types)] | ||
|
||
struct Texture; | ||
|
||
trait Surface { | ||
type TextureIter<'a>: Iterator<Item = &'a Texture> | ||
where | ||
Self: 'a; | ||
|
||
fn get_texture(&self) -> Self::TextureIter<'_>; | ||
} | ||
|
||
trait Swapchain { | ||
type Surface<'a>: Surface | ||
where | ||
Self: 'a; | ||
|
||
fn get_surface(&self) -> Self::Surface<'_>; | ||
} | ||
|
||
impl<'s> Surface for &'s Texture { | ||
type TextureIter<'a> = std::option::IntoIter<&'a Texture>; | ||
//~^ ERROR the type | ||
|
||
fn get_texture(&self) -> Self::TextureIter<'_> { | ||
let option: Option<&Texture> = Some(self); | ||
option.into_iter() | ||
} | ||
} | ||
|
||
impl Swapchain for Texture { | ||
type Surface<'a> = &'a Texture; | ||
|
||
fn get_surface(&self) -> Self::Surface<'_> { | ||
self | ||
} | ||
} | ||
|
||
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,22 @@ | ||
error[E0477]: the type `&'s Texture` does not fulfill the required lifetime | ||
--> $DIR/issue-92033.rs:22:28 | ||
| | ||
LL | / type TextureIter<'a>: Iterator<Item = &'a Texture> | ||
LL | | where | ||
LL | | Self: 'a; | ||
| |_________________- definition of `TextureIter` from trait | ||
... | ||
LL | type TextureIter<'a> = std::option::IntoIter<&'a Texture>; | ||
| - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | | ||
| help: try copying this clause from the trait: `where Self: 'a` | ||
| | ||
note: type must outlive the lifetime `'a` as defined here | ||
--> $DIR/issue-92033.rs:22:22 | ||
| | ||
LL | type TextureIter<'a> = std::option::IntoIter<&'a Texture>; | ||
| ^^ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0477`. |