Skip to content

Lint to find std imports that could be imported as core or alloc #8917

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
i509VCB opened this issue May 30, 2022 · 2 comments
Closed

Lint to find std imports that could be imported as core or alloc #8917

i509VCB opened this issue May 30, 2022 · 2 comments
Labels
A-lint Area: New lints

Comments

@i509VCB
Copy link
Contributor

i509VCB commented May 30, 2022

What it does

If an import is a type exposed in core or alloc, the lint should warn that a the type could be imported using core or alloc instead.

Lint Name

prefer_core_alloc_imports

Category

pedantic

Advantage

  • For crates which support no_std environments, this makes finding accidental std import additions easier that could break the crate when compiling for a no_std environment.

Drawbacks

  • Crates which reexport core, alloc or std might behave differently.

Example

use std::mem::size_of;
use std::vec::Vec;

Could be written as:

use core::mem::size_of;
use alloc::vec::Vec;
@i509VCB i509VCB added the A-lint Area: New lints label May 30, 2022
@Serial-ATA
Copy link
Contributor

Duplicate of #7724

@giraffate
Copy link
Contributor

Thanks for suggesting new lint!

I'm closing this because of #8917 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: New lints
Projects
None yet
Development

No branches or pull requests

3 participants