]> git.lizzy.rs Git - rust.git/commitdiff
Report lint names in json diagnostics
authorOliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>
Tue, 24 Oct 2017 06:37:41 +0000 (08:37 +0200)
committerOliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>
Thu, 2 Nov 2017 09:19:41 +0000 (10:19 +0100)
src/librustc/lint/mod.rs
src/librustc_errors/emitter.rs
src/test/ui/lint/unused_parens_json_suggestion.stderr

index 52dcbfdedef5d23a3ceec8af92095fac62e79a51..9317b6d3d5b95bb33dca24a91119dc8ee9fc2be0 100644 (file)
@@ -463,6 +463,8 @@ pub fn struct_lint_level<'a>(sess: &'a Session,
         }
     }
 
+    err.code(name);
+
     // Check for future incompatibility lints and issue a stronger warning.
     let lints = sess.lint_store.borrow();
     if let Some(future_incompatible) = lints.future_incompatible(LintId::of(lint)) {
index 5db5a9a1133d8dcb2fe5307c8b72c92e656da606..356b3dadb7b552379863e57c11891ecea3761c81 100644 (file)
@@ -906,7 +906,8 @@ fn emit_message_default(&mut self,
         } else {
             buffer.append(0, &level.to_string(), Style::Level(level.clone()));
             match code {
-                &Some(ref code) => {
+                // only render error codes, not lint codes
+                &Some(ref code) if code.starts_with("E") && code.len() == 5 => {
                     buffer.append(0, "[", Style::Level(level.clone()));
                     buffer.append(0, &code, Style::Level(level.clone()));
                     buffer.append(0, "]", Style::Level(level.clone()));
index ae5b53da1750387f461b47cb47c33438d53eff58..02bb76722e6fad7c6a0338de61dcc3af951d2c03 100644 (file)
@@ -1 +1 @@
-{"message":"unnecessary parentheses around assigned value","code":null,"level":"warning","spans":[{"file_name":"$DIR/unused_parens_json_suggestion.rs","byte_start":1001,"byte_end":1014,"line_start":24,"line_end":24,"column_start":14,"column_end":27,"is_primary":true,"text":[{"text":"    let _a = (1 / (2 + 3));","highlight_start":14,"highlight_end":27}],"label":null,"suggested_replacement":null,"expansion":null}],"children":[{"message":"lint level defined here","code":null,"level":"note","spans":[{"file_name":"$DIR/unused_parens_json_suggestion.rs","byte_start":847,"byte_end":860,"line_start":19,"line_end":19,"column_start":9,"column_end":22,"is_primary":true,"text":[{"text":"#![warn(unused_parens)]","highlight_start":9,"highlight_end":22}],"label":null,"suggested_replacement":null,"expansion":null}],"children":[],"rendered":null},{"message":"remove these parentheses","code":null,"level":"help","spans":[{"file_name":"$DIR/unused_parens_json_suggestion.rs","byte_start":1001,"byte_end":1014,"line_start":24,"line_end":24,"column_start":14,"column_end":27,"is_primary":true,"text":[{"text":"    let _a = (1 / (2 + 3));","highlight_start":14,"highlight_end":27}],"label":null,"suggested_replacement":"1 / (2 + 3)","expansion":null}],"children":[],"rendered":null}],"rendered":null}
+{"message":"unnecessary parentheses around assigned value","code":{"code":"unused_parens","explanation":null},"level":"warning","spans":[{"file_name":"$DIR/unused_parens_json_suggestion.rs","byte_start":1001,"byte_end":1014,"line_start":24,"line_end":24,"column_start":14,"column_end":27,"is_primary":true,"text":[{"text":"    let _a = (1 / (2 + 3));","highlight_start":14,"highlight_end":27}],"label":null,"suggested_replacement":null,"expansion":null}],"children":[{"message":"lint level defined here","code":null,"level":"note","spans":[{"file_name":"$DIR/unused_parens_json_suggestion.rs","byte_start":847,"byte_end":860,"line_start":19,"line_end":19,"column_start":9,"column_end":22,"is_primary":true,"text":[{"text":"#![warn(unused_parens)]","highlight_start":9,"highlight_end":22}],"label":null,"suggested_replacement":null,"expansion":null}],"children":[],"rendered":null},{"message":"remove these parentheses","code":null,"level":"help","spans":[{"file_name":"$DIR/unused_parens_json_suggestion.rs","byte_start":1001,"byte_end":1014,"line_start":24,"line_end":24,"column_start":14,"column_end":27,"is_primary":true,"text":[{"text":"    let _a = (1 / (2 + 3));","highlight_start":14,"highlight_end":27}],"label":null,"suggested_replacement":"1 / (2 + 3)","expansion":null}],"children":[],"rendered":null}],"rendered":null}