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

Inconsistent line breaks in match #3963

Closed
EverlastingBugstopper opened this issue Dec 12, 2019 · 2 comments
Closed

Inconsistent line breaks in match #3963

EverlastingBugstopper opened this issue Dec 12, 2019 · 2 comments

Comments

@EverlastingBugstopper
Copy link

What I expect:

impl fmt::Display for RemoteObject {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        match &self.object_type {
            RemoteObjectType::Undefined => write!(f, "undefined"),
            RemoteObjectType::Boolean 
            | RemoteObjectType::String => self.display_value(f),
            RemoteObjectType::Null 
            | RemoteObjectType::Object => self.display_object(f),
            RemoteObjectType::BigInt
            | RemoteObjectType::Number
            | RemoteObjectType::Symbol
            | RemoteObjectType::Function => self.display_description(f),
        }
    }
}

What rustfmt produces:

impl fmt::Display for RemoteObject {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        match &self.object_type {
            RemoteObjectType::Undefined => write!(f, "undefined"),
            RemoteObjectType::Boolean | RemoteObjectType::String => self.display_value(f),
            RemoteObjectType::Null | RemoteObjectType::Object => self.display_object(f),
            RemoteObjectType::BigInt
            | RemoteObjectType::Number
            | RemoteObjectType::Symbol
            | RemoteObjectType::Function => self.display_description(f),
        }
    }
}

If this isn't a bug - happy to close! Might just be a personal preference of mine :)

@topecongiro
Copy link
Contributor

This is not a bug, rustfmt uses multiple lines for a match arm only if it exceeds max-width (which is 100 by default). So the first three arms are kept in a single line, whereas the last one gets spanned to multiple lines.

@topecongiro
Copy link
Contributor

Closing in favor of #4005.

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

2 participants