@@ -316,11 +316,10 @@ pub fn cfg_matches(diagnostic: &SpanHandler, cfgs: &[P<MetaItem>], cfg: &ast::Me
316
316
mis. iter ( ) . all ( |mi| cfg_matches ( diagnostic, cfgs, & * * mi) ) ,
317
317
ast:: MetaList ( ref pred, ref mis) if pred. get ( ) == "not" => {
318
318
if mis. len ( ) != 1 {
319
- diagnostic. span_warn ( cfg. span , "the use of multiple cfgs in the same `not` \
320
- statement is deprecated. Change `not(a, b)` to \
321
- `not(all(a, b))`.") ;
319
+ diagnostic. span_err ( cfg. span , "expected 1 cfg-pattern" ) ;
320
+ return false ;
322
321
}
323
- !mis . iter ( ) . all ( |mi| cfg_matches ( diagnostic, cfgs, & * * mi ) )
322
+ !cfg_matches ( diagnostic, cfgs, & * mis [ 0 ] )
324
323
}
325
324
ast:: MetaList ( ref pred, _) => {
326
325
diagnostic. span_err ( cfg. span , format ! ( "invalid predicate `{}`" , pred) . as_slice ( ) ) ;
@@ -330,56 +329,6 @@ pub fn cfg_matches(diagnostic: &SpanHandler, cfgs: &[P<MetaItem>], cfg: &ast::Me
330
329
}
331
330
}
332
331
333
- /// Tests if any `cfg(...)` meta items in `metas` match `cfg`. e.g.
334
- ///
335
- /// test_cfg(`[foo="a", bar]`, `[cfg(foo), cfg(bar)]`) == true
336
- /// test_cfg(`[foo="a", bar]`, `[cfg(not(bar))]`) == false
337
- /// test_cfg(`[foo="a", bar]`, `[cfg(bar, foo="a")]`) == true
338
- /// test_cfg(`[foo="a", bar]`, `[cfg(bar, foo="b")]`) == false
339
- pub fn test_cfg < ' a , AM : AttrMetaMethods , It : Iterator < & ' a AM > >
340
- ( cfg : & [ P < MetaItem > ] , mut metas : It ) -> bool {
341
- // having no #[cfg(...)] attributes counts as matching.
342
- let mut no_cfgs = true ;
343
-
344
- // this would be much nicer as a chain of iterator adaptors, but
345
- // this doesn't work.
346
- let some_cfg_matches = metas. fold ( false , |matches, mi| {
347
- debug ! ( "testing name: {}" , mi. name( ) ) ;
348
- let this_matches = if mi. check_name ( "cfg" ) { // it is a #[cfg()] attribute
349
- debug ! ( "is cfg" ) ;
350
- no_cfgs = false ;
351
- // only #[cfg(...)] ones are understood.
352
- match mi. meta_item_list ( ) {
353
- Some ( cfg_meta) => {
354
- debug ! ( "is cfg(...)" ) ;
355
- cfg_meta. iter ( ) . all ( |cfg_mi| {
356
- debug ! ( "cfg({}[...])" , cfg_mi. name( ) ) ;
357
- match cfg_mi. node {
358
- ast:: MetaList ( ref s, ref not_cfgs)
359
- if s. equiv ( & ( "not" ) ) => {
360
- debug ! ( "not!" ) ;
361
- // inside #[cfg(not(...))], so these need to all
362
- // not match.
363
- !not_cfgs. iter ( ) . all ( |mi| {
364
- debug ! ( "cfg(not({}[...]))" , mi. name( ) ) ;
365
- contains ( cfg, & * * mi)
366
- } )
367
- }
368
- _ => contains ( cfg, & * * cfg_mi)
369
- }
370
- } )
371
- }
372
- None => false
373
- }
374
- } else {
375
- false
376
- } ;
377
- matches || this_matches
378
- } ) ;
379
- debug ! ( "test_cfg (no_cfgs={}, some_cfg_matches={})" , no_cfgs, some_cfg_matches) ;
380
- no_cfgs || some_cfg_matches
381
- }
382
-
383
332
/// Represents the #[deprecated="foo"] and friends attributes.
384
333
#[ deriving( Encodable , Decodable , Clone , Show ) ]
385
334
pub struct Stability {
0 commit comments