Description
The places where rewrite_assign_rhsh()/_with()
are used, and the comments between lhs and rhs are not handled, were identified in #4626. I submitted PRs to use rewrite_assign_rhs_with_comments()
for the rewrite_assignment
and format_trait
cases.
For the following cases, it is not clear if and what should be done. There seem to be three options:
- Do nothing, as it is not expected that comments will be added between the lhs (
... =
) and rhs in these cases. - Enhance the code to use
rewrite_assign_rhs_with_comments
instead ofrewrite_assign_rhs...
. - Only check whether all comments are included in the formatted code and if not use the original code (using
recover_comment_removed()
).
Following are the relevant cases with code examples when I was able to find an example:
enum Foo {
Bar,
Baz = /* Block comment */ 123,
Quux = // Line comment
124,
}
#![feature(trait_alias)]
trait Foo =/*comment*/std::fmt::Debug + Send;
trait Bar =/*comment*/Foo + Sync;
type Kilometers =/*comment*/i32;
-
rewrite_struct_field()
Could not find an example. Per this code requires new line inside of field type. -
rewrite_opaque_impl_type()
Could not find an example. -
Static ast::ForeignItem
Could not find an example. -
Macro format_lazy_static()
Maybe this case is not relevant currently, asformat_lazy_static()
is not called if thelazy_static!
macro contains a comment - see here. -
ast::WherePredicate::BoundPredicate
Could not find an example. -
ast::WherePredicate::EqPredicate
Could not find an example.