about summary refs log tree commit diff
path: root/src/librustc_errors
diff options
context:
space:
mode:
authorAnthonyMikh <anthony.mikh@yandex.ru>2019-09-25 23:41:27 +0300
committerGitHub <noreply@github.com>2019-09-25 23:41:27 +0300
commitaef169b4e637fe417f05fa50450b90e403023a5f (patch)
treeb7fd6dc81a62f343ed77cb5beddab350bf80cc10 /src/librustc_errors
parentd6327e8f12cc51254d62e6755f67ea580fc4dd21 (diff)
downloadrust-aef169b4e637fe417f05fa50450b90e403023a5f.tar.gz
rust-aef169b4e637fe417f05fa50450b90e403023a5f.zip
Use Option::map_or where applicable
Diffstat (limited to 'src/librustc_errors')
-rw-r--r--src/librustc_errors/emitter.rs11
1 files changed, 3 insertions, 8 deletions
diff --git a/src/librustc_errors/emitter.rs b/src/librustc_errors/emitter.rs
index 17a5fac6da7..61bd4899f3c 100644
--- a/src/librustc_errors/emitter.rs
+++ b/src/librustc_errors/emitter.rs
@@ -764,11 +764,7 @@ impl EmitterWriter {
             annotations_position.push((p, annotation));
             for (j, next) in annotations.iter().enumerate() {
                 if j > i  {
-                    let l = if let Some(ref label) = next.label {
-                        label.len() + 2
-                    } else {
-                        0
-                    };
+                    let l = next.label.map_or(0, |label| label.len() + 2);
                     if (overlaps(next, annotation, l) // Do not allow two labels to be in the same
                                                      // line if they overlap including padding, to
                                                      // avoid situations like:
@@ -1311,13 +1307,12 @@ impl EmitterWriter {
                 for line in &annotated_file.lines {
                     max_line_len = max(max_line_len, annotated_file.file
                         .get_line(line.line_index - 1)
-                        .map(|s| s.len())
-                        .unwrap_or(0));
+                        .map_or(0, |s| s.len());
                     for ann in &line.annotations {
                         span_right_margin = max(span_right_margin, ann.start_col);
                         span_right_margin = max(span_right_margin, ann.end_col);
                         // FIXME: account for labels not in the same line
-                        let label_right = ann.label.as_ref().map(|l| l.len() + 1).unwrap_or(0);
+                        let label_right = ann.label.as_ref().map_or(0, |l| l.len() + 1);
                         label_right_margin = max(label_right_margin, ann.end_col + label_right);
                     }
                 }