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

Create new lints with #[clippy::version = "nightly"] #14299

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Alexendoo
Copy link
Member

This is a partial solution to https://rust-lang.zulipchat.com/#narrow/channel/257328-clippy/topic/Using.20CURRENT_RUSTC_VERSION.20in.20clippy.3A.3Aversion.3F

I was not sure if CURRENT_RUSTC_VERSION would work for the stable/beta doc generation so there's no automation here, the versions still need to be manually corrected during the changelog update. But it will eventually (when we're past old PRs with verison = "1.xy.0") solve the issue of wrong versions being shown in the docs

If we figure out that CURRENT_RUSTC_VERSION can be made to work it would be easy enough to move to also

r? @flip1995

cc @xFrednet

changelog: none

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Feb 26, 2025
@flip1995
Copy link
Member

flip1995 commented Feb 26, 2025

(Long text about a problem where I think I came up with a solution while spelling it out. Jump to the last paragraph, if you only want to know the solution)

This is a bit awkward for beta/stable branching (what triggers the doc generation):

To get the beta commit of Clippy, I check which commit of Clippy is in the beta branch in the Rust repo. This commit is always the commit of the sync 2 weeks before the release. That commit would contain the #[clippy::version = nightly] attributes. But we don't want them in beta (or stable) branch.

So to fix that, we (the person doing the syncs) would have to do an extra version replacement during the sync 2 weeks before the release. Or maybe doing so before every sync would be even better. If this needs to be done during sync, we need to automate it with a cargo dev command. (Haven't looked at the changes, you might've already done this)

However checking this in CI is tricky. We could check in the Rustup PR, that there are no clippy::version = nightly attributes in the codebase. But I'm afraid that's not enough. This check would have to run in the Rust repo when doing the sync from Clippy->Rust. Otherwise, if the Clippy->Rust direction sync is delayed and there is time in between the Rust->Clippy sync and the Clippy->Rust sync, a new lint might be added, rendering the check on the Rustup PR in the Clippy repo useless.

While writing this, we could also get around this: Add a test to tests/ that only runs if RUSTC_TEST_SUITE (opposite to the version check tests), that checks the codebase for clippy::version = nightly. Then one would be forced to update the versions during the Clippy->Rust sync.

@Alexendoo Alexendoo force-pushed the clippy-version-nightly branch from a66f49a to 0190457 Compare February 28, 2025 15:25
@Alexendoo
Copy link
Member Author

That sounds good, here's an example output

running 1 test
test no_nightly_versions_in_rust_repo ... FAILED

failures:

---- no_nightly_versions_in_rust_repo stdout ----
clippy_lints/src/doc/mod.rs:85: doc_link_code has #[clippy::version = "nightly"]
clippy_lints/src/doc/mod.rs:451: doc_overindented_list_items has #[clippy::version = "nightly"]
clippy_lints/src/loops/mod.rs:718: manual_slice_fill has #[clippy::version = "nightly"]
clippy_lints/src/matches/mod.rs:975: manual_ok_err has #[clippy::version = "nightly"]
clippy_lints/src/mem_replace.rs:46: mem_replace_option_with_some has #[clippy::version = "nightly"]
clippy_lints/src/methods/mod.rs:4465: io_other_error has #[clippy::version = "nightly"]
clippy_lints/src/methods/mod.rs:4440: manual_contains has #[clippy::version = "nightly"]
clippy_lints/src/methods/mod.rs:4322: manual_repeat_n has #[clippy::version = "nightly"]
clippy_lints/src/methods/mod.rs:4373: return_and_then has #[clippy::version = "nightly"]
clippy_lints/src/methods/mod.rs:4345: sliced_string_as_bytes has #[clippy::version = "nightly"]
clippy_lints/src/methods/mod.rs:4413: unbuffered_bytes has #[clippy::version = "nightly"]
clippy_lints/src/methods/mod.rs:4295: useless_nonzero_new_unchecked has #[clippy::version = "nightly"]
clippy_lints/src/precedence.rs:28: precedence_bits has #[clippy::version = "nightly"]
clippy_lints/src/single_option_map.rs:12: single_option_map has #[clippy::version = "nightly"]
clippy_lints/src/unnecessary_semicolon.rs:9: unnecessary_semicolon has #[clippy::version = "nightly"]
clippy_lints/src/unneeded_struct_pattern.rs:9: unneeded_struct_pattern has #[clippy::version = "nightly"]
clippy_lints/src/deprecated_lints.rs: option_map_or_err_ok has #[clippy::version = "nightly"]

thread 'no_nightly_versions_in_rust_repo' panicked at tests/lint-definitions.rs:34:5:
assertion failed: !failed

@Alexendoo Alexendoo force-pushed the clippy-version-nightly branch from 0190457 to 782a868 Compare March 4, 2025 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants