Closed
Description
trait Mk {
type Assoc;
}
fn mk<T: Mk>(t: T) -> T::Assoc {
todo!()
}
fn foo<S: Mk + Default>() {
let x = Default::default();
let y = mk::<_ /* ?z */>(x);
let x: S = x;
}
error[E0282]: type annotations needed for `<_ as Mk>::Assoc`
--> <source>:11:9
|
11 | let y = mk::<_ /* ?z */>(x);
| ^
|
help: consider giving `y` an explicit type, where the type for associated type `<_ as Mk>::Assoc` is specified
|
11 | let y: <_ as Mk>::Assoc = mk::<_ /* ?z */>(x);
| ++++++++++++++++++
Related, heavily reduced from an example in syn:
fn main() {
let mut x: Vec<_> = vec![];
x.extend(Some(1i32).into_iter().map(|x| x));
}