Skip to content

Commit cd54134

Browse files
author
Elliott Slaughter
committed
---
yaml --- r: 28132 b: refs/heads/try c: 0031617 h: refs/heads/master v: v3
1 parent ce8750a commit cd54134

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: cd6f24f9d14ac90d167386a56e7a6ac1f0318195
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: cd6f24f9d14ac90d167386a56e7a6ac1f0318195
5-
refs/heads/try: adf9fa229fbf9da048c766ec966d6d7c0babb5c9
5+
refs/heads/try: 0031617f30f159df2cef301c9d574cd219e16b16
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: d0c6ce338884ee21843f4b40bf6bf18d222ce5df

branches/try/src/rustc/driver/driver.rs

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,22 +62,29 @@ fn default_configuration(sess: session, argv0: ~str, input: input) ->
6262
mk(~"build_input", source_name(input))];
6363
}
6464

65+
fn append_configuration(cfg: ast::crate_cfg, name: ~str) -> ast::crate_cfg {
66+
if attr::contains_name(cfg, name) {
67+
return cfg;
68+
} else {
69+
return vec::append_one(cfg, attr::mk_word_item(name));
70+
}
71+
}
72+
6573
fn build_configuration(sess: session, argv0: ~str, input: input) ->
6674
ast::crate_cfg {
6775
// Combine the configuration requested by the session (command line) with
6876
// some default and generated configuration items
6977
let default_cfg = default_configuration(sess, argv0, input);
7078
let user_cfg = sess.opts.cfg;
7179
// If the user wants a test runner, then add the test cfg
72-
let gen_cfg =
73-
{
74-
if sess.opts.test && !attr::contains_name(user_cfg, ~"test") {
75-
~[attr::mk_word_item(~"test")]
76-
} else {
77-
~[attr::mk_word_item(~"notest")]
78-
}
79-
};
80-
return vec::append(vec::append(user_cfg, gen_cfg), default_cfg);
80+
let user_cfg = append_configuration(
81+
user_cfg,
82+
if sess.opts.test { ~"test" } else { ~"notest" });
83+
// If the user requested GC, then add the GC cfg
84+
let user_cfg = append_configuration(
85+
user_cfg,
86+
if sess.opts.gc { ~"gc" } else { ~"nogc" });
87+
return vec::append(user_cfg, default_cfg);
8188
}
8289

8390
// Convert strings provided as --cfg [cfgspec] into a crate_cfg

0 commit comments

Comments
 (0)