@@ -3,18 +3,12 @@ use std::fs::{create_dir_all, read_to_string, File};
33use std:: io:: prelude:: * ;
44use std:: path:: Path ;
55
6- use tempfile:: tempdir;
7-
86use rustc_span:: edition:: Edition ;
9- use rustc_span:: DUMMY_SP ;
107
11- use crate :: config:: { Options , RenderOptions } ;
12- use crate :: doctest:: { generate_args_file, Collector , GlobalTestOptions } ;
8+ use crate :: config:: RenderOptions ;
139use crate :: html:: escape:: Escape ;
1410use crate :: html:: markdown;
15- use crate :: html:: markdown:: {
16- find_testable_code, ErrorCodes , HeadingOffset , IdMap , Markdown , MarkdownWithToc ,
17- } ;
11+ use crate :: html:: markdown:: { ErrorCodes , HeadingOffset , IdMap , Markdown , MarkdownWithToc } ;
1812
1913/// Separate any lines at the start of the file that begin with `# ` or `%`.
2014fn extract_leading_metadata ( s : & str ) -> ( Vec < & str > , & str ) {
@@ -141,48 +135,3 @@ pub(crate) fn render<P: AsRef<Path>>(
141135 Ok ( _) => Ok ( ( ) ) ,
142136 }
143137}
144-
145- /// Runs any tests/code examples in the markdown file `input`.
146- pub ( crate ) fn test ( options : Options ) -> Result < ( ) , String > {
147- use rustc_session:: config:: Input ;
148- let input_str = match & options. input {
149- Input :: File ( path) => {
150- read_to_string ( & path) . map_err ( |err| format ! ( "{}: {err}" , path. display( ) ) ) ?
151- }
152- Input :: Str { name : _, input } => input. clone ( ) ,
153- } ;
154-
155- let mut opts = GlobalTestOptions :: default ( ) ;
156- opts. no_crate_inject = true ;
157-
158- let temp_dir =
159- tempdir ( ) . map_err ( |error| format ! ( "failed to create temporary directory: {error:?}" ) ) ?;
160- let file_path = temp_dir. path ( ) . join ( "rustdoc-cfgs" ) ;
161- generate_args_file ( & file_path, & options) ?;
162-
163- let mut collector = Collector :: new (
164- options. input . filestem ( ) . to_string ( ) ,
165- options. clone ( ) ,
166- true ,
167- opts,
168- None ,
169- options. input . opt_path ( ) . map ( ToOwned :: to_owned) ,
170- options. enable_per_target_ignores ,
171- file_path,
172- ) ;
173- collector. set_position ( DUMMY_SP ) ;
174- let codes = ErrorCodes :: from ( options. unstable_features . is_nightly_build ( ) ) ;
175-
176- // For markdown files, custom code classes will be disabled until the feature is enabled by default.
177- find_testable_code (
178- & input_str,
179- & mut collector,
180- codes,
181- options. enable_per_target_ignores ,
182- None ,
183- false ,
184- ) ;
185-
186- crate :: doctest:: run_tests ( options. test_args , options. nocapture , collector. tests ) ;
187- Ok ( ( ) )
188- }
0 commit comments