Skip to content

Commit

Permalink
Fix bug checking wrong side of binary expression, add more test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcusGrass authored and ytmimi committed Mar 5, 2024
1 parent e8ac06d commit d5674a3
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,8 @@ pub(crate) fn format_expr(
match lhs.kind {
ast::ExprKind::Lit(token_lit) => lit_ends_in_dot(&token_lit),
ast::ExprKind::Unary(_, ref expr) => needs_space_before_range(context, expr),
ast::ExprKind::Binary(_, ref expr, _) => {
needs_space_before_range(context, expr)
ast::ExprKind::Binary(_, _, ref rhs_expr) => {
needs_space_before_range(context, rhs_expr)
}
_ => false,
}
Expand Down
3 changes: 3 additions & 0 deletions tests/source/issue-6059/repro.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn float_range_tests() {
self.coords.x -= rng.gen_range(-self.radius / 2. .. self.radius / 2.);
}
6 changes: 6 additions & 0 deletions tests/target/issue-6059/additional.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
fn float_range_tests() {
let _range = 3. / 2. ..4.;
let _range = 3.0 / 2. ..4.0;
let _range = 3.0 / 2.0..4.0;
let _range = 3. / 2.0..4.0;
}
3 changes: 0 additions & 3 deletions tests/target/issue-6059/no_trailing_dot.rs

This file was deleted.

3 changes: 3 additions & 0 deletions tests/target/issue-6059/repro.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn float_range_tests() {
self.coords.x -= rng.gen_range(-self.radius / 2. ..self.radius / 2.);
}
3 changes: 0 additions & 3 deletions tests/target/issue-6059/trailing_dot.rs

This file was deleted.

0 comments on commit d5674a3

Please sign in to comment.