Support running bevy_lint_driver without the rustc path
#511
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
Right now,
bevy_lint_driverexpects itself to be called like:It expects its first argument to be the path to
rustc, as that's what Cargo passes to it. This, however, can lead to confusion when a normal user tries to runbevy_lint_driveras if it wererustc:$ rustc --version rustc 1.89.0-nightly (414482f6a 2025-05-13) $ bevy_lint_driver --version Usage: rustc [OPTIONS] INPUT Options: -h, --help Display this message --cfg <SPEC> Configure the compilation environment. SPEC supports the syntax `<NAME>[="<VALUE>"]`. # ...Unbeknownst to them,
bevy_lint_driversilently ate--versionbecause it thought it was the path torustc. Instead, the user should have run:This behavior is problematic because it's undocumented and breaks our UI tests, forcing us to use a workaround.
Solution
The path to
rustcis now optional. If it is not specified,bevy_lint_driverassume it is simply the string"rustc"and fill it in for you. This means this now works:I use some optimized slice trickery to avoid reallocations when performing this adjustment, so the implementation isn't as simple as described. With this change, we can finally remove the
ui_testhack, which is super nice!I still wouldn't recommend using
bevy_lint_driverdirectly as a user, which is why it's not documented much, but this removes one of its sharp edges.