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

A line-broken struct literal is indented one level too deep if followed by a method call #1139

Closed
nabijaczleweli opened this issue Aug 25, 2016 · 5 comments

Comments

@nabijaczleweli
Copy link

nabijaczleweli commented Aug 25, 2016

Happens on: v0.5, v0.6, master (59e199b)

Example code follows.

Expected:

struct Struct {
    i: i32,
    j: i32,
    k: i32,
    l: i32,
    m: i32,
}

impl Struct {
    fn err(self) -> ! {}
}

fn main() {
    Struct {
        i: 0,
        j: 0,
        k: 0,
        l: 0,
    }
    .err();
}

Actual:

struct Struct {
    i: i32,
    j: i32,
    k: i32,
    l: i32,
    m: i32,
}

impl Struct {
    fn err(self) -> ! {}
}

fn main() {
    Struct {
            i: 0,
            j: 0,
            k: 0,
            l: 0,
        }
        .err();
}
@nabijaczleweli nabijaczleweli changed the title If a function is called on a broken {}-constructed struct everything is indented one level too deep If a function is called directly on a broken {}-constructed struct everything is indented one level too deep Aug 25, 2016
@nrc nrc changed the title If a function is called directly on a broken {}-constructed struct everything is indented one level too deep If a function is called directly on a line-broken struct literal everything is indented one level too deep Aug 25, 2016
@nabijaczleweli
Copy link
Author

Any updates on this?

@sinkuu
Copy link
Contributor

sinkuu commented Sep 17, 2016

Isn't this an intended behavior? #816 (comment)

@nabijaczleweli
Copy link
Author

It looks ugly so I'd guess no :P

@nrc
Copy link
Member

nrc commented Sep 17, 2016

It kind of is intended behaviour, but it does look a bit ugly. I'm not sure what is preferable though? The constraint is that if there is a method chain, it should be indented, it would be nice, I guess to put the method call on the same line as the }, and then indent further items in the chain by a single space. I seem to remember there were issues with this approach though.

@nrc nrc changed the title If a function is called directly on a line-broken struct literal everything is indented one level too deep A line-broken struct literal is indented one level too deep if followed by a method call Jan 4, 2017
@topecongiro
Copy link
Contributor

Closing since this is fixed on the current master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants