@@ -56,16 +56,11 @@ extern crate serialize as rustc_serialize; // used by deriving
56
56
use std:: default:: Default ;
57
57
use std:: env;
58
58
use std:: panic;
59
- use std:: path:: PathBuf ;
60
59
use std:: process;
61
60
use std:: sync:: mpsc:: channel;
62
61
63
- use syntax:: edition:: Edition ;
64
62
use rustc:: session:: { early_warn, early_error} ;
65
- use rustc:: session:: search_paths:: SearchPaths ;
66
- use rustc:: session:: config:: { ErrorOutputType , RustcOptGroup , Externs , CodegenOptions } ;
67
- use rustc_target:: spec:: TargetTriple ;
68
- use rustc:: session:: config:: get_cmd_lint_options;
63
+ use rustc:: session:: config:: { ErrorOutputType , RustcOptGroup } ;
69
64
70
65
#[ macro_use]
71
66
mod externalfiles;
@@ -387,17 +382,23 @@ fn main_args(args: &[String]) -> isize {
387
382
options. codegen_options )
388
383
}
389
384
( false , true ) => return markdown:: render ( & options. input , options. output ,
390
- & matches,
385
+ & options. markdown_css ,
386
+ options. markdown_playground_url
387
+ . or ( options. playground_url ) ,
391
388
& options. external_html ,
392
389
!options. markdown_no_toc , & diag) ,
393
390
( false , false ) => { }
394
391
}
395
392
396
- let res = acquire_input ( options. input . clone ( ) , options. externs . clone ( ) , options. edition ,
397
- options. codegen_options . clone ( ) , matches, options. error_format ,
398
- move |out, matches| {
393
+ //TODO: split render-time options into their own struct so i don't have to clone here
394
+ rust_input ( options. clone ( ) , move |out| {
399
395
let Output { krate, passes, renderinfo } = out;
400
396
info ! ( "going to format" ) ;
397
+ let diag = core:: new_handler ( options. error_format ,
398
+ None ,
399
+ options. debugging_options . treat_err_as_bug ,
400
+ options. debugging_options . ui_testing ) ;
401
+ let html_opts = options. clone ( ) ;
401
402
html:: render:: run ( krate, options. extern_html_root_urls , & options. external_html , options. playground_url ,
402
403
options. output ,
403
404
options. resource_suffix ,
@@ -408,106 +409,48 @@ fn main_args(args: &[String]) -> isize {
408
409
options. themes ,
409
410
options. enable_minification , options. id_map ,
410
411
options. enable_index_page , options. index_page ,
411
- & matches ,
412
+ html_opts ,
412
413
& diag)
413
414
. expect ( "failed to generate documentation" ) ;
414
415
0
415
- } ) ;
416
- res. unwrap_or_else ( |s| {
417
- diag. struct_err ( & format ! ( "input error: {}" , s) ) . emit ( ) ;
418
- 1
419
416
} )
420
417
}
421
418
422
- /// Looks inside the command line arguments to extract the relevant input format
423
- /// and files and then generates the necessary rustdoc output for formatting.
424
- fn acquire_input < R , F > ( input : PathBuf ,
425
- externs : Externs ,
426
- edition : Edition ,
427
- cg : CodegenOptions ,
428
- matches : getopts:: Matches ,
429
- error_format : ErrorOutputType ,
430
- f : F )
431
- -> Result < R , String >
432
- where R : ' static + Send , F : ' static + Send + FnOnce ( Output , & getopts:: Matches ) -> R {
433
- match matches. opt_str ( "r" ) . as_ref ( ) . map ( |s| & * * s) {
434
- Some ( "rust" ) => Ok ( rust_input ( input, externs, edition, cg, matches, error_format, f) ) ,
435
- Some ( s) => Err ( format ! ( "unknown input format: {}" , s) ) ,
436
- None => Ok ( rust_input ( input, externs, edition, cg, matches, error_format, f) )
437
- }
438
- }
439
-
440
419
/// Interprets the input file as a rust source file, passing it through the
441
420
/// compiler all the way through the analysis passes. The rustdoc output is then
442
421
/// generated from the cleaned AST of the crate.
443
422
///
444
423
/// This form of input will run all of the plug/cleaning passes
445
- fn rust_input < R , F > ( cratefile : PathBuf ,
446
- externs : Externs ,
447
- edition : Edition ,
448
- cg : CodegenOptions ,
449
- matches : getopts:: Matches ,
450
- error_format : ErrorOutputType ,
424
+ fn rust_input < R , F > ( options : config:: Options ,
451
425
f : F ) -> R
452
426
where R : ' static + Send ,
453
- F : ' static + Send + FnOnce ( Output , & getopts :: Matches ) -> R
427
+ F : ' static + Send + FnOnce ( Output ) -> R
454
428
{
455
- let default_passes = if matches. opt_present ( "no-defaults" ) {
456
- passes:: DefaultPassOption :: None
457
- } else if matches. opt_present ( "document-private-items" ) {
458
- passes:: DefaultPassOption :: Private
459
- } else {
460
- passes:: DefaultPassOption :: Default
461
- } ;
462
-
463
- let manual_passes = matches. opt_strs ( "passes" ) ;
464
- let plugins = matches. opt_strs ( "plugins" ) ;
465
-
466
429
// First, parse the crate and extract all relevant information.
467
- let mut paths = SearchPaths :: new ( ) ;
468
- for s in & matches. opt_strs ( "L" ) {
469
- paths. add_path ( s, ErrorOutputType :: default ( ) ) ;
470
- }
471
- let mut cfgs = matches. opt_strs ( "cfg" ) ;
472
- cfgs. push ( "rustdoc" . to_string ( ) ) ;
473
- let triple = matches. opt_str ( "target" ) . map ( |target| {
474
- if target. ends_with ( ".json" ) {
475
- TargetTriple :: TargetPath ( PathBuf :: from ( target) )
476
- } else {
477
- TargetTriple :: TargetTriple ( target)
478
- }
479
- } ) ;
480
- let maybe_sysroot = matches. opt_str ( "sysroot" ) . map ( PathBuf :: from) ;
481
- let crate_name = matches. opt_str ( "crate-name" ) ;
482
- let crate_version = matches. opt_str ( "crate-version" ) ;
483
- let plugin_path = matches. opt_str ( "plugin-path" ) ;
484
-
485
430
info ! ( "starting to run rustc" ) ;
486
- let display_warnings = matches. opt_present ( "display-warnings" ) ;
487
-
488
- let force_unstable_if_unmarked = matches. opt_strs ( "Z" ) . iter ( ) . any ( |x| {
489
- * x == "force-unstable-if-unmarked"
490
- } ) ;
491
- let treat_err_as_bug = matches. opt_strs ( "Z" ) . iter ( ) . any ( |x| {
492
- * x == "treat-err-as-bug"
493
- } ) ;
494
- let ui_testing = matches. opt_strs ( "Z" ) . iter ( ) . any ( |x| {
495
- * x == "ui-testing"
496
- } ) ;
497
-
498
- let ( lint_opts, describe_lints, lint_cap) = get_cmd_lint_options ( & matches, error_format) ;
499
431
500
432
let ( tx, rx) = channel ( ) ;
501
433
502
434
let result = rustc_driver:: monitor ( move || syntax:: with_globals ( move || {
503
435
use rustc:: session:: config:: Input ;
504
436
437
+ let paths = options. libs ;
438
+ let cfgs = options. cfgs ;
439
+ let triple = options. target ;
440
+ let maybe_sysroot = options. maybe_sysroot ;
441
+ let crate_name = options. crate_name ;
442
+ let crate_version = options. crate_version ;
443
+ let force_unstable_if_unmarked = options. debugging_options . force_unstable_if_unmarked ;
444
+ let treat_err_as_bug = options. debugging_options . treat_err_as_bug ;
445
+ let ui_testing = options. debugging_options . ui_testing ;
446
+
505
447
let ( mut krate, renderinfo, passes) =
506
- core:: run_core ( paths, cfgs, externs, Input :: File ( cratefile) , triple, maybe_sysroot,
507
- display_warnings, crate_name. clone ( ) ,
508
- force_unstable_if_unmarked, edition, cg, error_format,
509
- lint_opts, lint_cap, describe_lints, manual_passes, default_passes,
510
- treat_err_as_bug, ui_testing) ;
448
+ core:: run_core ( paths, cfgs, options. externs , Input :: File ( options. input ) , triple, maybe_sysroot,
449
+ options. display_warnings , crate_name. clone ( ) ,
450
+ force_unstable_if_unmarked, options. edition , options. codegen_options , options. error_format ,
451
+ options. lint_opts , options. lint_cap , options. describe_lints ,
452
+ options. manual_passes , options. default_passes , treat_err_as_bug,
453
+ ui_testing) ;
511
454
512
455
info ! ( "finished with rustc" ) ;
513
456
@@ -517,14 +460,6 @@ where R: 'static + Send,
517
460
518
461
krate. version = crate_version;
519
462
520
- if !plugins. is_empty ( ) {
521
- eprintln ! ( "WARNING: --plugins no longer functions; see CVE-2018-1000622" ) ;
522
- }
523
-
524
- if !plugin_path. is_none ( ) {
525
- eprintln ! ( "WARNING: --plugin-path no longer functions; see CVE-2018-1000622" ) ;
526
- }
527
-
528
463
info ! ( "Executing passes" ) ;
529
464
530
465
for pass in & passes {
@@ -547,8 +482,7 @@ where R: 'static + Send,
547
482
krate = pass ( krate) ;
548
483
}
549
484
550
- tx. send ( f ( Output { krate : krate, renderinfo : renderinfo, passes : passes } ,
551
- & matches) ) . unwrap ( ) ;
485
+ tx. send ( f ( Output { krate : krate, renderinfo : renderinfo, passes : passes } ) ) . unwrap ( ) ;
552
486
} ) ) ;
553
487
554
488
match result {
0 commit comments