We want to start using rustfmt on the code base of librsvg. I've stumbled on a bug though where if you run rustfmt once it will change the files, but if run again it will reset them to the previous state. This seem to happen no matter which of those 2 states the code base sits. I am not sure how to describe it better.
This is sort of a blocker since the CI rustfmt test will always fail :(
Using rustfmt 0.3.8
➜ rustfmt -Vv
0.3.8-nightly ( )
I've made a separate branch to test this.
Steps to reproduce:
git clone https://gitlab.gnome.org/alatiera/librsvg.git --branch rustfmt-visual-bugcargo fmt --allcargo fmt --all againFixed as of version 0.7.
Nevermind it's still happening, I hadn't drunk coffee yet sorry!
This is still happening on rustfmt 0.99.2-nightly (5c9a2b6 2018-08-07). We've updated the branch to account for rustfmt differences from when the issue was reported. The instructions are the same.
@alatiera also added a CI job that runs cargo fmt --check and cargo fmt twice to showcase the issue. Note, for example, this last diff:
Diff in /builds/alatiera/librsvg/rsvg_internals/src/structure.rs at line 238:
Attribute::X => self.x.set(parse("x", value, LengthDir::Horizontal, None)?),
Attribute::Y => self.y.set(parse("y", value, LengthDir::Vertical, None)?),
- Attribute::Width => {
- self.w.set(parse("width",
- value,
- LengthDir::Horizontal,
- Some(RsvgLength::check_nonnegative)).map(Some)?)
- }
- Attribute::Height => {
- self.h.set(parse("height",
- value,
- LengthDir::Vertical,
- Some(RsvgLength::check_nonnegative)).map(Some)?)
- }
+ Attribute::Width => self.w
+ .set(parse("width",
+ value,
+ LengthDir::Horizontal,
+ Some(RsvgLength::check_nonnegative)).map(Some)?),
+ Attribute::Height => self.h
+ .set(parse("height",
+ value,
+ LengthDir::Vertical,
+ Some(RsvgLength::check_nonnegative)).map(Some)?),
_ => (),
}
which in the second run gets reverted back:
Diff in /builds/alatiera/librsvg/rsvg_internals/src/structure.rs at line 242:
Attribute::X => self.x.set(parse("x", value, LengthDir::Horizontal, None)?),
Attribute::Y => self.y.set(parse("y", value, LengthDir::Vertical, None)?),
- Attribute::Width => self.w
- .set(parse("width",
- value,
- LengthDir::Horizontal,
- Some(RsvgLength::check_nonnegative)).map(Some)?),
- Attribute::Height => self.h
- .set(parse("height",
- value,
- LengthDir::Vertical,
- Some(RsvgLength::check_nonnegative)).map(Some)?),
+ Attribute::Width => {
+ self.w.set(parse("width",
+ value,
+ LengthDir::Horizontal,
+ Some(RsvgLength::check_nonnegative)).map(Some)?)
+ }
+ Attribute::Height => {
+ self.h.set(parse("height",
+ value,
+ LengthDir::Vertical,
+ Some(RsvgLength::check_nonnegative)).map(Some)?)
+ }
_ => (),
}
Found a short example: a cycle between
fn main() {
match option {
None => some_function(first_reasonably_long_argument,
second_reasonably_long_argument),
}
}
and
fn main() {
match option {
None => {
some_function(first_reasonably_long_argument,
second_reasonably_long_argument)
}
}
}
Most helpful comment
Nevermind it's still happening, I hadn't drunk coffee yet sorry!