-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-trait-systemArea: Trait systemArea: Trait systemA-type-systemArea: Type systemArea: Type systemC-future-incompatibilityCategory: Future-incompatibility lintsCategory: Future-incompatibility lintsE-hardCall for participation: Hard difficulty. Experience needed to fix: A lot.Call for participation: Hard difficulty. Experience needed to fix: A lot.I-needs-decisionIssue: In need of a decision.Issue: In need of a decision.P-mediumMedium priorityMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.
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 (_) -> _);
}
EntilZha, ebkalderon, Flaise, nixpulvis, lfrancke and 3 more
Metadata
Metadata
Assignees
Labels
A-trait-systemArea: Trait systemArea: Trait systemA-type-systemArea: Type systemArea: Type systemC-future-incompatibilityCategory: Future-incompatibility lintsCategory: Future-incompatibility lintsE-hardCall for participation: Hard difficulty. Experience needed to fix: A lot.Call for participation: Hard difficulty. Experience needed to fix: A lot.I-needs-decisionIssue: In need of a decision.Issue: In need of a decision.P-mediumMedium priorityMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-typesRelevant to the types 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