Skip to content

Show bounds on variable with generic type #11099

Description

@hniksic

When I place the cursor over a variable defined with a generic type, I only get the name of the generic type, not its trait bounds (which is what I'm interested in, especially for types bounded by closure traits). For example, in a function defined like this:

pub fn run<F>(make_sessionizer: F)
where
    F: FnOnce(&Arc<Database>),
{
    // imagine many lines here...
    let sessionizer = make_sessionizer(Arc::new(Database));
    // ...
}

I would expect hovering above make_sessionizer to tell me how I can call the function, e.g. something like F: FnOnce(&Arc<Database>). What I actually get is make_sessionizer: F, which is technically correct, but not very useful on its own:

image

I use Emacs with Rustic, but I believe the contents of the popup entirely comes from rust-analyzer. For example (taken on slightly different code, but showing the same thing):

[Trace - 03:44:39 PM] Received response 'textDocument/hover - (6979)' in 887ms.
Result: {
  "range": {
    "end": {
      "character": 34,
      "line": 227
    },
    "start": {
      "character": 17,
      "line": 227
    }
  },
  "contents": {
    "value": "\n```rust\nmake_event_loader: F\n```",
    "kind": "markdown"
  }
}

Originally reported as brotzeit/rustic#311.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-hoverhover featureA-idegeneral IDE featuresC-featureCategory: feature request

    Type

    No type

    Fields

    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