File tree 4 files changed +65
-14
lines changed
4 files changed +65
-14
lines changed Original file line number Diff line number Diff line change @@ -208,18 +208,19 @@ actual:\n\
208
208
testfile : & Path , src : ~str ) -> ProcRes {
209
209
compose_and_run_compiler (
210
210
config, props, testfile,
211
- make_typecheck_args ( config, testfile) ,
211
+ make_typecheck_args ( config, props , testfile) ,
212
212
Some ( src) )
213
213
}
214
214
215
- fn make_typecheck_args ( config : config , testfile : & Path ) -> ProcArgs {
215
+ fn make_typecheck_args ( config : config , props : TestProps , testfile : & Path ) -> ProcArgs {
216
216
let prog = config. rustc_path ;
217
217
let mut args = ~[ ~"-",
218
218
~" --no-trans", ~"--lib",
219
219
~"-L ", config. build_base . to_str ( ) ,
220
220
~"-L ",
221
221
aux_output_dir_name ( config, testfile) . to_str ( ) ] ;
222
222
args += split_maybe_args ( config. rustcflags ) ;
223
+ args += split_maybe_args ( props. compile_flags ) ;
223
224
return ProcArgs { prog : prog. to_str ( ) , args : args} ;
224
225
}
225
226
}
Original file line number Diff line number Diff line change @@ -185,18 +185,19 @@ pub fn metas_in_cfg(cfg: ast::crate_cfg,
185
185
// Pull the inner meta_items from the #[cfg(meta_item, ...)] attributes,
186
186
// so we can match against them. This is the list of configurations for
187
187
// which the item is valid
188
- let cfg_metas =
189
- vec:: concat (
190
- vec:: filter_map ( cfg_metas, |i| attr:: get_meta_item_list ( i) ) ) ;
191
-
192
- let has_cfg_metas = vec:: len ( cfg_metas) > 0 u;
193
- if !has_cfg_metas { return true ; }
194
-
195
- for cfg_metas. each |cfg_mi| {
196
- if attr:: contains ( cfg, * cfg_mi) { return true ; }
197
- }
198
-
199
- return false ;
188
+ let cfg_metas = vec:: filter_map ( cfg_metas, |i| attr:: get_meta_item_list ( i) ) ;
189
+
190
+ if cfg_metas. all ( |c| c. is_empty ( ) ) { return true ; }
191
+
192
+ cfg_metas. any ( |cfg_meta| {
193
+ cfg_meta. all ( |cfg_mi| {
194
+ match cfg_mi. node {
195
+ ast:: meta_list( s, ref it) if * s == ~"not"
196
+ => it. all ( |mi| !attr:: contains ( cfg, * mi) ) ,
197
+ _ => attr:: contains ( cfg, * cfg_mi)
198
+ }
199
+ } )
200
+ } )
200
201
}
201
202
202
203
Original file line number Diff line number Diff line change
1
+ // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2
+ // file at the top-level directory of this distribution and at
3
+ // http://rust-lang.org/COPYRIGHT.
4
+ //
5
+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6
+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7
+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8
+ // option. This file may not be copied, modified, or distributed
9
+ // except according to those terms.
10
+
11
+ // compile-flags: --cfg foo
12
+
13
+ #[ cfg( foo, bar) ] // foo AND bar
14
+ fn foo ( ) { }
15
+
16
+ fn main ( ) {
17
+ foo ( ) ; //~ ERROR unresolved name: `foo`.
18
+ }
Original file line number Diff line number Diff line change
1
+ // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2
+ // file at the top-level directory of this distribution and at
3
+ // http://rust-lang.org/COPYRIGHT.
4
+ //
5
+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6
+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7
+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8
+ // option. This file may not be copied, modified, or distributed
9
+ // except according to those terms.
10
+
11
+ // xfail-fast
12
+ // compile-flags: --cfg fooA --cfg fooB
13
+
14
+ // fooA AND !bar
15
+ #[ cfg( fooA, not( bar) ) ]
16
+ fn foo1 ( ) -> int { 1 }
17
+
18
+ // !fooA AND !bar
19
+ #[ cfg( not( fooA, bar) ) ]
20
+ fn foo2 ( ) -> int { 2 }
21
+
22
+ // fooC OR (fooB AND !bar)
23
+ #[ cfg( fooC) ]
24
+ #[ cfg( fooB, not( bar) ) ]
25
+ fn foo2 ( ) -> int { 3 }
26
+
27
+
28
+ fn main ( ) {
29
+ fail_unless ! ( 1 == foo1( ) ) ;
30
+ fail_unless ! ( 3 == foo2( ) ) ;
31
+ }
You can’t perform that action at this time.
0 commit comments