-
Notifications
You must be signed in to change notification settings - Fork 13.4k
RFC3239: Implement cfg(target)
- Part 2
#96913
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,17 @@ | ||
// check-fail | ||
|
||
#![feature(cfg_target_compact)] | ||
|
||
#[cfg(target(o::o))] | ||
//~^ ERROR `cfg` predicate key must be an identifier | ||
fn one() {} | ||
|
||
#[cfg(target(os = 8))] | ||
//~^ ERROR literal in `cfg` predicate value must be a string | ||
fn two() {} | ||
|
||
#[cfg(target(os = "linux", pointer(width = "64")))] | ||
//~^ ERROR invalid predicate `target_pointer` | ||
fn three() {} | ||
|
||
fn main() {} |
This file contains hidden or 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,22 @@ | ||
error: `cfg` predicate key must be an identifier | ||
--> $DIR/cfg-target-compact-errors.rs:5:14 | ||
| | ||
LL | #[cfg(target(o::o))] | ||
| ^^^^ | ||
|
||
error[E0565]: literal in `cfg` predicate value must be a string | ||
--> $DIR/cfg-target-compact-errors.rs:9:19 | ||
| | ||
LL | #[cfg(target(os = 8))] | ||
| ^ | ||
|
||
error[E0537]: invalid predicate `target_pointer` | ||
--> $DIR/cfg-target-compact-errors.rs:13:28 | ||
| | ||
LL | #[cfg(target(os = "linux", pointer(width = "64")))] | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
Some errors have detailed explanations: E0537, E0565. | ||
For more information about an error, try `rustc --explain E0537`. |
This file contains hidden or 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 @@ | ||
// run-pass | ||
#![feature(cfg_target_compact)] | ||
|
||
#[cfg(target(os = "linux", pointer_width = "64"))] | ||
pub fn main() { | ||
} | ||
|
||
#[cfg(not(target(os = "linux", pointer_width = "64")))] | ||
pub fn main() { | ||
} |
This file contains hidden or 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,15 @@ | ||
// This test check that we correctly emit an warning for compact cfg | ||
// | ||
// check-pass | ||
// compile-flags:--check-cfg=names() -Z unstable-options | ||
|
||
#![feature(cfg_target_compact)] | ||
|
||
#[cfg(target(os = "linux", arch = "arm"))] | ||
pub fn expected() {} | ||
|
||
#[cfg(target(os = "linux", architecture = "arm"))] | ||
//~^ WARNING unexpected `cfg` condition name | ||
pub fn unexpected() {} | ||
|
||
fn main() {} |
This file contains hidden or 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 @@ | ||
warning: unexpected `cfg` condition name | ||
--> $DIR/compact-names.rs:11:28 | ||
| | ||
LL | #[cfg(target(os = "linux", architecture = "arm"))] | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: `#[warn(unexpected_cfgs)]` on by default | ||
|
||
warning: 1 warning emitted | ||
|
This file contains hidden or 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,15 @@ | ||
// This test check that we correctly emit an warning for compact cfg | ||
// | ||
// check-pass | ||
// compile-flags:--check-cfg=values() -Z unstable-options | ||
|
||
#![feature(cfg_target_compact)] | ||
|
||
#[cfg(target(os = "linux", arch = "arm"))] | ||
pub fn expected() {} | ||
|
||
#[cfg(target(os = "linux", arch = "X"))] | ||
//~^ WARNING unexpected `cfg` condition value | ||
pub fn unexpected() {} | ||
|
||
fn main() {} |
This file contains hidden or 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 @@ | ||
warning: unexpected `cfg` condition value | ||
--> $DIR/compact-values.rs:11:28 | ||
| | ||
LL | #[cfg(target(os = "linux", arch = "X"))] | ||
| ^^^^^^^^^^ | ||
| | ||
= note: `#[warn(unexpected_cfgs)]` on by default | ||
= note: expected values for `target_arch` are: aarch64, arm, avr, bpf, hexagon, m68k, mips, mips64, msp430, nvptx64, powerpc, powerpc64, riscv32, riscv64, s390x, sparc, sparc64, wasm32, wasm64, x86, x86_64 | ||
|
||
warning: 1 warning emitted | ||
|
13 changes: 13 additions & 0 deletions
13
src/test/ui/feature-gates/feature-gate-cfg-target-compact.rs
This file contains hidden or 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,13 @@ | ||
#[cfg(target(os = "x"))] //~ ERROR compact `cfg(target(..))` is experimental | ||
struct Foo(u64, u64); | ||
|
||
#[cfg_attr(target(os = "x"), x)] //~ ERROR compact `cfg(target(..))` is experimental | ||
struct Bar(u64, u64); | ||
|
||
#[cfg(not(any(all(target(os = "x")))))] //~ ERROR compact `cfg(target(..))` is experimental | ||
fn foo() {} | ||
|
||
fn main() { | ||
cfg!(target(os = "x")); | ||
//~^ ERROR compact `cfg(target(..))` is experimental and subject to change | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.