From 08287c1e26c6faa18c145a8a794fdd25408217a4 Mon Sep 17 00:00:00 2001 From: Esteban Küber Date: Sun, 28 Jan 2018 18:37:55 -0800 Subject: Toggle span highlighting on `-Zteach` --- src/librustc_errors/emitter.rs | 21 ++++++++++++++------- src/librustc_errors/lib.rs | 2 +- 2 files changed, 15 insertions(+), 8 deletions(-) (limited to 'src/librustc_errors') diff --git a/src/librustc_errors/emitter.rs b/src/librustc_errors/emitter.rs index 289383088c8..f05609b4d47 100644 --- a/src/librustc_errors/emitter.rs +++ b/src/librustc_errors/emitter.rs @@ -106,6 +106,7 @@ pub struct EmitterWriter { dst: Destination, cm: Option>, short_message: bool, + teach: bool, } struct FileWithAnnotatedLines { @@ -117,32 +118,37 @@ struct FileWithAnnotatedLines { impl EmitterWriter { pub fn stderr(color_config: ColorConfig, code_map: Option>, - short_message: bool) + short_message: bool, + teach: bool) -> EmitterWriter { if color_config.use_color() { let dst = Destination::from_stderr(); EmitterWriter { dst, cm: code_map, - short_message: short_message, + short_message, + teach, } } else { EmitterWriter { dst: Raw(Box::new(io::stderr())), cm: code_map, - short_message: short_message, + short_message, + teach, } } } pub fn new(dst: Box, code_map: Option>, - short_message: bool) + short_message: bool, + teach: bool) -> EmitterWriter { EmitterWriter { dst: Raw(dst), cm: code_map, - short_message: short_message, + short_message, + teach, } } @@ -551,13 +557,14 @@ impl EmitterWriter { code_offset + annotation.start_col, style); } - _ => { + _ if self.teach => { buffer.set_style_range(line_offset, code_offset + annotation.start_col, code_offset + annotation.end_col, style, annotation.is_primary); - } + } + _ => {} } } diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs index 3d50c95d3f4..47eb04621a1 100644 --- a/src/librustc_errors/lib.rs +++ b/src/librustc_errors/lib.rs @@ -297,7 +297,7 @@ impl Handler { cm: Option>, flags: HandlerFlags) -> Handler { - let emitter = Box::new(EmitterWriter::stderr(color_config, cm, false)); + let emitter = Box::new(EmitterWriter::stderr(color_config, cm, false, false)); Handler::with_emitter_and_flags(emitter, flags) } -- cgit 1.4.1-3-g733a5