rust-lang / rust-lang/cargo

no_std crates should not permit non-no_std dependencies

Open
#8,798 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-new-lint C-bug S-needs-design
Dominant language
Rust
Stars
15.5k
Forks
3k
Avg merge
23h 30m
Merged PRs (30d)
51

Description

I couldn't find this exact problem mentioned elsewhere.

Problem

Cargo rightly produces errors for uses of std within a crate but will not complain about dependencies that rely on std when building for platforms that support std. This means that an implicit std requirement can quietly sneak into a project. It seems rather bizarre that cargo does not catch this issue.

Possible Solution(s)

  • Make cargo search for uses of std when building dependencies and produce an error
  • Do not permit std as a dependency in the dependency graph for no_std crates
  • Only permit dependencies that are explicitly tagged with #![no_std] for no_std crates

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No files, tests, or entry points are named. Start by tracing Cargo's dependency-resolution and build behavior for no_std crates, then define which proposed restriction should apply and how a failing dependency graph would demonstrate that the work is complete.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
build-system
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.