Skip to content

Feature request: Setting to pull import suggestions/autoimports from core:: not std:: #10718

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

Closed
thomcc opened this issue Nov 8, 2021 · 3 comments
Labels
A-assists A-completion autocompletion A-config configuration C-feature Category: feature request S-actionable Someone could pick this issue up and work on it right now

Comments

@thomcc
Copy link
Member

thomcc commented Nov 8, 2021

Sorry in advance if I just failed to find the way to do this.

I would like to be able to configure r-a to prefer core:: for autoimports (err, the import suggestion list, I guess) whenever available, rather than std::. It already does this when it knows #![no_std] is enabled, but often this is conditional on some feature which happens to be on under the current r-a configuration, but isn't guaranteed to be on in that module, etc.

I would honestly even be fine if this option forced r-a to only ever use core:: for this and ignore std::, since I usually have to put imports from std:: in some scope or behind a #[cfg] anyway.

@lnicola lnicola added A-assists A-completion autocompletion C-feature Category: feature request S-actionable Someone could pick this issue up and work on it right now labels Nov 8, 2021
@bjorn3
Copy link
Member

bjorn3 commented Nov 8, 2021

I think it makes sense to default to core:: in case of a conditional #![no_std] too and only fallback to std:: if no core:: path exists in that case.

@CryZe
Copy link
Contributor

CryZe commented Nov 8, 2021

Would it maybe make sense to just always prefer core over std? That would certainly help people identify subsets of their crates that would work nicely on no_std. And it never really hurts (all that much). Maybe there could be a setting to turn it off.

@Veykril Veykril added the A-config configuration label Dec 14, 2021
bors added a commit that referenced this issue Apr 20, 2022
…=jonas-schievink

feat: prefer core/alloc over std in auto-imports if `#[no_std]` is conditional

We already did this if `#![no_std]` was present, this PR makes it work with `#![cfg_attr(not(test), no_std)]` too, which is very common in libraries.

Fixes #12035
cc #10718
@jonas-schievink
Copy link
Contributor

I think it makes sense to default to core:: in case of a conditional #![no_std] too and only fallback to std:: if no core:: path exists in that case.

This is now implemented in #12041

@Veykril Veykril closed this as completed Jul 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-assists A-completion autocompletion A-config configuration C-feature Category: feature request S-actionable Someone could pick this issue up and work on it right now
Projects
None yet
Development

No branches or pull requests

6 participants