tamer: diagnose::resolver::Column::At: Remove
This is redundant with the `Endpoints` variant, although it did read better. It's just another case to have to handle. I was originally going to use `std::ops::RangeInclusive` for `Endpoints`, however that struct also contains an extra bool indicating whether it was exhausted (as an iterator), which isn't appropriate for this. DEV-12151main
parent
ec93488365
commit
0928427116
|
@ -20,8 +20,8 @@
|
|||
//! Rendering of diagnostic information.
|
||||
|
||||
use super::{
|
||||
AnnotatedSpan, Diagnostic, Label, Level, ResolvedSpan,
|
||||
SpanResolver, SpanResolverError,
|
||||
AnnotatedSpan, Diagnostic, Label, Level, ResolvedSpan, SpanResolver,
|
||||
SpanResolverError,
|
||||
};
|
||||
use crate::span::{Context, Span, UNKNOWN_SPAN};
|
||||
use std::fmt::{self, Display, Write};
|
||||
|
|
|
@ -177,9 +177,6 @@ impl ResolvedSpan {
|
|||
/// with font rather than a byte offset.
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
|
||||
pub enum Column {
|
||||
/// A 1-indexed column number.
|
||||
At(NonZeroU32),
|
||||
|
||||
/// A range of 1-indexed columns, inclusive.
|
||||
Endpoints(NonZeroU32, NonZeroU32),
|
||||
|
||||
|
@ -196,9 +193,7 @@ impl Display for Column {
|
|||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
// Coerces to a single column number.
|
||||
Self::At(at) | Self::Endpoints(at, _) | Self::Before(at) => {
|
||||
Display::fmt(at, f)
|
||||
}
|
||||
Self::Endpoints(at, _) | Self::Before(at) => Display::fmt(at, f),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -631,10 +626,8 @@ impl Line {
|
|||
// Start will only be > end (by 1) if the span begins on a newline.
|
||||
if span.len() == 0 {
|
||||
Column::Before(col_start)
|
||||
} else if col_start >= col_end {
|
||||
Column::At(col_start)
|
||||
} else {
|
||||
Column::Endpoints(col_start, col_end)
|
||||
Column::Endpoints(col_start, col_end.max(col_start))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -119,7 +119,10 @@ fn last_byte_of_line() {
|
|||
span,
|
||||
lines: NonEmptyVec::new(vec![SourceLine {
|
||||
num: 3.unwrap_into(),
|
||||
column: Some(Column::At(6.unwrap_into(),)),
|
||||
column: Some(Column::Endpoints(
|
||||
6.unwrap_into(),
|
||||
6.unwrap_into()
|
||||
)),
|
||||
span: ctx.span(14, 6),
|
||||
text: "line 3".into(),
|
||||
}])
|
||||
|
@ -322,7 +325,10 @@ fn newline_between_lines() {
|
|||
span,
|
||||
lines: NonEmptyVec::new(vec![SourceLine {
|
||||
num: 2.unwrap_into(),
|
||||
column: Some(Column::At(7.unwrap_into())),
|
||||
column: Some(Column::Endpoints(
|
||||
7.unwrap_into(),
|
||||
7.unwrap_into()
|
||||
)),
|
||||
// Trailing newline _is not_ stripped since it was
|
||||
// explicitly referenced;
|
||||
// we don't want our line span to not contain the
|
||||
|
@ -744,7 +750,10 @@ fn at_invalid_char_boundary() {
|
|||
// Intuitively this really should be [2,4],
|
||||
// but the implementation shouldn't change to
|
||||
// accommodate this very unlikely case.
|
||||
column: Some(Column::At(4.unwrap_into(),)),
|
||||
column: Some(Column::Endpoints(
|
||||
4.unwrap_into(),
|
||||
4.unwrap_into()
|
||||
)),
|
||||
span: line_span,
|
||||
text: buf.clone().into(),
|
||||
}])
|
||||
|
@ -760,7 +769,10 @@ fn at_invalid_char_boundary() {
|
|||
num: 1.unwrap_into(),
|
||||
// Also unideal,
|
||||
// but see comment for previous assertion.
|
||||
column: Some(Column::At(4.unwrap_into(),)),
|
||||
column: Some(Column::Endpoints(
|
||||
4.unwrap_into(),
|
||||
4.unwrap_into()
|
||||
)),
|
||||
span: line_span,
|
||||
text: buf.clone().into(),
|
||||
}])
|
||||
|
|
Loading…
Reference in New Issue