@@ -62,22 +62,29 @@ fn default_configuration(sess: session, argv0: ~str, input: input) ->
62
62
mk ( ~"build_input", source_name ( input) ) ] ;
63
63
}
64
64
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
+
65
73
fn build_configuration ( sess : session , argv0 : ~str , input : input ) ->
66
74
ast:: crate_cfg {
67
75
// Combine the configuration requested by the session (command line) with
68
76
// some default and generated configuration items
69
77
let default_cfg = default_configuration ( sess, argv0, input) ;
70
78
let user_cfg = sess. opts . cfg ;
71
79
// 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) ;
81
88
}
82
89
83
90
// Convert strings provided as --cfg [cfgspec] into a crate_cfg
0 commit comments