Skip to content

Support running bevy_lint_driver without the rustc path #511

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

BD103
Copy link
Member

@BD103 BD103 commented Jul 8, 2025

Problem

Right now, bevy_lint_driver expects itself to be called like:

$ bevy_lint_driver /path/to/rustc ...ARGUMENTS

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 run bevy_lint_driver as if it were rustc:

$ 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_driver silently ate --version because it thought it was the path to rustc. Instead, the user should have run:

$ bevy_lint_driver rustc --version

This behavior is problematic because it's undocumented and breaks our UI tests, forcing us to use a workaround.

Solution

The path to rustc is now optional. If it is not specified, bevy_lint_driver assume it is simply the string "rustc" and fill it in for you. This means this now works:

$ bevy_lint_driver --version
rustc 1.89.0-nightly (414482f6a 2025-05-13)

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_test hack, which is super nice!

I still wouldn't recommend using bevy_lint_driver directly as a user, which is why it's not documented much, but this removes one of its sharp edges.

@BD103 BD103 added A-Linter Related to the linter and custom lints C-Usability An improvement that makes the API more pleasant D-Trivial Nice and easy! A great choice to get started with Bevy CLI S-Needs-Review The PR needs to be reviewed before it can be merged labels Jul 8, 2025
@BD103
Copy link
Member Author

BD103 commented Jul 9, 2025

I'm not sure why the UI tests are failing, let me take a look at that . _.

@BD103 BD103 marked this pull request as draft July 9, 2025 02:13
@BD103 BD103 added S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged and removed S-Needs-Review The PR needs to be reviewed before it can be merged labels Jul 9, 2025
@BD103 BD103 added this to the `bevy_lint` v0.5.0 milestone Jul 12, 2025
@BD103 BD103 added the S-Blocked This cannot move forward until something else changes label Jul 12, 2025
@BD103
Copy link
Member Author

BD103 commented Jul 12, 2025

I'm marking this as blocked until v0.4.0 is released.

@BD103 BD103 force-pushed the driver-without-rustc branch from 2c07302 to b13975b Compare July 23, 2025 12:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Linter Related to the linter and custom lints C-Usability An improvement that makes the API more pleasant D-Trivial Nice and easy! A great choice to get started with Bevy CLI S-Blocked This cannot move forward until something else changes S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant