@@ -56,16 +56,11 @@ extern crate serialize as rustc_serialize; // used by deriving
5656use std:: default:: Default ;
5757use std:: env;
5858use std:: panic;
59- use std:: path:: PathBuf ;
6059use std:: process;
6160use std:: sync:: mpsc:: channel;
6261
63- use syntax:: edition:: Edition ;
6462use 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 } ;
6964
7065#[ macro_use]
7166mod externalfiles;
@@ -387,17 +382,23 @@ fn main_args(args: &[String]) -> isize {
387382 options. codegen_options )
388383 }
389384 ( 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 ) ,
391388 & options. external_html ,
392389 !options. markdown_no_toc , & diag) ,
393390 ( false , false ) => { }
394391 }
395392
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| {
399395 let Output { krate, passes, renderinfo } = out;
400396 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 ( ) ;
401402 html:: render:: run ( krate, options. extern_html_root_urls , & options. external_html , options. playground_url ,
402403 options. output ,
403404 options. resource_suffix ,
@@ -408,106 +409,48 @@ fn main_args(args: &[String]) -> isize {
408409 options. themes ,
409410 options. enable_minification , options. id_map ,
410411 options. enable_index_page , options. index_page ,
411- & matches ,
412+ html_opts ,
412413 & diag)
413414 . expect ( "failed to generate documentation" ) ;
414415 0
415- } ) ;
416- res. unwrap_or_else ( |s| {
417- diag. struct_err ( & format ! ( "input error: {}" , s) ) . emit ( ) ;
418- 1
419416 } )
420417}
421418
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-
440419/// Interprets the input file as a rust source file, passing it through the
441420/// compiler all the way through the analysis passes. The rustdoc output is then
442421/// generated from the cleaned AST of the crate.
443422///
444423/// 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 ,
451425 f : F ) -> R
452426where R : ' static + Send ,
453- F : ' static + Send + FnOnce ( Output , & getopts :: Matches ) -> R
427+ F : ' static + Send + FnOnce ( Output ) -> R
454428{
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-
466429 // 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-
485430 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) ;
499431
500432 let ( tx, rx) = channel ( ) ;
501433
502434 let result = rustc_driver:: monitor ( move || syntax:: with_globals ( move || {
503435 use rustc:: session:: config:: Input ;
504436
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+
505447 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) ;
511454
512455 info ! ( "finished with rustc" ) ;
513456
@@ -517,14 +460,6 @@ where R: 'static + Send,
517460
518461 krate. version = crate_version;
519462
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-
528463 info ! ( "Executing passes" ) ;
529464
530465 for pass in & passes {
@@ -547,8 +482,7 @@ where R: 'static + Send,
547482 krate = pass ( krate) ;
548483 }
549484
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 ( ) ;
552486 } ) ) ;
553487
554488 match result {
0 commit comments