@@ -163,7 +163,7 @@ pub(crate) fn run(dcx: DiagCtxtHandle<'_>, options: RustdocOptions) -> Result<()
163
163
let args_path = temp_dir. path ( ) . join ( "rustdoc-cfgs" ) ;
164
164
crate :: wrap_return ( dcx, generate_args_file ( & args_path, & options) ) ?;
165
165
166
- let CreateRunnableDoctests {
166
+ let CreateRunnableDocTests {
167
167
standalone_tests,
168
168
mergeable_tests,
169
169
rustdoc_options,
@@ -179,7 +179,7 @@ pub(crate) fn run(dcx: DiagCtxtHandle<'_>, options: RustdocOptions) -> Result<()
179
179
let opts = scrape_test_config ( crate_name, crate_attrs, args_path) ;
180
180
let enable_per_target_ignores = options. enable_per_target_ignores ;
181
181
182
- let mut collector = CreateRunnableDoctests :: new ( options, opts) ;
182
+ let mut collector = CreateRunnableDocTests :: new ( options, opts) ;
183
183
let hir_collector = HirCollector :: new (
184
184
& compiler. sess ,
185
185
tcx. hir ( ) ,
@@ -250,7 +250,7 @@ pub(crate) fn run_tests(
250
250
rustdoc_options : & Arc < RustdocOptions > ,
251
251
unused_extern_reports : & Arc < Mutex < Vec < UnusedExterns > > > ,
252
252
mut standalone_tests : Vec < test:: TestDescAndFn > ,
253
- mergeable_tests : FxHashMap < Edition , Vec < ( DocTestBuilder , ScrapedDoctest ) > > ,
253
+ mergeable_tests : FxHashMap < Edition , Vec < ( DocTestBuilder , ScrapedDocTest ) > > ,
254
254
) {
255
255
let mut test_args = Vec :: with_capacity ( rustdoc_options. test_args . len ( ) + 1 ) ;
256
256
test_args. insert ( 0 , "rustdoctest" . to_string ( ) ) ;
@@ -432,8 +432,13 @@ fn wrapped_rustc_command(rustc_wrappers: &[PathBuf], rustc_binary: &Path) -> Com
432
432
command
433
433
}
434
434
435
- /// This struct contains information needed for running a doctest.
436
- struct RunnableDoctest {
435
+ /// Information needed for running a bundle of doctests.
436
+ ///
437
+ /// This data structure contains the "full" test code, including the wrappers
438
+ /// (if multiple doctests are merged), `main` function,
439
+ /// and everything needed to calculate the compiler's command-line arguments.
440
+ /// The `# ` prefix on boring lines has also been stripped.
441
+ struct RunnableDocTest {
437
442
full_test_code : String ,
438
443
full_test_line_offset : usize ,
439
444
test_opts : IndividualTestOptions ,
@@ -444,14 +449,14 @@ struct RunnableDoctest {
444
449
no_run : bool ,
445
450
}
446
451
447
- impl RunnableDoctest {
452
+ impl RunnableDocTest {
448
453
fn path_for_merged_doctest ( & self ) -> PathBuf {
449
454
self . test_opts . outdir . path ( ) . join ( & format ! ( "doctest_{}.rs" , self . edition) )
450
455
}
451
456
}
452
457
453
458
fn run_test (
454
- doctest : RunnableDoctest ,
459
+ doctest : RunnableDocTest ,
455
460
rustdoc_options : & RustdocOptions ,
456
461
supports_color : bool ,
457
462
is_multiple_tests : bool ,
@@ -700,15 +705,15 @@ impl IndividualTestOptions {
700
705
}
701
706
702
707
/// A doctest scraped from the code, ready to be turned into a runnable test.
703
- pub ( crate ) struct ScrapedDoctest {
708
+ pub ( crate ) struct ScrapedDocTest {
704
709
filename : FileName ,
705
710
line : usize ,
706
711
langstr : LangString ,
707
712
text : String ,
708
713
name : String ,
709
714
}
710
715
711
- impl ScrapedDoctest {
716
+ impl ScrapedDocTest {
712
717
fn new (
713
718
filename : FileName ,
714
719
line : usize ,
@@ -748,14 +753,14 @@ impl ScrapedDoctest {
748
753
}
749
754
}
750
755
751
- pub ( crate ) trait DoctestVisitor {
756
+ pub ( crate ) trait DocTestVisitor {
752
757
fn visit_test ( & mut self , test : String , config : LangString , rel_line : MdRelLine ) ;
753
758
fn visit_header ( & mut self , _name : & str , _level : u32 ) { }
754
759
}
755
760
756
- struct CreateRunnableDoctests {
761
+ struct CreateRunnableDocTests {
757
762
standalone_tests : Vec < test:: TestDescAndFn > ,
758
- mergeable_tests : FxHashMap < Edition , Vec < ( DocTestBuilder , ScrapedDoctest ) > > ,
763
+ mergeable_tests : FxHashMap < Edition , Vec < ( DocTestBuilder , ScrapedDocTest ) > > ,
759
764
760
765
rustdoc_options : Arc < RustdocOptions > ,
761
766
opts : GlobalTestOptions ,
@@ -765,10 +770,10 @@ struct CreateRunnableDoctests {
765
770
can_merge_doctests : bool ,
766
771
}
767
772
768
- impl CreateRunnableDoctests {
769
- fn new ( rustdoc_options : RustdocOptions , opts : GlobalTestOptions ) -> CreateRunnableDoctests {
773
+ impl CreateRunnableDocTests {
774
+ fn new ( rustdoc_options : RustdocOptions , opts : GlobalTestOptions ) -> CreateRunnableDocTests {
770
775
let can_merge_doctests = rustdoc_options. edition >= Edition :: Edition2024 ;
771
- CreateRunnableDoctests {
776
+ CreateRunnableDocTests {
772
777
standalone_tests : Vec :: new ( ) ,
773
778
mergeable_tests : FxHashMap :: default ( ) ,
774
779
rustdoc_options : Arc :: new ( rustdoc_options) ,
@@ -780,7 +785,7 @@ impl CreateRunnableDoctests {
780
785
}
781
786
}
782
787
783
- fn add_test ( & mut self , scraped_test : ScrapedDoctest ) {
788
+ fn add_test ( & mut self , scraped_test : ScrapedDocTest ) {
784
789
// For example `module/file.rs` would become `module_file_rs`
785
790
let file = scraped_test
786
791
. filename
@@ -829,7 +834,7 @@ impl CreateRunnableDoctests {
829
834
fn generate_test_desc_and_fn (
830
835
& mut self ,
831
836
test : DocTestBuilder ,
832
- scraped_test : ScrapedDoctest ,
837
+ scraped_test : ScrapedDocTest ,
833
838
) -> test:: TestDescAndFn {
834
839
if !scraped_test. langstr . compile_fail {
835
840
self . compiling_test_count . fetch_add ( 1 , Ordering :: SeqCst ) ;
@@ -847,7 +852,7 @@ impl CreateRunnableDoctests {
847
852
848
853
fn generate_test_desc_and_fn (
849
854
test : DocTestBuilder ,
850
- scraped_test : ScrapedDoctest ,
855
+ scraped_test : ScrapedDocTest ,
851
856
opts : GlobalTestOptions ,
852
857
rustdoc_options : Arc < RustdocOptions > ,
853
858
unused_externs : Arc < Mutex < Vec < UnusedExterns > > > ,
@@ -894,7 +899,7 @@ fn doctest_run_fn(
894
899
test_opts : IndividualTestOptions ,
895
900
global_opts : GlobalTestOptions ,
896
901
doctest : DocTestBuilder ,
897
- scraped_test : ScrapedDoctest ,
902
+ scraped_test : ScrapedDocTest ,
898
903
rustdoc_options : Arc < RustdocOptions > ,
899
904
unused_externs : Arc < Mutex < Vec < UnusedExterns > > > ,
900
905
) -> Result < ( ) , String > {
@@ -907,7 +912,7 @@ fn doctest_run_fn(
907
912
& global_opts,
908
913
Some ( & global_opts. crate_name ) ,
909
914
) ;
910
- let runnable_test = RunnableDoctest {
915
+ let runnable_test = RunnableDocTest {
911
916
full_test_code,
912
917
full_test_line_offset,
913
918
test_opts,
@@ -980,7 +985,7 @@ fn doctest_run_fn(
980
985
}
981
986
982
987
#[ cfg( test) ] // used in tests
983
- impl DoctestVisitor for Vec < usize > {
988
+ impl DocTestVisitor for Vec < usize > {
984
989
fn visit_test ( & mut self , _test : String , _config : LangString , rel_line : MdRelLine ) {
985
990
self . push ( 1 + rel_line. offset ( ) ) ;
986
991
}
0 commit comments