Skip to content

Commit

Permalink
Rollup merge of rust-lang#89483 - hkmatsumoto:patch-diagnostics-2, r=…
Browse files Browse the repository at this point in the history
…estebank

Practice diagnostic message convention

Detected by rust-lang#89455.

r? `@estebank`
  • Loading branch information
Manishearth authored Oct 4, 2021
2 parents e122009 + 3818981 commit e11685f
Show file tree
Hide file tree
Showing 63 changed files with 167 additions and 168 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_ast_passes/src/ast_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ impl<'a> AstValidator<'a> {
)
.span_label(self.current_extern_span(), "in this `extern` block")
.note(&format!(
"This limitation may be lifted in the future; see issue #{} <https://github.com/rust-lang/rust/issues/{}> for more information",
"this limitation may be lifted in the future; see issue #{} <https://github.com/rust-lang/rust/issues/{}> for more information",
n, n,
))
.emit();
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_builtin_macros/src/concat_idents.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub fn expand_concat_idents<'cx>(
tts: TokenStream,
) -> Box<dyn base::MacResult + 'cx> {
if tts.is_empty() {
cx.span_err(sp, "concat_idents! takes 1 or more arguments.");
cx.span_err(sp, "concat_idents! takes 1 or more arguments");
return DummyResult::any(sp);
}

Expand All @@ -22,7 +22,7 @@ pub fn expand_concat_idents<'cx>(
match e {
TokenTree::Token(Token { kind: token::Comma, .. }) => {}
_ => {
cx.span_err(sp, "concat_idents! expecting comma.");
cx.span_err(sp, "concat_idents! expecting comma");
return DummyResult::any(sp);
}
}
Expand All @@ -34,7 +34,7 @@ pub fn expand_concat_idents<'cx>(
}
}

cx.span_err(sp, "concat_idents! requires ident args.");
cx.span_err(sp, "concat_idents! requires ident args");
return DummyResult::any(sp);
}
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_builtin_macros/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ fn should_panic(cx: &ExtCtxt<'_>, i: &ast::Item) -> ShouldPanic {
.note(
"errors in this attribute were erroneously \
allowed and will become a hard error in a \
future release.",
future release",
)
.emit();
ShouldPanic::Yes(None)
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_const_eval/src/transform/check_consts/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ impl NonConstOp for RawPtrComparison {
let mut err = ccx
.tcx
.sess
.struct_span_err(span, "pointers cannot be reliably compared during const eval.");
.struct_span_err(span, "pointers cannot be reliably compared during const eval");
err.note(
"see issue #53020 <https://github.com/rust-lang/rust/issues/53020> \
for more information",
Expand Down Expand Up @@ -443,7 +443,7 @@ impl NonConstOp for RawPtrToIntCast {
let mut err = ccx
.tcx
.sess
.struct_span_err(span, "pointers cannot be cast to integers during const eval.");
.struct_span_err(span, "pointers cannot be cast to integers during const eval");
err.note("at compile-time, pointers do not have an integer value");
err.note(
"avoiding this restriction via `transmute`, `union`, or raw pointers leads to compile-time undefined behavior",
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_lint/src/array_into_iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ impl<'tcx> LateLintPass<'tcx> for ArrayIntoIter {
let mut diag = lint.build(&format!(
"this method call resolves to `<&{} as IntoIterator>::into_iter` \
(due to backwards compatibility), \
but will resolve to <{} as IntoIterator>::into_iter in Rust 2021.",
but will resolve to <{} as IntoIterator>::into_iter in Rust 2021",
target, target,
));
diag.span_suggestion(
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_lint/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,7 @@ impl EarlyLintPass for AnonymousParameters {

lint.build(
"anonymous parameters are deprecated and will be \
removed in the next edition.",
removed in the next edition",
)
.span_suggestion(
arg.pat.span,
Expand Down Expand Up @@ -1629,9 +1629,9 @@ impl<'tcx> LateLintPass<'tcx> for TrivialConstraints {
let predicates = cx.tcx.predicates_of(item.def_id);
for &(predicate, span) in predicates.predicates {
let predicate_kind_name = match predicate.kind().skip_binder() {
Trait(..) => "Trait",
Trait(..) => "trait",
TypeOutlives(..) |
RegionOutlives(..) => "Lifetime",
RegionOutlives(..) => "lifetime",

// Ignore projections, as they can only be global
// if the trait bound is global
Expand Down
7 changes: 3 additions & 4 deletions compiler/rustc_lint/src/non_ascii_idents.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,18 +331,17 @@ impl EarlyLintPass for NonAsciiIdents {
for ((sp, ch_list), script_set) in lint_reports {
cx.struct_span_lint(MIXED_SCRIPT_CONFUSABLES, sp, |lint| {
let message = format!(
"The usage of Script Group `{}` in this crate consists solely of mixed script confusables",
"the usage of Script Group `{}` in this crate consists solely of mixed script confusables",
script_set);
let mut note = "The usage includes ".to_string();
let mut note = "the usage includes ".to_string();
for (idx, ch) in ch_list.into_iter().enumerate() {
if idx != 0 {
note += ", ";
}
let char_info = format!("'{}' (U+{:04X})", ch, ch as u32);
note += &char_info;
}
note += ".";
lint.build(&message).note(&note).note("Please recheck to make sure their usages are indeed what you want.").emit()
lint.build(&message).note(&note).note("please recheck to make sure their usages are indeed what you want").emit()
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_metadata/src/creader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,7 @@ impl<'a> CrateLoader<'a> {
"no global memory allocator found but one is \
required; link to std or \
add `#[global_allocator]` to a static item \
that implements the GlobalAlloc trait.",
that implements the GlobalAlloc trait",
);
}
self.cstore.allocator_kind = Some(AllocatorKind::Default);
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_metadata/src/native_libs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,13 +319,13 @@ impl Collector<'tcx> {
self.tcx.sess.err(&format!(
"renaming of the library `{}` was specified, \
however this crate contains no `#[link(...)]` \
attributes referencing this library.",
attributes referencing this library",
lib.name
));
} else if !renames.insert(&lib.name) {
self.tcx.sess.err(&format!(
"multiple renamings were \
specified for library `{}` .",
specified for library `{}`",
lib.name
));
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_passes/src/weak_lang_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ fn verify<'tcx>(tcx: TyCtxt<'tcx>, items: &lang_items::LanguageItems) {
tcx.sess.err("`#[panic_handler]` function required, but not found");
} else if item == LangItem::Oom {
if !tcx.features().default_alloc_error_handler {
tcx.sess.err("`#[alloc_error_handler]` function required, but not found.");
tcx.sess.note_without_error("Use `#![feature(default_alloc_error_handler)]` for a default error handler.");
tcx.sess.err("`#[alloc_error_handler]` function required, but not found");
tcx.sess.note_without_error("Use `#![feature(default_alloc_error_handler)]` for a default error handler");
}
} else {
tcx.sess.err(&format!("language item required, but not found: `{}`", name));
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_resolve/src/imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1339,7 +1339,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
};

if module.is_trait() {
self.r.session.span_err(import.span, "items in traits are not importable.");
self.r.session.span_err(import.span, "items in traits are not importable");
return;
} else if ptr::eq(module, import.parent_scope.module) {
return;
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_session/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1384,7 +1384,7 @@ fn validate_commandline_args_with_session_available(sess: &Session) {
// Cannot enable crt-static with sanitizers on Linux
if sess.crt_static(None) && !sess.opts.debugging_opts.sanitizer.is_empty() {
sess.err(
"Sanitizer is incompatible with statically linked libc, \
"sanitizer is incompatible with statically linked libc, \
disable it using `-C target-feature=-crt-static`",
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
});
let unit_obligation = obligation.with(predicate.to_predicate(tcx));
if self.predicate_may_hold(&unit_obligation) {
err.note("this trait is implemented for `()`.");
err.note("this trait is implemented for `()`");
err.note(
"this error might have been caused by changes to \
Rust's type-inference algorithm (see issue #48950 \
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_trait_selection/src/traits/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ fn dump_vtable_entries<'tcx>(
trait_ref: ty::PolyTraitRef<'tcx>,
entries: &[VtblEntry<'tcx>],
) {
let msg = format!("Vtable entries for `{}`: {:#?}", trait_ref, entries);
let msg = format!("vtable entries for `{}`: {:#?}", trait_ref, entries);
tcx.sess.struct_span_err(sp, &msg).emit();
}

Expand Down
4 changes: 2 additions & 2 deletions library/core/src/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1305,7 +1305,7 @@ impl Clone for BorrowRef<'_> {
#[stable(feature = "rust1", since = "1.0.0")]
#[cfg_attr(
not(bootstrap),
must_not_suspend = "Holding a Ref across suspend \
must_not_suspend = "holding a Ref across suspend \
points can cause BorrowErrors"
)]
pub struct Ref<'b, T: ?Sized + 'b> {
Expand Down Expand Up @@ -1686,7 +1686,7 @@ impl<'b> BorrowRefMut<'b> {
#[stable(feature = "rust1", since = "1.0.0")]
#[cfg_attr(
not(bootstrap),
must_not_suspend = "Holding a RefMut across suspend \
must_not_suspend = "holding a RefMut across suspend \
points can cause BorrowErrors"
)]
pub struct RefMut<'b, T: ?Sized + 'b> {
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/sync/mutex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ unsafe impl<T: ?Sized + Send> Sync for Mutex<T> {}
#[must_use = "if unused the Mutex will immediately unlock"]
#[cfg_attr(
not(bootstrap),
must_not_suspend = "Holding a MutexGuard across suspend \
must_not_suspend = "holding a MutexGuard across suspend \
points can cause deadlocks, delays, \
and cause Futures to not implement `Send`"
)]
Expand Down
4 changes: 2 additions & 2 deletions library/std/src/sync/rwlock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ unsafe impl<T: ?Sized + Send + Sync> Sync for RwLock<T> {}
#[must_use = "if unused the RwLock will immediately unlock"]
#[cfg_attr(
not(bootstrap),
must_not_suspend = "Holding a RwLockReadGuard across suspend \
must_not_suspend = "holding a RwLockReadGuard across suspend \
points can cause deadlocks, delays, \
and cause Futures to not implement `Send`"
)]
Expand All @@ -123,7 +123,7 @@ unsafe impl<T: ?Sized + Sync> Sync for RwLockReadGuard<'_, T> {}
#[must_use = "if unused the RwLock will immediately unlock"]
#[cfg_attr(
not(bootstrap),
must_not_suspend = "Holding a RwLockWriteGuard across suspend \
must_not_suspend = "holding a RwLockWriteGuard across suspend \
points can cause deadlocks, delays, \
and cause Future's to not implement `Send`"
)]
Expand Down
6 changes: 3 additions & 3 deletions src/test/ui/anon-params/anon-params-deprecated.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
warning: anonymous parameters are deprecated and will be removed in the next edition.
warning: anonymous parameters are deprecated and will be removed in the next edition
--> $DIR/anon-params-deprecated.rs:9:12
|
LL | fn foo(i32);
Expand All @@ -12,7 +12,7 @@ LL | #![warn(anonymous_parameters)]
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
= note: for more information, see issue #41686 <https://github.com/rust-lang/rust/issues/41686>

warning: anonymous parameters are deprecated and will be removed in the next edition.
warning: anonymous parameters are deprecated and will be removed in the next edition
--> $DIR/anon-params-deprecated.rs:12:30
|
LL | fn bar_with_default_impl(String, String) {}
Expand All @@ -21,7 +21,7 @@ LL | fn bar_with_default_impl(String, String) {}
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
= note: for more information, see issue #41686 <https://github.com/rust-lang/rust/issues/41686>

warning: anonymous parameters are deprecated and will be removed in the next edition.
warning: anonymous parameters are deprecated and will be removed in the next edition
--> $DIR/anon-params-deprecated.rs:12:38
|
LL | fn bar_with_default_impl(String, String) {}
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/consts/const-eval/const_raw_ptr_ops.stderr
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
error: pointers cannot be reliably compared during const eval.
error: pointers cannot be reliably compared during const eval
--> $DIR/const_raw_ptr_ops.rs:4:26
|
LL | const X: bool = unsafe { &1 as *const i32 == &2 as *const i32 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #53020 <https://github.com/rust-lang/rust/issues/53020> for more information

error: pointers cannot be reliably compared during const eval.
error: pointers cannot be reliably compared during const eval
--> $DIR/const_raw_ptr_ops.rs:6:27
|
LL | const X2: bool = unsafe { 42 as *const i32 == 43 as *const i32 };
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/consts/const-eval/match-test-ptr-null.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error: pointers cannot be cast to integers during const eval.
error: pointers cannot be cast to integers during const eval
--> $DIR/match-test-ptr-null.rs:6:15
|
LL | match &1 as *const i32 as usize {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ LL | const unsafe extern "C" fn use_float() { 1.0 + 1.0; }
= note: see issue #57241 <https://github.com/rust-lang/rust/issues/57241> for more information
= help: add `#![feature(const_fn_floating_point_arithmetic)]` to the crate attributes to enable

error: pointers cannot be cast to integers during const eval.
error: pointers cannot be cast to integers during const eval
--> $DIR/const-extern-fn-min-const-fn.rs:9:48
|
LL | const extern "C" fn ptr_cast(val: *const u8) { val as usize; }
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/consts/issue-17458.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error: pointers cannot be cast to integers during const eval.
error: pointers cannot be cast to integers during const eval
--> $DIR/issue-17458.rs:1:28
|
LL | static X: usize = unsafe { core::ptr::null::<usize>() as usize };
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/consts/issue-25826.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error: pointers cannot be reliably compared during const eval.
error: pointers cannot be reliably compared during const eval
--> $DIR/issue-25826.rs:3:30
|
LL | const A: bool = unsafe { id::<u8> as *const () < id::<u16> as *const () };
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error: pointers cannot be cast to integers during const eval.
error: pointers cannot be cast to integers during const eval
--> $DIR/issue-52023-array-size-pointer-cast.rs:2:17
|
LL | let _ = [0; (&0 as *const i32) as usize];
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/consts/min_const_fn/cmp_fn_pointers.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ LL | const fn cmp(x: fn(), y: fn()) -> bool {
= note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information
= help: add `#![feature(const_fn_fn_ptr_basics)]` to the crate attributes to enable

error: pointers cannot be reliably compared during const eval.
error: pointers cannot be reliably compared during const eval
--> $DIR/cmp_fn_pointers.rs:4:14
|
LL | unsafe { x == y }
Expand Down
8 changes: 4 additions & 4 deletions src/test/ui/consts/min_const_fn/min_const_fn.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ LL | const fn foo26() -> &'static u32 { &BAR }
|
= help: consider extracting the value of the `static` to a `const`, and referring to that

error: pointers cannot be cast to integers during const eval.
error: pointers cannot be cast to integers during const eval
--> $DIR/min_const_fn.rs:92:42
|
LL | const fn foo30(x: *const u32) -> usize { x as usize }
Expand All @@ -173,7 +173,7 @@ LL | const fn foo30(x: *const u32) -> usize { x as usize }
= note: at compile-time, pointers do not have an integer value
= note: avoiding this restriction via `transmute`, `union`, or raw pointers leads to compile-time undefined behavior

error: pointers cannot be cast to integers during const eval.
error: pointers cannot be cast to integers during const eval
--> $DIR/min_const_fn.rs:94:63
|
LL | const fn foo30_with_unsafe(x: *const u32) -> usize { unsafe { x as usize } }
Expand All @@ -182,7 +182,7 @@ LL | const fn foo30_with_unsafe(x: *const u32) -> usize { unsafe { x as usize }
= note: at compile-time, pointers do not have an integer value
= note: avoiding this restriction via `transmute`, `union`, or raw pointers leads to compile-time undefined behavior

error: pointers cannot be cast to integers during const eval.
error: pointers cannot be cast to integers during const eval
--> $DIR/min_const_fn.rs:96:42
|
LL | const fn foo30_2(x: *mut u32) -> usize { x as usize }
Expand All @@ -191,7 +191,7 @@ LL | const fn foo30_2(x: *mut u32) -> usize { x as usize }
= note: at compile-time, pointers do not have an integer value
= note: avoiding this restriction via `transmute`, `union`, or raw pointers leads to compile-time undefined behavior

error: pointers cannot be cast to integers during const eval.
error: pointers cannot be cast to integers during const eval
--> $DIR/min_const_fn.rs:98:63
|
LL | const fn foo30_2_with_unsafe(x: *mut u32) -> usize { unsafe { x as usize } }
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/error-codes/E0395.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error: pointers cannot be reliably compared during const eval.
error: pointers cannot be reliably compared during const eval
--> $DIR/E0395.rs:4:29
|
LL | static BAZ: bool = unsafe { (&FOO as *const i32) == (&BAR as *const i32) };
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/future-incompatible-lint-group.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
warning: anonymous parameters are deprecated and will be removed in the next edition.
warning: anonymous parameters are deprecated and will be removed in the next edition
--> $DIR/future-incompatible-lint-group.rs:7:10
|
LL | fn f(u8) {}
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/imports/issue-30560.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error: items in traits are not importable.
error: items in traits are not importable
--> $DIR/issue-30560.rs:7:5
|
LL | use T::*;
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/issues/issue-18294.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error: pointers cannot be cast to integers during const eval.
error: pointers cannot be cast to integers during const eval
--> $DIR/issue-18294.rs:3:31
|
LL | const Y: usize = unsafe { &X as *const u32 as usize };
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/issues/issue-50403.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error: concat_idents! takes 1 or more arguments.
error: concat_idents! takes 1 or more arguments
--> $DIR/issue-50403.rs:4:13
|
LL | let x = concat_idents!();
Expand Down
Loading

0 comments on commit e11685f

Please sign in to comment.