Skip to content

assoc types: type inference works with UFCS but not with method calls #22165

@japaric

Description

@japaric

STR

#![crate_type = "lib"]

trait Tuple {
    type Array: Toa<Item=Self>;
}

trait Toa {
    type Item;

    fn push(&mut self, Self::Item);
    fn with_capacity(usize) -> Self;
}

#[cfg(not(works))]
fn f<T: Tuple>(t: T) -> T::Array {
    let mut toa = Toa::with_capacity(1);
    toa.push(t);  //~ error: the type of this value must be known in this context
    toa
}

#[cfg(works)]
fn g<T: Tuple>(t: T) -> T::Array {
    let mut toa = Toa::with_capacity(1);
    Toa::push(&mut toa, t);
    toa
}

Version

rustc 1.0.0-nightly (134e00be7 2015-02-09 19:01:37 +0000)

cc @nikomatsakis

(Deja Vu, I feel like I've reported/seen a similar problem before, but it didn't involve associated types)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-associated-itemsArea: Associated items (types, constants & functions)A-inferenceArea: Type inferenceA-type-systemArea: Type systemC-bugCategory: This is a bug.T-compilerRelevant 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.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions