Skip to content

Commit e91f889

Browse files
committed
Auto merge of #31671 - ranma42:printcfg, r=alexcrichton
Show `cfg` as possible argument to `--print` and make it so that `--print cfg` also outputs the `target_feature`s. Should I also extend `src/test/run-make/print-cfg/Makefile` to check that `target_feature`s are actually printed?
2 parents 809b14a + 4e46eee commit e91f889

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/librustc/session/config.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -887,7 +887,7 @@ pub fn rustc_short_optgroups() -> Vec<RustcOptGroup> {
887887
"[asm|llvm-bc|llvm-ir|obj|link|dep-info]"),
888888
opt::multi_s("", "print", "Comma separated list of compiler information to \
889889
print on stdout",
890-
"[crate-name|file-names|sysroot|target-list]"),
890+
"[crate-name|file-names|sysroot|cfg|target-list]"),
891891
opt::flagmulti_s("g", "", "Equivalent to -C debuginfo=2"),
892892
opt::flagmulti_s("O", "", "Equivalent to -C opt-level=2"),
893893
opt::opt_s("o", "", "Write output to <filename>", "FILENAME"),

src/librustc_driver/lib.rs

+13-2
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ use syntax::errors;
9494
use syntax::errors::emitter::Emitter;
9595
use syntax::diagnostics;
9696
use syntax::parse::token;
97-
use syntax::feature_gate::UnstableFeatures;
97+
use syntax::feature_gate::{GatedCfg, UnstableFeatures};
9898

9999
#[cfg(test)]
100100
pub mod test;
@@ -565,7 +565,18 @@ impl RustcDefaultCalls {
565565
}
566566
}
567567
PrintRequest::Cfg => {
568-
for cfg in config::build_configuration(sess) {
568+
let mut cfg = config::build_configuration(&sess);
569+
target_features::add_configuration(&mut cfg, &sess);
570+
571+
let allow_unstable_cfg = match get_unstable_features_setting() {
572+
UnstableFeatures::Disallow => false,
573+
_ => true,
574+
};
575+
576+
for cfg in cfg {
577+
if !allow_unstable_cfg && GatedCfg::gate(&*cfg).is_some() {
578+
continue;
579+
}
569580
match cfg.node {
570581
ast::MetaItemKind::Word(ref word) => println!("{}", word),
571582
ast::MetaItemKind::NameValue(ref name, ref value) => {

0 commit comments

Comments
 (0)