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,
348348 }
349349}
350350
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+
351365impl < ' a > CompilerCalls < ' a > for RustcDefaultCalls {
352366 fn early_callback ( & mut self ,
353367 matches : & getopts:: Matches ,
354- _sopts : & config:: Options ,
368+ sopts : & config:: Options ,
355369 descriptions : & diagnostics:: registry:: Registry ,
356370 output : ErrorOutputType )
357371 -> Compilation {
@@ -360,6 +374,7 @@ impl<'a> CompilerCalls<'a> for RustcDefaultCalls {
360374 return Compilation :: Stop ;
361375 }
362376
377+ check_cfg ( sopts, output) ;
363378 Compilation :: Continue
364379 }
365380
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