Hi, I’m integrating a client with rust-analyzer and trying to fetch code actions based on Clippy diagnostics.
I sent a textDocument/codeAction request with this Clippy warning:
warning: writing `&Vec` instead of `&[_]` involves a new object where a slice will do
help: change this to: `&[NewLineStyle]`
The request includes:
-
diagnostics field with Clippy's ptr_arg warning
-
range that overlaps the warning's range
-
valid textDocument.uri
However, the response is just an empty array .
Does rust-analyzer currently support returning quick fixes for Clippy lints like this?
Or is there anything I need to configure (e.g. checkOnSave.command = "clippy") or change in the request?
Thanks!
ra version: "0.3.2379-standalone (8365cf853e 2025-04-13)"
complete request return json:
{"jsonrpc":"2.0","method":"textDocument/codeAction","params":{"context":{"diagnostics":[{"code":"ptr_arg","codeDescription":{"href":"https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg"},"data":{"rendered":"warning: writing `&Vec` instead of `&[_]` involves a new object where a slice will do\n --> crates\\doc\\src\\lines\\mod.rs:2885:26\n |\n2885 | semantic_styles: &Vec<NewLineStyle>,\n | ^^^^^^^^^^^^^^^^^^ help: change this to: `&[NewLineStyle]`\n |\n = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg\n = note: `#[warn(clippy::ptr_arg)]` on by default\n\n"},"message":"writing `&Vec` instead of `&[_]` involves a new object where a slice will do\nfor further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg\n`#[warn(clippy::ptr_arg)]` on by default","range":{"end":{"character":43,"line":2884},"start":{"character":25,"line":2884}},"relatedInformation":[{"location":{"range":{"end":{"character":43,"line":2884},"start":{"character":25,"line":2884}},"uri":"file:///d:/git/cozy-lapce/crates/doc/src/lines/mod.rs"},"message":"change this to: `&[NewLineStyle]`"}],"severity":2,"source":"clippy"},{"code":"ptr_arg","codeDescription":{"href":"https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg"},"message":"change this to: `&[NewLineStyle]`","range":{"end":{"character":43,"line":2884},"start":{"character":25,"line":2884}},"relatedInformation":[{"location":{"range":{"end":{"character":43,"line":2884},"start":{"character":25,"line":2884}},"uri":"file:///d:/git/cozy-lapce/crates/doc/src/lines/mod.rs"},"message":"original diagnostic"}],"severity":4,"source":"clippy"}]},"range":{"end":{"character":25,"line":2884},"start":{"character":25,"line":2884}},"textDocument":{"uri":"file:///D:/git/cozy-lapce/crates/doc/src/lines/mod.rs"}},"id":297}
{"jsonrpc":"2.0","id":297,"result":[]}