Add new error-format value to use annotate-snippet output
This commit is contained in:
parent
3f727aeeb7
commit
c04a2ccb35
@ -2002,6 +2002,9 @@ pub fn build_session_options_and_crate_config(
|
||||
match matches.opt_str("error-format").as_ref().map(|s| &s[..]) {
|
||||
None |
|
||||
Some("human") => ErrorOutputType::HumanReadable(HumanReadableErrorType::Default(color)),
|
||||
Some("human-annotate-rs") => {
|
||||
ErrorOutputType::HumanReadable(HumanReadableErrorType::AnnotateRs(color))
|
||||
},
|
||||
Some("json") => ErrorOutputType::Json { pretty: false, json_rendered },
|
||||
Some("pretty-json") => ErrorOutputType::Json { pretty: true, json_rendered },
|
||||
Some("short") => ErrorOutputType::HumanReadable(HumanReadableErrorType::Short(color)),
|
||||
@ -2038,6 +2041,13 @@ pub fn build_session_options_and_crate_config(
|
||||
"--error-format=pretty-json is unstable",
|
||||
);
|
||||
}
|
||||
if let ErrorOutputType::HumanReadable(HumanReadableErrorType::AnnotateRs(_)) =
|
||||
error_format {
|
||||
early_error(
|
||||
ErrorOutputType::Json { pretty: false, json_rendered },
|
||||
"--error-format=human-annotate-rs is unstable",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if debugging_opts.pgo_gen.enabled() && debugging_opts.pgo_use.is_some() {
|
||||
|
@ -23,6 +23,8 @@
|
||||
|
||||
use errors::{DiagnosticBuilder, DiagnosticId, Applicability};
|
||||
use errors::emitter::{Emitter, EmitterWriter};
|
||||
use errors::emitter::HumanReadableErrorType;
|
||||
use errors::annotate_rs_emitter::{AnnotateRsEmitterWriter};
|
||||
use syntax::ast::{self, NodeId};
|
||||
use syntax::edition::Edition;
|
||||
use syntax::feature_gate::{self, AttributeType};
|
||||
@ -1031,22 +1033,31 @@ fn default_emitter(
|
||||
match (sopts.error_format, emitter_dest) {
|
||||
(config::ErrorOutputType::HumanReadable(kind), dst) => {
|
||||
let (short, color_config) = kind.unzip();
|
||||
let emitter = match dst {
|
||||
None => EmitterWriter::stderr(
|
||||
color_config,
|
||||
|
||||
if let HumanReadableErrorType::AnnotateRs(_) = kind {
|
||||
let emitter = AnnotateRsEmitterWriter::new(
|
||||
Some(source_map.clone()),
|
||||
short,
|
||||
sopts.debugging_opts.teach,
|
||||
),
|
||||
Some(dst) => EmitterWriter::new(
|
||||
dst,
|
||||
Some(source_map.clone()),
|
||||
short,
|
||||
false, // no teach messages when writing to a buffer
|
||||
false, // no colors when writing to a buffer
|
||||
),
|
||||
};
|
||||
Box::new(emitter.ui_testing(sopts.debugging_opts.ui_testing))
|
||||
);
|
||||
Box::new(emitter.ui_testing(sopts.debugging_opts.ui_testing))
|
||||
} else {
|
||||
let emitter = match dst {
|
||||
None => EmitterWriter::stderr(
|
||||
color_config,
|
||||
Some(source_map.clone()),
|
||||
short,
|
||||
sopts.debugging_opts.teach,
|
||||
),
|
||||
Some(dst) => EmitterWriter::new(
|
||||
dst,
|
||||
Some(source_map.clone()),
|
||||
short,
|
||||
false, // no teach messages when writing to a buffer
|
||||
false, // no colors when writing to a buffer
|
||||
),
|
||||
};
|
||||
Box::new(emitter.ui_testing(sopts.debugging_opts.ui_testing))
|
||||
}
|
||||
},
|
||||
(config::ErrorOutputType::Json { pretty, json_rendered }, None) => Box::new(
|
||||
JsonEmitter::stderr(
|
||||
|
5
src/test/ui/annotate-snippet/missing-type.rs
Normal file
5
src/test/ui/annotate-snippet/missing-type.rs
Normal file
@ -0,0 +1,5 @@
|
||||
// compile-flags: --error-format human-annotate-rs
|
||||
|
||||
pub fn main() {
|
||||
let x: Iter;
|
||||
}
|
Loading…
Reference in New Issue
Block a user