Skip to content

Commit 8b731a5

Browse files
Add error codes
1 parent 2e00b31 commit 8b731a5

File tree

4 files changed

+113
-216
lines changed

4 files changed

+113
-216
lines changed

src/librustc_resolve/build_reduced_graph.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -208,10 +208,10 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
208208
// Return an error here by looking up the namespace that
209209
// had the duplicate.
210210
let ns = ns.unwrap();
211-
self.resolve_error(sp,
212-
&format!("duplicate definition of {} `{}`",
213-
namespace_error_to_string(duplicate_type),
214-
token::get_name(name)));
211+
resolve_err!(self, sp, E0428,
212+
"duplicate definition of {} `{}`",
213+
namespace_error_to_string(duplicate_type),
214+
token::get_name(name));
215215
{
216216
let r = child.span_for_namespace(ns);
217217
if let Some(sp) = r {
@@ -304,8 +304,9 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
304304
full_path.segments.last().unwrap().identifier.name;
305305
if &token::get_name(source_name)[..] == "mod" ||
306306
&token::get_name(source_name)[..] == "self" {
307-
self.resolve_error(view_path.span,
308-
"`self` imports are only allowed within a { } list");
307+
resolve_err!(self, view_path.span, E0429,
308+
"{}",
309+
"`self` imports are only allowed within a { } list");
309310
}
310311

311312
let subclass = SingleImport(binding.name,
@@ -325,8 +326,9 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
325326
_ => None
326327
}).collect::<Vec<Span>>();
327328
if mod_spans.len() > 1 {
328-
self.resolve_error(mod_spans[0],
329-
"`self` import can only appear once in the list");
329+
resolve_err!(self, mod_spans[0], E0430,
330+
"{}",
331+
"`self` import can only appear once in the list");
330332
for other_span in mod_spans.iter().skip(1) {
331333
self.session.span_note(*other_span,
332334
"another `self` import appears here");
@@ -341,7 +343,8 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
341343
let name = match module_path.last() {
342344
Some(name) => *name,
343345
None => {
344-
self.resolve_error(source_item.span,
346+
resolve_err!(self, source_item.span, E0431,
347+
"{}",
345348
"`self` import can only appear in an import list \
346349
with a non-empty prefix");
347350
continue;

src/librustc_resolve/diagnostics.rs

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,5 +209,45 @@ register_diagnostics! {
209209
E0257,
210210
E0258,
211211
E0364, // item is private
212-
E0365 // item is private
212+
E0365, // item is private
213+
E0397, // failed to resolve
214+
E0398, // unresolved import
215+
E0399, // can't capture dynamic environment in a fn item
216+
E0400, // attempt to use a non-constant value in a constant
217+
E0401, // can't use type parameters from outer function
218+
E0402, // cannot use an outer type parameter in this context
219+
E0403, // the name `{}` is already used
220+
E0404, // is not a trait
221+
E0405, // use of undeclared trait name
222+
E0406, // undeclared associated type
223+
E0407, // method is not a member of trait
224+
E0408, // variable from pattern #1 is not bound in pattern #
225+
E0409, // variable is bound with different mode in pattern # than in
226+
// pattern #1
227+
E0410, // variable from pattern is not bound in pattern 1
228+
E0411, // use of `Self` outside of an impl or trait
229+
E0412, // use of undeclared
230+
E0413, // declaration of shadows an enum variant or unit-like struct in
231+
// scope
232+
E0414, // only irrefutable patterns allowed here
233+
E0415, // identifier is bound more than once in this parameter list
234+
E0416, // identifier is bound more than once in the same pattern
235+
E0417, // static variables cannot be referenced in a pattern, use a
236+
// `const` instead
237+
E0418, // is not an enum variant, struct or const
238+
E0419, // unresolved enum variant, struct or const
239+
E0420, // is not an associated const
240+
E0421, // unresolved associated const
241+
E0422, // does not name a structure
242+
E0423, // is a struct variant name, but this expression uses it like a
243+
// function name
244+
E0424, // `self` is not available in a static method.
245+
E0425, // unresolved name
246+
E0426, // use of undeclared label
247+
E0427, // cannot use `ref` binding mode with ...
248+
E0428, // duplicate definition of ...
249+
E0429, // `self` imports are only allowed within a { } list
250+
E0430, // `self` import can only appear once in the list
251+
E0431 // `self` import can only appear in an import list with a non-empty
252+
// prefix
213253
}

0 commit comments

Comments
 (0)