Rollup merge of #125210 - fmease:fix-up-some-diags, r=davidtwco

Cleanup: Fix up some diagnostics

Several diagnostics contained their error code inside their primary message which is no bueno.
This PR moves them out of the message and turns them into structured error codes.

Also fixes another occurrence of `->` after a selector in a Fluent message which is not correct. I've fixed two other instances of this issue in #104345 (2022) but didn't update all instances as I've noted here: https://github.com/rust-lang/rust/pull/104345#issuecomment-1312705977 (“the future is now!”).
This commit is contained in:
Matthias Krüger 2024-05-23 14:09:24 +02:00 committed by GitHub
commit 337987bf63
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 57 additions and 47 deletions

View File

@ -104,10 +104,10 @@ infer_compare_impl_item_obligation = ...so that the definition in impl matches t
infer_consider_specifying_length = consider specifying the actual array length
infer_data_flows = ...but data{$label_var1_exists ->
[true] {" "}from `{$label_var1}`
*[false] -> {""}
*[false] {""}
} flows{$label_var2_exists ->
[true] {" "}into `{$label_var2}`
*[false] -> {""}
*[false] {""}
} here
infer_data_lifetime_flow = ...but data with one lifetime flows into the other here

View File

@ -627,7 +627,7 @@ lint_pattern_in_foreign = patterns aren't allowed in foreign function declaratio
.label = pattern not allowed in foreign function
lint_private_extern_crate_reexport =
extern crate `{$ident}` is private, and cannot be re-exported (error E0365), consider declaring with `pub`
extern crate `{$ident}` is private, and cannot be re-exported, consider declaring with `pub`
lint_proc_macro_back_compat = using an old version of `{$crate_name}`
.note = older versions of the `{$crate_name}` crate will stop compiling in future versions of Rust; please update to `{$crate_name}` v{$fixed_version}, or switch to one of the `{$crate_name}` alternatives

View File

@ -2228,7 +2228,7 @@ pub struct MacroUseDeprecated;
pub struct UnusedMacroUse;
#[derive(LintDiagnostic)]
#[diag(lint_private_extern_crate_reexport)]
#[diag(lint_private_extern_crate_reexport, code = E0365)]
pub struct PrivateExternCrateReexport {
pub ident: Ident,
}

View File

@ -335,12 +335,12 @@ mir_build_unsafe_fn_safe_body = an unsafe function restricts its caller, but its
mir_build_unsafe_not_inherited = items do not inherit unsafety from separate enclosing items
mir_build_unsafe_op_in_unsafe_fn_borrow_of_layout_constrained_field_requires_unsafe =
borrow of layout constrained field with interior mutability is unsafe and requires unsafe block (error E0133)
borrow of layout constrained field with interior mutability is unsafe and requires unsafe block
.note = references to fields of layout constrained fields lose the constraints. Coupled with interior mutability, the field can be changed to invalid values
.label = borrow of layout constrained field with interior mutability
mir_build_unsafe_op_in_unsafe_fn_call_to_fn_with_requires_unsafe =
call to function `{$function}` with `#[target_feature]` is unsafe and requires unsafe block (error E0133)
call to function `{$function}` with `#[target_feature]` is unsafe and requires unsafe block
.help = in order for the call to be safe, the context requires the following additional target {$missing_target_features_count ->
[1] feature
*[count] features
@ -355,48 +355,47 @@ mir_build_unsafe_op_in_unsafe_fn_call_to_fn_with_requires_unsafe =
.label = call to function with `#[target_feature]`
mir_build_unsafe_op_in_unsafe_fn_call_to_unsafe_fn_requires_unsafe =
call to unsafe function `{$function}` is unsafe and requires unsafe block (error E0133)
call to unsafe function `{$function}` is unsafe and requires unsafe block
.note = consult the function's documentation for information on how to avoid undefined behavior
.label = call to unsafe function
mir_build_unsafe_op_in_unsafe_fn_call_to_unsafe_fn_requires_unsafe_nameless =
call to unsafe function is unsafe and requires unsafe block (error E0133)
call to unsafe function is unsafe and requires unsafe block
.note = consult the function's documentation for information on how to avoid undefined behavior
.label = call to unsafe function
mir_build_unsafe_op_in_unsafe_fn_deref_raw_pointer_requires_unsafe =
dereference of raw pointer is unsafe and requires unsafe block (error E0133)
dereference of raw pointer is unsafe and requires unsafe block
.note = raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior
.label = dereference of raw pointer
mir_build_unsafe_op_in_unsafe_fn_extern_static_requires_unsafe =
use of extern static is unsafe and requires unsafe block (error E0133)
use of extern static is unsafe and requires unsafe block
.note = extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior
.label = use of extern static
mir_build_unsafe_op_in_unsafe_fn_initializing_type_with_requires_unsafe =
initializing type with `rustc_layout_scalar_valid_range` attr is unsafe and requires unsafe
block (error E0133)
initializing type with `rustc_layout_scalar_valid_range` attr is unsafe and requires unsafe block
.note = initializing a layout restricted type's field with a value outside the valid range is undefined behavior
.label = initializing type with `rustc_layout_scalar_valid_range` attr
mir_build_unsafe_op_in_unsafe_fn_inline_assembly_requires_unsafe =
use of inline assembly is unsafe and requires unsafe block (error E0133)
use of inline assembly is unsafe and requires unsafe block
.note = inline assembly is entirely unchecked and can cause undefined behavior
.label = use of inline assembly
mir_build_unsafe_op_in_unsafe_fn_mutable_static_requires_unsafe =
use of mutable static is unsafe and requires unsafe block (error E0133)
use of mutable static is unsafe and requires unsafe block
.note = mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior
.label = use of mutable static
mir_build_unsafe_op_in_unsafe_fn_mutation_of_layout_constrained_field_requires_unsafe =
mutation of layout constrained field is unsafe and requires unsafe block (error E0133)
mutation of layout constrained field is unsafe and requires unsafe block
.note = mutating layout constrained fields cannot statically be checked for valid values
.label = mutation of layout constrained field
mir_build_unsafe_op_in_unsafe_fn_union_field_requires_unsafe =
access to union field is unsafe and requires unsafe block (error E0133)
access to union field is unsafe and requires unsafe block
.note = the field may not be properly initialized: using uninitialized data will cause undefined behavior
.label = access to union field

View File

@ -21,7 +21,7 @@ pub struct UnconditionalRecursion {
}
#[derive(LintDiagnostic)]
#[diag(mir_build_unsafe_op_in_unsafe_fn_call_to_unsafe_fn_requires_unsafe)]
#[diag(mir_build_unsafe_op_in_unsafe_fn_call_to_unsafe_fn_requires_unsafe, code = E0133)]
#[note]
pub struct UnsafeOpInUnsafeFnCallToUnsafeFunctionRequiresUnsafe {
#[label]
@ -32,7 +32,7 @@ pub struct UnsafeOpInUnsafeFnCallToUnsafeFunctionRequiresUnsafe {
}
#[derive(LintDiagnostic)]
#[diag(mir_build_unsafe_op_in_unsafe_fn_call_to_unsafe_fn_requires_unsafe_nameless)]
#[diag(mir_build_unsafe_op_in_unsafe_fn_call_to_unsafe_fn_requires_unsafe_nameless, code = E0133)]
#[note]
pub struct UnsafeOpInUnsafeFnCallToUnsafeFunctionRequiresUnsafeNameless {
#[label]
@ -42,7 +42,7 @@ pub struct UnsafeOpInUnsafeFnCallToUnsafeFunctionRequiresUnsafeNameless {
}
#[derive(LintDiagnostic)]
#[diag(mir_build_unsafe_op_in_unsafe_fn_inline_assembly_requires_unsafe)]
#[diag(mir_build_unsafe_op_in_unsafe_fn_inline_assembly_requires_unsafe, code = E0133)]
#[note]
pub struct UnsafeOpInUnsafeFnUseOfInlineAssemblyRequiresUnsafe {
#[label]
@ -52,7 +52,7 @@ pub struct UnsafeOpInUnsafeFnUseOfInlineAssemblyRequiresUnsafe {
}
#[derive(LintDiagnostic)]
#[diag(mir_build_unsafe_op_in_unsafe_fn_initializing_type_with_requires_unsafe)]
#[diag(mir_build_unsafe_op_in_unsafe_fn_initializing_type_with_requires_unsafe, code = E0133)]
#[note]
pub struct UnsafeOpInUnsafeFnInitializingTypeWithRequiresUnsafe {
#[label]
@ -62,7 +62,7 @@ pub struct UnsafeOpInUnsafeFnInitializingTypeWithRequiresUnsafe {
}
#[derive(LintDiagnostic)]
#[diag(mir_build_unsafe_op_in_unsafe_fn_mutable_static_requires_unsafe)]
#[diag(mir_build_unsafe_op_in_unsafe_fn_mutable_static_requires_unsafe, code = E0133)]
#[note]
pub struct UnsafeOpInUnsafeFnUseOfMutableStaticRequiresUnsafe {
#[label]
@ -72,7 +72,7 @@ pub struct UnsafeOpInUnsafeFnUseOfMutableStaticRequiresUnsafe {
}
#[derive(LintDiagnostic)]
#[diag(mir_build_unsafe_op_in_unsafe_fn_extern_static_requires_unsafe)]
#[diag(mir_build_unsafe_op_in_unsafe_fn_extern_static_requires_unsafe, code = E0133)]
#[note]
pub struct UnsafeOpInUnsafeFnUseOfExternStaticRequiresUnsafe {
#[label]
@ -82,7 +82,7 @@ pub struct UnsafeOpInUnsafeFnUseOfExternStaticRequiresUnsafe {
}
#[derive(LintDiagnostic)]
#[diag(mir_build_unsafe_op_in_unsafe_fn_deref_raw_pointer_requires_unsafe)]
#[diag(mir_build_unsafe_op_in_unsafe_fn_deref_raw_pointer_requires_unsafe, code = E0133)]
#[note]
pub struct UnsafeOpInUnsafeFnDerefOfRawPointerRequiresUnsafe {
#[label]
@ -92,7 +92,7 @@ pub struct UnsafeOpInUnsafeFnDerefOfRawPointerRequiresUnsafe {
}
#[derive(LintDiagnostic)]
#[diag(mir_build_unsafe_op_in_unsafe_fn_union_field_requires_unsafe)]
#[diag(mir_build_unsafe_op_in_unsafe_fn_union_field_requires_unsafe, code = E0133)]
#[note]
pub struct UnsafeOpInUnsafeFnAccessToUnionFieldRequiresUnsafe {
#[label]
@ -102,7 +102,10 @@ pub struct UnsafeOpInUnsafeFnAccessToUnionFieldRequiresUnsafe {
}
#[derive(LintDiagnostic)]
#[diag(mir_build_unsafe_op_in_unsafe_fn_mutation_of_layout_constrained_field_requires_unsafe)]
#[diag(
mir_build_unsafe_op_in_unsafe_fn_mutation_of_layout_constrained_field_requires_unsafe,
code = E0133
)]
#[note]
pub struct UnsafeOpInUnsafeFnMutationOfLayoutConstrainedFieldRequiresUnsafe {
#[label]
@ -112,7 +115,10 @@ pub struct UnsafeOpInUnsafeFnMutationOfLayoutConstrainedFieldRequiresUnsafe {
}
#[derive(LintDiagnostic)]
#[diag(mir_build_unsafe_op_in_unsafe_fn_borrow_of_layout_constrained_field_requires_unsafe)]
#[diag(
mir_build_unsafe_op_in_unsafe_fn_borrow_of_layout_constrained_field_requires_unsafe,
code = E0133,
)]
pub struct UnsafeOpInUnsafeFnBorrowOfLayoutConstrainedFieldRequiresUnsafe {
#[label]
pub span: Span,
@ -121,7 +127,7 @@ pub struct UnsafeOpInUnsafeFnBorrowOfLayoutConstrainedFieldRequiresUnsafe {
}
#[derive(LintDiagnostic)]
#[diag(mir_build_unsafe_op_in_unsafe_fn_call_to_fn_with_requires_unsafe)]
#[diag(mir_build_unsafe_op_in_unsafe_fn_call_to_fn_with_requires_unsafe, code = E0133)]
#[help]
pub struct UnsafeOpInUnsafeFnCallToFunctionWithRequiresUnsafe {
#[label]

View File

@ -22,7 +22,7 @@ note: the crate import `core` is defined here
LL | extern crate core;
| ^^^^^^^^^^^^^^^^^^
error: extern crate `core` is private, and cannot be re-exported (error E0365), consider declaring with `pub`
error[E0365]: extern crate `core` is private, and cannot be re-exported, consider declaring with `pub`
--> $DIR/pub-reexport-priv-extern-crate.rs:2:9
|
LL | pub use core as reexported_core;
@ -34,4 +34,5 @@ LL | pub use core as reexported_core;
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0603`.
Some errors have detailed explanations: E0365, E0603.
For more information about an error, try `rustc --explain E0365`.

View File

@ -91,7 +91,7 @@ LL | const _: () = sse2_and_fxsr();
= help: in order for the call to be safe, the context requires the following additional target features: sse2 and fxsr
= note: the fxsr and sse2 target features being enabled in the build configuration does not remove the requirement to list them in `#[target_feature]`
error: call to function `sse2` with `#[target_feature]` is unsafe and requires unsafe block (error E0133)
error[E0133]: call to function `sse2` with `#[target_feature]` is unsafe and requires unsafe block
--> $DIR/safe-calls.rs:70:5
|
LL | sse2();

View File

@ -1,4 +1,4 @@
warning: call to unsafe function `unsf` is unsafe and requires unsafe block (error E0133)
warning[E0133]: call to unsafe function `unsf` is unsafe and requires unsafe block
--> $DIR/edition-2024-unsafe_op_in_unsafe_fn.rs:10:5
|
LL | unsf();
@ -15,3 +15,4 @@ LL | unsafe fn foo() {
warning: 1 warning emitted
For more information about this error, try `rustc --explain E0133`.

View File

@ -1,4 +1,4 @@
warning: call to unsafe function `unsf` is unsafe and requires unsafe block (error E0133)
warning[E0133]: call to unsafe function `unsf` is unsafe and requires unsafe block
--> $DIR/edition_2024_default.rs:13:5
|
LL | unsf();
@ -15,3 +15,4 @@ LL | unsafe fn foo() {
warning: 1 warning emitted
For more information about this error, try `rustc --explain E0133`.

View File

@ -1,4 +1,4 @@
error: call to unsafe function `unsf` is unsafe and requires unsafe block (error E0133)
error[E0133]: call to unsafe function `unsf` is unsafe and requires unsafe block
--> $DIR/in_2024_compatibility.rs:7:5
|
LL | unsf();
@ -20,3 +20,4 @@ LL | #![deny(rust_2024_compatibility)]
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0133`.

View File

@ -1,4 +1,4 @@
error: call to unsafe function `unsf` is unsafe and requires unsafe block (error E0133)
error[E0133]: call to unsafe function `unsf` is unsafe and requires unsafe block
--> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:9:5
|
LL | unsf();
@ -17,7 +17,7 @@ note: the lint level is defined here
LL | #![deny(unsafe_op_in_unsafe_fn)]
| ^^^^^^^^^^^^^^^^^^^^^^
error: dereference of raw pointer is unsafe and requires unsafe block (error E0133)
error[E0133]: dereference of raw pointer is unsafe and requires unsafe block
--> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:11:5
|
LL | *PTR;
@ -26,7 +26,7 @@ LL | *PTR;
= note: for more information, see issue #71668 <https://github.com/rust-lang/rust/issues/71668>
= note: raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior
error: use of mutable static is unsafe and requires unsafe block (error E0133)
error[E0133]: use of mutable static is unsafe and requires unsafe block
--> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:13:5
|
LL | VOID = ();
@ -47,7 +47,7 @@ note: the lint level is defined here
LL | #![deny(unused_unsafe)]
| ^^^^^^^^^^^^^
error: call to unsafe function `unsf` is unsafe and requires unsafe block (error E0133)
error[E0133]: call to unsafe function `unsf` is unsafe and requires unsafe block
--> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:24:5
|
LL | unsf();
@ -67,7 +67,7 @@ LL | #[deny(warnings)]
| ^^^^^^^^
= note: `#[deny(unsafe_op_in_unsafe_fn)]` implied by `#[deny(warnings)]`
error: dereference of raw pointer is unsafe and requires unsafe block (error E0133)
error[E0133]: dereference of raw pointer is unsafe and requires unsafe block
--> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:26:5
|
LL | *PTR;
@ -76,7 +76,7 @@ LL | *PTR;
= note: for more information, see issue #71668 <https://github.com/rust-lang/rust/issues/71668>
= note: raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior
error: use of mutable static is unsafe and requires unsafe block (error E0133)
error[E0133]: use of mutable static is unsafe and requires unsafe block
--> $DIR/rfc-2585-unsafe_op_in_unsafe_fn.rs:28:5
|
LL | VOID = ();

View File

@ -1,4 +1,4 @@
error: call to unsafe function `unsf` is unsafe and requires unsafe block (error E0133)
error[E0133]: call to unsafe function `unsf` is unsafe and requires unsafe block
--> $DIR/wrapping-unsafe-block-sugg.rs:13:5
|
LL | unsf();
@ -17,7 +17,7 @@ note: the lint level is defined here
LL | #![deny(unsafe_op_in_unsafe_fn)]
| ^^^^^^^^^^^^^^^^^^^^^^
error: call to unsafe function `unsf` is unsafe and requires unsafe block (error E0133)
error[E0133]: call to unsafe function `unsf` is unsafe and requires unsafe block
--> $DIR/wrapping-unsafe-block-sugg.rs:17:5
|
LL | unsf();
@ -26,7 +26,7 @@ LL | unsf();
= note: for more information, see issue #71668 <https://github.com/rust-lang/rust/issues/71668>
= note: consult the function's documentation for information on how to avoid undefined behavior
error: dereference of raw pointer is unsafe and requires unsafe block (error E0133)
error[E0133]: dereference of raw pointer is unsafe and requires unsafe block
--> $DIR/wrapping-unsafe-block-sugg.rs:25:13
|
LL | let y = *x;
@ -40,7 +40,7 @@ note: an unsafe function restricts its caller, but its body is safe by default
LL | pub unsafe fn bar(x: *const i32) -> i32 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: dereference of raw pointer is unsafe and requires unsafe block (error E0133)
error[E0133]: dereference of raw pointer is unsafe and requires unsafe block
--> $DIR/wrapping-unsafe-block-sugg.rs:29:9
|
LL | y + *x
@ -49,7 +49,7 @@ LL | y + *x
= note: for more information, see issue #71668 <https://github.com/rust-lang/rust/issues/71668>
= note: raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior
error: use of mutable static is unsafe and requires unsafe block (error E0133)
error[E0133]: use of mutable static is unsafe and requires unsafe block
--> $DIR/wrapping-unsafe-block-sugg.rs:38:13
|
LL | let y = BAZ;
@ -63,7 +63,7 @@ note: an unsafe function restricts its caller, but its body is safe by default
LL | pub unsafe fn baz() -> i32 {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
error: use of mutable static is unsafe and requires unsafe block (error E0133)
error[E0133]: use of mutable static is unsafe and requires unsafe block
--> $DIR/wrapping-unsafe-block-sugg.rs:42:9
|
LL | y + BAZ
@ -72,7 +72,7 @@ LL | y + BAZ
= note: for more information, see issue #71668 <https://github.com/rust-lang/rust/issues/71668>
= note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior
error: call to unsafe function `unsf` is unsafe and requires unsafe block (error E0133)
error[E0133]: call to unsafe function `unsf` is unsafe and requires unsafe block
--> $DIR/wrapping-unsafe-block-sugg.rs:48:36
|
LL | macro_rules! unsafe_macro { () => (unsf()) }
@ -90,7 +90,7 @@ LL | pub unsafe fn unsafe_in_macro() {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in the macro `unsafe_macro` (in Nightly builds, run with -Z macro-backtrace for more info)
error: call to unsafe function `unsf` is unsafe and requires unsafe block (error E0133)
error[E0133]: call to unsafe function `unsf` is unsafe and requires unsafe block
--> $DIR/wrapping-unsafe-block-sugg.rs:48:36
|
LL | macro_rules! unsafe_macro { () => (unsf()) }
@ -105,3 +105,4 @@ LL | unsafe_macro!();
error: aborting due to 8 previous errors
For more information about this error, try `rustc --explain E0133`.