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 assistance tries to import unstable core::error::Error #15610

Closed
kpreid opened this issue Sep 13, 2023 · 1 comment · Fixed by #15611
Closed

Import assistance tries to import unstable core::error::Error #15610

kpreid opened this issue Sep 13, 2023 · 1 comment · Fixed by #15611
Labels
A-assists A-completion autocompletion C-bug Category: bug

Comments

@kpreid
Copy link
Contributor

kpreid commented Sep 13, 2023

What happens

Start with something like this (#[cfg(feature = "std")]s omitted for simplicity):

#![no_std]
extern crate std;
struct Foo;
impl Error for Foo {}

Put the cursor on Error and try to fix the missing name. std::error::Error will not be in the list of imports or qualifications; core::error::Error will be, but that is feature-gated so it won't compile. This also happens with the type paths created by completing a method declaration in a trait, e.g. source<TAB> in the trait body once the trait is qualified:

impl std::error::Error for Foo {
    fn source(&self) -> Option<&(dyn core::error::Error + 'static)> {
        //                           ^^^^ oops
    }
}

What should happen

rust-analyzer should instead use the stable path std::error::Error that is available.

Versions

rust-analyzer version: 0.3.1657-standalone (326f37e 2023-09-10)

rustc version: rustc 1.72.0 (5680fa18f 2023-08-23)

@kpreid kpreid added the C-bug Category: bug label Sep 13, 2023
@Veykril
Copy link
Member

Veykril commented Sep 14, 2023

Right, we don't look at the stability of the segments in import paths yet (the core::error module is currently unstable)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-assists A-completion autocompletion C-bug Category: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants