Skip to content

Trait method and associated type auto completion removes comments and attributes #8739

@vallentin

Description

@vallentin

When implementing a trait, I sometimes write comments and attributes before adding the actual method or associated type. I've encountered a bug, where if you use auto completion, then the comments and attribute prior are removed.

I can recall this issue having existed for a long time. So thought I might as well finally report it.


Steps to reproduce

  1. Create a trait, which has any amount of methods and/or associated types
  2. Start implementing the trait for a type
  3. Write comments and/or attributes
  4. Start typing the name of a method or associated type
  5. Press Enter to auto complete
  6. Now the method/type has been auto completed, while the previous comments and/or attributes have been removed

Example

I think a code snippet is less sufficient in this case, so I'll include screenshots.

  • Before shows the comments and attributes, with the auto complete prompt open
  • After is after having pressed Enter enter on the auto complete suggestion
Before After
before after
Before After
before after

It also happens for associated types.

Before After
before after

rust-analyzer version: 6175353 2021-04-26 stable

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-completionautocompletionS-actionableSomeone could pick this issue up and work on it right now

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions