Skip to content

Commit

Permalink
Rollup merge of rust-lang#26898 - GuillaumeGomez:fixup, r=eddyb
Browse files Browse the repository at this point in the history
 r? @eddyb

First part of the improvement. I then intend to improve resolve_error as indicated by @eddyb. Do not merge for now (please !).
  • Loading branch information
Manishearth committed Jul 16, 2015
2 parents 38e875a + 60133aa commit 1da1a46
Show file tree
Hide file tree
Showing 4 changed files with 539 additions and 216 deletions.
34 changes: 23 additions & 11 deletions src/librustc_resolve/build_reduced_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use ParentLink::{self, ModuleParentLink, BlockParentLink};
use Resolver;
use resolve_imports::Shadowable;
use TypeNsDef;
use {resolve_error, ResolutionError};

use self::DuplicateCheckingMode::*;
use self::NamespaceError::*;
Expand Down Expand Up @@ -208,10 +209,13 @@ 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_error(
self,
sp,
ResolutionError::DuplicateDefinition(
namespace_error_to_string(duplicate_type),
name)
);
{
let r = child.span_for_namespace(ns);
if let Some(sp) = r {
Expand Down Expand Up @@ -304,8 +308,10 @@ 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_error(self,
view_path.span,
ResolutionError::SelfImportsOnlyAllowedWithin
);
}

let subclass = SingleImport(binding.name,
Expand All @@ -325,8 +331,11 @@ 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_error(
self,
mod_spans[0],
ResolutionError::SelfImportCanOnlyAppearOnceInTheList
);
for other_span in mod_spans.iter().skip(1) {
self.session.span_note(*other_span,
"another `self` import appears here");
Expand All @@ -341,9 +350,12 @@ 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,
"`self` import can only appear in an import list \
with a non-empty prefix");
resolve_error(
self,
source_item.span,
ResolutionError::
SelfImportOnlyInImportListWithNonEmptyPrefix
);
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
}
Loading

0 comments on commit 1da1a46

Please sign in to comment.