-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Closed
Labels
C-bugCategory: bugCategory: bug
Description
When using [Self] in documentation comments for traits and enums, rust-analyzer does not resolve and display hover information for Self, while it works in struct documentation comments. This makes documentation less usable in editors and IDEs. In all these cases, rustdoc resolves Self properly and generates correct links. To summarize the support for Self in documentation:
| Case | R-A Hover Info | rustdoc |
|---|---|---|
| Structs | 🟢 Works | 🟢 Works |
| Enums | 🔴 Fails | 🟢 Works |
| Traits | 🔴 Fails | 🟢 Works |
rust-analyzer version: 0.3.2761-standalone & 1.93.0 (254b596 2026-01-19)
rustc version: 1.93.0 (254b59607 2026-01-19)
editor or extension: VSCode 1.108.2 & Zed 0.220.3
relevant settings: N/A
repository link (if public, optional): ra-self-in-trait (Screenshots included)
code snippet to reproduce:
/// A sample struct.
/// - [`my_field`](Self::my_field)
/// - [`get_my_field`](Self::get_my_field)
pub struct MyStruct {
pub my_field: i32,
pub another_field: i32,
}
impl MyStruct {
/// Reads [`my_field`](Self::my_field).
pub fn get_my_field(&self) -> i32 {
self.my_field
}
}
/// A sample enum.
/// - [`VariantOne`](Self::One)
/// - [`VariantTwo`](Self::Two)
pub enum MyEnum {
One,
Two,
}
/// A sample trait.
/// - [`ReturnType`](Self::ReturnType)
/// - [`do_something`](Self::do_something)
pub trait MyTrait {
type ReturnType;
fn do_something(&self) -> Self::ReturnType;
}Metadata
Metadata
Assignees
Labels
C-bugCategory: bugCategory: bug