-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
#![cfg] to disable a crate disables #![no_std] #39183
Copy link
Copy link
Open
Labels
A-attributesArea: Attributes (`#[…]`, `#![…]`)Area: Attributes (`#[…]`, `#![…]`)C-bugCategory: This is a bug.Category: This is a bug.I-needs-decisionIssue: In need of a decision.Issue: In need of a decision.T-langRelevant to the language teamRelevant to the language team
Metadata
Metadata
Assignees
Labels
A-attributesArea: Attributes (`#[…]`, `#![…]`)Area: Attributes (`#[…]`, `#![…]`)C-bugCategory: This is a bug.Category: This is a bug.I-needs-decisionIssue: In need of a decision.Issue: In need of a decision.T-langRelevant to the language teamRelevant to the language team
Type
Fields
Give feedbackNo fields configured for issues without a type.
Using
#![cfg]to disable a crate on platforms where it makes no sense is usually a great idea. That way people can unconditionally depend on your crate and use it only on the targets where it is needed. However it disables the entire crate, including all global attributes, which means normally a crate that has#![no_std]wouldn't depend on std, but if you use#![cfg]to disable that crate, suddenly it does depend on std! The only workaround is to not use#![cfg]and instead manually disable each item in thelib.rs, except for specific attributes like#![no_std].For example:
Observe as libstd is passed to the linker despite both crates using
#![no_std].