Ensure space after binary exprs that ends with . before range expr

Removing the space would lead to compilation errors.
This commit is contained in:
MarcusGrass 2024-03-05 04:19:57 +01:00 committed by GitHub
parent 35c1b7d734
commit 73c81495cd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 15 additions and 0 deletions

View File

@ -282,6 +282,9 @@ 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 rhs_expr) => {
needs_space_before_range(context, rhs_expr)
}
_ => false,
}
}

View File

@ -0,0 +1,3 @@
fn float_range_tests() {
self.coords.x -= rng.gen_range(-self.radius / 2. .. self.radius / 2.);
}

View File

@ -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;
}

View File

@ -0,0 +1,3 @@
fn float_range_tests() {
self.coords.x -= rng.gen_range(-self.radius / 2. ..self.radius / 2.);
}