Minor visibility and formatting improvements.
This commit is contained in:
parent
c475e2303b
commit
c1f01638af
3 changed files with 20 additions and 15 deletions
|
@ -130,8 +130,8 @@ impl Margin {
|
||||||
fn was_cut_right(&self, line_len: usize) -> bool {
|
fn was_cut_right(&self, line_len: usize) -> bool {
|
||||||
let right =
|
let right =
|
||||||
if self.computed_right == self.span_right || self.computed_right == self.label_right {
|
if self.computed_right == self.span_right || self.computed_right == self.label_right {
|
||||||
// Account for the "..." padding given above. Otherwise we end up with code lines that
|
// Account for the "..." padding given above. Otherwise we end up with code lines
|
||||||
// do fit but end in "..." as if they were trimmed.
|
// that do fit but end in "..." as if they were trimmed.
|
||||||
self.computed_right - 6
|
self.computed_right - 6
|
||||||
} else {
|
} else {
|
||||||
self.computed_right
|
self.computed_right
|
||||||
|
@ -657,9 +657,9 @@ pub struct HumanEmitter {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct FileWithAnnotatedLines {
|
pub(crate) struct FileWithAnnotatedLines {
|
||||||
pub file: Lrc<SourceFile>,
|
pub(crate) file: Lrc<SourceFile>,
|
||||||
pub lines: Vec<Line>,
|
pub(crate) lines: Vec<Line>,
|
||||||
multiline_depth: usize,
|
multiline_depth: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -724,8 +724,9 @@ impl HumanEmitter {
|
||||||
.skip(left)
|
.skip(left)
|
||||||
.take_while(|ch| {
|
.take_while(|ch| {
|
||||||
// Make sure that the trimming on the right will fall within the terminal width.
|
// Make sure that the trimming on the right will fall within the terminal width.
|
||||||
// FIXME: `unicode_width` sometimes disagrees with terminals on how wide a `char` is.
|
// FIXME: `unicode_width` sometimes disagrees with terminals on how wide a `char`
|
||||||
// For now, just accept that sometimes the code line will be longer than desired.
|
// is. For now, just accept that sometimes the code line will be longer than
|
||||||
|
// desired.
|
||||||
let next = unicode_width::UnicodeWidthChar::width(*ch).unwrap_or(1);
|
let next = unicode_width::UnicodeWidthChar::width(*ch).unwrap_or(1);
|
||||||
if taken + next > right - left {
|
if taken + next > right - left {
|
||||||
return false;
|
return false;
|
||||||
|
@ -2228,8 +2229,8 @@ impl HumanEmitter {
|
||||||
buffer.puts(*row_num - 1, max_line_num_len + 3, &line, Style::NoStyle);
|
buffer.puts(*row_num - 1, max_line_num_len + 3, &line, Style::NoStyle);
|
||||||
*row_num += 1;
|
*row_num += 1;
|
||||||
}
|
}
|
||||||
// If the last line is exactly equal to the line we need to add, we can skip both of them.
|
// If the last line is exactly equal to the line we need to add, we can skip both of
|
||||||
// This allows us to avoid output like the following:
|
// them. This allows us to avoid output like the following:
|
||||||
// 2 - &
|
// 2 - &
|
||||||
// 2 + if true { true } else { false }
|
// 2 + if true { true } else { false }
|
||||||
// 3 - if true { true } else { false }
|
// 3 - if true { true } else { false }
|
||||||
|
@ -2586,6 +2587,7 @@ fn num_overlap(
|
||||||
let extra = if inclusive { 1 } else { 0 };
|
let extra = if inclusive { 1 } else { 0 };
|
||||||
(b_start..b_end + extra).contains(&a_start) || (a_start..a_end + extra).contains(&b_start)
|
(b_start..b_end + extra).contains(&a_start) || (a_start..a_end + extra).contains(&b_start)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn overlaps(a1: &Annotation, a2: &Annotation, padding: usize) -> bool {
|
fn overlaps(a1: &Annotation, a2: &Annotation, padding: usize) -> bool {
|
||||||
num_overlap(
|
num_overlap(
|
||||||
a1.start_col.display,
|
a1.start_col.display,
|
||||||
|
|
|
@ -23,9 +23,11 @@ impl<'args> TranslateError<'args> {
|
||||||
pub fn message(id: &'args Cow<'args, str>, args: &'args FluentArgs<'args>) -> Self {
|
pub fn message(id: &'args Cow<'args, str>, args: &'args FluentArgs<'args>) -> Self {
|
||||||
Self::One { id, args, kind: TranslateErrorKind::MessageMissing }
|
Self::One { id, args, kind: TranslateErrorKind::MessageMissing }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn primary(id: &'args Cow<'args, str>, args: &'args FluentArgs<'args>) -> Self {
|
pub fn primary(id: &'args Cow<'args, str>, args: &'args FluentArgs<'args>) -> Self {
|
||||||
Self::One { id, args, kind: TranslateErrorKind::PrimaryBundleMissing }
|
Self::One { id, args, kind: TranslateErrorKind::PrimaryBundleMissing }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn attribute(
|
pub fn attribute(
|
||||||
id: &'args Cow<'args, str>,
|
id: &'args Cow<'args, str>,
|
||||||
args: &'args FluentArgs<'args>,
|
args: &'args FluentArgs<'args>,
|
||||||
|
@ -33,6 +35,7 @@ impl<'args> TranslateError<'args> {
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self::One { id, args, kind: TranslateErrorKind::AttributeMissing { attr } }
|
Self::One { id, args, kind: TranslateErrorKind::AttributeMissing { attr } }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn value(id: &'args Cow<'args, str>, args: &'args FluentArgs<'args>) -> Self {
|
pub fn value(id: &'args Cow<'args, str>, args: &'args FluentArgs<'args>) -> Self {
|
||||||
Self::One { id, args, kind: TranslateErrorKind::ValueMissing }
|
Self::One { id, args, kind: TranslateErrorKind::ValueMissing }
|
||||||
}
|
}
|
||||||
|
|
|
@ -217,10 +217,10 @@ impl CodeSuggestion {
|
||||||
|
|
||||||
use rustc_span::{CharPos, Pos};
|
use rustc_span::{CharPos, Pos};
|
||||||
|
|
||||||
/// Extracts a substring from the provided `line_opt` based on the specified low and high indices,
|
/// Extracts a substring from the provided `line_opt` based on the specified low and high
|
||||||
/// appends it to the given buffer `buf`, and returns the count of newline characters in the substring
|
/// indices, appends it to the given buffer `buf`, and returns the count of newline
|
||||||
/// for accurate highlighting.
|
/// characters in the substring for accurate highlighting. If `line_opt` is `None`, a
|
||||||
/// If `line_opt` is `None`, a newline character is appended to the buffer, and 0 is returned.
|
/// newline character is appended to the buffer, and 0 is returned.
|
||||||
///
|
///
|
||||||
/// ## Returns
|
/// ## Returns
|
||||||
///
|
///
|
||||||
|
@ -486,8 +486,8 @@ struct DiagCtxtInner {
|
||||||
/// have been converted.
|
/// have been converted.
|
||||||
check_unstable_expect_diagnostics: bool,
|
check_unstable_expect_diagnostics: bool,
|
||||||
|
|
||||||
/// Expected [`DiagInner`][struct@diagnostic::DiagInner]s store a [`LintExpectationId`] as part of
|
/// Expected [`DiagInner`][struct@diagnostic::DiagInner]s store a [`LintExpectationId`] as part
|
||||||
/// the lint level. [`LintExpectationId`]s created early during the compilation
|
/// of the lint level. [`LintExpectationId`]s created early during the compilation
|
||||||
/// (before `HirId`s have been defined) are not stable and can therefore not be
|
/// (before `HirId`s have been defined) are not stable and can therefore not be
|
||||||
/// stored on disk. This buffer stores these diagnostics until the ID has been
|
/// stored on disk. This buffer stores these diagnostics until the ID has been
|
||||||
/// replaced by a stable [`LintExpectationId`]. The [`DiagInner`][struct@diagnostic::DiagInner]s
|
/// replaced by a stable [`LintExpectationId`]. The [`DiagInner`][struct@diagnostic::DiagInner]s
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue