]> git.lizzy.rs Git - rust.git/blobdiff - compiler/rustc_errors/src/emitter.rs
Remove unused code from remaining compiler crates
[rust.git] / compiler / rustc_errors / src / emitter.rs
index 4555168af0ab526bafca9d45a7eb5415c852cf22..b5155f8e910d7049654d6a2273ffdbca25a8c98f 100644 (file)
@@ -510,8 +510,6 @@ fn source_map(&self) -> Option<&Lrc<SourceMap>> {
     fn emit_diagnostic(&mut self, _: &Diagnostic) {}
 }
 
-/// Maximum number of lines we will print for each error; arbitrary.
-pub const MAX_HIGHLIGHT_LINES: usize = 6;
 /// Maximum number of lines we will print for a multiline suggestion; arbitrary.
 ///
 /// This should be replaced with a more involved mechanism to output multiline suggestions that
@@ -1227,18 +1225,14 @@ fn emit_message_default(
             }
             draw_note_separator(&mut buffer, 0, max_line_num_len + 1);
             if *level != Level::FailureNote {
-                let level_str = level.to_string();
-                if !level_str.is_empty() {
-                    buffer.append(0, &level_str, Style::MainHeaderMsg);
-                    buffer.append(0, ": ", Style::NoStyle);
-                }
+                buffer.append(0, level.to_str(), Style::MainHeaderMsg);
+                buffer.append(0, ": ", Style::NoStyle);
             }
             self.msg_to_buffer(&mut buffer, msg, max_line_num_len, "note", None);
         } else {
-            let level_str = level.to_string();
             // The failure note level itself does not provide any useful diagnostic information
-            if *level != Level::FailureNote && !level_str.is_empty() {
-                buffer.append(0, &level_str, Style::Level(*level));
+            if *level != Level::FailureNote {
+                buffer.append(0, level.to_str(), Style::Level(*level));
             }
             // only render error codes, not lint codes
             if let Some(DiagnosticId::Error(ref code)) = *code {
@@ -1246,7 +1240,7 @@ fn emit_message_default(
                 buffer.append(0, &code, Style::Level(*level));
                 buffer.append(0, "]", Style::Level(*level));
             }
-            if *level != Level::FailureNote && !level_str.is_empty() {
+            if *level != Level::FailureNote {
                 buffer.append(0, ": ", header_style);
             }
             for &(ref text, _) in msg.iter() {
@@ -1548,11 +1542,9 @@ fn emit_suggestion_default(
         let mut buffer = StyledBuffer::new();
 
         // Render the suggestion message
-        let level_str = level.to_string();
-        if !level_str.is_empty() {
-            buffer.append(0, &level_str, Style::Level(*level));
-            buffer.append(0, ": ", Style::HeaderMsg);
-        }
+        buffer.append(0, level.to_str(), Style::Level(*level));
+        buffer.append(0, ": ", Style::HeaderMsg);
+
         self.msg_to_buffer(
             &mut buffer,
             &[(suggestion.msg.to_owned(), Style::NoStyle)],