Rustfmt: wrong line length calculation

Created on 11 Apr 2017  路  2Comments  路  Source: rust-lang/rustfmt

If I run:

$ rustfmt --version
0.8.3 ()

with such code:

fn test() -> Result<i32, String> {
    let r: Result<i32, String> = Ok(17);
    r.map_err(|err| format!("Someting really, really wrong, may be flash in the sun  : {}", err))?;
    Ok(15)
}

rustfmt works without problem, but if I place the same amount of chars (not bytes) into line:

fn test() -> Result<i32, String> {
    let r: Result<i32, String> = Ok(17);
    r.map_err(|err| format!("效褌芯-褌芯 锌芯褕谢芯 褋芯胁褋械屑 薪械 褌邪泻, 屑芯卸械褌 斜褘褌褜 胁褋锌褘褕泻邪 薪邪 褋芯谢薪褑械: {}", err))?;
    Ok(15)
}

it reports error: line exceeded maximum length (maximum: 100, found: 144) (sorry)

rustfmt should work with chars, not bytes, because of editors/code review tools and so on,
display both code examples using the same amount of horizontal space.

duplicate

Most helpful comment

I have run into this problem too and it's quite annoying.

All 2 comments

I have run into this problem too and it's quite annoying.

dup of #6 (sorry, this is really important to fix and it has taken forever)

Was this page helpful?
0 / 5 - 0 ratings