Skip to content

Regression from 1.20 to 1.21 stable -> stable with StreamingIterator code #45438

Closed
@mikeyhew

Description

@mikeyhew

The following code compiles with Rust version 1.20, but not with 1.21 and above:

pub trait StreamingIterator<'a>: 'a {
    type Item: 'a;

    fn next(&'a mut self) -> Option<Self::Item>;
}

pub trait StreamingIteratorExt: for<'a> StreamingIterator<'a> {}

impl<I> StreamingIteratorExt for I where
    I: for<'a>StreamingIterator<'a>
{}

Error in Rust 1.21+:

error[E0310]: the parameter type `I` may not live long enough
  --> src/lib.rs:14:9
   |
14 | impl<I> StreamingIteratorExt for I where
   |      -  ^^^^^^^^^^^^^^^^^^^^
   |      |
   |      help: consider adding an explicit lifetime bound `I: 'static`...
   |
note: ...so that the type `I` will meet its required lifetime bounds
  --> src/lib.rs:14:9
   |
14 | impl<I> StreamingIteratorExt for I where
   |         ^^^^^^^^^^^^^^^^^^^^

Note the Self: 'a bound on StreamingIterator. If I remove it, the error goes away.

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.P-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions