Why are nested associated type paths considered ambiguous?

Viewed 276

Why are nested associated type paths considered ambiguous?

fn flatten<I>(iter: I) -> Option<I::Item::Item>
where
    I: Iterator,
    I::Item: IntoIterator,
{
    None
}
error[E0223]: ambiguous associated type
 --> src/lib.rs:1:34
  |
1 | fn flatten<I>(iter: I) -> Option<I::Item::Item>
  |                                  ^^^^^^^^^^^^^ help: use fully-qualified syntax: `<<I as Iterator>::Item as Trait>::Item`

Shouldn't the compiler be able to resolve the path without fully-qualified syntax? There is only one type I could be referring to, so I don't see why it is ambiguous. Is this a limitation of the compiler or is it intended behavior?

1 Answers
Related