diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2018-01-19 13:04:14 +0530 |
|---|---|---|
| committer | Manish Goregaokar <manishsmail@gmail.com> | 2018-01-29 11:41:02 +0530 |
| commit | a53bdc6212b9abf8538a877ebfde214120bf061f (patch) | |
| tree | 7621118b3e82bafa43a27dbe21e6ebbed5536f18 /src/libsyntax | |
| parent | 937bc2e04aaad37f97d367f7c5073c352e357bb5 (diff) | |
Add -Zapproximate-suggestions
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/json.rs | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/libsyntax/json.rs b/src/libsyntax/json.rs index 0dec26e4f74..7a8717ada4c 100644 --- a/src/libsyntax/json.rs +++ b/src/libsyntax/json.rs @@ -38,34 +38,41 @@ pub struct JsonEmitter { registry: Option<Registry>, cm: Rc<CodeMapper + 'static>, pretty: bool, + /// Whether "approximate suggestions" are enabled in the config + approximate_suggestions: bool, } impl JsonEmitter { pub fn stderr(registry: Option<Registry>, code_map: Rc<CodeMap>, - pretty: bool) -> JsonEmitter { + pretty: bool, + approximate_suggestions: bool) -> JsonEmitter { JsonEmitter { dst: Box::new(io::stderr()), registry, cm: code_map, pretty, + approximate_suggestions, } } pub fn basic(pretty: bool) -> JsonEmitter { let file_path_mapping = FilePathMapping::empty(); - JsonEmitter::stderr(None, Rc::new(CodeMap::new(file_path_mapping)), pretty) + JsonEmitter::stderr(None, Rc::new(CodeMap::new(file_path_mapping)), + pretty, false) } pub fn new(dst: Box<Write + Send>, registry: Option<Registry>, code_map: Rc<CodeMap>, - pretty: bool) -> JsonEmitter { + pretty: bool, + approximate_suggestions: bool) -> JsonEmitter { JsonEmitter { dst, registry, cm: code_map, pretty, + approximate_suggestions, } } } @@ -283,6 +290,13 @@ impl DiagnosticSpan { def_site_span, }) }); + + let suggestion_approximate = if je.approximate_suggestions { + suggestion.map(|x| x.1) + } else { + None + }; + DiagnosticSpan { file_name: start.file.name.to_string(), byte_start: span.lo().0 - start.file.start_pos.0, @@ -294,7 +308,7 @@ impl DiagnosticSpan { is_primary, text: DiagnosticSpanLine::from_span(span, je), suggested_replacement: suggestion.map(|x| x.0.clone()), - suggestion_approximate: suggestion.map(|x| x.1), + suggestion_approximate, expansion: backtrace_step, label, } |
