-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Closed
Labels
C-bugCategory: bugCategory: bug
Description
These inlay hints seem to be unnecessary to me:
This is in an otherwise-unchanged project created with cargo init.
fn a(s: &String) {}
fn main() {
let s = "".to_owned();
a(&s)
}First, "".to_owned() gets adjusted to (&*"").to_owned(). std::borrow::ToOwned::to_owned takes a &self reciever, and "" is of type &'static str, so no reborrow or deref coercion should be needed here.
Then, a(&s) gets annotated as a(&*&s), which is again very strange: s: String and fn a takes a &String parameter, so the exact type requested is being supplied.
Apparently these are reborrow hints. I'd actually like to see when Rust automatically does deref coercion or similar, but reborrows appear to happen on basically every usage of basically every variable, so I don't get much value out of them.
rust-analyzer 2025-08-11rustc 1.88.0 (6b00bc388 2025-06-23)- Editor:
NVIM v0.11.3, built-in LSP client - Relevant settings:
rust-analyzer.inlayHints.expressionAdjustmentHints.enable = "always"
Metadata
Metadata
Assignees
Labels
C-bugCategory: bugCategory: bug