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

Rustfmt fails to fmt #4135

Closed
jyn514 opened this issue Apr 22, 2020 · 2 comments
Closed

Rustfmt fails to fmt #4135

jyn514 opened this issue Apr 22, 2020 · 2 comments

Comments

@jyn514
Copy link
Member

jyn514 commented Apr 22, 2020

Consider the following code:

impl S {
    fn f() {
        self.g(
            {
                if b {
                    Err(w(
                        i(
                            "expected float or integer types for both operands of {}, got '{}' and '{}'",
                            token,
                        )), left)
                }
                match d {
                    _ => h(m,b), 
                }
            },
        )
    }
}

There are many style issues, but the one that caught my attention was the lack of a space after the comma. I tried and sure enough if you add a trailing space rustfmt will refuse to format at all and give an internal error as a result:

error[internal]: left behind trailing whitespace
  --> /home/joshua/src/rust/rcc/comma.rs:13:13:32
   |
13 |                     _ => h(m,b), 
   |                                 ^
@jyn514
Copy link
Member Author

jyn514 commented Apr 22, 2020

This appears to be related to the length of the string somehow, if I cut down the length it formats correctly:

impl S {
    fn f() {
        self.g(
            {
                if b {
                    Err(w(
                        i(
                            "expected ",
                            token,
                        )), left)
                }
                match d {
                    _ => h(m,b), 
                }
            },
        )
    }
}

transformed to

impl S {
    fn f() {
        self.g({
            if b {
                Err(w(i("expected ", token)), left)
            }
            match d {
                _ => h(m, b),
            }
        })
    }
}

@calebcartwright
Copy link
Member

Closing in favor of #3863

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

3 participants