]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #47540 - Manishearth:suggestion, r=nrc
authorbors <bors@rust-lang.org>
Thu, 1 Feb 2018 04:47:46 +0000 (04:47 +0000)
committerbors <bors@rust-lang.org>
Thu, 1 Feb 2018 04:47:46 +0000 (04:47 +0000)
Add approximate suggestions for rustfix

This adds `span_approximate_suggestion()` that lets you emit a
suggestion marked as "non-machine applicable" in the JSON output. UI
users see no difference. This is for when rustc and clippy wish to
 emit suggestions which will make sense to the reader (e.g. they may
have placeholders like `<type>`) but are not source-applicable, so that
rustfix/etc can ignore these.

fixes #39254

1  2 
src/librustc/session/mod.rs
src/librustc_errors/lib.rs
src/libsyntax/json.rs

index b526819e3ce70f5bc00943634e7528f7d751da1f,d311076c39e8d1aa4ae1e467dfa472a87776c0d0..f4a00a43d8d92b5dcb471e5bb1c3e973906bab0b
@@@ -904,25 -904,24 +904,27 @@@ pub fn build_session_with_codemap(sopts
  
      let emitter: Box<Emitter> = match (sopts.error_format, emitter_dest) {
          (config::ErrorOutputType::HumanReadable(color_config), None) => {
 -            Box::new(EmitterWriter::stderr(color_config, Some(codemap.clone()), false))
 +            Box::new(EmitterWriter::stderr(color_config,
 +                                           Some(codemap.clone()),
 +                                           false,
 +                                           sopts.debugging_opts.teach))
          }
          (config::ErrorOutputType::HumanReadable(_), Some(dst)) => {
 -            Box::new(EmitterWriter::new(dst, Some(codemap.clone()), false))
 +            Box::new(EmitterWriter::new(dst, Some(codemap.clone()), false, false))
          }
          (config::ErrorOutputType::Json(pretty), None) => {
-             Box::new(JsonEmitter::stderr(Some(registry), codemap.clone(), pretty))
+             Box::new(JsonEmitter::stderr(Some(registry), codemap.clone(),
+                      pretty, sopts.debugging_opts.approximate_suggestions))
          }
          (config::ErrorOutputType::Json(pretty), Some(dst)) => {
-             Box::new(JsonEmitter::new(dst, Some(registry), codemap.clone(), pretty))
+             Box::new(JsonEmitter::new(dst, Some(registry), codemap.clone(),
+                      pretty, sopts.debugging_opts.approximate_suggestions))
          }
          (config::ErrorOutputType::Short(color_config), None) => {
 -            Box::new(EmitterWriter::stderr(color_config, Some(codemap.clone()), true))
 +            Box::new(EmitterWriter::stderr(color_config, Some(codemap.clone()), true, false))
          }
          (config::ErrorOutputType::Short(_), Some(dst)) => {
 -            Box::new(EmitterWriter::new(dst, Some(codemap.clone()), true))
 +            Box::new(EmitterWriter::new(dst, Some(codemap.clone()), true, false))
          }
      };
  
Simple merge
Simple merge