diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2018-01-28 18:37:55 -0800 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2018-01-29 08:59:15 -0800 |
| commit | 08287c1e26c6faa18c145a8a794fdd25408217a4 (patch) | |
| tree | 897420f822df3f373916e93e57f8cc2f65f04f6e /src/librustc_errors | |
| parent | 871856e8312e7248d12f06f0faa1555f38e50a93 (diff) | |
| download | rust-08287c1e26c6faa18c145a8a794fdd25408217a4.tar.gz rust-08287c1e26c6faa18c145a8a794fdd25408217a4.zip | |
Toggle span highlighting on `-Zteach`
Diffstat (limited to 'src/librustc_errors')
| -rw-r--r-- | src/librustc_errors/emitter.rs | 21 | ||||
| -rw-r--r-- | src/librustc_errors/lib.rs | 2 |
2 files changed, 15 insertions, 8 deletions
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<Rc<CodeMapper>>, short_message: bool, + teach: bool, } struct FileWithAnnotatedLines { @@ -117,32 +118,37 @@ struct FileWithAnnotatedLines { impl EmitterWriter { pub fn stderr(color_config: ColorConfig, code_map: Option<Rc<CodeMapper>>, - 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<Write + Send>, code_map: Option<Rc<CodeMapper>>, - 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<Rc<CodeMapper>>, 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) } |
