rust-lang / rust-lang/rust-analyzer
Show the derived/implemented traits directly on the type when the mouse is hovering over the type name.
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
For example, when my mouse cursor is above the std::net::TcpListener in my code, I get this in the "tooltip":
std::net::tcp
pub struct TcpListener // size = 4, align = 4
A TCP socket server, listening for connections.
After creating a TcpListener by [bind]ing it to a socket address, it listens for incoming TCP connections. These can be accepted by calling [accept] or by iterating over the [Incoming](vscode-file://vscode-app/opt/visual-studio-code/resources/app/out/vs/code/electron-sandbox/workbench/workbench.html) iterator returned by [incoming](vscode-file://vscode-app/opt/visual-studio-code/resources/app/out/vs/code/electron-sandbox/workbench/workbench.html).
The socket will be closed when the value is dropped.
The Transmission Control Protocol is specified in [IETF RFC 793](vscode-file://vscode-app/opt/visual-studio-code/resources/app/out/vs/code/electron-sandbox/workbench/workbench.html).
Examples
use std::net::{TcpListener, TcpStream};
fn handle_client(stream: TcpStream) {
// ...
}
fn main() -> std::io::Result<()> {
let listener = TcpListener::bind("127.0.0.1:80")?;
// accept connections and process them serially
for stream in listener.incoming() {
handle_client(stream?);
}
Ok(())
}
[10 implementations](vscode-file://vscode-app/opt/visual-studio-code/resources/app/out/vs/code/electron-sandbox/workbench/workbench.html)
This is all fine and dandy; however, it would also be really useful if all the trait implementations were shown for this type, close to the full path to the type in the first line. The size and alignment are both great, but having the traits implemented listed would be a more useful thing, in my opinion. Especially it would be helpful since many crates provide trait implementations during the code generation stage, so it is really hard to find out if a certain trait is implemented for the type or not, as what you see in the code is some macro magic with many different conditions, where you might not know which one is truth and so, leads to some trait being implemented for this type.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing rust-analyzer's hover handling for a type name, using the TcpListener tooltip described in the issue as the expected context. Determine where the existing type path, size, alignment, and documentation are assembled. Done means the hover tooltip also lists the traits implemented for the hovered type, including implementations produced through macros.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100