Skip to content

Commit

Permalink
Test HRTB issue accepted by compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
meffij committed Aug 14, 2019
1 parent c43d03a commit e5017de
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/test/ui/issues/issue-50301.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Tests that HRTBs are correctly accepted -- https://github.com/rust-lang/rust/issues/50301
// check-pass
trait Trait
where
for<'a> &'a Self::IntoIter: IntoIterator<Item = u32>,
{
type IntoIter;
fn get(&self) -> Self::IntoIter;
}

struct Impl(Vec<u32>);

impl Trait for Impl {
type IntoIter = ImplIntoIter;
fn get(&self) -> Self::IntoIter {
ImplIntoIter(self.0.clone())
}
}

struct ImplIntoIter(Vec<u32>);

impl<'a> IntoIterator for &'a ImplIntoIter {
type Item = <Self::IntoIter as Iterator>::Item;
type IntoIter = std::iter::Cloned<std::slice::Iter<'a, u32>>;
fn into_iter(self) -> Self::IntoIter {
(&self.0).into_iter().cloned()
}
}

fn main() {
}

0 comments on commit e5017de

Please sign in to comment.