Skip to content

Missing type parameters in creation of Default impl #8827

@kinnison

Description

@kinnison

For reference I am using rust-analyzer via vs-code.

  • vs-code extension version 0.3.594
  • Nightly channel
  • PersistentState: {
      lastCheck: 1620934826021,
      releaseId: 42876454,
      serverVersion: '0.2.591'
    }
    
  • Nightly (rustc 1.54.0-nightly (5c0292654 2021-05-11))

Given the following input code:

pub mod submod {
    pub struct Foo<T> {
        _bar: *mut T,
    }

    impl<T> Foo<T> {
        pub fn new() -> Self {
            todo!()
        }
    }
}

Rust-analyzer offers to "Generate a Default impl from a new fn" If I use this assist, I get the following impl generated:

    impl Default for Foo<T> {
        fn default() -> Self {
            Self::new()
        }
    }

Note the missing <T> for the impl

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-assistsE-has-instructionsIssue has some instructions and pointers to code to get startedS-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