Rust is an actively developing language that experiments with new ideas and actively gains new features. API changes, idiomatic syntax structures are changing over time. And it is a good thing to see the language developing.
One of the downside of moving language is that existing codebase need to be adopted for new language structures/API. The changes are usually trivial but still require time from the project developers.
The best way to resolve this situation is to have a command-line tool that allows to do mass refactoring based on some AST conversion rules. Such rules can be as simple as 'rename method ‘String::foo’ to ‘String::bar’ but more complex as changing syntax, adding/removing parameters, function inlining, etc…
Here is an use case: I have a large project and just updated rust compiler requirement from 1.12 to 1.14 and I want to move the project to the new syntax, e.g.:
- use ‘…’ for matching where appropriate
- remove ‘empty string’ argument from println!()
- replace try! macro with ‘?’ operator
Instead of grepping code and manually fixing it I would prefer to run a tool similar to ‘rustfmt’. But instead of formatting the code it manipulates AST and changing it according to some rules. Think it’s like ‘Rails automatic db migration’ but for sources instead of records in a database. Such tool would make compiler upgrades much more pleasant.
And such tool can be made generic to work with any crate API upgrades: e.g. crate ‘foo’ changed its API so the crate developer can add a migration rule that describes code that use to be before and how it should be transformed. Such rule can be put to the project sources and distributed with Cargo.
I was looking for such Rust tool and did not find it. Do you think such tool would be useful? Worth filing a request to Rust team?