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

Implement field_init_shorthand feature #1215

Closed
MoSal opened this issue Nov 10, 2016 · 5 comments
Closed

Implement field_init_shorthand feature #1215

MoSal opened this issue Nov 10, 2016 · 5 comments
Labels
good first issue Issues up for grabs, also good candidates for new rustfmt contributors p-high

Comments

@MoSal
Copy link

MoSal commented Nov 10, 2016

#![feature(field_init_shorthand)]

struct AA{}
struct BB{}

struct CC {
    a: AA,
    b: BB
}

impl CC {
    fn new(a: AA, b: BB) -> Self {
        Self { a, b }
    }
}

cargo fmt error:

error: expected `:`, found `,`
  --> /tmp/foo/src/lib.rs:13:17
   |
13 |         Self { a, b }
   |                 ^

@nrc nrc added good first issue Issues up for grabs, also good candidates for new rustfmt contributors p-high labels Nov 10, 2016
@nrc nrc changed the title Fails if field_init_shorthand feature is used Implement field_init_shorthand feature Nov 10, 2016
@matthew-piziak
Copy link

Weird. Looks like it doesn't error anymore on master. This works. Instead it just inserts the field names. I don't see the commit changing it though.

@clarfonthey
Copy link

Is there any progress on this?

@clarfonthey
Copy link

It appears that this works in the latest rustfmt, but it defaults to expanding out the shorthand. I think that the default should be to always use the shorthand when possible.

@nrc
Copy link
Member

nrc commented Feb 14, 2017

Fixed by fad74c8

@nrc nrc closed this as completed Feb 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Issues up for grabs, also good candidates for new rustfmt contributors p-high
Projects
None yet
Development

No branches or pull requests

5 participants