Open
Description
Opening an issue since I could not find any information on when/if this will be enforced. Would be really useful for some generalizing I am trying for parser-combinators which I can't do currently without complicating the API.
Specifically I'd like to use a trait bound in a type definition to access an associated type to avoid passing it seperately but due to this issue I simply get a compiler error.
Simplified code which exhibits the error:
trait Stream {
type Item;
}
trait Parser {
type Input: Stream;
}
fn test<T>(u: T) -> T
where T: Parser {
panic!()
}
type Res<I: Stream> = (I, <I as Stream>::Item);
impl <'a> Stream for &'a str { type Item = char; }
impl <I> Parser for fn (I) -> Res<I> where I: Stream { type Input = I; }
//Works
//fn f(_: &str) -> (&str, char) {
//Errors
fn f(_: &str) -> Res<&str> {
panic!()
}
fn main() {
let _ = test(f as fn (_) -> _);
}
Metadata
Metadata
Assignees
Labels
Area: Trait systemArea: Type systemCategory: Future-incompatibility lintsCall for participation: Hard difficulty. Experience needed to fix: A lot.Issue: In need of a decision.Medium priorityRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.
Type
Projects
Status
Idea
Status
Fixed By