-
Notifications
You must be signed in to change notification settings - Fork 11
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
API: Include the lint crate in the lint identifier #288
Conversation
f587a4c
to
326c9f7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beware that I changed the book chapter about specifying lints in #283. The docs there already include the requirement of specifying the lint crate name in the lint name.
// `marker_api::declare_lint` uses the `CARGO_CRATE_NAME` environment value. | ||
// Setting it here once, makes sure that it'll be available, during the | ||
// compilation of all ui test files. | ||
std::env::set_var("CARGO_CRATE_NAME", "marker_lints_uitests"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a painful papercut. I don't fully understand how it works. Why is this marker_lints_uitests
and not just marker_lints
? The name marker_lints_uitests
isn't mentioned anywhere else in this PR. I also don't see this code setup for marker_uilints
.
Could this be avoided? Otherwise, could the workaround be encapsulated inside of marker_uitest::simple_ui_test_config
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ui_test
doesn't use Cargo and instead calls the rustc driver directly. This is for a few reasons, as Cargo would need a workspace, Cargo.toml
file and would also be a bit slower for only compiling a single file. However, this also means that any environment values usually set by Cargo (starting with CARGO_*
) are not set when the uitest files are compiled.
This should really only be noticed, if someone writes lints for the marker_api::declare_lint!
macro. That's why only the uitest of marker_lints
required this environment value to be set. So I don't really see it as a paper cut.
This PR adds the lint crate name, as an infix for the lint identifier.
marker::diag_msg_uppercase_start
->marker::marker_lints::diag_msg_uppercase_start
This prevents lint name collisions across different lint crates.
This is a major breaking change, but I think it'll definitely be worth it in the long run. We might want to add a way to rename lint crates, this would allow users to shorten some names, like this:
marker::super_lints::diag_msg_uppercase_start
->marker::super::diag_msg_uppercase_start
Inspired by #278