Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assignment LHS to RHS Comments handling when rewrite_assign_rhs is used #4667

Open
davidBar-On opened this issue Jan 24, 2021 · 0 comments
Open

Comments

@davidBar-On
Copy link
Contributor

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:

  1. Do nothing, as it is not expected that comments will be added between the lhs (... =) and rhs in these cases.
  2. Enhance the code to use rewrite_assign_rhs_with_comments instead of rewrite_assign_rhs....
  3. 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:

  1. format_variant()
enum Foo {
    Bar,
    Baz = /* Block comment */ 123,
    Quux = // Line comment
	124,
}
  1. format_trait_alias()
#![feature(trait_alias)]
trait Foo =/*comment*/std::fmt::Debug + Send;
trait Bar =/*comment*/Foo + Sync;
  1. rewrite_type()
type Kilometers =/*comment*/i32;
  1. rewrite_struct_field()
    Could not find an example. Per this code requires new line inside of field type.

  2. rewrite_opaque_impl_type()
    Could not find an example.

  3. Static ast::ForeignItem
    Could not find an example.

  4. Macro format_lazy_static()
    Maybe this case is not relevant currently, as format_lazy_static() is not called if the lazy_static! macro contains a comment - see here.

  5. ast::WherePredicate::BoundPredicate
    Could not find an example.

  6. ast::WherePredicate::EqPredicate
    Could not find an example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants