I would suggest the following:
- start out by adding
#![warn(if_let_rescope)]to top of your whole crate, and runcargo check(without otherrust_2024_compatibilitylints, to help focus your attention to this relevant case) - manually look at all the places that are linted, see if there are any in your code where there is actually any change in behavior to be expected
- if your code doesn’t use
unsafe, there’s generally little concern of any bad bugs being introduced anyway, so if it’s too much effort to do the manual review, feel free to skip everything up to this point
- if your code doesn’t use
- when you’re happy with your manual handling of
if_let_rescope-cases, change your code by adding a#![allow(if_let_rescope)]to the top of your crate instead - proceed with edition migration for other issues besides
if_let_rescope. From these remarks for partial migration, it sounds like for more fine-graned / partial fixups like this you would have to:- not use the convenient
cargo fix --editioncommand anymore, if you want to automatically fix other parts of your code. I couldn’t find a way to make this command apply less than all the lints it knows. Instead, if you still want other auto-fixes applied, you can use normalcargo fix– for example:- you could add
#![warn(rust_2024_compatibility)]to the top of your crate, before the#![allow(if_let_rescope)]from above which disables the if-let specific part of this lint group - then use normal
cargo fixwithout the--editionargument to fix the auto-fixable warnings that this produces
- you could add
- not use the convenient
- eventually, you’ll be updating the crate’s edition to
2024; make sure the code still compiles and works - after migration, you can remove the new crate-level
#![warn(…)]and#![allow(…)]again- the
if_let_rescopewill not further warn on your code after the migration; you don’t have to worry about needing to keep around one (or many) such#[allow(if_let_rescope)]in your code, it isn’t necessary - most migration lints are not really meant to be activated outside of migration scenarios;
if_let_rescopeis allow-by-default for a reason, and this one is also explicitly meant to be ignored in cases where you know better than the lint and can determine that your code doesn’t actually change meaning – or at least not significantly so
- the