Open ding-young opened 3 months ago
@rustbot claim
rewrite_***
We need to complete refactoring following functions to implement rewrite_result
for Expr
combine_strs_with_missing_comments
itemize_list
, write_list
, Iterator for ListItems
rewrite_comment
These are the list of functions that I have to update.
This issue tracks the necessary tasks to implement
rewrite_result
for all the nodes that haverewrite
implementation.Background
Current
rewrite
method returns Option, which means that it gives None without any context when formatting fails. To improve tracking the context of formatting failures, we plan to add a new methodrewrite_result
in Rewrite trait and gradually replacerewrite
withrewrite_result
.Target AST nodes
Below is the list of structs that currently implement the rewrite method. Most of these structs are rustc AST node, but it may be rustfmt representation of AST nodes (ex. Chain). Each task requires both implementing
rewrite_result
for that node and then modifyingrewrite
body with callingrewrite_result
. Still,rewrite
signature will remain the same and the return value ofrewrite_result
will be squashed into Option until we are ready to propagate Result upwards.rewrite_***
on the right are the functions that need to be modified to implementrewrite_result
for corresponding ast node.attr.rs
chains.rs
expr.rs
imports.rs
items.rs
macros.rs
matches.rs
overflow.rs
Expr, GenericParam, MacroArg, NestedMetaItem, SegmentParam FieldDef, TuplePatField, Ty, Pat #6291
patterns.rs
stmt.rs
types.rs
Future Tasks
Future tasks have two directions: one is propagating errors upward, and the other is generating a Result from downward that can potentially cause failure. Corresponding gh issues will be created after the tasks for this issue are done.
Reference
This issue is part of the Google Summer of Code project. For detailed description, see GSoC project page.