Understand rustfmt's formatting scope and semantics
mainUnlike simple whitespace formatters, rustfmt is designed to be semantics-preserving but not necessarily syntax-preserving. This means it can perform structural changes to the AST (Abstract Syntax Tree) to satisfy style guidelines, such as:
- Changing glob imports to explicit list or single imports.
- Re-ordering imports.
- Moving bounds to
whereclauses. - Combining multiple
implblocks into a singleimplblock.
However, rustfmt will not change variable names or perform any actions that could change the program's High-Level Intermediate Representation (HIR) or overall semantics.