Make '#[allow(private_bounds)]' compiler version-aware
The current fix for #2608 as implemented in e7ef93be495793ba570f13e43772ddff895b644c 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.
https://github.com/rwf2/Rocket/blob/b3abc760aee8556f5b455f13aaa4a1c7ae70bd85/core/codegen/src/derive/from_form.rs#L123-L131
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 e7ef93be495793ba570f13e43772ddff895b644c.
Cons. None known to the author.
Feel free to make comments and suggest edits to this PR! 👋
When rustc is newer than 1.74.0...
As of https://github.com/rwf2/Rocket/commit/38dbab8dd36b008108aba0a7af5ecf949ae238b9, 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.
@SergioBenitez,
Changes are made and filed.