-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #110141 - petrochenkov:cratecfg2, r=WaffleLapkin
expand: Change how `#![cfg(FALSE)]` behaves on crate root Previously it removed all other attributes from the crate root. Now it removes only attributes below itself (during both regular expansion and pre-configuration). So it becomes possible to configure some global crate properties even for fully unconfigured crates. Fixes #104633 Part of #110082
- Loading branch information
Showing
10 changed files
with
63 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
// It is unclear whether a fully unconfigured crate should link to standard library, | ||
// or what its `no_std`/`no_core`/`compiler_builtins` status, more precisely. | ||
// Currently the usual standard library prelude is added to such crates, | ||
// and therefore they link to libstd. | ||
// `#![no_std]` on a fully unconfigured crate is respected if it's placed before `cfg(FALSE)`. | ||
// This crate has no such attribute, therefore this crate does link to libstd. | ||
|
||
#![cfg(FALSE)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// `#![no_std]` on a fully unconfigured crate is respected if it's placed before `cfg(FALSE)`. | ||
// Therefore this crate does link to libstd. | ||
|
||
#![cfg(FALSE)] | ||
#![no_std] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// `#![no_std]` on a fully unconfigured crate is respected if it's placed before `cfg(FALSE)`. | ||
// Therefore this crate doesn't link to libstd. | ||
|
||
// no-prefer-dynamic | ||
|
||
#![no_std] | ||
#![crate_type = "lib"] | ||
#![cfg(FALSE)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// No error, panic handler is supplied by libstd linked though the empty library. | ||
|
||
// check-pass | ||
// aux-build: cfg_false_lib_no_std_after.rs | ||
|
||
#![no_std] | ||
|
||
extern crate cfg_false_lib_no_std_after as _; | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Error, the linked empty library is `no_std` and doesn't provide a panic handler. | ||
|
||
// dont-check-compiler-stderr | ||
// error-pattern: `#[panic_handler]` function required, but not found | ||
// aux-build: cfg_false_lib_no_std_before.rs | ||
|
||
#![no_std] | ||
|
||
extern crate cfg_false_lib_no_std_before as _; | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters