Skip to content

Add impl members assist shold not copy docstrings and attrs #1022

@matklad

Description

@matklad

when invoking assist for impl PartialEq for Diagnostics, I get

impl PartialEq for Diagnostics {
        /// This method tests for `self` and `other` values to be equal, and is used
        /// by `==`.
        #[must_use]
        #[stable(feature = "rust1", since = "1.0.0")]
        fn eq(&self, other: &Rhs) -> bool { unimplemented!() }
        /// This method tests for `!=`.
        #[inline]
        #[must_use]
        #[stable(feature = "rust1", since = "1.0.0")]
        fn ne(&self, other: &Rhs) -> bool { !self.eq(other) }
}

There are two problems here:

  • doc comments and attributes should not be copied
  • default methods like ne should not be copied

Code and tests for this feature are here:

https://github.com/rust-analyzer/rust-analyzer/blob/3d7a330f320ac2ebf73df012556d64be9b120445/crates/ra_assists/src/add_missing_impl_members.rs

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions