Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: rust-lang/rustfmt
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: karyon/rustfmt
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Able to merge. These branches can be automatically merged.
  • 1 commit
  • 2 files changed
  • 1 contributor

Commits on Oct 22, 2021

  1. Fix tabs having a fixed width internally

    Ref #4968. Tabs were always counted to have a width of config.tab_spaces.
    Since they actually can have less than that depending on the line's
    previous contents, rustfmt would sometimes complain about the line
    length even if the line did actually fit.
    karyon committed Oct 22, 2021
    Copy the full SHA
    e8ec129 View commit details
Showing with 9 additions and 1 deletion.
  1. +1 −1 src/formatting.rs
  2. +8 −0 tests/target/configs/error_on_unformatted/false_with_error_on_line_overflow.rs
2 changes: 1 addition & 1 deletion src/formatting.rs
Original file line number Diff line number Diff line change
@@ -559,7 +559,7 @@ impl<'a> FormatLines<'a> {
fn char(&mut self, c: char, kind: FullCodeCharKind) {
self.newline_count = 0;
self.line_len += if c == '\t' {
self.config.tab_spaces()
self.config.tab_spaces() - self.line_len % self.config.tab_spaces()
} else {
1
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// rustfmt-error_on_unformatted: true
// rustfmt-error_on_line_overflow: true

// Part of #4968. These are 100 chars, so it should be fine, but rustfmt panicked.
fn panic_with_tabs() {
let a = "tab here: Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonu est \
est, consetetur sadipscing";
}