27
27
#![ allow( non_camel_case_types) ]
28
28
29
29
use libc;
30
+ use rustc:: session:: config:: get_unstable_features_setting;
30
31
use std:: ascii:: AsciiExt ;
31
32
use std:: cell:: RefCell ;
32
33
use std:: default:: Default ;
33
34
use std:: ffi:: CString ;
34
35
use std:: fmt;
35
36
use std:: slice;
36
37
use std:: str;
37
- use std :: env ;
38
+ use syntax :: feature_gate :: UnstableFeatures ;
38
39
39
40
use html:: render:: derive_id;
40
41
use html:: toc:: TocBuilder ;
@@ -440,18 +441,6 @@ pub fn find_testable_code(doc: &str, tests: &mut ::test::Collector) {
440
441
}
441
442
}
442
443
443
- fn get_unstable_features_setting ( ) -> bool {
444
- // Check if we can activate compile_fail option or not.
445
- //
446
- // It is done to ensure that it won't be used out-of-tree
447
- // because it's not ready yet for production.
448
- match ( option_env ! ( "CFG_BOOTSTRAP_KEY" ) ,
449
- env:: var ( "RUSTC_BOOTSTRAP_KEY" ) . ok ( ) ) {
450
- ( Some ( ref cfg) , Some ( ref r_key) ) => cfg == r_key,
451
- _ => false ,
452
- }
453
- }
454
-
455
444
#[ derive( Eq , PartialEq , Clone , Debug ) ]
456
445
struct LangString {
457
446
should_panic : bool ,
@@ -478,7 +467,10 @@ impl LangString {
478
467
let mut seen_rust_tags = false ;
479
468
let mut seen_other_tags = false ;
480
469
let mut data = LangString :: all_false ( ) ;
481
- let allow_compile_fail = get_unstable_features_setting ( ) ;
470
+ let allow_compile_fail = match get_unstable_features_setting ( ) {
471
+ UnstableFeatures :: Allow | UnstableFeatures :: Cheat => true ,
472
+ _ => false ,
473
+ } ;
482
474
483
475
let tokens = string. split ( |c : char |
484
476
!( c == '_' || c == '-' || c. is_alphanumeric ( ) )
@@ -487,11 +479,7 @@ impl LangString {
487
479
for token in tokens {
488
480
match token {
489
481
"" => { } ,
490
- "should_panic" => {
491
- data. should_panic = true ;
492
- seen_rust_tags = true ;
493
- data. no_run = true ;
494
- } ,
482
+ "should_panic" => { data. should_panic = true ; seen_rust_tags = true ; } ,
495
483
"no_run" => { data. no_run = true ; seen_rust_tags = true ; } ,
496
484
"ignore" => { data. ignore = true ; seen_rust_tags = true ; } ,
497
485
"rust" => { data. rust = true ; seen_rust_tags = true ; } ,
@@ -600,10 +588,10 @@ mod tests {
600
588
t ( "rust" , false , false , false , true , false , false ) ;
601
589
t ( "sh" , false , false , false , false , false , false ) ;
602
590
t ( "ignore" , false , false , true , true , false , false ) ;
603
- t ( "should_panic" , true , true , false , true , false , false ) ;
591
+ t ( "should_panic" , true , false , false , true , false , false ) ;
604
592
t ( "no_run" , false , true , false , true , false , false ) ;
605
593
t ( "test_harness" , false , false , false , true , true , false ) ;
606
- t ( "compile_fail" , false , false , false , true , false , true ) ;
594
+ t ( "compile_fail" , false , true , false , true , false , true ) ;
607
595
t ( "{.no_run .example}" , false , true , false , true , false , false ) ;
608
596
t ( "{.sh .should_panic}" , true , false , false , true , false , false ) ;
609
597
t ( "{.example .rust}" , false , false , false , true , false , false ) ;
0 commit comments