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

Format fails silently with long string #5517

Closed
sampaioletti opened this issue Aug 23, 2022 · 7 comments
Closed

Format fails silently with long string #5517

sampaioletti opened this issue Aug 23, 2022 · 7 comments

Comments

@sampaioletti
Copy link

Hello,

When a file has a long line of text it fails silently without formatting the rest of the document

struct SomeStruct {
    inner: String,
}

impl SomeStruct {
    pub fn new() -> SomeStruct {
        SomeStruct
        { //<-intentional Format Mistake
            //fails silently
            inner: "Some long text Some long text Some long text Some long text Some long text Some long text Some long text".into()
            //works
            // inner: "Short text".into()
        }
    }
}

link with code in the playground...if you comment out the long inner line and use the shorter one..fmt works

https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=2d15a242e19893857057fb430005361f

Awesome project thank you very much

@ytmimi
Copy link
Contributor

ytmimi commented Aug 23, 2022

Try setting error_on_unformatted=true to get feedback. Odd that a warning isn't emitted when error_on_unformatted=false.

@ytmimi
Copy link
Contributor

ytmimi commented Aug 23, 2022

fails silently without formatting the rest of the document

I don't believe the claim that we fail to format the rest of the document is correct. Can you please elaborate with a code snippet that shows that behavior.

Invoking rustfmt from the command line with the following input show that we still format things further on in the document even though we don't format the struct.

input

struct SomeStruct {
    inner: String,
}

impl SomeStruct {
    pub fn new() -> SomeStruct {
        SomeStruct
        { //<-intentional Format Mistake
            //fails silently
            inner: "Some long text Some long text Some long text Some long text Some long text Some long text Some long text".into()
            //works
            // inner: "Short text".into()
        }
    }
}

fn     main()       {
println!("hello world!");
}

output

struct SomeStruct {
    inner: String,
}

impl SomeStruct {
    pub fn new() -> SomeStruct {
        SomeStruct
        { //<-intentional Format Mistake
            //fails silently
            inner: "Some long text Some long text Some long text Some long text Some long text Some long text Some long text".into()
            //works
            // inner: "Short text".into()
        }
    }
}

fn main() {
    println!("hello world!");
}

@sampaioletti
Copy link
Author

I'm sorry you are correct...it does format the rest of the document outside of the struct in question, I hadn't explored it further than what i show in the comments.

error_on_unformatted=true didn't make a difference for me

@ytmimi
Copy link
Contributor

ytmimi commented Aug 23, 2022

Got it.

Can you try setting both error_on_line_overflow=true and error_on_unformatted=true to see if you get output then. Recently it was described that both need to be set to get feedback #5477 (comment).

@sampaioletti
Copy link
Author

You nailed it..sorry i searched for other issues but didn't come across that or the ones it references...I'll close this then since it's a duplicate..thank you for your help!

@ytmimi
Copy link
Contributor

ytmimi commented Aug 23, 2022

No worries! It never hurts to reach out! Please let us know if anything else comes up😁

@sampaioletti
Copy link
Author

Will do, Thanks!

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

No branches or pull requests

2 participants