Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import/qualify trait Deref suggesting lazy_static::__Deref instead of std::ops::Deref #9197

Closed
Tracked by #86 ...
ThePuzzlemaker opened this issue Jun 10, 2021 · 2 comments · Fixed by #15473
Closed
Tracked by #86 ...
Labels
A-assists A-completion autocompletion S-unactionable Issue requires feedback, design decisions or is blocked on other work

Comments

@ThePuzzlemaker
Copy link

The code action to import/qualify a trait suggests lazy_static::__Deref instead of std::ops::Deref for just the name Deref.

To reproduce:

  • Add lazy_static v1.4.0 to the Cargo.toml (Not sure if this happens on other versions)
  • Create an impl block impl Deref for Foo.
  • Press alt-period or whatever code action shortcut is set up while the cursor is over the Deref in the impl Deref for Foo block.
  • lazy_static::__Deref is suggested instead of std::ops::Deref.

image

Information:
IDE: VSCode
Plugin: matklad.rust-analyzer v0.2.621
rust-analyzer version: rust-analyzer 28e32fe 2021-05-31 stable
Rust: 1.52.1

@lnicola
Copy link
Member

lnicola commented Jun 10, 2021

CC #9113

@Veykril
Copy link
Member

Veykril commented Jun 10, 2021

The problem here is that lazy_static reexports Deref with a doc hidden. We should ideally honor the #[doc(hidden)] attribute unless its hidden in the same crate we are importing from.
Minimal test case for autoimport that imports __Deref:

//- /main.rs crate:main deps:std,lazy_static
impl Deref$0 for () {}
//- /lazy_static.rs crate:lazy_static deps:core
#[doc(hidden)]
pub use core::ops::Deref as __Deref;
//- /std.rs crate:std deps:core
pub use core::ops;
//- /core.rs crate:core
pub mod ops {
    pub trait Deref {}
}

Though I don't think we can do anything here at the moment as re-exports/renames aren't really being represented in the hir yet so we lose the attribute info here i think?

@Veykril Veykril added A-assists A-completion autocompletion S-unactionable Issue requires feedback, design decisions or is blocked on other work labels Jun 10, 2021
bors bot added a commit that referenced this issue Jul 28, 2021
9719: feat: Make flyimport respect `#[doc(hidden)]` r=jonas-schievink a=jonas-schievink

Fixes #7718 (we still don't respect `#[doc(hidden)]` on reexports, but that is tracked by #9197)

bors r 

Co-authored-by: Jonas Schievink <[email protected]>
@bors bors closed this as completed in 44cf174 Aug 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-assists A-completion autocompletion S-unactionable Issue requires feedback, design decisions or is blocked on other work
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants