Skip to content

Commit 7eb1e98

Browse files
Transform error codes into strings
1 parent 01a8b5f commit 7eb1e98

File tree

70 files changed

+402
-392
lines changed

Some content is hidden

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

70 files changed

+402
-392
lines changed

src/librustc/mir/interpret/error.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ impl<'tcx> ConstEvalErr<'tcx> {
212212
}
213213

214214
pub fn struct_error<'tcx>(tcx: TyCtxtAt<'tcx>, msg: &str) -> DiagnosticBuilder<'tcx> {
215-
struct_span_err!(tcx.sess, tcx.span, E0080, "{}", msg)
215+
struct_span_err!(tcx.sess, tcx.span, "E0080", "{}", msg)
216216
}
217217

218218
/// Packages the kind of error we got from the const code interpreter

src/librustc/ty/query/plumbing.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ impl<'tcx> TyCtxt<'tcx> {
346346
let mut err = struct_span_err!(
347347
self.sess,
348348
span,
349-
E0391,
349+
"E0391",
350350
"cycle detected when {}",
351351
stack[0].query.describe(self)
352352
);

src/librustc_ast_lowering/expr.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
540540
let mut err = struct_span_err!(
541541
self.sess,
542542
await_span,
543-
E0728,
543+
"E0728",
544544
"`await` is only allowed inside `async` functions and blocks"
545545
);
546546
err.span_label(await_span, "only allowed inside `async` functions and blocks");
@@ -692,7 +692,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
692692
struct_span_err!(
693693
self.sess,
694694
fn_decl_span,
695-
E0628,
695+
"E0628",
696696
"too many parameters for a generator (expected 0 or 1 parameters)"
697697
)
698698
.emit();
@@ -704,7 +704,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
704704
}
705705
None => {
706706
if movability == Movability::Static {
707-
struct_span_err!(self.sess, fn_decl_span, E0697, "closures cannot be static")
707+
struct_span_err!(self.sess, fn_decl_span, "E0697", "closures cannot be static")
708708
.emit();
709709
}
710710
None
@@ -733,7 +733,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
733733
struct_span_err!(
734734
this.sess,
735735
fn_decl_span,
736-
E0708,
736+
"E0708",
737737
"`async` non-`move` closures with parameters are not currently supported",
738738
)
739739
.help(
@@ -946,7 +946,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
946946
struct_span_err!(
947947
self.sess,
948948
span,
949-
E0727,
949+
"E0727",
950950
"`async` generators are not yet supported"
951951
)
952952
.emit();

src/librustc_ast_lowering/item.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1269,7 +1269,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
12691269
}
12701270

12711271
fn error_on_invalid_abi(&self, abi: StrLit) {
1272-
struct_span_err!(self.sess, abi.span, E0703, "invalid ABI: found `{}`", abi.symbol)
1272+
struct_span_err!(self.sess, abi.span, "E0703", "invalid ABI: found `{}`", abi.symbol)
12731273
.span_label(abi.span, "invalid ABI")
12741274
.help(&format!("valid ABIs: {}", abi::all_names().join(", ")))
12751275
.emit();

src/librustc_ast_lowering/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1318,7 +1318,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
13181318
let mut err = struct_span_err!(
13191319
self.sess,
13201320
t.span,
1321-
E0562,
1321+
"E0562",
13221322
"`impl Trait` not allowed outside of {}",
13231323
allowed_in,
13241324
);
@@ -2532,7 +2532,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
25322532
),
25332533
};
25342534

2535-
let mut err = struct_span_err!(self.sess, span, E0637, "{}", msg,);
2535+
let mut err = struct_span_err!(self.sess, span, "E0637", "{}", msg,);
25362536
err.span_label(span, label);
25372537
err.emit();
25382538

src/librustc_ast_passes/ast_validation.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ impl<'a> AstValidator<'a> {
202202
}
203203

204204
let mut err =
205-
struct_span_err!(self.session, vis.span, E0449, "unnecessary visibility qualifier");
205+
struct_span_err!(self.session, vis.span, "E0449", "unnecessary visibility qualifier");
206206
if vis.node.is_pub() {
207207
err.span_label(vis.span, "`pub` not permitted here because it's implied");
208208
}
@@ -229,7 +229,7 @@ impl<'a> AstValidator<'a> {
229229
struct_span_err!(
230230
self.session,
231231
fn_span,
232-
E0706,
232+
"E0706",
233233
"functions in traits cannot be declared `async`"
234234
)
235235
.span_label(span, "`async` because of this")
@@ -244,7 +244,7 @@ impl<'a> AstValidator<'a> {
244244
struct_span_err!(
245245
self.session,
246246
span,
247-
E0379,
247+
"E0379",
248248
"functions in traits cannot be declared const"
249249
)
250250
.span_label(span, "functions in traits cannot be const")
@@ -700,7 +700,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
700700
struct_span_err!(
701701
self.session,
702702
expr.span,
703-
E0472,
703+
"E0472",
704704
"asm! is unsupported on this target"
705705
)
706706
.emit();
@@ -719,7 +719,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
719719
struct_span_err!(
720720
self.session,
721721
span,
722-
E0561,
722+
"E0561",
723723
"patterns aren't allowed in function pointer types"
724724
)
725725
.emit();
@@ -734,7 +734,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
734734
struct_span_err!(
735735
self.session,
736736
lifetime.ident.span,
737-
E0226,
737+
"E0226",
738738
"only a single explicit lifetime bound is permitted"
739739
)
740740
.emit();
@@ -750,7 +750,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
750750
struct_span_err!(
751751
self.session,
752752
ty.span,
753-
E0667,
753+
"E0667",
754754
"`impl Trait` is not allowed in path parameters"
755755
)
756756
.emit();
@@ -760,7 +760,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
760760
struct_span_err!(
761761
self.session,
762762
ty.span,
763-
E0666,
763+
"E0666",
764764
"nested `impl Trait` is not allowed"
765765
)
766766
.span_label(outer_impl_trait_sp, "outer `impl Trait`")
@@ -854,7 +854,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
854854
struct_span_err!(
855855
self.session,
856856
item.span,
857-
E0197,
857+
"E0197",
858858
"inherent impls cannot be unsafe"
859859
)
860860
.span_label(span, "unsafe because of this")
@@ -910,7 +910,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
910910
struct_span_err!(
911911
self.session,
912912
item.span,
913-
E0567,
913+
"E0567",
914914
"auto traits cannot have generic parameters"
915915
)
916916
.emit();
@@ -919,7 +919,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
919919
struct_span_err!(
920920
self.session,
921921
item.span,
922-
E0568,
922+
"E0568",
923923
"auto traits cannot have super traits"
924924
)
925925
.emit();
@@ -928,7 +928,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
928928
struct_span_err!(
929929
self.session,
930930
item.span,
931-
E0380,
931+
"E0380",
932932
"auto traits cannot have methods or associated items"
933933
)
934934
.emit();

src/librustc_attr/builtin.rs

+21-20
Original file line numberDiff line numberDiff line change
@@ -29,25 +29,25 @@ fn handle_errors(sess: &ParseSess, span: Span, error: AttrError) {
2929
let diag = &sess.span_diagnostic;
3030
match error {
3131
AttrError::MultipleItem(item) => {
32-
struct_span_err!(diag, span, E0538, "multiple '{}' items", item).emit();
32+
struct_span_err!(diag, span, "E0538", "multiple '{}' items", item).emit();
3333
}
3434
AttrError::UnknownMetaItem(item, expected) => {
3535
let expected = expected.iter().map(|name| format!("`{}`", name)).collect::<Vec<_>>();
36-
struct_span_err!(diag, span, E0541, "unknown meta item '{}'", item)
36+
struct_span_err!(diag, span, "E0541", "unknown meta item '{}'", item)
3737
.span_label(span, format!("expected one of {}", expected.join(", ")))
3838
.emit();
3939
}
4040
AttrError::MissingSince => {
41-
struct_span_err!(diag, span, E0542, "missing 'since'").emit();
41+
struct_span_err!(diag, span, "E0542", "missing 'since'").emit();
4242
}
4343
AttrError::MissingFeature => {
44-
struct_span_err!(diag, span, E0546, "missing 'feature'").emit();
44+
struct_span_err!(diag, span, "E0546", "missing 'feature'").emit();
4545
}
4646
AttrError::MultipleStabilityLevels => {
47-
struct_span_err!(diag, span, E0544, "multiple stability levels").emit();
47+
struct_span_err!(diag, span, "E0544", "multiple stability levels").emit();
4848
}
4949
AttrError::UnsupportedLiteral(msg, is_bytestr) => {
50-
let mut err = struct_span_err!(diag, span, E0565, "{}", msg);
50+
let mut err = struct_span_err!(diag, span, "E0565", "{}", msg);
5151
if is_bytestr {
5252
if let Ok(lint_str) = sess.source_map().span_to_snippet(span) {
5353
err.span_suggestion(
@@ -99,7 +99,8 @@ pub fn find_unwind_attr(diagnostic: Option<&Handler>, attrs: &[Attribute]) -> Op
9999
}
100100

101101
diagnostic.map(|d| {
102-
struct_span_err!(d, attr.span, E0633, "malformed `unwind` attribute input")
102+
struct_span_err!(d, attr.span, "E0633",
103+
"malformed `unwind` attribute input")
103104
.span_label(attr.span, "invalid argument")
104105
.span_suggestions(
105106
attr.span,
@@ -286,7 +287,7 @@ where
286287
*item = Some(v);
287288
true
288289
} else {
289-
struct_span_err!(diagnostic, meta.span, E0539, "incorrect meta item").emit();
290+
struct_span_err!(diagnostic, meta.span, "E0539", "incorrect meta item").emit();
290291
false
291292
}
292293
};
@@ -337,7 +338,7 @@ where
337338
struct_span_err!(
338339
diagnostic,
339340
item_sp,
340-
E0540,
341+
"E0540",
341342
"multiple rustc_deprecated attributes"
342343
)
343344
.emit();
@@ -355,7 +356,7 @@ where
355356
continue;
356357
}
357358
_ => {
358-
struct_span_err!(diagnostic, attr.span, E0543, "missing 'reason'")
359+
struct_span_err!(diagnostic, attr.span, "E0543", "missing 'reason'")
359360
.emit();
360361
continue;
361362
}
@@ -477,7 +478,7 @@ where
477478
continue;
478479
}
479480
_ => {
480-
struct_span_err!(diagnostic, attr.span, E0547, "missing 'issue'")
481+
struct_span_err!(diagnostic, attr.span, "E0547", "missing 'issue'")
481482
.emit();
482483
continue;
483484
}
@@ -567,7 +568,7 @@ where
567568
struct_span_err!(
568569
diagnostic,
569570
item_sp,
570-
E0549,
571+
"E0549",
571572
"rustc_deprecated attribute must be paired with \
572573
either stable or unstable attribute"
573574
)
@@ -584,7 +585,7 @@ where
584585
struct_span_err!(
585586
diagnostic,
586587
item_sp,
587-
E0717,
588+
"E0717",
588589
"rustc_promotable and rustc_allow_const_fn_ptr attributes \
589590
must be paired with either a rustc_const_unstable or a rustc_const_stable \
590591
attribute"
@@ -679,7 +680,7 @@ pub fn eval_condition(
679680
struct_span_err!(
680681
sess.span_diagnostic,
681682
cfg.span,
682-
E0536,
683+
"E0536",
683684
"expected 1 cfg-pattern"
684685
)
685686
.emit();
@@ -692,7 +693,7 @@ pub fn eval_condition(
692693
struct_span_err!(
693694
sess.span_diagnostic,
694695
cfg.span,
695-
E0537,
696+
"E0537",
696697
"invalid predicate `{}`",
697698
pprust::path_to_string(&cfg.path)
698699
)
@@ -737,7 +738,7 @@ where
737738
}
738739

739740
if depr.is_some() {
740-
struct_span_err!(diagnostic, item_sp, E0550, "multiple deprecated attributes").emit();
741+
struct_span_err!(diagnostic, item_sp, "E0550", "multiple deprecated attributes").emit();
741742
break;
742743
}
743744

@@ -775,7 +776,7 @@ where
775776
),
776777
);
777778
} else {
778-
struct_span_err!(diagnostic, meta.span, E0551, "incorrect meta item")
779+
struct_span_err!(diagnostic, meta.span, "E0551", "incorrect meta item")
779780
.emit();
780781
}
781782

@@ -940,7 +941,7 @@ pub fn find_repr_attrs(sess: &ParseSess, attr: &Attribute) -> Vec<ReprAttr> {
940941
struct_span_err!(
941942
diagnostic,
942943
item.span(),
943-
E0589,
944+
"E0589",
944945
"invalid `repr(align)` attribute: {}",
945946
literal_error
946947
)
@@ -954,7 +955,7 @@ pub fn find_repr_attrs(sess: &ParseSess, attr: &Attribute) -> Vec<ReprAttr> {
954955
let mut err = struct_span_err!(
955956
diagnostic,
956957
item.span(),
957-
E0693,
958+
"E0693",
958959
"incorrect `repr(align)` attribute format"
959960
);
960961
match value.kind {
@@ -986,7 +987,7 @@ pub fn find_repr_attrs(sess: &ParseSess, attr: &Attribute) -> Vec<ReprAttr> {
986987
struct_span_err!(
987988
diagnostic,
988989
item.span(),
989-
E0552,
990+
"E0552",
990991
"unrecognized representation hint"
991992
)
992993
.emit();

0 commit comments

Comments
 (0)