Skip to content

Commit 1389caf

Browse files
authored
Rollup merge of rust-lang#68096 - varkor:diagnostic-cleanup, r=Centril
Clean up some diagnostics by making them more consistent In general: - Diagnostic should start with a lowercase letter. - Diagnostics should not end with a full stop. - Ellipses contain three dots. - Backticks should encode Rust code. I also reworded a couple of messages to make them read more clearly. It might be sensible to create a style guide for diagnostics, so these informal conventions are written down somewhere, after which we could audit the existing diagnostics. r? @Centril
2 parents 6b83862 + 1faa05d commit 1389caf

File tree

95 files changed

+294
-292
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+294
-292
lines changed

src/libcore/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
// Here we explicitly #[cfg]-out this whole crate when testing. If we don't do
4545
// this, both the generated test artifact and the linked libtest (which
4646
// transitively includes libcore) will both define the same set of lang items,
47-
// and this will cause the E0152 "duplicate lang item found" error. See
47+
// and this will cause the E0152 "found duplicate lang item" error. See
4848
// discussion in #50466 for details.
4949
//
5050
// This cfg won't affect doc tests.

src/librustc/middle/lang_items.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ impl LanguageItemCollector<'tcx> {
184184
self.tcx.sess,
185185
span,
186186
E0152,
187-
"duplicate lang item found: `{}`.",
187+
"found duplicate lang item `{}`",
188188
name
189189
),
190190
None => {
@@ -206,12 +206,12 @@ impl LanguageItemCollector<'tcx> {
206206
},
207207
};
208208
if let Some(span) = self.tcx.hir().span_if_local(original_def_id) {
209-
err.span_note(span, "first defined here.");
209+
err.span_note(span, "first defined here");
210210
} else {
211211
match self.tcx.extern_crate(original_def_id) {
212212
Some(ExternCrate {dependency_of, ..}) => {
213213
err.note(&format!(
214-
"first defined in crate `{}` (which `{}` depends on).",
214+
"first defined in crate `{}` (which `{}` depends on)",
215215
self.tcx.crate_name(original_def_id.krate),
216216
self.tcx.crate_name(*dependency_of)));
217217
},

src/librustc/traits/error_reporting.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1156,7 +1156,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
11561156
err.span_help(impl_span, "trait impl with same name found");
11571157
let trait_crate = self.tcx.crate_name(trait_with_same_path.krate);
11581158
let crate_msg = format!(
1159-
"Perhaps two different versions of crate `{}` are being used?",
1159+
"perhaps two different versions of crate `{}` are being used?",
11601160
trait_crate
11611161
);
11621162
err.note(&crate_msg);

src/librustc_ast_passes/feature_gate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
413413
self.check_extern(bare_fn_ty.ext);
414414
}
415415
ast::TyKind::Never => {
416-
gate_feature_post!(&self, never_type, ty.span, "The `!` type is experimental");
416+
gate_feature_post!(&self, never_type, ty.span, "the `!` type is experimental");
417417
}
418418
_ => {}
419419
}

src/librustc_builtin_macros/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ fn should_panic(cx: &ExtCtxt<'_>, i: &ast::Item) -> ShouldPanic {
325325
`expected = \"error message\"`",
326326
)
327327
.note(
328-
"Errors in this attribute were erroneously \
328+
"errors in this attribute were erroneously \
329329
allowed and will become a hard error in a \
330330
future release.",
331331
)

src/librustc_lint/builtin.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ impl EarlyLintPass for AnonymousParameters {
657657
)
658658
.span_suggestion(
659659
arg.pat.span,
660-
"Try naming the parameter or explicitly \
660+
"try naming the parameter or explicitly \
661661
ignoring it",
662662
format!("_: {}", ty_snip),
663663
appl,
@@ -1934,21 +1934,21 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidValue {
19341934
use rustc::ty::TyKind::*;
19351935
match ty.kind {
19361936
// Primitive types that don't like 0 as a value.
1937-
Ref(..) => Some((format!("References must be non-null"), None)),
1937+
Ref(..) => Some((format!("references must be non-null"), None)),
19381938
Adt(..) if ty.is_box() => Some((format!("`Box` must be non-null"), None)),
1939-
FnPtr(..) => Some((format!("Function pointers must be non-null"), None)),
1940-
Never => Some((format!("The never type (`!`) has no valid value"), None)),
1939+
FnPtr(..) => Some((format!("function pointers must be non-null"), None)),
1940+
Never => Some((format!("the `!` type has no valid value"), None)),
19411941
RawPtr(tm) if matches!(tm.ty.kind, Dynamic(..)) =>
19421942
// raw ptr to dyn Trait
19431943
{
1944-
Some((format!("The vtable of a wide raw pointer must be non-null"), None))
1944+
Some((format!("the vtable of a wide raw pointer must be non-null"), None))
19451945
}
19461946
// Primitive types with other constraints.
19471947
Bool if init == InitKind::Uninit => {
1948-
Some((format!("Booleans must be `true` or `false`"), None))
1948+
Some((format!("booleans must be either `true` or `false`"), None))
19491949
}
19501950
Char if init == InitKind::Uninit => {
1951-
Some((format!("Characters must be a valid unicode codepoint"), None))
1951+
Some((format!("characters must be a valid Unicode codepoint"), None))
19521952
}
19531953
// Recurse and checks for some compound types.
19541954
Adt(adt_def, substs) if !adt_def.is_union() => {
@@ -1959,21 +1959,24 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidValue {
19591959
// return `Bound::Excluded`. (And we have tests checking that we
19601960
// handle the attribute correctly.)
19611961
(Bound::Included(lo), _) if lo > 0 => {
1962-
return Some((format!("{} must be non-null", ty), None));
1962+
return Some((format!("`{}` must be non-null", ty), None));
19631963
}
19641964
(Bound::Included(_), _) | (_, Bound::Included(_))
19651965
if init == InitKind::Uninit =>
19661966
{
19671967
return Some((
1968-
format!("{} must be initialized inside its custom valid range", ty),
1968+
format!(
1969+
"`{}` must be initialized inside its custom valid range",
1970+
ty,
1971+
),
19691972
None,
19701973
));
19711974
}
19721975
_ => {}
19731976
}
19741977
// Now, recurse.
19751978
match adt_def.variants.len() {
1976-
0 => Some((format!("0-variant enums have no valid value"), None)),
1979+
0 => Some((format!("enums with no variants have no valid value"), None)),
19771980
1 => {
19781981
// Struct, or enum with exactly one variant.
19791982
// Proceed recursively, check all fields.

src/librustc_mir/borrow_check/nll.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ pub(super) fn dump_annotation<'a, 'tcx>(
360360
// better.
361361

362362
if let Some(closure_region_requirements) = closure_region_requirements {
363-
let mut err = tcx.sess.diagnostic().span_note_diag(body.span, "External requirements");
363+
let mut err = tcx.sess.diagnostic().span_note_diag(body.span, "external requirements");
364364

365365
regioncx.annotate(tcx, &mut err);
366366

@@ -379,7 +379,7 @@ pub(super) fn dump_annotation<'a, 'tcx>(
379379

380380
err.buffer(errors_buffer);
381381
} else {
382-
let mut err = tcx.sess.diagnostic().span_note_diag(body.span, "No external requirements");
382+
let mut err = tcx.sess.diagnostic().span_note_diag(body.span, "no external requirements");
383383
regioncx.annotate(tcx, &mut err);
384384

385385
err.buffer(errors_buffer);

src/librustc_parse/parser/attr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,8 @@ impl<'a> Parser<'a> {
236236
self.struct_span_err(lit.span, msg)
237237
.help(
238238
"instead of using a suffixed literal \
239-
(1u8, 1.0f32, etc.), use an unsuffixed version \
240-
(1, 1.0, etc.).",
239+
(`1u8`, `1.0f32`, etc.), use an unsuffixed version \
240+
(`1`, `1.0`, etc.)",
241241
)
242242
.emit()
243243
}

src/librustc_parse/parser/pat.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,13 +209,13 @@ impl<'a> Parser<'a> {
209209
if let Ok(seq_snippet) = self.span_to_snippet(seq_span) {
210210
err.span_suggestion(
211211
seq_span,
212-
"try adding parentheses to match on a tuple..",
212+
"try adding parentheses to match on a tuple...",
213213
format!("({})", seq_snippet),
214214
Applicability::MachineApplicable,
215215
)
216216
.span_suggestion(
217217
seq_span,
218-
"..or a vertical bar to match on multiple alternatives",
218+
"...or a vertical bar to match on multiple alternatives",
219219
format!("{}", seq_snippet.replace(",", " |")),
220220
Applicability::MachineApplicable,
221221
);

src/librustc_passes/diagnostic_items.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ fn collect_item(
7373
)),
7474
};
7575
if let Some(span) = tcx.hir().span_if_local(original_def_id) {
76-
err.span_note(span, "first defined here.");
76+
err.span_note(span, "first defined here");
7777
} else {
7878
err.note(&format!(
7979
"first defined in crate `{}`.",

0 commit comments

Comments
 (0)