Minor visibility and formatting improvements.

This commit is contained in:
Nicholas Nethercote 2024-02-29 09:09:19 +11:00
parent c475e2303b
commit c1f01638af
3 changed files with 20 additions and 15 deletions

View file

@ -130,8 +130,8 @@ impl Margin {
fn was_cut_right(&self, line_len: usize) -> bool {
let 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
// do fit but end in "..." as if they were trimmed.
// Account for the "..." padding given above. Otherwise we end up with code lines
// that do fit but end in "..." as if they were trimmed.
self.computed_right - 6
} else {
self.computed_right
@ -657,9 +657,9 @@ pub struct HumanEmitter {
}
#[derive(Debug)]
pub struct FileWithAnnotatedLines {
pub file: Lrc<SourceFile>,
pub lines: Vec<Line>,
pub(crate) struct FileWithAnnotatedLines {
pub(crate) file: Lrc<SourceFile>,
pub(crate) lines: Vec<Line>,
multiline_depth: usize,
}
@ -724,8 +724,9 @@ impl HumanEmitter {
.skip(left)
.take_while(|ch| {
// 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.
// For now, just accept that sometimes the code line will be longer than desired.
// FIXME: `unicode_width` sometimes disagrees with terminals on how wide a `char`
// 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);
if taken + next > right - left {
return false;
@ -2228,8 +2229,8 @@ impl HumanEmitter {
buffer.puts(*row_num - 1, max_line_num_len + 3, &line, Style::NoStyle);
*row_num += 1;
}
// If the last line is exactly equal to the line we need to add, we can skip both of them.
// This allows us to avoid output like the following:
// If the last line is exactly equal to the line we need to add, we can skip both of
// them. This allows us to avoid output like the following:
// 2 - &
// 2 + 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 };
(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 {
num_overlap(
a1.start_col.display,

View file

@ -23,9 +23,11 @@ impl<'args> TranslateError<'args> {
pub fn message(id: &'args Cow<'args, str>, args: &'args FluentArgs<'args>) -> Self {
Self::One { id, args, kind: TranslateErrorKind::MessageMissing }
}
pub fn primary(id: &'args Cow<'args, str>, args: &'args FluentArgs<'args>) -> Self {
Self::One { id, args, kind: TranslateErrorKind::PrimaryBundleMissing }
}
pub fn attribute(
id: &'args Cow<'args, str>,
args: &'args FluentArgs<'args>,
@ -33,6 +35,7 @@ impl<'args> TranslateError<'args> {
) -> Self {
Self::One { id, args, kind: TranslateErrorKind::AttributeMissing { attr } }
}
pub fn value(id: &'args Cow<'args, str>, args: &'args FluentArgs<'args>) -> Self {
Self::One { id, args, kind: TranslateErrorKind::ValueMissing }
}

View file

@ -217,10 +217,10 @@ impl CodeSuggestion {
use rustc_span::{CharPos, Pos};
/// Extracts a substring from the provided `line_opt` based on the specified low and high indices,
/// appends it to the given buffer `buf`, and returns the count of newline characters in the substring
/// for accurate highlighting.
/// If `line_opt` is `None`, a newline character is appended to the buffer, and 0 is returned.
/// Extracts a substring from the provided `line_opt` based on the specified low and high
/// indices, appends it to the given buffer `buf`, and returns the count of newline
/// characters in the substring for accurate highlighting. If `line_opt` is `None`, a
/// newline character is appended to the buffer, and 0 is returned.
///
/// ## Returns
///
@ -486,8 +486,8 @@ struct DiagCtxtInner {
/// have been converted.
check_unstable_expect_diagnostics: bool,
/// Expected [`DiagInner`][struct@diagnostic::DiagInner]s store a [`LintExpectationId`] as part of
/// the lint level. [`LintExpectationId`]s created early during the compilation
/// Expected [`DiagInner`][struct@diagnostic::DiagInner]s store a [`LintExpectationId`] as part
/// 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
/// stored on disk. This buffer stores these diagnostics until the ID has been
/// replaced by a stable [`LintExpectationId`]. The [`DiagInner`][struct@diagnostic::DiagInner]s