/// Interprets the input file as a rust source file, passing it through the
/// compiler all the way through the analysis passes. The rustdoc output is then
/// generated from the cleaned AST of the crate.
///
/// This form of input will run all of the plug/cleaning passes
Interprets the input file as a rust source file, passing it through the
compiler all the way through the analysis passes. The rustdoc output is then
generated from the cleaned AST of the crate.

This form of input will run all of the plug/cleaning passes
Interprets the input file as a rust source file passing it through the compiler all the way through the analysis passes . The rustdoc output is then generated from the cleaned AST of the crate . This form of input will run all of the plug / cleaning passes
fn rust_input<R, F>(cratefile: PathBuf,
                    externs: Externs,
                    edition: Edition,
                    cg: CodegenOptions,
                    matches: &getopts::Matches,
                    error_format: ErrorOutputType,
                    f: F) -> R
where R: 'static + Send,
      F: 'static + Send + FnOnce(Output) -> R
{
    let default_passes = if matches.opt_present("no-defaults") {
        passes::DefaultPassOption::None
    } else if matches.opt_present("document-private-items") {
        passes::DefaultPassOption::Private
    } else {
        passes::DefaultPassOption::Default
    };
    let manual_passes = matches.opt_strs("passes");
    let plugins = matches.opt_strs("plugins");
    // First, parse the crate and extract all relevant information.
    let mut paths = SearchPaths::new();
    for s in &matches.opt_strs("L") {
        paths.add_path(s, ErrorOutputType::default());
    }
    let cfgs = matches.opt_strs("cfg");
    let triple = matches.opt_str("target").map(|target| {
        if target.ends_with(".json") {
            TargetTriple::TargetPath(PathBuf::from(target))
        } else {
            TargetTriple::TargetTriple(target)
        }
    });
    let maybe_sysroot = matches.opt_str("sysroot").map(PathBuf::from);
    let crate_name = matches.opt_str("crate-name");
    let crate_version = matches.opt_str("crate-version");
    let plugin_path = matches.opt_str("plugin-path");
    info!("starting to run rustc");
    let display_warnings = matches.opt_present("display-warnings");
    let force_unstable_if_unmarked = matches.opt_strs("Z").iter().any(|x| {
        *x == "force-unstable-if-unmarked"
    });
    let (lint_opts, describe_lints, lint_cap) = get_cmd_lint_options(matches, error_format);
    let (tx, rx) = channel();
    let result = rustc_driver::monitor(move || syntax::with_globals(move || {
        use rustc::session::config::Input;
        let (mut krate, renderinfo, passes) =
            core::run_core(paths, cfgs, externs, Input::File(cratefile), triple, maybe_sysroot,
                           display_warnings, crate_name.clone(),
                           force_unstable_if_unmarked, edition, cg, error_format,
                           lint_opts, lint_cap, describe_lints, manual_passes, default_passes);
        info!("finished with rustc");
        if let Some(name) = crate_name {
            krate.name = name
        }
        krate.version = crate_version;
        if !plugins.is_empty() {
            eprintln!("WARNING: --plugins no longer functions; see CVE-2018-1000622");
        }
        if !plugin_path.is_none() {
            eprintln!("WARNING: --plugin-path no longer functions; see CVE-2018-1000622");
        }
        info!("Executing passes");
        for pass in &passes {
            // determine if we know about this pass
            let pass = match passes::find_pass(pass) {
                Some(pass) => if let Some(pass) = pass.late_fn() {
                    pass
                } else {
                    // not a late pass, but still valid so don't report the error
                    continue
                }
                None => {
                    error!("unknown pass {}, skipping", *pass);
                    continue
                },
            };
            // run it
            krate = pass(krate);
        }
        tx.send(f(Output { krate: krate, renderinfo: renderinfo, passes: passes })).unwrap();
    }));
    match result {
        Ok(()) => rx.recv().unwrap(),
        Err(_) => panic::resume_unwind(Box::new(errors::FatalErrorMarker)),
    }
}
fn rust_input < R , F > ( cratefile : PathBuf , externs : Externs , edition : Edition , cg : CodegenOptions , matches : & getopts :: Matches , error_format : ErrorOutputType , f : F ) -> R where R : ' static + Send , F : ' static + Send + FnOnce ( Output ) -> R { let default_passes = if matches . opt_present ( " " ) { passes :: DefaultPassOption :: None } else if matches . opt_present ( " " ) { passes :: DefaultPassOption :: Private } else { passes :: DefaultPassOption :: Default } ; let manual_passes = matches . opt_strs ( " " ) ; let plugins = matches . opt_strs ( " " ) ; // First, parse the crate and extract all relevant information. let mut paths = SearchPaths :: new ( ) ; for s in & matches . opt_strs ( " " ) { paths . add_path ( s , ErrorOutputType :: default ( ) ) ; } let cfgs = matches . opt_strs ( " " ) ; let triple = matches . opt_str ( " " ) . map ( | target | { if target . ends_with ( " " ) { TargetTriple :: TargetPath ( PathBuf :: from ( target ) ) } else { TargetTriple :: TargetTriple ( target ) } } ) ; let maybe_sysroot = matches . opt_str ( " " ) . map ( PathBuf :: from ) ; let crate_name = matches . opt_str ( " " ) ; let crate_version = matches . opt_str ( " " ) ; let plugin_path = matches . opt_str ( " " ) ; info ! ( " " ) ; let display_warnings = matches . opt_present ( " " ) ; let force_unstable_if_unmarked = matches . opt_strs ( " " ) . iter ( ) . any ( | x | { * x == " " } ) ; let ( lint_opts , describe_lints , lint_cap ) = get_cmd_lint_options ( matches , error_format ) ; let ( tx , rx ) = channel ( ) ; let result = rustc_driver :: monitor ( move | | syntax :: with_globals ( move | | { use rustc :: session :: config :: Input ; let ( mut krate , renderinfo , passes ) = core :: run_core ( paths , cfgs , externs , Input :: File ( cratefile ) , triple , maybe_sysroot , display_warnings , crate_name . clone ( ) , force_unstable_if_unmarked , edition , cg , error_format , lint_opts , lint_cap , describe_lints , manual_passes , default_passes ) ; info ! ( " " ) ; if let Some ( name ) = crate_name { krate . name = name } krate . version = crate_version ; if ! plugins . is_empty ( ) { eprintln ! ( " " ) ; } if ! plugin_path . is_none ( ) { eprintln ! ( " " ) ; } info ! ( " " ) ; for pass in & passes { // determine if we know about this pass let pass = match passes :: find_pass ( pass ) { Some ( pass ) => if let Some ( pass ) = pass . late_fn ( ) { pass } else { // not a late pass, but still valid so don't report the error continue } None => { error ! ( " " pass ) ; continue } , } ; // run it krate = pass ( krate ) ; } tx . send ( f ( Output { krate : krate , renderinfo : renderinfo , passes : passes } ) ) . unwrap ( ) ; } ) ) ; match result { Ok ( ( ) ) => rx . recv ( ) . unwrap ( ) , Err ( _ ) => panic :: resume_unwind ( Box :: new ( errors :: FatalErrorMarker ) ) , } }
Interprets the input file as a rust source file, passing it through the
compiler all the way through the analysis passes.
Interprets the input file as a rust source file passing it through the compiler all the way through the analysis passes .
cratefile
PathBuf
externs
Externs
edition
Edition
cg
CodegenOptions
matches
&getopts::Matches
error_format
ErrorOutputType
f
F