@@ -34,6 +34,7 @@ use std::ffi::CString;
34
34
use std:: fmt;
35
35
use std:: slice;
36
36
use std:: str;
37
+ use std:: env;
37
38
38
39
use html:: render:: derive_id;
39
40
use html:: toc:: TocBuilder ;
@@ -439,6 +440,18 @@ pub fn find_testable_code(doc: &str, tests: &mut ::test::Collector) {
439
440
}
440
441
}
441
442
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
+
442
455
#[ derive( Eq , PartialEq , Clone , Debug ) ]
443
456
struct LangString {
444
457
should_panic : bool ,
@@ -465,6 +478,7 @@ impl LangString {
465
478
let mut seen_rust_tags = false ;
466
479
let mut seen_other_tags = false ;
467
480
let mut data = LangString :: all_false ( ) ;
481
+ let allow_compile_fail = get_unstable_features_setting ( ) ;
468
482
469
483
let tokens = string. split ( |c : char |
470
484
!( c == '_' || c == '-' || c. is_alphanumeric ( ) )
@@ -473,13 +487,20 @@ impl LangString {
473
487
for token in tokens {
474
488
match token {
475
489
"" => { } ,
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
+ } ,
477
495
"no_run" => { data. no_run = true ; seen_rust_tags = true ; } ,
478
496
"ignore" => { data. ignore = true ; seen_rust_tags = true ; } ,
479
497
"rust" => { data. rust = true ; seen_rust_tags = true ; } ,
480
498
"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
+ } ,
483
504
_ => { seen_other_tags = true }
484
505
}
485
506
}
0 commit comments