Skip to content

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

Closed
@kpreid

Description

@kpreid

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)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions