rust-lang / rustfmt

Format Rust code
https://rust-lang.github.io/rustfmt/
Apache License 2.0
5.85k stars 860 forks source link

Implement rewrite_result for AST nodes #6201

Closed ding-young closed 1 week ago

ding-young commented 1 week ago

Background

Since current rewrite method cannot track the context , this pr plans to implement rewrite_result method that returns Result. I will replace rewrite with rewrite_result in further pr.

Detail

Added a default implementation of the rewrite_result method, which calls the existing rewrite method and transforms the Option into a Result with a default error kind. Additionally, I implemented the rewrite_result method for the Chain and ast::Local types by copying the body of their respective rewrite functions and replacing some of the Option handling logic with appropriate error handling.

TODO & Question

calebcartwright commented 1 week ago

Haven't had a chance to look at this, but just wanted to say I'm intrigued and excited by the title and description!

ding-young commented 1 week ago

@calebcartwright Thank you so much for your interest! I've actually posted a tracking issue (#6206) for this project, where you can follow along with updates and progress.