@@ -38,9 +38,6 @@ use crate::passes::span_of_attrs;
38
38
crate struct TestOptions {
39
39
/// Whether to disable the default `extern crate my_crate;` when creating doctests.
40
40
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 ,
44
41
/// Additional crate-level attributes to add to doctests.
45
42
crate attrs : Vec < String > ,
46
43
}
@@ -65,14 +62,16 @@ crate fn run(options: Options) -> Result<(), ErrorReported> {
65
62
}
66
63
} ) ;
67
64
65
+ debug ! ( ?lint_opts) ;
66
+
68
67
let crate_types =
69
68
if options. proc_macro_crate { vec ! [ CrateType :: ProcMacro ] } else { vec ! [ CrateType :: Rlib ] } ;
70
69
71
70
let sessopts = config:: Options {
72
71
maybe_sysroot : options. maybe_sysroot . clone ( ) ,
73
72
search_paths : options. libs . clone ( ) ,
74
73
crate_types,
75
- lint_opts : if !options . display_doctest_warnings { lint_opts } else { vec ! [ ] } ,
74
+ lint_opts,
76
75
lint_cap : Some ( options. lint_cap . unwrap_or ( lint:: Forbid ) ) ,
77
76
cg : options. codegen_options . clone ( ) ,
78
77
externs : options. externs . clone ( ) ,
@@ -106,7 +105,6 @@ crate fn run(options: Options) -> Result<(), ErrorReported> {
106
105
} ;
107
106
108
107
let test_args = options. test_args . clone ( ) ;
109
- let display_doctest_warnings = options. display_doctest_warnings ;
110
108
let nocapture = options. nocapture ;
111
109
let externs = options. externs . clone ( ) ;
112
110
let json_unused_externs = options. json_unused_externs ;
@@ -118,8 +116,7 @@ crate fn run(options: Options) -> Result<(), ErrorReported> {
118
116
let collector = global_ctxt. enter ( |tcx| {
119
117
let crate_attrs = tcx. hir ( ) . attrs ( CRATE_HIR_ID ) ;
120
118
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) ;
123
120
let enable_per_target_ignores = options. enable_per_target_ignores ;
124
121
let mut collector = Collector :: new (
125
122
tcx. crate_name ( LOCAL_CRATE ) ,
@@ -165,7 +162,7 @@ crate fn run(options: Options) -> Result<(), ErrorReported> {
165
162
Err ( ErrorReported ) => return Err ( ErrorReported ) ,
166
163
} ;
167
164
168
- run_tests ( test_args, nocapture, display_doctest_warnings , tests) ;
165
+ run_tests ( test_args, nocapture, tests) ;
169
166
170
167
// Collect and warn about unused externs, but only if we've gotten
171
168
// reports for each doctest
@@ -208,29 +205,19 @@ crate fn run(options: Options) -> Result<(), ErrorReported> {
208
205
Ok ( ( ) )
209
206
}
210
207
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 > ) {
217
209
test_args. insert ( 0 , "rustdoctest" . to_string ( ) ) ;
218
210
if nocapture {
219
211
test_args. push ( "--nocapture" . to_string ( ) ) ;
220
212
}
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 ) ;
226
214
}
227
215
228
216
// Look for `#![doc(test(no_crate_inject))]`, used by crates in the std facade.
229
217
fn scrape_test_config ( attrs : & [ ast:: Attribute ] ) -> TestOptions {
230
218
use rustc_ast_pretty:: pprust;
231
219
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 ( ) } ;
234
221
235
222
let test_attrs: Vec < _ > = attrs
236
223
. iter ( )
@@ -510,7 +497,7 @@ crate fn make_test(
510
497
let mut prog = String :: new ( ) ;
511
498
let mut supports_color = false ;
512
499
513
- if opts. attrs . is_empty ( ) && !opts . display_doctest_warnings {
500
+ if opts. attrs . is_empty ( ) {
514
501
// If there aren't any attributes supplied by #![doc(test(attr(...)))], then allow some
515
502
// lints that are commonly triggered in doctests. The crate-level test attributes are
516
503
// commonly used to make tests fail in case they trigger warnings, so having this there in
0 commit comments