Skip to content

Commit 590fa1e

Browse files
Convert to inline diagnostics in rustc_ty_utils
1 parent 55407b8 commit 590fa1e

File tree

7 files changed

+38
-102
lines changed

7 files changed

+38
-102
lines changed

Cargo.lock

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3817,7 +3817,6 @@ dependencies = [
38173817
"rustc_span",
38183818
"rustc_target",
38193819
"rustc_trait_selection",
3820-
"rustc_ty_utils",
38213820
"serde_json",
38223821
"shlex",
38233822
"tracing",
@@ -4809,7 +4808,6 @@ dependencies = [
48094808
"rustc_abi",
48104809
"rustc_data_structures",
48114810
"rustc_errors",
4812-
"rustc_fluent_macro",
48134811
"rustc_hashes",
48144812
"rustc_hir",
48154813
"rustc_index",

compiler/rustc_driver_impl/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ rustc_session = { path = "../rustc_session" }
4949
rustc_span = { path = "../rustc_span" }
5050
rustc_target = { path = "../rustc_target" }
5151
rustc_trait_selection = { path = "../rustc_trait_selection" }
52-
rustc_ty_utils = { path = "../rustc_ty_utils" }
5352
serde_json = "1.0.59"
5453
shlex = "1.0"
5554
tracing = { version = "0.1.35" }

compiler/rustc_driver_impl/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ pub static DEFAULT_LOCALE_RESOURCES: &[&str] = &[
143143
rustc_resolve::DEFAULT_LOCALE_RESOURCE,
144144
rustc_session::DEFAULT_LOCALE_RESOURCE,
145145
rustc_trait_selection::DEFAULT_LOCALE_RESOURCE,
146-
rustc_ty_utils::DEFAULT_LOCALE_RESOURCE,
147146
// tidy-alphabetical-end
148147
];
149148

compiler/rustc_ty_utils/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ itertools = "0.12"
99
rustc_abi = { path = "../rustc_abi" }
1010
rustc_data_structures = { path = "../rustc_data_structures" }
1111
rustc_errors = { path = "../rustc_errors" }
12-
rustc_fluent_macro = { path = "../rustc_fluent_macro" }
1312
rustc_hashes = { path = "../rustc_hashes" }
1413
rustc_hir = { path = "../rustc_hir" }
1514
rustc_index = { path = "../rustc_index" }

compiler/rustc_ty_utils/messages.ftl

Lines changed: 0 additions & 61 deletions
This file was deleted.

compiler/rustc_ty_utils/src/errors.rs

Lines changed: 38 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -6,103 +6,107 @@ use rustc_middle::ty::{GenericArg, Ty};
66
use rustc_span::Span;
77

88
#[derive(Diagnostic)]
9-
#[diag(ty_utils_needs_drop_overflow)]
9+
#[diag("overflow while checking whether `{$query_ty}` requires drop")]
1010
pub(crate) struct NeedsDropOverflow<'tcx> {
1111
pub query_ty: Ty<'tcx>,
1212
}
1313

1414
#[derive(Diagnostic)]
15-
#[diag(ty_utils_generic_constant_too_complex)]
16-
#[help]
15+
#[diag("overly complex generic constant")]
16+
#[help("consider moving this anonymous constant into a `const` function")]
1717
pub(crate) struct GenericConstantTooComplex {
1818
#[primary_span]
1919
pub span: Span,
20-
#[note(ty_utils_maybe_supported)]
20+
#[note("this operation may be supported in the future")]
2121
pub maybe_supported: bool,
2222
#[subdiagnostic]
2323
pub sub: GenericConstantTooComplexSub,
2424
}
2525

2626
#[derive(Subdiagnostic)]
2727
pub(crate) enum GenericConstantTooComplexSub {
28-
#[label(ty_utils_borrow_not_supported)]
28+
#[label("borrowing is not supported in generic constants")]
2929
BorrowNotSupported(#[primary_span] Span),
30-
#[label(ty_utils_address_and_deref_not_supported)]
30+
#[label("dereferencing or taking the address is not supported in generic constants")]
3131
AddressAndDerefNotSupported(#[primary_span] Span),
32-
#[label(ty_utils_array_not_supported)]
32+
#[label("array construction is not supported in generic constants")]
3333
ArrayNotSupported(#[primary_span] Span),
34-
#[label(ty_utils_block_not_supported)]
34+
#[label("blocks are not supported in generic constants")]
3535
BlockNotSupported(#[primary_span] Span),
36-
#[label(ty_utils_never_to_any_not_supported)]
36+
#[label("coercing the `never` type is not supported in generic constants")]
3737
NeverToAnyNotSupported(#[primary_span] Span),
38-
#[label(ty_utils_tuple_not_supported)]
38+
#[label("tuple construction is not supported in generic constants")]
3939
TupleNotSupported(#[primary_span] Span),
40-
#[label(ty_utils_index_not_supported)]
40+
#[label("indexing is not supported in generic constants")]
4141
IndexNotSupported(#[primary_span] Span),
42-
#[label(ty_utils_field_not_supported)]
42+
#[label("field access is not supported in generic constants")]
4343
FieldNotSupported(#[primary_span] Span),
44-
#[label(ty_utils_const_block_not_supported)]
44+
#[label("const blocks are not supported in generic constants")]
4545
ConstBlockNotSupported(#[primary_span] Span),
46-
#[label(ty_utils_adt_not_supported)]
46+
#[label("struct/enum construction is not supported in generic constants")]
4747
AdtNotSupported(#[primary_span] Span),
48-
#[label(ty_utils_pointer_not_supported)]
48+
#[label("pointer casts are not allowed in generic constants")]
4949
PointerNotSupported(#[primary_span] Span),
50-
#[label(ty_utils_yield_not_supported)]
50+
#[label("coroutine control flow is not allowed in generic constants")]
5151
YieldNotSupported(#[primary_span] Span),
52-
#[label(ty_utils_loop_not_supported)]
52+
#[label("loops and loop control flow are not supported in generic constants")]
5353
LoopNotSupported(#[primary_span] Span),
54-
#[label(ty_utils_box_not_supported)]
54+
#[label("allocations are not allowed in generic constants")]
5555
BoxNotSupported(#[primary_span] Span),
56-
#[label(ty_utils_binary_not_supported)]
56+
#[label("unsupported binary operation in generic constants")]
5757
BinaryNotSupported(#[primary_span] Span),
58-
#[label(ty_utils_by_use_not_supported)]
58+
#[label(".use is not allowed in generic constants")]
5959
ByUseNotSupported(#[primary_span] Span),
60-
#[label(ty_utils_logical_op_not_supported)]
60+
#[label(
61+
"unsupported operation in generic constants, short-circuiting operations would imply control flow"
62+
)]
6163
LogicalOpNotSupported(#[primary_span] Span),
62-
#[label(ty_utils_assign_not_supported)]
64+
#[label("assignment is not supported in generic constants")]
6365
AssignNotSupported(#[primary_span] Span),
64-
#[label(ty_utils_closure_and_return_not_supported)]
66+
#[label("closures and function keywords are not supported in generic constants")]
6567
ClosureAndReturnNotSupported(#[primary_span] Span),
66-
#[label(ty_utils_control_flow_not_supported)]
68+
#[label("control flow is not supported in generic constants")]
6769
ControlFlowNotSupported(#[primary_span] Span),
68-
#[label(ty_utils_inline_asm_not_supported)]
70+
#[label("assembly is not supported in generic constants")]
6971
InlineAsmNotSupported(#[primary_span] Span),
70-
#[label(ty_utils_operation_not_supported)]
72+
#[label("unsupported operation in generic constants")]
7173
OperationNotSupported(#[primary_span] Span),
7274
}
7375

7476
#[derive(Diagnostic)]
75-
#[diag(ty_utils_unexpected_fnptr_associated_item)]
77+
#[diag("`FnPtr` trait with unexpected associated item")]
7678
pub(crate) struct UnexpectedFnPtrAssociatedItem {
7779
#[primary_span]
7880
pub span: Span,
7981
}
8082

8183
#[derive(Diagnostic)]
82-
#[diag(ty_utils_non_primitive_simd_type)]
84+
#[diag(
85+
"monomorphising SIMD type `{$ty}` with a non-primitive-scalar (integer/float/pointer) element type `{$e_ty}`"
86+
)]
8387
pub(crate) struct NonPrimitiveSimdType<'tcx> {
8488
pub ty: Ty<'tcx>,
8589
pub e_ty: Ty<'tcx>,
8690
}
8791

8892
#[derive(Diagnostic)]
89-
#[diag(ty_utils_impl_trait_duplicate_arg)]
93+
#[diag("non-defining opaque type use in defining scope")]
9094
pub(crate) struct DuplicateArg<'tcx> {
9195
pub arg: GenericArg<'tcx>,
9296
#[primary_span]
93-
#[label]
97+
#[label("generic argument `{$arg}` used twice")]
9498
pub span: Span,
95-
#[note]
99+
#[note("for this opaque type")]
96100
pub opaque_span: Span,
97101
}
98102

99103
#[derive(Diagnostic)]
100-
#[diag(ty_utils_impl_trait_not_param, code = E0792)]
104+
#[diag("non-defining opaque type use in defining scope", code = E0792)]
101105
pub(crate) struct NotParam<'tcx> {
102106
pub arg: GenericArg<'tcx>,
103107
#[primary_span]
104-
#[label]
108+
#[label("argument `{$arg}` is not a generic parameter")]
105109
pub span: Span,
106-
#[note]
110+
#[note("for this opaque type")]
107111
pub opaque_span: Span,
108112
}

compiler/rustc_ty_utils/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ pub mod sig_types;
3131
mod structural_match;
3232
mod ty;
3333

34-
rustc_fluent_macro::fluent_messages! { "../messages.ftl" }
35-
3634
pub fn provide(providers: &mut Providers) {
3735
abi::provide(providers);
3836
assoc::provide(providers);

0 commit comments

Comments
 (0)