Skip to content

Commit 098f48c

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 1abb7e9 + 6ea4dba commit 098f48c

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

+1-1
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

+3-3
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

+1-1
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

+1-1
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

+1-1
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

+13-10
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

+2-2
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

+2-2
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

+2-2
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

+1-1
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 `{}`.",

src/librustc_resolve/build_reduced_graph.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -963,7 +963,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
963963
.session
964964
.struct_span_err(
965965
attr.span,
966-
"`macro_use` is not supported on `extern crate self`",
966+
"`#[macro_use]` is not supported on `extern crate self`",
967967
)
968968
.emit();
969969
}
@@ -1054,10 +1054,10 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
10541054
fn contains_macro_use(&mut self, attrs: &[ast::Attribute]) -> bool {
10551055
for attr in attrs {
10561056
if attr.check_name(sym::macro_escape) {
1057-
let msg = "macro_escape is a deprecated synonym for macro_use";
1057+
let msg = "`#[macro_escape]` is a deprecated synonym for `#[macro_use]`";
10581058
let mut err = self.r.session.struct_span_warn(attr.span, msg);
10591059
if let ast::AttrStyle::Inner = attr.style {
1060-
err.help("consider an outer attribute, `#[macro_use]` mod ...").emit();
1060+
err.help("try an outer attribute: `#[macro_use]`").emit();
10611061
} else {
10621062
err.emit();
10631063
}
@@ -1066,7 +1066,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
10661066
}
10671067

10681068
if !attr.is_word() {
1069-
self.r.session.span_err(attr.span, "arguments to macro_use are not allowed here");
1069+
self.r.session.span_err(attr.span, "arguments to `macro_use` are not allowed here");
10701070
}
10711071
return true;
10721072
}

src/librustc_resolve/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2006,7 +2006,7 @@ impl<'a> Resolver<'a> {
20062006
continue;
20072007
}
20082008
}
2009-
let msg = "there are too many initial `super`s.".to_string();
2009+
let msg = "there are too many leading `super` keywords".to_string();
20102010
return PathResult::Failed {
20112011
span: ident.span,
20122012
label: msg,

src/librustc_typeck/check/cast.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ impl<'a, 'tcx> CastCheck<'tcx> {
381381
if unknown_cast_to { "to" } else { "from" }
382382
);
383383
err.note(
384-
"The type information given here is insufficient to check whether \
384+
"the type information given here is insufficient to check whether \
385385
the pointer cast is valid",
386386
);
387387
if unknown_cast_to {

src/librustc_typeck/check/method/suggest.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
479479
macro_rules! report_function {
480480
($span:expr, $name:expr) => {
481481
err.note(&format!(
482-
"{} is a function, perhaps you wish to call it",
482+
"`{}` is a function, perhaps you wish to call it",
483483
$name
484484
));
485485
};

src/librustc_typeck/check/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1664,7 +1664,7 @@ fn check_opaque_for_cycles<'tcx>(
16641664
if let hir::OpaqueTyOrigin::AsyncFn = origin {
16651665
struct_span_err!(tcx.sess, span, E0733, "recursion in an `async fn` requires boxing",)
16661666
.span_label(span, "recursive `async fn`")
1667-
.note("a recursive `async fn` must be rewritten to return a boxed `dyn Future`.")
1667+
.note("a recursive `async fn` must be rewritten to return a boxed `dyn Future`")
16681668
.emit();
16691669
} else {
16701670
let mut err =

src/libstd/panicking.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ fn default_hook(info: &PanicInfo<'_>) {
199199
let _ = writeln!(
200200
err,
201201
"note: run with `RUST_BACKTRACE=1` \
202-
environment variable to display a backtrace."
202+
environment variable to display a backtrace"
203203
);
204204
}
205205
}

src/test/compile-fail/panic-handler-twice.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use core::panic::PanicInfo;
1010

1111
#[panic_handler]
1212
fn panic(info: &PanicInfo) -> ! {
13-
//~^ error duplicate lang item found: `panic_impl`
13+
//~^ ERROR found duplicate lang item `panic_impl`
1414
loop {}
1515
}
1616

src/test/run-make-fulldeps/libtest-json/output-default.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{ "type": "test", "event": "started", "name": "a" }
33
{ "type": "test", "name": "a", "event": "ok" }
44
{ "type": "test", "event": "started", "name": "b" }
5-
{ "type": "test", "name": "b", "event": "failed", "stdout": "thread 'main' panicked at 'assertion failed: false', f.rs:9:5\nnote: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.\n" }
5+
{ "type": "test", "name": "b", "event": "failed", "stdout": "thread 'main' panicked at 'assertion failed: false', f.rs:9:5\nnote: run with `RUST_BACKTRACE=1` environment variable to display a backtrace\n" }
66
{ "type": "test", "event": "started", "name": "c" }
77
{ "type": "test", "name": "c", "event": "ok" }
88
{ "type": "test", "event": "started", "name": "d" }

src/test/run-make-fulldeps/libtest-json/output-stdout-success.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{ "type": "test", "event": "started", "name": "a" }
33
{ "type": "test", "name": "a", "event": "ok", "stdout": "print from successful test\n" }
44
{ "type": "test", "event": "started", "name": "b" }
5-
{ "type": "test", "name": "b", "event": "failed", "stdout": "thread 'main' panicked at 'assertion failed: false', f.rs:9:5\nnote: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.\n" }
5+
{ "type": "test", "name": "b", "event": "failed", "stdout": "thread 'main' panicked at 'assertion failed: false', f.rs:9:5\nnote: run with `RUST_BACKTRACE=1` environment variable to display a backtrace\n" }
66
{ "type": "test", "event": "started", "name": "c" }
77
{ "type": "test", "name": "c", "event": "ok", "stdout": "thread 'main' panicked at 'assertion failed: false', f.rs:15:5\n" }
88
{ "type": "test", "event": "started", "name": "d" }

src/test/rustdoc-ui/failed-doctest-output.stdout

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ stderr:
2727
stderr 1
2828
stderr 2
2929
thread 'main' panicked at 'oh no', $DIR/failed-doctest-output.rs:7:1
30-
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
30+
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
3131

3232

3333

src/test/ui/anon-params-deprecated.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ warning: anonymous parameters are deprecated and will be removed in the next edi
22
--> $DIR/anon-params-deprecated.rs:9:12
33
|
44
LL | fn foo(i32);
5-
| ^^^ help: Try naming the parameter or explicitly ignoring it: `_: i32`
5+
| ^^^ help: try naming the parameter or explicitly ignoring it: `_: i32`
66
|
77
note: lint level defined here
88
--> $DIR/anon-params-deprecated.rs:1:9
@@ -16,7 +16,7 @@ warning: anonymous parameters are deprecated and will be removed in the next edi
1616
--> $DIR/anon-params-deprecated.rs:12:30
1717
|
1818
LL | fn bar_with_default_impl(String, String) {}
19-
| ^^^^^^ help: Try naming the parameter or explicitly ignoring it: `_: String`
19+
| ^^^^^^ help: try naming the parameter or explicitly ignoring it: `_: String`
2020
|
2121
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
2222
= note: for more information, see issue #41686 <https://github.com/rust-lang/rust/issues/41686>
@@ -25,7 +25,7 @@ warning: anonymous parameters are deprecated and will be removed in the next edi
2525
--> $DIR/anon-params-deprecated.rs:12:38
2626
|
2727
LL | fn bar_with_default_impl(String, String) {}
28-
| ^^^^^^ help: Try naming the parameter or explicitly ignoring it: `_: String`
28+
| ^^^^^^ help: try naming the parameter or explicitly ignoring it: `_: String`
2929
|
3030
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition!
3131
= note: for more information, see issue #41686 <https://github.com/rust-lang/rust/issues/41686>

src/test/ui/async-await/mutually-recursive-async-impl-trait-type.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ error[E0733]: recursion in an `async fn` requires boxing
44
LL | async fn rec_1() {
55
| ^ recursive `async fn`
66
|
7-
= note: a recursive `async fn` must be rewritten to return a boxed `dyn Future`.
7+
= note: a recursive `async fn` must be rewritten to return a boxed `dyn Future`
88

99
error[E0733]: recursion in an `async fn` requires boxing
1010
--> $DIR/mutually-recursive-async-impl-trait-type.rs:9:18
1111
|
1212
LL | async fn rec_2() {
1313
| ^ recursive `async fn`
1414
|
15-
= note: a recursive `async fn` must be rewritten to return a boxed `dyn Future`.
15+
= note: a recursive `async fn` must be rewritten to return a boxed `dyn Future`
1616

1717
error: aborting due to 2 previous errors
1818

src/test/ui/async-await/recursive-async-impl-trait-type.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0733]: recursion in an `async fn` requires boxing
44
LL | async fn recursive_async_function() -> () {
55
| ^^ recursive `async fn`
66
|
7-
= note: a recursive `async fn` must be rewritten to return a boxed `dyn Future`.
7+
= note: a recursive `async fn` must be rewritten to return a boxed `dyn Future`
88

99
error: aborting due to previous error
1010

src/test/ui/consts/const-eval/validate_uninhabited_zsts.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ LL | unsafe { std::mem::transmute(()) }
3434
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
3535
|
3636
= note: `#[warn(invalid_value)]` on by default
37-
= note: The never type (`!`) has no valid value
37+
= note: the `!` type has no valid value
3838

3939
warning: the type `Empty` does not permit zero-initialization
4040
--> $DIR/validate_uninhabited_zsts.rs:17:35
@@ -45,7 +45,7 @@ LL | const BAR: [Empty; 3] = [unsafe { std::mem::transmute(()) }; 3];
4545
| this code causes undefined behavior when executed
4646
| help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
4747
|
48-
= note: 0-variant enums have no valid value
48+
= note: enums with no variants have no valid value
4949

5050
error: aborting due to previous error
5151

src/test/ui/consts/miri_unleashed/mutable_const2.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ LL | const MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *m
1111
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1212

1313
thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', src/librustc_errors/lib.rs:346:17
14-
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
14+
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
1515

1616
error: internal compiler error: unexpected panic
1717

0 commit comments

Comments
 (0)