pub fn new_handler(error_format: ErrorOutputType, source_map: Option<Lrc<source_map::SourceMap>>)
    -> errors::Handler
{
    // rustdoc doesn't override (or allow to override) anything from this that is relevant here, so
    // stick to the defaults
    let sessopts = Options::default();
    let emitter: Box<dyn Emitter + sync::Send> = match error_format {
        ErrorOutputType::HumanReadable(color_config) => Box::new(
            EmitterWriter::stderr(
                color_config,
                source_map.map(|cm| cm as _),
                false,
                sessopts.debugging_opts.teach,
            ).ui_testing(sessopts.debugging_opts.ui_testing)
        ),
        ErrorOutputType::Json(pretty) => {
            let source_map = source_map.unwrap_or_else(
                || Lrc::new(source_map::SourceMap::new(sessopts.file_path_mapping())));
            Box::new(
                JsonEmitter::stderr(
                    None,
                    source_map,
                    pretty,
                ).ui_testing(sessopts.debugging_opts.ui_testing)
            )
        },
        ErrorOutputType::Short(color_config) => Box::new(
            EmitterWriter::stderr(
                color_config,
                source_map.map(|cm| cm as _),
                true,
                false)
        ),
    };

    errors::Handler::with_emitter_and_flags(
        emitter,
        errors::HandlerFlags {
            can_emit_warnings: true,
            treat_err_as_bug: false,
            report_delayed_bugs: false,
            external_macro_backtrace: false,
            ..Default::default()
        },
    )
}
/// Creates a new diagnostic `Handler` that can be used to emit warnings and errors.
///
/// If the given `error_format` is `ErrorOutputType::Json` and no `SourceMap` is given, a new one
/// will be created for the handler.
Creates a new diagnostic `Handler` that can be used to emit warnings and errors.
Creates a new diagnostic ` Handler ` that can be used to emit warnings and errors .
pub fn new_handler(error_format: ErrorOutputType, source_map: Option<Lrc<source_map::SourceMap>>)
    -> errors::Handler
{
    // rustdoc doesn't override (or allow to override) anything from this that is relevant here, so
    // stick to the defaults
    let sessopts = Options::default();
    let emitter: Box<dyn Emitter + sync::Send> = match error_format {
        ErrorOutputType::HumanReadable(color_config) => Box::new(
            EmitterWriter::stderr(
                color_config,
                source_map.map(|cm| cm as _),
                false,
                sessopts.debugging_opts.teach,
            ).ui_testing(sessopts.debugging_opts.ui_testing)
        ),
        ErrorOutputType::Json(pretty) => {
            let source_map = source_map.unwrap_or_else(
                || Lrc::new(source_map::SourceMap::new(sessopts.file_path_mapping())));
            Box::new(
                JsonEmitter::stderr(
                    None,
                    source_map,
                    pretty,
                ).ui_testing(sessopts.debugging_opts.ui_testing)
            )
        },
        ErrorOutputType::Short(color_config) => Box::new(
            EmitterWriter::stderr(
                color_config,
                source_map.map(|cm| cm as _),
                true,
                false)
        ),
    };
    errors::Handler::with_emitter_and_flags(
        emitter,
        errors::HandlerFlags {
            can_emit_warnings: true,
            treat_err_as_bug: false,
            report_delayed_bugs: false,
            external_macro_backtrace: false,
            ..Default::default()
        },
    )
}
pub fn new_handler ( error_format : ErrorOutputType , source_map : Option < Lrc < source_map :: SourceMap > > ) -> errors :: Handler { // rustdoc doesn't override (or allow to override) anything from this that is relevant here, so // stick to the defaults let sessopts = Options :: default ( ) ; let emitter : Box < dyn Emitter + sync :: Send > = match error_format { ErrorOutputType :: HumanReadable ( color_config ) => Box :: new ( EmitterWriter :: stderr ( color_config , source_map . map ( | cm | cm as _ ) , false , sessopts . debugging_opts . teach , ) . ui_testing ( sessopts . debugging_opts . ui_testing ) ) , ErrorOutputType :: Json ( pretty ) => { let source_map = source_map . unwrap_or_else ( | | Lrc :: new ( source_map :: SourceMap :: new ( sessopts . file_path_mapping ( ) ) ) ) ; Box :: new ( JsonEmitter :: stderr ( None , source_map , pretty , ) . ui_testing ( sessopts . debugging_opts . ui_testing ) ) } , ErrorOutputType :: Short ( color_config ) => Box :: new ( EmitterWriter :: stderr ( color_config , source_map . map ( | cm | cm as _ ) , true , false ) ) , } ; errors :: Handler :: with_emitter_and_flags ( emitter , errors :: HandlerFlags { can_emit_warnings : true , treat_err_as_bug : false , report_delayed_bugs : false , external_macro_backtrace : false , .. Default :: default ( ) } , ) }
Creates a new diagnostic `Handler` that can be used to emit warnings and errors.
Creates a new diagnostic ` Handler ` that can be used to emit warnings and errors .
error_format
ErrorOutputType
source_map
Option<Lrc<source_map::SourceMap>>
error_format
ErrorOutputType
source_map
Option<Lrc<source_map::SourceMap>>