about summary refs log tree commit diff
path: root/src/librustc_errors
diff options
context:
space:
mode:
authorPhilipp Hansch <dev@phansch.net>2019-06-03 07:38:19 +0200
committerPhilipp Hansch <dev@phansch.net>2019-06-04 18:46:00 +0200
commit4a6b91cd66e7293af2ff4120b510fab1818b45cf (patch)
tree4c92732910c5dfdd748acec12aacdeffe167c332 /src/librustc_errors
parent94c8aa67917fe053c9d03d5be22ded221c0a5241 (diff)
downloadrust-4a6b91cd66e7293af2ff4120b510fab1818b45cf.tar.gz
rust-4a6b91cd66e7293af2ff4120b510fab1818b45cf.zip
Simplify source_string and block-format methods
Diffstat (limited to 'src/librustc_errors')
-rw-r--r--src/librustc_errors/annotate_rs_emitter.rs27
1 files changed, 13 insertions, 14 deletions
diff --git a/src/librustc_errors/annotate_rs_emitter.rs b/src/librustc_errors/annotate_rs_emitter.rs
index a5699035dea..f3c55ae79f7 100644
--- a/src/librustc_errors/annotate_rs_emitter.rs
+++ b/src/librustc_errors/annotate_rs_emitter.rs
@@ -138,13 +138,11 @@ impl<'a>  DiagnosticConverter<'a> {
     }
 
     /// Provides the source string for the given `line` of `file`
-    fn source_string(file: Lrc<SourceFile>,
-                     line: &Line) -> String {
-        let source_string = match file.get_line(line.line_index - 1) {
-            Some(s) => s.clone(),
-            None => return String::new(),
-        };
-        source_string.to_string()
+    fn source_string(
+        file: Lrc<SourceFile>,
+        line: &Line
+    ) -> String {
+        file.get_line(line.line_index - 1).map(|a| a.to_string()).unwrap_or(String::new())
     }
 
     /// Maps `Diagnostic::Level` to `snippet::AnnotationType`
@@ -184,13 +182,14 @@ impl AnnotateRsEmitterWriter {
         self
     }
 
-    fn emit_messages_default(&mut self,
-                             level: &Level,
-                             message: String,
-                             code: &Option<DiagnosticId>,
-                             msp: &MultiSpan,
-                             children: &[SubDiagnostic],
-                             suggestions: &[CodeSuggestion]
+    fn emit_messages_default(
+        &mut self,
+        level: &Level,
+        message: String,
+        code: &Option<DiagnosticId>,
+        msp: &MultiSpan,
+        children: &[SubDiagnostic],
+        suggestions: &[CodeSuggestion]
     ) {
         let converter = DiagnosticConverter {
             source_map: self.source_map.clone(),