2727#![ allow( non_camel_case_types) ]
2828
2929use libc;
30+ use rustc:: session:: config:: get_unstable_features_setting;
3031use std:: ascii:: AsciiExt ;
3132use std:: cell:: RefCell ;
3233use std:: default:: Default ;
3334use std:: ffi:: CString ;
3435use std:: fmt;
3536use std:: slice;
3637use std:: str;
37- use std :: env ;
38+ use syntax :: feature_gate :: UnstableFeatures ;
3839
3940use html:: render:: derive_id;
4041use html:: toc:: TocBuilder ;
@@ -440,18 +441,6 @@ pub fn find_testable_code(doc: &str, tests: &mut ::test::Collector) {
440441 }
441442}
442443
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-
455444#[ derive( Eq , PartialEq , Clone , Debug ) ]
456445struct LangString {
457446 should_panic : bool ,
@@ -478,7 +467,10 @@ impl LangString {
478467 let mut seen_rust_tags = false ;
479468 let mut seen_other_tags = false ;
480469 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+ } ;
482474
483475 let tokens = string. split ( |c : char |
484476 !( c == '_' || c == '-' || c. is_alphanumeric ( ) )
@@ -487,11 +479,7 @@ impl LangString {
487479 for token in tokens {
488480 match token {
489481 "" => { } ,
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 ; } ,
495483 "no_run" => { data. no_run = true ; seen_rust_tags = true ; } ,
496484 "ignore" => { data. ignore = true ; seen_rust_tags = true ; } ,
497485 "rust" => { data. rust = true ; seen_rust_tags = true ; } ,
@@ -600,10 +588,10 @@ mod tests {
600588 t ( "rust" , false , false , false , true , false , false ) ;
601589 t ( "sh" , false , false , false , false , false , false ) ;
602590 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 ) ;
604592 t ( "no_run" , false , true , false , true , false , false ) ;
605593 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 ) ;
607595 t ( "{.no_run .example}" , false , true , false , true , false , false ) ;
608596 t ( "{.sh .should_panic}" , true , false , false , true , false , false ) ;
609597 t ( "{.example .rust}" , false , false , false , true , false , false ) ;
0 commit comments