Skip to content

Commit c1f0163

Browse files
committed
Minor visibility and formatting improvements.
1 parent c475e23 commit c1f0163

File tree

3 files changed

+20
-15
lines changed

3 files changed

+20
-15
lines changed

compiler/rustc_errors/src/emitter.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ impl Margin {
130130
fn was_cut_right(&self, line_len: usize) -> bool {
131131
let right =
132132
if self.computed_right == self.span_right || self.computed_right == self.label_right {
133-
// Account for the "..." padding given above. Otherwise we end up with code lines that
134-
// do fit but end in "..." as if they were trimmed.
133+
// Account for the "..." padding given above. Otherwise we end up with code lines
134+
// that do fit but end in "..." as if they were trimmed.
135135
self.computed_right - 6
136136
} else {
137137
self.computed_right
@@ -657,9 +657,9 @@ pub struct HumanEmitter {
657657
}
658658

659659
#[derive(Debug)]
660-
pub struct FileWithAnnotatedLines {
661-
pub file: Lrc<SourceFile>,
662-
pub lines: Vec<Line>,
660+
pub(crate) struct FileWithAnnotatedLines {
661+
pub(crate) file: Lrc<SourceFile>,
662+
pub(crate) lines: Vec<Line>,
663663
multiline_depth: usize,
664664
}
665665

@@ -724,8 +724,9 @@ impl HumanEmitter {
724724
.skip(left)
725725
.take_while(|ch| {
726726
// Make sure that the trimming on the right will fall within the terminal width.
727-
// FIXME: `unicode_width` sometimes disagrees with terminals on how wide a `char` is.
728-
// For now, just accept that sometimes the code line will be longer than desired.
727+
// FIXME: `unicode_width` sometimes disagrees with terminals on how wide a `char`
728+
// is. For now, just accept that sometimes the code line will be longer than
729+
// desired.
729730
let next = unicode_width::UnicodeWidthChar::width(*ch).unwrap_or(1);
730731
if taken + next > right - left {
731732
return false;
@@ -2228,8 +2229,8 @@ impl HumanEmitter {
22282229
buffer.puts(*row_num - 1, max_line_num_len + 3, &line, Style::NoStyle);
22292230
*row_num += 1;
22302231
}
2231-
// If the last line is exactly equal to the line we need to add, we can skip both of them.
2232-
// This allows us to avoid output like the following:
2232+
// If the last line is exactly equal to the line we need to add, we can skip both of
2233+
// them. This allows us to avoid output like the following:
22332234
// 2 - &
22342235
// 2 + if true { true } else { false }
22352236
// 3 - if true { true } else { false }
@@ -2586,6 +2587,7 @@ fn num_overlap(
25862587
let extra = if inclusive { 1 } else { 0 };
25872588
(b_start..b_end + extra).contains(&a_start) || (a_start..a_end + extra).contains(&b_start)
25882589
}
2590+
25892591
fn overlaps(a1: &Annotation, a2: &Annotation, padding: usize) -> bool {
25902592
num_overlap(
25912593
a1.start_col.display,

compiler/rustc_errors/src/error.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,19 @@ impl<'args> TranslateError<'args> {
2323
pub fn message(id: &'args Cow<'args, str>, args: &'args FluentArgs<'args>) -> Self {
2424
Self::One { id, args, kind: TranslateErrorKind::MessageMissing }
2525
}
26+
2627
pub fn primary(id: &'args Cow<'args, str>, args: &'args FluentArgs<'args>) -> Self {
2728
Self::One { id, args, kind: TranslateErrorKind::PrimaryBundleMissing }
2829
}
30+
2931
pub fn attribute(
3032
id: &'args Cow<'args, str>,
3133
args: &'args FluentArgs<'args>,
3234
attr: &'args str,
3335
) -> Self {
3436
Self::One { id, args, kind: TranslateErrorKind::AttributeMissing { attr } }
3537
}
38+
3639
pub fn value(id: &'args Cow<'args, str>, args: &'args FluentArgs<'args>) -> Self {
3740
Self::One { id, args, kind: TranslateErrorKind::ValueMissing }
3841
}

compiler/rustc_errors/src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -217,10 +217,10 @@ impl CodeSuggestion {
217217

218218
use rustc_span::{CharPos, Pos};
219219

220-
/// Extracts a substring from the provided `line_opt` based on the specified low and high indices,
221-
/// appends it to the given buffer `buf`, and returns the count of newline characters in the substring
222-
/// for accurate highlighting.
223-
/// If `line_opt` is `None`, a newline character is appended to the buffer, and 0 is returned.
220+
/// Extracts a substring from the provided `line_opt` based on the specified low and high
221+
/// indices, appends it to the given buffer `buf`, and returns the count of newline
222+
/// characters in the substring for accurate highlighting. If `line_opt` is `None`, a
223+
/// newline character is appended to the buffer, and 0 is returned.
224224
///
225225
/// ## Returns
226226
///
@@ -486,8 +486,8 @@ struct DiagCtxtInner {
486486
/// have been converted.
487487
check_unstable_expect_diagnostics: bool,
488488

489-
/// Expected [`DiagInner`][struct@diagnostic::DiagInner]s store a [`LintExpectationId`] as part of
490-
/// the lint level. [`LintExpectationId`]s created early during the compilation
489+
/// Expected [`DiagInner`][struct@diagnostic::DiagInner]s store a [`LintExpectationId`] as part
490+
/// of the lint level. [`LintExpectationId`]s created early during the compilation
491491
/// (before `HirId`s have been defined) are not stable and can therefore not be
492492
/// stored on disk. This buffer stores these diagnostics until the ID has been
493493
/// replaced by a stable [`LintExpectationId`]. The [`DiagInner`][struct@diagnostic::DiagInner]s

0 commit comments

Comments
 (0)