diff --git a/posts/2024-11-01-gsoc-2024-results.md b/posts/2024-11-01-gsoc-2024-results.md index 0d10a00cf..db837d6fa 100644 --- a/posts/2024-11-01-gsoc-2024-results.md +++ b/posts/2024-11-01-gsoc-2024-results.md @@ -120,11 +120,15 @@ The vast majority of `run-make` tests [now use the Rust-based test infrastructur - Mentor: [Yacin Tmimi](https://github.com/ytmimi) - [Final report](https://ding-young.github.io/posts/gsoc-final/) -[rustfmt] is a Rust code formatter that is widely used across the Rust ecosystem thanks to its direct integration within Cargo. Usually, you just run `cargo fmt` and you can immediately enjoy a properly formatted Rust project. However, there are edge cases in which `rustfmt` can fail to format your code. That is not such an issue on its own, but it becomes more problematic when it fails *silently*, without giving the user any context about what went wrong. This is what sometimes happens in `rustfmt`, due to technical debt that made it difficult to add proper error reporting in all situations. +[rustfmt] is a Rust code formatter that is widely used across the Rust ecosystem thanks to its direct integration within Cargo. Usually, you just run `cargo fmt` and you can immediately enjoy a properly formatted Rust project. However, there are edge cases in which `rustfmt` can fail to format your code. That is not such an issue on its own, but it becomes more problematic when it fails *silently*, without giving the user any context about what went wrong. This is what was happening in `rustfmt`, as many functions simply returned an `Option` instead of a `Result`, which made it difficult to add proper error reporting. -The goal of SeoYoung's project was to perform a large internal refactoring of `rustfmt` that would allow tracking context about what went wrong during reformatting. In turn, this would enable turning silent failures into proper error messages that could help users examine and debug what went wrong. It could even allow `rustfmt` to retry formatting in more situations. +The goal of SeoYoung's project was to perform a large internal refactoring of `rustfmt` that would allow tracking context about what went wrong during reformatting. In turn, this would enable turning silent failures into proper error messages that could help users examine and debug what went wrong, and could even allow `rustfmt` to retry formatting in more situations. -TODO +At first, this might sound like an easy task, but performing such large-scale refactoring within a complex project such as `rustfmt` is not so simple. SeoYoung needed to come up with an approach to incrementally apply these refactors, so that they would be easy to review and wouldn't impact the entire code base at once. She introduced a new trait that enhanced the original `Rewrite` trait, and modified existing implementations to align with it. She also had to deal with various edge cases that we hadn't anticipated before the project started. SeoYoung was meticulous and systematic with her approach, and made sure that no formatting functions or methods were missed. + +Ultimately, the refactor was a success! Internally, rustfmt now keeps track of more information related to formatting failures, including errors that it could not possibly report before, such as issues with macro formatting. It also has the ability to provide information about source code spans, which helps identify parts of code that require spacing adjustments when exceeding the maximum line width. We don't yet currently propagate that additional failure context as user facing error messages, as that was a stretch goal that we didn't have time to complete, but SeoYoung has expressed interest in continuing to work on that as a future improvement! + +Apart from working on error context propagation, SeoYoung also made various other improvements that enhanced the overall quality of the codebase, and she was also helping other contributors understand `rustfmt`. Thank you for making the foundations of formatting better for everyone! [rustfmt]: https://github.com/rust-lang/rustfmt