Skip to content

Add #[derive(Debug)] code action only triggers on line start #20941

@eduardorittner

Description

@eduardorittner

The code action to add #[derive(Debug)] for a struct which needs it only shows up when the cursor is on the first character of the line (in this case, the 's' of the struct keyword), while the intuitive behavior would be to suggest this action when hovering over the struct definition: only the struct's name or (preferably) anywhere in the struct definition. The same behavior is also true for enums as well.

rust-analyzer version: rust-analyzer 1.89.0 (2948388 2025-08-04)

rustc version: rustc 1.89.0 (29483883e 2025-08-04)

editor or extension: Helix and Neovim

relevant settings: All default settings

code snippet to reproduce:

struct MyData {
    data: usize,
}

fn main() {
    let data = MyData { data: 0 };
    println!("{data:?}");
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions