@@ -34,6 +34,7 @@ use std::ffi::CString;
3434use std:: fmt;
3535use std:: slice;
3636use std:: str;
37+ use std:: env;
3738
3839use html:: render:: derive_id;
3940use html:: toc:: TocBuilder ;
@@ -439,6 +440,18 @@ pub fn find_testable_code(doc: &str, tests: &mut ::test::Collector) {
439440 }
440441}
441442
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+
442455#[ derive( Eq , PartialEq , Clone , Debug ) ]
443456struct LangString {
444457 should_panic : bool ,
@@ -465,6 +478,7 @@ impl LangString {
465478 let mut seen_rust_tags = false ;
466479 let mut seen_other_tags = false ;
467480 let mut data = LangString :: all_false ( ) ;
481+ let allow_compile_fail = get_unstable_features_setting ( ) ;
468482
469483 let tokens = string. split ( |c : char |
470484 !( c == '_' || c == '-' || c. is_alphanumeric ( ) )
@@ -473,13 +487,20 @@ impl LangString {
473487 for token in tokens {
474488 match token {
475489 "" => { } ,
476- "should_panic" => { data. should_panic = true ; seen_rust_tags = true ; } ,
490+ "should_panic" => {
491+ data. should_panic = true ;
492+ seen_rust_tags = true ;
493+ data. no_run = true ;
494+ } ,
477495 "no_run" => { data. no_run = true ; seen_rust_tags = true ; } ,
478496 "ignore" => { data. ignore = true ; seen_rust_tags = true ; } ,
479497 "rust" => { data. rust = true ; seen_rust_tags = true ; } ,
480498 "test_harness" => { data. test_harness = true ; seen_rust_tags = true ; } ,
481- "compile_fail" => { data. compile_fail = true ; seen_rust_tags = true ;
482- data. no_run = true ; } ,
499+ "compile_fail" if allow_compile_fail => {
500+ data. compile_fail = true ;
501+ seen_rust_tags = true ;
502+ data. no_run = true ;
503+ } ,
483504 _ => { seen_other_tags = true }
484505 }
485506 }
0 commit comments