diff options
| author | AnthonyMikh <anthony.mikh@yandex.ru> | 2019-10-01 01:08:51 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-10-01 01:08:51 +0300 |
| commit | 55b54285c811b6ab12bb0ba001126fd5b7d3bd09 (patch) | |
| tree | bc3af9f193ad0c1daf122a45427f3e95fd3614d8 /src/librustc_errors | |
| parent | 9d73176978c1eece320fe7786d7f66db2bbb6838 (diff) | |
Simplify a conditional in `collect_annotations`
Also avoid excessive cloning
Diffstat (limited to 'src/librustc_errors')
| -rw-r--r-- | src/librustc_errors/emitter.rs | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/src/librustc_errors/emitter.rs b/src/librustc_errors/emitter.rs index 0e384567846..d5e9d718430 100644 --- a/src/librustc_errors/emitter.rs +++ b/src/librustc_errors/emitter.rs @@ -1707,7 +1707,7 @@ impl FileWithAnnotatedLines { hi.col_display += 1; } - let ann_type = if lo.line != hi.line { + if lo.line != hi.line { let ml = MultilineAnnotation { depth: 1, line_start: lo.line, @@ -1715,25 +1715,20 @@ impl FileWithAnnotatedLines { start_col: lo.col_display, end_col: hi.col_display, is_primary: span_label.is_primary, - label: span_label.label.clone(), + label: span_label.label, overlaps_exactly: false, }; - multiline_annotations.push((lo.file.clone(), ml.clone())); - AnnotationType::Multiline(ml) + multiline_annotations.push((lo.file, ml)); } else { - AnnotationType::Singleline - }; - let ann = Annotation { - start_col: lo.col_display, - end_col: hi.col_display, - is_primary: span_label.is_primary, - label: span_label.label.clone(), - annotation_type: ann_type, - }; - - if !ann.is_multiline() { + let ann = Annotation { + start_col: lo.col_display, + end_col: hi.col_display, + is_primary: span_label.is_primary, + label: span_label.label, + annotation_type: AnnotationType::Singleline, + }; add_annotation_to_file(&mut output, lo.file, lo.line, ann); - } + }; } } |
