Skip to content

Lint to identify core symbols consumed through std #7724

Closed
@d-e-s-o

Description

@d-e-s-o

What it does

Personally, I think it would be helpful to have a lint that tells me that a symbol that I am using is available from the core crate, but I am importing it through std.

Categories (optional)

  • Kind: probably clippy::pedantic

What is the advantage of the recommended code over the original code

In embedded development or whenever there may be a reason to have no_std compatibility in one form or another at some point, it is helpful to get an understanding of what is consumed from std, but really coming from core and could be used directly from there (and would not need to be feature gated, replaced, or whatever). Hence, having a lint that could highlight the use of re-exported core symbols through std would be useful, e.g., when no_std support is desirable at some point in the future, but perhaps not implemented right now.

Drawbacks

Not everyone may feel strongly about identifying core functionality as such and, in fact, in a good amount of cases there may not be any benefit to side-stepping std partly. But then it should be an optional feature, similar in nature to print_stdout, for example.

Example

use std::hash::Hasher;

Could be written as:

use core::hash::Hasher;

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintArea: New lintsL-restrictionLint: Belongs in the restriction lint group

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions