Skip to content

Improvements of librustc_resolve and add missing error codes #26898

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jul 17, 2015
21 changes: 12 additions & 9 deletions src/librustc_resolve/build_reduced_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,10 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
// Return an error here by looking up the namespace that
// had the duplicate.
let ns = ns.unwrap();
self.resolve_error(sp,
&format!("duplicate definition of {} `{}`",
namespace_error_to_string(duplicate_type),
token::get_name(name)));
resolve_err!(self, sp, E0428,
"duplicate definition of {} `{}`",
namespace_error_to_string(duplicate_type),
token::get_name(name));
{
let r = child.span_for_namespace(ns);
if let Some(sp) = r {
Expand Down Expand Up @@ -304,8 +304,9 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
full_path.segments.last().unwrap().identifier.name;
if &token::get_name(source_name)[..] == "mod" ||
&token::get_name(source_name)[..] == "self" {
self.resolve_error(view_path.span,
"`self` imports are only allowed within a { } list");
resolve_err!(self, view_path.span, E0429,
"{}",
"`self` imports are only allowed within a { } list");
}

let subclass = SingleImport(binding.name,
Expand All @@ -325,8 +326,9 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
_ => None
}).collect::<Vec<Span>>();
if mod_spans.len() > 1 {
self.resolve_error(mod_spans[0],
"`self` import can only appear once in the list");
resolve_err!(self, mod_spans[0], E0430,
"{}",
"`self` import can only appear once in the list");
for other_span in mod_spans.iter().skip(1) {
self.session.span_note(*other_span,
"another `self` import appears here");
Expand All @@ -341,7 +343,8 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
let name = match module_path.last() {
Some(name) => *name,
None => {
self.resolve_error(source_item.span,
resolve_err!(self, source_item.span, E0431,
"{}",
"`self` import can only appear in an import list \
with a non-empty prefix");
continue;
Expand Down
46 changes: 43 additions & 3 deletions src/librustc_resolve/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,52 @@ http://doc.rust-lang.org/reference.html#types
}

register_diagnostics! {
E0157,
E0153,
E0153, // called no where
E0157, // called from no where
E0253, // not directly importable
E0254, // import conflicts with imported crate in this module
E0257,
E0258,
E0364, // item is private
E0365 // item is private
E0365, // item is private
E0401, // can't use type parameters from outer function
E0402, // cannot use an outer type parameter in this context
E0403, // the name `{}` is already used
E0404, // is not a trait
E0405, // use of undeclared trait name
E0406, // undeclared associated type
E0407, // method is not a member of trait
E0408, // variable from pattern #1 is not bound in pattern #
E0409, // variable is bound with different mode in pattern # than in
// pattern #1
E0410, // variable from pattern is not bound in pattern 1
E0411, // use of `Self` outside of an impl or trait
E0412, // use of undeclared
E0413, // declaration of shadows an enum variant or unit-like struct in
// scope
E0414, // only irrefutable patterns allowed here
E0415, // identifier is bound more than once in this parameter list
E0416, // identifier is bound more than once in the same pattern
E0417, // static variables cannot be referenced in a pattern, use a
// `const` instead
E0418, // is not an enum variant, struct or const
E0419, // unresolved enum variant, struct or const
E0420, // is not an associated const
E0421, // unresolved associated const
E0422, // does not name a structure
E0423, // is a struct variant name, but this expression uses it like a
// function name
E0424, // `self` is not available in a static method.
E0425, // unresolved name
E0426, // use of undeclared label
E0427, // cannot use `ref` binding mode with ...
E0428, // duplicate definition of ...
E0429, // `self` imports are only allowed within a { } list
E0430, // `self` import can only appear once in the list
E0431, // `self` import can only appear in an import list with a non-empty
// prefix
E0432, // unresolved import
E0433, // failed to resolve
E0434, // can't capture dynamic environment in a fn item
E0435 // attempt to use a non-constant value in a constant
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: why not have a trailing comma?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a macro. In this case, if I add one, an error is reported.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The macro should be improved to allow the trailing comma. It's a separate issue though..

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bluss: I'll take a look to it if you want, but in another PR.

}
Loading