-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Closed
Labels
A-tytype system / type inference / traits / method resolutiontype system / type inference / traits / method resolutionC-bugCategory: bugCategory: bugS-needs-testBug fixed, but needs a test.Bug fixed, but needs a test.good first issue
Description
In the following code (minimized from futures::{Stream, TryStream}) try_poll_next() method is displayed as unresolved reference, however it is compilable
pub trait TryStream: Stream {
fn try_poll_next(&self) {}
}
pub trait Stream {
// Removing associated type makes the error disappear
type Item;
fn poll_next(&self) {}
}
// Trait that only has `Stream` as super-trait
trait StreamAlias: Stream<Item = ()> {}
// Blanket impls
impl<S: Stream<Item = ()>> TryStream for S {}
impl<S: Stream<Item = ()>> StreamAlias for S {}
// Concrete implementor of `Stream`
struct StreamImpl;
impl Stream for StreamImpl {
type Item = ();
}
fn foo() -> impl StreamAlias {
StreamImpl
}
fn main() {
let alias = foo();
// try_poll_next() here is unresolved, though the code compiles
alias.try_poll_next();
// However direct `Stream` supertrait works, this method is resolved
alias.poll_next();
}lnicola, davidatsurge and prmadev
Metadata
Metadata
Assignees
Labels
A-tytype system / type inference / traits / method resolutiontype system / type inference / traits / method resolutionC-bugCategory: bugCategory: bugS-needs-testBug fixed, but needs a test.Bug fixed, but needs a test.good first issue