You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This code compiles fine, but rust-analyzer reports an error on the second-last line (a.overload()), this is the error:
call to unsafe function is unsafe and requires an unsafe function or block
So rust-analzyer seems to think that we are calling Trait::overload although in reality we are calling X::overload. What is weird is that if I remove the unsafe there is no complain even though the Trait::overload method has the wrong return type.
Also note that if I replace the Send bound by another non-auto-trait like Default and impl<T: Default> Default for X<T> { ... } then rust-analyzer does not complain, so it seems to be related to auto traits.
The text was updated successfully, but these errors were encountered:
Okay yes, this is related to auto traits. rust-analyzer doesn't handle auto traits correctly currently (because this leads to a major perf degradation, see #19122) - therefore it treats the trait impl as applying to Arc<X<T>> (which it is not, because we don't know that T: Send), so it get a priority over the inherent impl, because the inherent impl requires a deref.
rust-analyzer version: rust-analyzer version: 0.3.2299-standalone
rustc version: rustc 1.84.1 (e71f9a9a9 2025-01-27)
editor or extension: VSCode with extension version v0.3.2299
code snippet to reproduce:
This code compiles fine, but rust-analyzer reports an error on the second-last line (
a.overload()
), this is the error:So
rust-analzyer
seems to think that we are callingTrait::overload
although in reality we are callingX::overload
. What is weird is that if I remove theunsafe
there is no complain even though theTrait::overload
method has the wrong return type.Also note that if I replace the
Send
bound by another non-auto-trait likeDefault
andimpl<T: Default> Default for X<T> { ... }
then rust-analyzer does not complain, so it seems to be related to auto traits.The text was updated successfully, but these errors were encountered: