Skip to content
This repository was archived by the owner on Nov 18, 2022. It is now read-only.

cargo fmt and vs code autosave formatting result in different outputs #192

Closed
dreuter opened this issue Nov 20, 2017 · 2 comments
Closed

Comments

@dreuter
Copy link

dreuter commented Nov 20, 2017

Hi :)

Thanks for this great vs code extension :)

I am using vs code with this version:

Version 1.18.1
Commit 929bacba01ef658b873545e26034d1a8067445e9
Date 2017-11-16T18:34:22.110Z
Shell 1.7.9
Renderer 58.0.3029.110
Node 7.9.0
Architecture x64

and Rust (rls) version 0.3.2

When I write a simple program like this (cargo new test-rustfmt-vscode and replace lib.rs with these contents):

#[cfg(test)]
mod tests {
    #[test]
    fn it_works() {
        test();
        assert_eq!(2 + 2, 4);
    }
    type VeryLongName = i32;

    fn test(_a: VeryLongName,
            _b: VeryLongName,
            _c: VeryLongName,
            _d: VeryLongName,
            _e: VeryLongName) {
        ()
    }
}

and autoformat with cargo fmt nothing changes.

If I run Format Document in vscode it results in this:

#[cfg(test)]
mod tests {
    #[test]
    fn it_works() {
        test();
        assert_eq!(2 + 2, 4);
    }
    type VeryLongName = i32;

    fn test(
        _a: VeryLongName,
        _b: VeryLongName,
        _c: VeryLongName,
        _d: VeryLongName,
        _e: VeryLongName,
    ) {
        ()
    }
}

Did I miss some obvious setting or is this a reproducible bug?

Also probably related: #122 #132

@nrc
Copy link
Member

nrc commented Nov 20, 2017

It looks like you are using an old version of rustfmt locally. Perhaps you are using the rustfmt crate instead of rustfmt-nightly?

@dreuter
Copy link
Author

dreuter commented Nov 22, 2017

Yes, that was the problem 👍

Sorry to bother you with this. I did not know about these changes in the rust autoformatter.

@dreuter dreuter closed this as completed Nov 22, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants