about summary refs log tree commit diff
path: root/compiler/rustc_errors/src
diff options
context:
space:
mode:
authorJuan Aguilar Santillana <mhpoin@gmail.com>2020-09-17 10:27:04 +0000
committerJuan Aguilar Santillana <mhpoin@gmail.com>2020-09-17 10:27:04 +0000
commit7b5d9836c47509e16900a274ed0b552a2e30a36a (patch)
treeb67eb6a22f8376ec7653a87a1b020b42e97ef54e /compiler/rustc_errors/src
parent7bdb5dee7bac15458b10b148e9e24968e633053e (diff)
downloadrust-7b5d9836c47509e16900a274ed0b552a2e30a36a.tar.gz
rust-7b5d9836c47509e16900a274ed0b552a2e30a36a.zip
Remove redundant to_string
Diffstat (limited to 'compiler/rustc_errors/src')
-rw-r--r--compiler/rustc_errors/src/emitter.rs22
1 files changed, 8 insertions, 14 deletions
diff --git a/compiler/rustc_errors/src/emitter.rs b/compiler/rustc_errors/src/emitter.rs
index 4555168af0a..98cbf98df92 100644
--- a/compiler/rustc_errors/src/emitter.rs
+++ b/compiler/rustc_errors/src/emitter.rs
@@ -1227,18 +1227,14 @@ impl EmitterWriter {
             }
             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 +1242,7 @@ impl EmitterWriter {
                 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 +1544,9 @@ impl EmitterWriter {
         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)],