Closed
Description
I'm working with combine and rust nightly to make some parsers and I'm wondering why both of these examples are not equivalent:
The first example compiles successfully:
pub fn source<'a, I>() -> impl Parser<Input = I, Output = Source>
where
I: RangeStream<Item = u8, Range = &'a [u8]>,
I::Error: ParseError<u8, &'a [u8], I::Position>,
<I::Error as ParseError<I::Item, I::Range, I::Position>>::StreamError: From<str::Utf8Error>
{
// ...
}
whereas this one
pub fn source<'a, I>() -> impl Parser<Input = I, Output = Source>
where
I: RangeStream<Item = u8, Range = &'a [u8]>,
I::Error: ParseError<I::Item, I::Range, I::Position>,
<I::Error as ParseError<I::Item, I::Range, I::Position>>::StreamError: From<str::Utf8Error>
{
// ...
}
produces this error:
error[E0277]: the trait bound `<I as combine::StreamOnce>::Error: combine::ParseError<u8, &'a [u8], <I as combine::StreamOnce>::Position>` is not satisfied
--> src/parser.rs:57:1
|
57 | / pub fn source<'a, I>() -> impl Parser<Input = I, Output = Source>
58 | | where
... |
89 | | )
90 | | }
| |_^ the trait `combine::ParseError<u8, &'a [u8], <I as combine::StreamOnce>::Position>` is not implemented for `<I as combine::StreamOnce>::Error`
|
= help: consider adding a `where <I as combine::StreamOnce>::Error: combine::ParseError<u8, &'a [u8], <I as combine::StreamOnce>::Position>` bound
error[E0277]: the trait bound `<I as combine::StreamOnce>::Error: combine::ParseError<u8, &'a [u8], <I as combine::StreamOnce>::Position>` is not satisfied
--> src/parser.rs:57:1
|
57 | / pub fn source<'a, I>() -> impl Parser<Input = I, Output = Source>
58 | | where
... |
89 | | )
90 | | }
| |_^ the trait `combine::ParseError<u8, &'a [u8], <I as combine::StreamOnce>::Position>` is not implemented for `<I as combine::StreamOnce>::Error`
AFAICT, the bounds: I::Error: ParseError<u8, &'a [u8], I::Position>
and I::Error: ParseError<I::Item, I::Range, I::Position>
should be identical since we know I::Item = u8
and I::Range = &'a [u8]
.
Is this a limitation of the compiler's inference, a bug, or something else?
Metadata
Metadata
Assignees
Labels
Area: Associated items (types, constants & functions)Category: An issue proposing an enhancement or a PR with one.Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable ExampleCall for participation: An issue has been fixed and does not reproduce, but no test has been added.Relevant to the language team
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
Marwes commentedon Jan 31, 2018
@brennie I believe this is #43475 (and a few other issues linked from that post). I think this is planned to be fixed with the trait system rewrite (lazy normalization) but I don't know what the timeline is for that :(.
rkarp commentedon Feb 3, 2018
The oldest related issue seems to be #24159, which was even before Rust 1.0. I think fixing this should be a priority considering that many people have run into this over almost 3 years.
[-]Inable to deduce associated type equality[/-][+]Unable to deduce associated type equality[/+]Rollup merge of rust-lang#81485 - jackh726:atb-issues, r=Mark-Simulacrum
jackh726 commentedon Dec 25, 2023
I'm going to close this since it may be fixed already, but regardless doesn't have an MCVE. There are cases where we'll still run into these types of problems, but I know there are other issues covering more complex cases.