@@ -38,9 +38,6 @@ use crate::passes::span_of_attrs;
3838crate struct TestOptions {
3939 /// Whether to disable the default `extern crate my_crate;` when creating doctests.
4040 crate no_crate_inject : bool ,
41- /// Whether to emit compilation warnings when compiling doctests. Setting this will suppress
42- /// the default `#![allow(unused)]`.
43- crate display_doctest_warnings : bool ,
4441 /// Additional crate-level attributes to add to doctests.
4542 crate attrs : Vec < String > ,
4643}
@@ -65,14 +62,16 @@ crate fn run(options: Options) -> Result<(), ErrorReported> {
6562 }
6663 } ) ;
6764
65+ debug ! ( ?lint_opts) ;
66+
6867 let crate_types =
6968 if options. proc_macro_crate { vec ! [ CrateType :: ProcMacro ] } else { vec ! [ CrateType :: Rlib ] } ;
7069
7170 let sessopts = config:: Options {
7271 maybe_sysroot : options. maybe_sysroot . clone ( ) ,
7372 search_paths : options. libs . clone ( ) ,
7473 crate_types,
75- lint_opts : if !options . display_doctest_warnings { lint_opts } else { vec ! [ ] } ,
74+ lint_opts,
7675 lint_cap : Some ( options. lint_cap . unwrap_or ( lint:: Forbid ) ) ,
7776 cg : options. codegen_options . clone ( ) ,
7877 externs : options. externs . clone ( ) ,
@@ -106,7 +105,6 @@ crate fn run(options: Options) -> Result<(), ErrorReported> {
106105 } ;
107106
108107 let test_args = options. test_args . clone ( ) ;
109- let display_doctest_warnings = options. display_doctest_warnings ;
110108 let nocapture = options. nocapture ;
111109 let externs = options. externs . clone ( ) ;
112110 let json_unused_externs = options. json_unused_externs ;
@@ -118,8 +116,7 @@ crate fn run(options: Options) -> Result<(), ErrorReported> {
118116 let collector = global_ctxt. enter ( |tcx| {
119117 let crate_attrs = tcx. hir ( ) . attrs ( CRATE_HIR_ID ) ;
120118
121- let mut opts = scrape_test_config ( crate_attrs) ;
122- opts. display_doctest_warnings |= options. display_doctest_warnings ;
119+ let opts = scrape_test_config ( crate_attrs) ;
123120 let enable_per_target_ignores = options. enable_per_target_ignores ;
124121 let mut collector = Collector :: new (
125122 tcx. crate_name ( LOCAL_CRATE ) ,
@@ -165,7 +162,7 @@ crate fn run(options: Options) -> Result<(), ErrorReported> {
165162 Err ( ErrorReported ) => return Err ( ErrorReported ) ,
166163 } ;
167164
168- run_tests ( test_args, nocapture, display_doctest_warnings , tests) ;
165+ run_tests ( test_args, nocapture, tests) ;
169166
170167 // Collect and warn about unused externs, but only if we've gotten
171168 // reports for each doctest
@@ -208,29 +205,19 @@ crate fn run(options: Options) -> Result<(), ErrorReported> {
208205 Ok ( ( ) )
209206}
210207
211- crate fn run_tests (
212- mut test_args : Vec < String > ,
213- nocapture : bool ,
214- display_doctest_warnings : bool ,
215- tests : Vec < test:: TestDescAndFn > ,
216- ) {
208+ crate fn run_tests ( mut test_args : Vec < String > , nocapture : bool , tests : Vec < test:: TestDescAndFn > ) {
217209 test_args. insert ( 0 , "rustdoctest" . to_string ( ) ) ;
218210 if nocapture {
219211 test_args. push ( "--nocapture" . to_string ( ) ) ;
220212 }
221- test:: test_main (
222- & test_args,
223- tests,
224- Some ( test:: Options :: new ( ) . display_output ( display_doctest_warnings) ) ,
225- ) ;
213+ test:: test_main ( & test_args, tests, None ) ;
226214}
227215
228216// Look for `#![doc(test(no_crate_inject))]`, used by crates in the std facade.
229217fn scrape_test_config ( attrs : & [ ast:: Attribute ] ) -> TestOptions {
230218 use rustc_ast_pretty:: pprust;
231219
232- let mut opts =
233- TestOptions { no_crate_inject : false , display_doctest_warnings : false , attrs : Vec :: new ( ) } ;
220+ let mut opts = TestOptions { no_crate_inject : false , attrs : Vec :: new ( ) } ;
234221
235222 let test_attrs: Vec < _ > = attrs
236223 . iter ( )
@@ -510,7 +497,7 @@ crate fn make_test(
510497 let mut prog = String :: new ( ) ;
511498 let mut supports_color = false ;
512499
513- if opts. attrs . is_empty ( ) && !opts . display_doctest_warnings {
500+ if opts. attrs . is_empty ( ) {
514501 // If there aren't any attributes supplied by #![doc(test(attr(...)))], then allow some
515502 // lints that are commonly triggered in doctests. The crate-level test attributes are
516503 // commonly used to make tests fail in case they trigger warnings, so having this there in
0 commit comments