pub fn monitor<F: FnOnce() + Send + 'static>(f: F) -> Result<(), CompilationFailure> {
    in_rustc_thread(move || {
        f()
    }).map_err(|value| {
        if value.is::<errors::FatalErrorMarker>() {
            CompilationFailure
        } else {
            // Thread panicked without emitting a fatal diagnostic
            eprintln!("");

            let emitter =
                Box::new(errors::emitter::EmitterWriter::stderr(errors::ColorConfig::Auto,
                                                                None,
                                                                false,
                                                                false));
            let handler = errors::Handler::with_emitter(true, false, emitter);

            // a .span_bug or .bug call has already printed what
            // it wants to print.
            if !value.is::<errors::ExplicitBug>() {
                handler.emit(&MultiSpan::new(),
                             "unexpected panic",
                             errors::Level::Bug);
            }

            let mut xs = vec![
                "the compiler unexpectedly panicked. this is a bug.".to_string(),
                format!("we would appreciate a bug report: {}", BUG_REPORT_URL),
                format!("rustc {} running on {}",
                        option_env!("CFG_VERSION").unwrap_or("unknown_version"),
                        config::host_triple()),
            ];

            if let Some((flags, excluded_cargo_defaults)) = extra_compiler_flags() {
                xs.push(format!("compiler flags: {}", flags.join(" ")));

                if excluded_cargo_defaults {
                    xs.push("some of the compiler flags provided by cargo are hidden".to_string());
                }
            }

            for note in &xs {
                handler.emit(&MultiSpan::new(),
                             &note,
                             errors::Level::Note);
            }

            panic::resume_unwind(Box::new(errors::FatalErrorMarker));
        }
    })
}
/// Run a procedure which will detect panics in the compiler and print nicer
/// error messages rather than just failing the test.
///
/// The diagnostic emitter yielded to the procedure should be used for reporting
/// errors of the compiler.
Run a procedure which will detect panics in the compiler and print nicer
error messages rather than just failing the test.

The diagnostic emitter yielded to the procedure should be used for reporting
errors of the compiler.
Run a procedure which will detect panics in the compiler and print nicer error messages rather than just failing the test . The diagnostic emitter yielded to the procedure should be used for reporting errors of the compiler .
pub fn monitor<F: FnOnce() + Send + 'static>(f: F) -> Result<(), CompilationFailure> {
    in_rustc_thread(move || {
        f()
    }).map_err(|value| {
        if value.is::<errors::FatalErrorMarker>() {
            CompilationFailure
        } else {
            // Thread panicked without emitting a fatal diagnostic
            eprintln!("");
            let emitter =
                Box::new(errors::emitter::EmitterWriter::stderr(errors::ColorConfig::Auto,
                                                                None,
                                                                false,
                                                                false));
            let handler = errors::Handler::with_emitter(true, false, emitter);
            // a .span_bug or .bug call has already printed what
            // it wants to print.
            if !value.is::<errors::ExplicitBug>() {
                handler.emit(&MultiSpan::new(),
                             "unexpected panic",
                             errors::Level::Bug);
            }
            let mut xs = vec![
                "the compiler unexpectedly panicked. this is a bug.".to_string(),
                format!("we would appreciate a bug report: {}", BUG_REPORT_URL),
                format!("rustc {} running on {}",
                        option_env!("CFG_VERSION").unwrap_or("unknown_version"),
                        config::host_triple()),
            ];
            if let Some((flags, excluded_cargo_defaults)) = extra_compiler_flags() {
                xs.push(format!("compiler flags: {}", flags.join(" ")));
                if excluded_cargo_defaults {
                    xs.push("some of the compiler flags provided by cargo are hidden".to_string());
                }
            }
            for note in &xs {
                handler.emit(&MultiSpan::new(),
                             &note,
                             errors::Level::Note);
            }
            panic::resume_unwind(Box::new(errors::FatalErrorMarker));
        }
    })
}
pub fn monitor < F : FnOnce ( ) + Send + ' static > ( f : F ) -> Result < ( ) , CompilationFailure > { in_rustc_thread ( move | | { f ( ) } ) . map_err ( | value | { if value . is :: < errors :: FatalErrorMarker > ( ) { CompilationFailure } else { // Thread panicked without emitting a fatal diagnostic eprintln ! ( " " ) ; let emitter = Box :: new ( errors :: emitter :: EmitterWriter :: stderr ( errors :: ColorConfig :: Auto , None , false , false ) ) ; let handler = errors :: Handler :: with_emitter ( true , false , emitter ) ; // a .span_bug or .bug call has already printed what // it wants to print. if ! value . is :: < errors :: ExplicitBug > ( ) { handler . emit ( & MultiSpan :: new ( ) , " " , errors :: Level :: Bug ) ; } let mut xs = vec ! [ " " to_string ( ) format ( " " BUG_REPORT_URL ) format ( " " option_env ( " " ) unwrap_or ( " " ) config host_triple ( ) ) ] ; if let Some ( ( flags , excluded_cargo_defaults ) ) = extra_compiler_flags ( ) { xs . push ( format ! ( " " flags join ( " " ) ) ) ; if excluded_cargo_defaults { xs . push ( " " . to_string ( ) ) ; } } for note in & xs { handler . emit ( & MultiSpan :: new ( ) , & note , errors :: Level :: Note ) ; } panic :: resume_unwind ( Box :: new ( errors :: FatalErrorMarker ) ) ; } } ) }
Run a procedure which will detect panics in the compiler and print nicer
error messages rather than just failing the test.
Run a procedure which will detect panics in the compiler and print nicer error messages rather than just failing the test .
f
F
f
F