Skip to content

alias-eq is weaker than just subst-relate for "rigid" associated types #2

Closed
@compiler-errors

Description

@compiler-errors
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));
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions