Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Rustc suggests .to_vec to convert a Vec<T> to Vec<U> #43149

Closed
Eijebong opened this issue Jul 10, 2017 · 1 comment
Closed

Rustc suggests .to_vec to convert a Vec<T> to Vec<U> #43149

Eijebong opened this issue Jul 10, 2017 · 1 comment
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug.

Comments

@Eijebong
Copy link
Contributor

Eijebong commented Jul 10, 2017

Hey all,

With the following piece of code (rust playground):

struct Foo {}
struct Bar {}

fn hey(pouet: Vec<Bar>){}

fn main() {
    let foo = vec![Foo {}];
    hey(foo);
}

rustc gives me the following error

error[E0308]: mismatched types
 --> a.rs:8:9
  |
8 |     hey(foo);
  |         ^^^ expected struct `Bar`, found struct `Foo`
  |
  = note: expected type `std::vec::Vec<Bar>`
             found type `std::vec::Vec<Foo>`
  = help: here are some functions which might fulfill your needs:
          - .to_vec()

which doesn't make sense since .to_vec() wouldn't in any case convert the inner type.

@Mark-Simulacrum Mark-Simulacrum added the A-diagnostics Area: Messages for errors, warnings, and lints label Jul 19, 2017
@Mark-Simulacrum Mark-Simulacrum added the C-bug Category: This is a bug. label Jul 26, 2017
@arielb1 arielb1 self-assigned this Aug 13, 2017
@arielb1 arielb1 closed this as completed Sep 4, 2017
@arielb1
Copy link
Contributor

arielb1 commented Sep 4, 2017

Fixed in 1.21

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

3 participants