Skip to content

Commit 8a0b5ae

Browse files
committed
Auto merge of rust-lang#119972 - nnethercote:add-ErrCode, r=oli-obk
Add `ErrCode` Error codes are integers, but `String` is used everywhere to represent them. Gross! This commit introduces `ErrCode`, an integral newtype for error codes, replacing `String`. The commit also introduces constants like `E0123` for all the used error codes. r? `@estebank`
2 parents 6351247 + 5d9dfbd commit 8a0b5ae

File tree

110 files changed

+1632
-1579
lines changed

Some content is hidden

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

110 files changed

+1632
-1579
lines changed

Cargo.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -1268,7 +1268,6 @@ name = "error_index_generator"
12681268
version = "0.0.0"
12691269
dependencies = [
12701270
"mdbook",
1271-
"rustc_error_codes",
12721271
]
12731272

12741273
[[package]]
@@ -3701,7 +3700,6 @@ dependencies = [
37013700
"rustc_codegen_ssa",
37023701
"rustc_const_eval",
37033702
"rustc_data_structures",
3704-
"rustc_error_codes",
37053703
"rustc_errors",
37063704
"rustc_expand",
37073705
"rustc_feature",
@@ -3774,9 +3772,11 @@ dependencies = [
37743772
"rustc_ast",
37753773
"rustc_ast_pretty",
37763774
"rustc_data_structures",
3775+
"rustc_error_codes",
37773776
"rustc_error_messages",
37783777
"rustc_fluent_macro",
37793778
"rustc_hir",
3779+
"rustc_index",
37803780
"rustc_lint_defs",
37813781
"rustc_macros",
37823782
"rustc_serialize",

compiler/rustc_ast_lowering/src/errors.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
use rustc_errors::DiagnosticArgFromDisplay;
1+
use rustc_errors::{codes::*, DiagnosticArgFromDisplay};
22
use rustc_macros::{Diagnostic, Subdiagnostic};
33
use rustc_span::{symbol::Ident, Span, Symbol};
44

55
#[derive(Diagnostic, Clone, Copy)]
6-
#[diag(ast_lowering_generic_type_with_parentheses, code = "E0214")]
6+
#[diag(ast_lowering_generic_type_with_parentheses, code = E0214)]
77
pub struct GenericTypeWithParentheses {
88
#[primary_span]
99
#[label]
@@ -22,7 +22,7 @@ pub struct UseAngleBrackets {
2222
}
2323

2424
#[derive(Diagnostic)]
25-
#[diag(ast_lowering_invalid_abi, code = "E0703")]
25+
#[diag(ast_lowering_invalid_abi, code = E0703)]
2626
#[note]
2727
pub struct InvalidAbi {
2828
#[primary_span]
@@ -89,7 +89,7 @@ pub enum AssocTyParenthesesSub {
8989
}
9090

9191
#[derive(Diagnostic)]
92-
#[diag(ast_lowering_misplaced_impl_trait, code = "E0562")]
92+
#[diag(ast_lowering_misplaced_impl_trait, code = E0562)]
9393
#[note]
9494
pub struct MisplacedImplTrait<'a> {
9595
#[primary_span]
@@ -114,15 +114,15 @@ pub struct UnderscoreExprLhsAssign {
114114
}
115115

116116
#[derive(Diagnostic, Clone, Copy)]
117-
#[diag(ast_lowering_base_expression_double_dot, code = "E0797")]
117+
#[diag(ast_lowering_base_expression_double_dot, code = E0797)]
118118
pub struct BaseExpressionDoubleDot {
119119
#[primary_span]
120120
#[suggestion(code = "/* expr */", applicability = "has-placeholders", style = "verbose")]
121121
pub span: Span,
122122
}
123123

124124
#[derive(Diagnostic, Clone, Copy)]
125-
#[diag(ast_lowering_await_only_in_async_fn_and_blocks, code = "E0728")]
125+
#[diag(ast_lowering_await_only_in_async_fn_and_blocks, code = E0728)]
126126
pub struct AwaitOnlyInAsyncFnAndBlocks {
127127
#[primary_span]
128128
#[label]
@@ -132,14 +132,14 @@ pub struct AwaitOnlyInAsyncFnAndBlocks {
132132
}
133133

134134
#[derive(Diagnostic, Clone, Copy)]
135-
#[diag(ast_lowering_coroutine_too_many_parameters, code = "E0628")]
135+
#[diag(ast_lowering_coroutine_too_many_parameters, code = E0628)]
136136
pub struct CoroutineTooManyParameters {
137137
#[primary_span]
138138
pub fn_decl_span: Span,
139139
}
140140

141141
#[derive(Diagnostic, Clone, Copy)]
142-
#[diag(ast_lowering_closure_cannot_be_static, code = "E0697")]
142+
#[diag(ast_lowering_closure_cannot_be_static, code = E0697)]
143143
pub struct ClosureCannotBeStatic {
144144
#[primary_span]
145145
pub fn_decl_span: Span,
@@ -154,14 +154,14 @@ pub struct FunctionalRecordUpdateDestructuringAssignment {
154154
}
155155

156156
#[derive(Diagnostic, Clone, Copy)]
157-
#[diag(ast_lowering_async_coroutines_not_supported, code = "E0727")]
157+
#[diag(ast_lowering_async_coroutines_not_supported, code = E0727)]
158158
pub struct AsyncCoroutinesNotSupported {
159159
#[primary_span]
160160
pub span: Span,
161161
}
162162

163163
#[derive(Diagnostic, Clone, Copy)]
164-
#[diag(ast_lowering_inline_asm_unsupported_target, code = "E0472")]
164+
#[diag(ast_lowering_inline_asm_unsupported_target, code = E0472)]
165165
pub struct InlineAsmUnsupportedTarget {
166166
#[primary_span]
167167
pub span: Span,

compiler/rustc_ast_passes/src/errors.rs

+19-19
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Errors emitted by ast_passes.
22
33
use rustc_ast::ParamKindOrd;
4-
use rustc_errors::{AddToDiagnostic, Applicability};
4+
use rustc_errors::{codes::*, AddToDiagnostic, Applicability};
55
use rustc_macros::{Diagnostic, Subdiagnostic};
66
use rustc_span::{symbol::Ident, Span, Symbol};
77

@@ -23,7 +23,7 @@ pub struct InvalidLabel {
2323
}
2424

2525
#[derive(Diagnostic)]
26-
#[diag(ast_passes_visibility_not_permitted, code = "E0449")]
26+
#[diag(ast_passes_visibility_not_permitted, code = E0449)]
2727
pub struct VisibilityNotPermitted {
2828
#[primary_span]
2929
pub span: Span,
@@ -44,7 +44,7 @@ pub enum VisibilityNotPermittedNote {
4444
}
4545

4646
#[derive(Diagnostic)]
47-
#[diag(ast_passes_trait_fn_const, code = "E0379")]
47+
#[diag(ast_passes_trait_fn_const, code = E0379)]
4848
pub struct TraitFnConst {
4949
#[primary_span]
5050
#[label]
@@ -302,14 +302,14 @@ pub struct ItemUnderscore<'a> {
302302
}
303303

304304
#[derive(Diagnostic)]
305-
#[diag(ast_passes_nomangle_ascii, code = "E0754")]
305+
#[diag(ast_passes_nomangle_ascii, code = E0754)]
306306
pub struct NoMangleAscii {
307307
#[primary_span]
308308
pub span: Span,
309309
}
310310

311311
#[derive(Diagnostic)]
312-
#[diag(ast_passes_module_nonascii, code = "E0754")]
312+
#[diag(ast_passes_module_nonascii, code = E0754)]
313313
#[help]
314314
pub struct ModuleNonAscii {
315315
#[primary_span]
@@ -318,7 +318,7 @@ pub struct ModuleNonAscii {
318318
}
319319

320320
#[derive(Diagnostic)]
321-
#[diag(ast_passes_auto_generic, code = "E0567")]
321+
#[diag(ast_passes_auto_generic, code = E0567)]
322322
pub struct AutoTraitGeneric {
323323
#[primary_span]
324324
#[suggestion(code = "", applicability = "machine-applicable")]
@@ -328,7 +328,7 @@ pub struct AutoTraitGeneric {
328328
}
329329

330330
#[derive(Diagnostic)]
331-
#[diag(ast_passes_auto_super_lifetime, code = "E0568")]
331+
#[diag(ast_passes_auto_super_lifetime, code = E0568)]
332332
pub struct AutoTraitBounds {
333333
#[primary_span]
334334
#[suggestion(code = "", applicability = "machine-applicable")]
@@ -338,7 +338,7 @@ pub struct AutoTraitBounds {
338338
}
339339

340340
#[derive(Diagnostic)]
341-
#[diag(ast_passes_auto_items, code = "E0380")]
341+
#[diag(ast_passes_auto_items, code = E0380)]
342342
pub struct AutoTraitItems {
343343
#[primary_span]
344344
pub spans: Vec<Span>,
@@ -384,28 +384,28 @@ impl AddToDiagnostic for EmptyLabelManySpans {
384384
}
385385

386386
#[derive(Diagnostic)]
387-
#[diag(ast_passes_pattern_in_fn_pointer, code = "E0561")]
387+
#[diag(ast_passes_pattern_in_fn_pointer, code = E0561)]
388388
pub struct PatternFnPointer {
389389
#[primary_span]
390390
pub span: Span,
391391
}
392392

393393
#[derive(Diagnostic)]
394-
#[diag(ast_passes_trait_object_single_bound, code = "E0226")]
394+
#[diag(ast_passes_trait_object_single_bound, code = E0226)]
395395
pub struct TraitObjectBound {
396396
#[primary_span]
397397
pub span: Span,
398398
}
399399

400400
#[derive(Diagnostic)]
401-
#[diag(ast_passes_impl_trait_path, code = "E0667")]
401+
#[diag(ast_passes_impl_trait_path, code = E0667)]
402402
pub struct ImplTraitPath {
403403
#[primary_span]
404404
pub span: Span,
405405
}
406406

407407
#[derive(Diagnostic)]
408-
#[diag(ast_passes_nested_impl_trait, code = "E0666")]
408+
#[diag(ast_passes_nested_impl_trait, code = E0666)]
409409
pub struct NestedImplTrait {
410410
#[primary_span]
411411
pub span: Span,
@@ -443,7 +443,7 @@ pub struct ObsoleteAuto {
443443
}
444444

445445
#[derive(Diagnostic)]
446-
#[diag(ast_passes_unsafe_negative_impl, code = "E0198")]
446+
#[diag(ast_passes_unsafe_negative_impl, code = E0198)]
447447
pub struct UnsafeNegativeImpl {
448448
#[primary_span]
449449
pub span: Span,
@@ -468,7 +468,7 @@ pub struct InherentImplCannot<'a> {
468468
}
469469

470470
#[derive(Diagnostic)]
471-
#[diag(ast_passes_inherent_cannot_be, code = "E0197")]
471+
#[diag(ast_passes_inherent_cannot_be, code = E0197)]
472472
pub struct InherentImplCannotUnsafe<'a> {
473473
#[primary_span]
474474
pub span: Span,
@@ -536,7 +536,7 @@ pub struct GenericDefaultTrailing {
536536
}
537537

538538
#[derive(Diagnostic)]
539-
#[diag(ast_passes_nested_lifetimes, code = "E0316")]
539+
#[diag(ast_passes_nested_lifetimes, code = E0316)]
540540
pub struct NestedLifetimes {
541541
#[primary_span]
542542
pub span: Span,
@@ -655,15 +655,15 @@ pub struct ConstAndCVariadic {
655655
}
656656

657657
#[derive(Diagnostic)]
658-
#[diag(ast_passes_pattern_in_foreign, code = "E0130")]
658+
#[diag(ast_passes_pattern_in_foreign, code = E0130)]
659659
pub struct PatternInForeign {
660660
#[primary_span]
661661
#[label]
662662
pub span: Span,
663663
}
664664

665665
#[derive(Diagnostic)]
666-
#[diag(ast_passes_pattern_in_bodiless, code = "E0642")]
666+
#[diag(ast_passes_pattern_in_bodiless, code = E0642)]
667667
pub struct PatternInBodiless {
668668
#[primary_span]
669669
#[label]
@@ -711,14 +711,14 @@ pub struct AssociatedSuggestion2 {
711711
}
712712

713713
#[derive(Diagnostic)]
714-
#[diag(ast_passes_stability_outside_std, code = "E0734")]
714+
#[diag(ast_passes_stability_outside_std, code = E0734)]
715715
pub struct StabilityOutsideStd {
716716
#[primary_span]
717717
pub span: Span,
718718
}
719719

720720
#[derive(Diagnostic)]
721-
#[diag(ast_passes_feature_on_non_nightly, code = "E0554")]
721+
#[diag(ast_passes_feature_on_non_nightly, code = E0554)]
722722
pub struct FeatureOnNonNightly {
723723
#[primary_span]
724724
pub span: Span,

0 commit comments

Comments
 (0)