Skip to content

Generate method assist misses generics when generating an impl block #19806

@svix-jplatte

Description

@svix-jplatte

Input:

struct Generic<T: Send>(T);

fn foo() {
    Generic("test").do_a_thing()
}

Current output:

struct Generic<T: Send>(T);
impl Generic {
    fn do_a_thing(&self) {
        todo!()
    }
}

fn foo() {
    Generic("test").do_a_thing()
}

Expected output:

struct Generic<T: Send>(T);

impl<T: Send> Generic<T> {
    fn do_a_thing(&self) {
        todo!()
    }
}

fn foo() {
    Generic("test").do_a_thing()
}

I suppose impl Generic<&'static str> would also be an option, but less likely to be what the user intended.

rust-analyzer version: 0.4.2462-standalone
rustc version: 1.89.0-nightly (414482f 2025-05-13)
editor or extension: VSCode (ext version 0.4.2462)

@rustbot label +A-assists

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions