rust-analyzer
rust-analyzer copied to clipboard
No type annotation when calling to_owned method on int or float
Hello,
I am currently learning Rust and was just playing around with methods and investigating std library and I found out that rust-analyzer doesn't know which type should be annotated if to_owned method is being called on int or float number (As you can see on picture, it is annotated as {unknown} if we hover over variable).
If it is being called on other structures like Array, Vector or String, it annotates just fine.
I don't know if I am reading std library correctly, but it looks like that internally it should just call clone method, but when we try to call clone method directly, rust-analyzer annotates type successfully.
Here we can see that even if that type is not annotated, type is still just fine and it compiles.
Here we can see that type gets resolved if we assign some value to variable.
Here we can see that type gets resolved if we explicitly annotate type.
So it looks like if rust-analyzer works with inferred type and we call that to_owned method, something happens which results with type not being annotated.
rust-analyzer version: 0.3.1203-standalone
rustc version: rustc 1.63.0 (4b91a6ea7 2022-08-08)