Skip to content

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

Open
@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 (414482f6a 2025-05-13)
editor or extension: VSCode (ext version 0.4.2462)

@rustbot label +A-assists

Activity

rustbot

rustbot commented on May 16, 2025

@rustbot
Collaborator

Unknown labels: S-assists

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @rustbot@svix-jplatte

        Issue actions

          Generate method assist misses generics when generating an impl block · Issue #19806 · rust-lang/rust-analyzer