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

Make '#[allow(private_bounds)]' compiler version-aware #2689

Merged
merged 1 commit into from
Apr 12, 2024
Merged

Make '#[allow(private_bounds)]' compiler version-aware #2689

merged 1 commit into from
Apr 12, 2024

Conversation

CSharperMantle
Copy link
Contributor

@CSharperMantle CSharperMantle commented Jan 4, 2024

The current fix for #2608 as implemented in e7ef93b addressed the problem by introducing both the new private_bounds lint rule and the deprecated private_in_public one. To smooth out the cross-version incompatibilities, @SergioBenitez added two more lint rules, namely renamed_and_removed_lints and unknown_lints, to suppress the warnings on both old and new rustcs.

Ok(quote_spanned! { mixed(input.span()) =>
/// Rocket generated FormForm context.
#[doc(hidden)]
#[allow(unknown_lints)]
#[allow(renamed_and_removed_lints)]
#[allow(private_in_public)]
#[allow(private_bounds)]
#vis struct #ctxt_ty #impl_gen #where_clause {
__opts: #_form::Options,

However, we can take one step further by utilizing version_check dependency. This PR proposes that the said crate checks the availability of private_bounds at codegen time, allowing for fewer lint rules generated in the AST.

The fix is implemented by introducing an auxiliary variable lints, which expands to different attributes of lint rules when compiled on different versions of rustc. When rustc is newer than 1.74.0, it is set to the token stream of #[allow(private_bounds)], utilizing the new feature; otherwise it is equal to the old sequence of #[allow(...)] rules. The need for #[allow(unknown_lints)] is eliminated.

Pros. Less lint rules generated while retaining the effect of the fix in e7ef93b.

Cons. None known to the author.

Feel free to make comments and suggest edits to this PR! 👋

@SergioBenitez
Copy link
Member

When rustc is newer than 1.74.0...

As of 38dbab8, the MSRV is now 1.75. Let's do the minimal thing that works on 1.75+ since we no longer need to support older versions.

@CSharperMantle
Copy link
Contributor Author

@SergioBenitez,

Changes are made and filed.

@SergioBenitez SergioBenitez merged commit ff12b1d into rwf2:master Apr 12, 2024
14 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants