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

imports.preferNoStd for alloc ignored when "extern crate std" is present #19053

Open
kristoff3r opened this issue Jan 27, 2025 · 0 comments
Open
Labels
A-assists C-bug Category: bug

Comments

@kristoff3r
Copy link

When a crate contains extern crate std; rust-analyzer always want to import e.g. String and other alloc imports from std, even when preferNoStd is set and/or the crate is #![no_std]. For imports from core it seems to suggest both, but with core first.

I discovered this while working on a bevy crate that has extern crate std behind a feature flag, but it seems to be a problem regardless of the feature flag.

rust-analyzer version: rust-analyzer version: 0.4.2281-standalone

rustc version: rustc 1.84.0 (9fc6b4312 2025-01-07)

editor or extension: VScode v0.4.2281 (pre-release)

relevant settings:
settings.json:

{
  "rust-analyzer.imports.preferNoStd": true
}

code snippet to reproduce:

#![no_std]

extern crate alloc;

extern crate std;

// ctrl+. on string only suggests std::string::String
pub fn foo() -> String {}
@kristoff3r kristoff3r added the C-bug Category: bug label Jan 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-assists C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

2 participants