Skip to content
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

Merged
merged 2 commits into from
Oct 12, 2023

Conversation

xFrednet
Copy link
Member

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

@xFrednet xFrednet added C-enhancement Category: New feature or request A-api Area: Stable API labels Oct 11, 2023
@xFrednet xFrednet added this to the v0.4.0 milestone Oct 11, 2023
Copy link
Contributor

@Veetaha Veetaha left a 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.

.github/workflows/gh-pages.yml Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
// `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");
Copy link
Contributor

@Veetaha Veetaha Oct 11, 2023

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?

Copy link
Member Author

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.

@xFrednet xFrednet added I-api-break Issue: This change will break the public API and removed I-api-break Issue: This change will break the public API labels Oct 12, 2023
@xFrednet
Copy link
Member Author

I assume this PR is ready, since all comments have been addressed. Merging this will also unblock the docs from #283

Thank you for the review and documentation update in #283

@xFrednet xFrednet added this pull request to the merge queue Oct 12, 2023
Merged via the queue into rust-marker:master with commit 886086e Oct 12, 2023
23 checks passed
@xFrednet xFrednet deleted the 278-lint-path-names branch October 12, 2023 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-api Area: Stable API C-enhancement Category: New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants