Skip to content

Type inference doesn't work for functions returning generic vectors with trait bounds #10436

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
huonw opened this issue Nov 12, 2013 · 2 comments · Fixed by #27154
Closed

Type inference doesn't work for functions returning generic vectors with trait bounds #10436

huonw opened this issue Nov 12, 2013 · 2 comments · Fixed by #27154
Labels
A-type-system Area: Type system

Comments

@huonw
Copy link
Member

huonw commented Nov 12, 2013

fn works<T>(x: T) -> ~[T] {
    ~[x]
}

fn doesnt<T: Clone>(x: T) -> ~[T] {
    ~[x]
}

fn main() {
    let _: ~[uint] = works(0); // this is ok.
    let _: ~[uint] = doesnt(0);
}
vec-infer.rs:11:21: 11:35 error: mismatched types: expected `~[uint]` but found `~[int]` (expected u but found )
vec-infer.rs:11     let _: ~[uint] = doesnt(0);
                                     ^~~~~~~~~~
error: aborting due to previous error
task 'rustc' failed at 'explicit failure', /home/huon/rust/src/libsyntax/diagnostic.rs:101
task '<main>' failed at 'explicit failure', /home/huon/rust/src/librustc/lib.rs:400
@nikomatsakis
Copy link
Contributor

cc me.

@japaric
Copy link
Member

japaric commented Nov 2, 2014

Triage: Not relevant right now, but this issue should be tested if/when we restore int/float fallback.

steveklabnik added a commit to steveklabnik/rust that referenced this issue Jul 21, 2015
steveklabnik added a commit to steveklabnik/rust that referenced this issue Jul 21, 2015
steveklabnik added a commit to steveklabnik/rust that referenced this issue Jul 21, 2015
steveklabnik added a commit to steveklabnik/rust that referenced this issue Jul 22, 2015
steveklabnik added a commit to steveklabnik/rust that referenced this issue Jul 22, 2015
steveklabnik added a commit to steveklabnik/rust that referenced this issue Jul 22, 2015
steveklabnik added a commit to steveklabnik/rust that referenced this issue Jul 22, 2015
flip1995 pushed a commit to flip1995/rust that referenced this issue Mar 10, 2023
help: refer to `cargo check --help`

Fixes rust-lang#10436

changelog: none
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-type-system Area: Type system
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants