Automated way to remove let chains

Is there a way to automate removing let chains?

I have a codebase which I'd like to maintain support for latest stable rust as well as 1.85.

Notably Rust 1.85 doesn't support let-chains. I find that let-chains do improve the code quality quite a bit so I'd like to continue using them.

I'm thinking of ways I can maintain both branches moving forward. One thought I had: If a clippy fixup lint existed for let-chains I could just apply that to produce code that's 1.85 compatible.

There isn't one currently. A Clippy lint with an automatic fix would be one way to do it.

You could also try rewriting yourself with syn.

There used to be rerast AST rewriter, but the project is dead, and won't recognize let chains syntax. Maybe ast-grep can?

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.