File tree Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -348,10 +348,24 @@ fn handle_explain(code: &str,
348
348
}
349
349
}
350
350
351
+ fn check_cfg ( sopts : & config:: Options ,
352
+ output : ErrorOutputType ) {
353
+ fn is_meta_list ( item : & ast:: MetaItem ) -> bool {
354
+ match item. node {
355
+ ast:: MetaItem_ :: MetaList ( ..) => true ,
356
+ _ => false ,
357
+ }
358
+ }
359
+
360
+ if sopts. cfg . iter ( ) . any ( |item| is_meta_list ( & * item) ) {
361
+ early_error ( output, "predicates are not allowed in --cfg" ) ;
362
+ }
363
+ }
364
+
351
365
impl < ' a > CompilerCalls < ' a > for RustcDefaultCalls {
352
366
fn early_callback ( & mut self ,
353
367
matches : & getopts:: Matches ,
354
- _sopts : & config:: Options ,
368
+ sopts : & config:: Options ,
355
369
descriptions : & diagnostics:: registry:: Registry ,
356
370
output : ErrorOutputType )
357
371
-> Compilation {
@@ -360,6 +374,7 @@ impl<'a> CompilerCalls<'a> for RustcDefaultCalls {
360
374
return Compilation :: Stop ;
361
375
}
362
376
377
+ check_cfg ( sopts, output) ;
363
378
Compilation :: Continue
364
379
}
365
380
Original file line number Diff line number Diff line change
1
+ // Copyright 2015 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(bar)
12
+ // error-pattern: predicates are not allowed in --cfg
13
+ fn main ( ) { }
You can’t perform that action at this time.
0 commit comments