Skip to content

[BUG] Rust format might break ranges in specific cases #6059

@PaulDotSH

Description

@PaulDotSH

In this code snippet

        self.coords.x -= rng.gen_range(-self.radius / 2. .. self.radius / 2.);

Running rust format will change this code to

        self.coords.x -= rng.gen_range(-self.radius / 2...self.radius / 2.);

Which will make rustc unable to compile the file because 2...X is not a valid syntax for ranges, however having the space lets rustc know that 2 is supposed to be a float and the dots represent a range.

Proposed fix:
Either do not remove the spaces in this case, or add a 0 in the case of floats.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugPanic, non-idempotency, invalid code, etc.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions