Skip to content

Make all manual_* lints do not delete comments during fix #361

@MKowalski8

Description

@MKowalski8

Problem

As for now, we have some inconsistency when it comes to manual_* lints. Some delete comments while fix and some doesn't. We want to make all of them support saving comments, like below:

From:

fn main() {
  let foo: Option::<i32> = Option::None;
  // This is just a variable.
  let _foo = match foo {
      Option::Some(_) => true,
      Option::None => {
          // do something
          false
      },
  };
}

To:

    fn main() {
        let foo: Option<i32> = Option::None;
        // This is just a variable.
        // do something
        let _foo = foo.is_some();
    }

At the moment // do something will be deleted.

Proposed Solution

manual_unwrap_or_default has universal solution that can be applied to other lints

fn extract_comments(db: &dyn SyntaxGroup, node: &SyntaxNode, indent: &str) -> String {

Notes

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Status

    Backlog Lint

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions