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

Off-by-two error wrapping line with use_small_heuristics Max #6219

Open
ia0 opened this issue Jun 26, 2024 · 2 comments
Open

Off-by-two error wrapping line with use_small_heuristics Max #6219

ia0 opened this issue Jun 26, 2024 · 2 comments

Comments

@ia0
Copy link

ia0 commented Jun 26, 2024

% rustfmt --version
rustfmt 1.7.1-nightly (fda509e 2024-06-25)

Content of src/main.rs:

/*
0         1         2         3         4         5         6         7         8         9
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
*/

fn main() {
    // This line has 100 characters ...............................................................9
    let connection = candidate.connect(Duration::from_secs(1)).context("connecting to the device")?;
    // This line has 99 characters ...............................................................8
    let connection = candidate.connect(Duration::from_secs(1)).context("connecting to the devic")?;
    // This line has 98 characters ..............................................................7
    let connection = candidate.connect(Duration::from_secs(1)).context("connecting to the devi")?;
}

Content of rustfmt.toml:

comment_width = 100
use_small_heuristics = "Max"

Expected formatting is that nothing changes. The file is already correctly formatted.

Actual formatting is the following (lines with 100 and 99 characters are wrapped):

/*
0         1         2         3         4         5         6         7         8         9
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
*/

fn main() {
    // This line has 100 characters ...............................................................9
    let connection =
        candidate.connect(Duration::from_secs(1)).context("connecting to the device")?;
    // This line has 99 characters ...............................................................8
    let connection =
        candidate.connect(Duration::from_secs(1)).context("connecting to the devic")?;
    // This line has 98 characters ..............................................................7
    let connection = candidate.connect(Duration::from_secs(1)).context("connecting to the devi")?;
}

Maybe it's related to #6180? Or maybe it's how use_small_heuristics = Max is supposed to work since the documentation doesn't say anything.

@ytmimi
Copy link
Contributor

ytmimi commented Jun 26, 2024

Thanks for the report! I think this is the same issue that was discussed in #6149 (comment)

@ia0
Copy link
Author

ia0 commented Jun 26, 2024

Thanks! I'll follow that PR.

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