Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rustc: Process #[cfg]/#[cfg_attr] on crates
This commit implements processing these two attributes at the crate level as well as at the item level. When #[cfg] is applied at the crate level, then the entire crate will be omitted if the cfg doesn't match. The #[cfg_attr] attribute is processed as usual in that the attribute is included or not depending on whether the cfg matches. This was spurred on by motivations of #18585 where #[cfg_attr] annotations will be applied at the crate-level. cc #18585
- Loading branch information
1 parent
45cbdec
commit 3dbd328
Showing
11 changed files
with
127 additions
and
23 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
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,12 @@ | ||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
#![cfg_attr(foo, experimental)] | ||
#![cfg_attr(not(foo), stable)] |
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,15 @@ | ||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
// compile-flags:--cfg foo | ||
|
||
#![cfg_attr(foo, experimental)] | ||
#![cfg_attr(not(foo), stable)] | ||
|
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,13 @@ | ||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
// error-pattern:main function not found | ||
|
||
#![cfg(bar)] |
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 |
---|---|---|
|
@@ -9,5 +9,5 @@ | |
// except according to those terms. | ||
|
||
pub fn expr_add_3() { | ||
3i + 33i; | ||
3i + 4; | ||
} |
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,16 @@ | ||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
// compile-flags: --cfg bar -D warnings | ||
// ignore-pretty | ||
|
||
#![cfg(bar)] | ||
|
||
fn main() {} |
3dbd328
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r=sfackler
3dbd328
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
saw approval from sfackler
at alexcrichton@3dbd328
3dbd328
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
merging alexcrichton/rust/cfg-attr-crate-level = 3dbd328 into auto
3dbd328
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alexcrichton/rust/cfg-attr-crate-level = 3dbd328 merged ok, testing candidate = ebc625a
3dbd328
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all tests pass:
success: http://buildbot.rust-lang.org/builders/auto-mac-32-opt/builds/2168
success: http://buildbot.rust-lang.org/builders/auto-mac-64-opt/builds/2167
success: http://buildbot.rust-lang.org/builders/auto-mac-64-nopt-c/builds/2160
success: http://buildbot.rust-lang.org/builders/auto-mac-64-nopt-t/builds/2167
success: http://buildbot.rust-lang.org/builders/auto-linux-32-opt/builds/2161
success: http://buildbot.rust-lang.org/builders/auto-linux-32-nopt-c/builds/2160
success: http://buildbot.rust-lang.org/builders/auto-linux-32-nopt-t/builds/2160
success: http://buildbot.rust-lang.org/builders/auto-linux-64-opt/builds/2164
success: http://buildbot.rust-lang.org/builders/auto-linux-64-nopt-c/builds/2157
success: http://buildbot.rust-lang.org/builders/auto-linux-64-nopt-t/builds/2156
success: http://buildbot.rust-lang.org/builders/auto-linux-64-x-android-t/builds/2160
success: http://buildbot.rust-lang.org/builders/auto-win-32-opt/builds/1819
success: http://buildbot.rust-lang.org/builders/auto-win-32-nopt-t/builds/1815
success: http://buildbot.rust-lang.org/builders/auto-win-32-nopt-c/builds/1823
success: http://buildbot.rust-lang.org/builders/auto-win-64-opt/builds/660
success: http://buildbot.rust-lang.org/builders/auto-win-64-nopt-t/builds/652
success: http://buildbot.rust-lang.org/builders/auto-win-64-nopt-c/builds/646
3dbd328
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fast-forwarding master to auto = ebc625a