Description
Description: when RA suggests .deref()
and picks a trait to auto-import to bring deref()
into scope, it chooses lazy_static::__Deref
instead of the more common std::ops::Deref
or core::ops::Deref
. My Cargo.toml contains lazy_static = "1.4.0"
under [dependencies]
.
VSCode screenshot:
Code to reproduce is below. The issue also occurs if rc::Rc
is replaced with cell::RefCell
(and .borrow()
added to obtain a Ref
), but I'm not sure about what happens with other Deref
implementors.
use std::rc::Rc;
struct A {
r: Rc<String>,
}
fn f() {
let a = A {
r: Rc::new("s".to_owned()),
};
let s = a.r.der| // Cursor to the right of `der`
// ┌──────────────────────────────────────────┐
// │³ deref() (use lazy_static::__Deref) │
// │³ deref_mut() (use std::ops::DerefMut) │
// └──────────────────────────────────────────┘
}
RA correctly suggests .deref()
as an autocomplete for der
, but chooses to auto-import the necessary trait from lazy_static::__Deref
, instead of std::ops::Deref
or core::ops::Deref
, which seem like more reasonable choices. (It correctly offers to import .deref_mut()
from std::ops::DerefMut
.) In the attached screenshot, pressing <TAB>
will insert use lazy_static::__Deref
near the top of the file.
Similarly, if you write out deref()
without importing anything, the fix-it for the error offers to import or qualify with lazy_static::_Deref
(same underlying issue, I assume).