X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Flibrustc_errors%2Fsnippet.rs;h=a39e19f0bf75b5dfe15cf80218ce9c950ac8df0f;hb=e7752aefdc0765f9350cbe5d563d6f46f9045e26;hp=47ba22d3d25aff6ebff6f6ee702bd1e4955df812;hpb=bfe9080ea023927f2a047a3b23ec579188c63b7d;p=rust.git diff --git a/src/librustc_errors/snippet.rs b/src/librustc_errors/snippet.rs index 47ba22d3d25..a39e19f0bf7 100644 --- a/src/librustc_errors/snippet.rs +++ b/src/librustc_errors/snippet.rs @@ -8,7 +8,6 @@ pub struct Line { pub annotations: Vec, } - #[derive(Clone, Debug, PartialOrd, Ord, PartialEq, Eq)] pub struct MultilineAnnotation { pub depth: usize, @@ -28,8 +27,10 @@ pub fn increase_depth(&mut self) { /// Compare two `MultilineAnnotation`s considering only the `Span` they cover. pub fn same_span(&self, other: &MultilineAnnotation) -> bool { - self.line_start == other.line_start && self.line_end == other.line_end - && self.start_col == other.start_col && self.end_col == other.end_col + self.line_start == other.line_start + && self.line_end == other.line_end + && self.start_col == other.start_col + && self.end_col == other.end_col } pub fn as_start(&self) -> Annotation { @@ -38,7 +39,7 @@ pub fn as_start(&self) -> Annotation { end_col: self.start_col + 1, is_primary: self.is_primary, label: None, - annotation_type: AnnotationType::MultilineStart(self.depth) + annotation_type: AnnotationType::MultilineStart(self.depth), } } @@ -48,7 +49,7 @@ pub fn as_end(&self) -> Annotation { end_col: self.end_col, is_primary: self.is_primary, label: self.label.clone(), - annotation_type: AnnotationType::MultilineEnd(self.depth) + annotation_type: AnnotationType::MultilineEnd(self.depth), } } @@ -58,7 +59,7 @@ pub fn as_line(&self) -> Annotation { end_col: 0, is_primary: self.is_primary, label: None, - annotation_type: AnnotationType::MultilineLine(self.depth) + annotation_type: AnnotationType::MultilineLine(self.depth), } } } @@ -117,19 +118,15 @@ pub struct Annotation { impl Annotation { /// Whether this annotation is a vertical line placeholder. pub fn is_line(&self) -> bool { - if let AnnotationType::MultilineLine(_) = self.annotation_type { - true - } else { - false - } + if let AnnotationType::MultilineLine(_) = self.annotation_type { true } else { false } } pub fn is_multiline(&self) -> bool { match self.annotation_type { - AnnotationType::Multiline(_) | - AnnotationType::MultilineStart(_) | - AnnotationType::MultilineLine(_) | - AnnotationType::MultilineEnd(_) => true, + AnnotationType::Multiline(_) + | AnnotationType::MultilineStart(_) + | AnnotationType::MultilineLine(_) + | AnnotationType::MultilineEnd(_) => true, _ => false, } } @@ -164,8 +161,7 @@ pub fn has_label(&self) -> bool { pub fn takes_space(&self) -> bool { // Multiline annotations always have to keep vertical space. match self.annotation_type { - AnnotationType::MultilineStart(_) | - AnnotationType::MultilineEnd(_) => true, + AnnotationType::MultilineStart(_) | AnnotationType::MultilineEnd(_) => true, _ => false, } }