Skip to content

Commit

Permalink
Add error codes to resolve
Browse files Browse the repository at this point in the history
  • Loading branch information
brson committed Jan 20, 2015
1 parent f68029e commit cf629e7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 17 deletions.
12 changes: 11 additions & 1 deletion src/librustc_resolve/diagnostics.rs
Expand Up @@ -12,7 +12,17 @@

register_diagnostics! {
E0157,
E0153
E0153,
E0251, // a named type or value has already been imported in this module
E0252, // a named type or value has already been imported in this module
E0253, // not directly importable
E0254, // import conflicts with imported crate in this module
E0255, // import conflicts with value in this module
E0256, // import conflicts with type in this module
E0257, // inherent implementations are only allowen on types defined in the current module
E0258, // import conflicts with existing submodule
E0259, // an extern crate has already been imported into this module
E0260 // name conflicts with an external crate that has been imported into this module
}

__build_diagnostic_array! { DIAGNOSTICS }
30 changes: 14 additions & 16 deletions src/librustc_resolve/lib.rs
Expand Up @@ -1722,7 +1722,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
in this module",
namespace_name,
token::get_name(name).get());
self.session.span_err(import_directive.span, msg.as_slice());
span_err!(self.session, import_directive.span, E0251, "{}", msg.as_slice());
} else {
let target = Target::new(containing_module.clone(),
name_bindings.clone(),
Expand Down Expand Up @@ -1769,7 +1769,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
ValueNS => "value",
},
token::get_name(name).get());
self.session.span_err(import_span, &msg[]);
span_err!(self.session, import_span, E0252, "{}", &msg[]);
}
Some(_) | None => {}
}
Expand All @@ -1784,7 +1784,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
if !name_bindings.defined_in_namespace_with(namespace, IMPORTABLE) {
let msg = format!("`{}` is not directly importable",
token::get_name(name));
self.session.span_err(import_span, &msg[]);
span_err!(self.session, import_span, E0253, "{}", &msg[]);
}
}

Expand All @@ -1809,7 +1809,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
crate in this module \
(maybe you meant `use {0}::*`?)",
token::get_name(name).get());
self.session.span_err(import_span, &msg[]);
span_err!(self.session, import_span, E0254, "{}", &msg[]);
}
Some(_) | None => {}
}
Expand All @@ -1831,7 +1831,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
let msg = format!("import `{}` conflicts with value \
in this module",
token::get_name(name).get());
self.session.span_err(import_span, &msg[]);
span_err!(self.session, import_span, E0255, "{}", &msg[]);
if let Some(span) = value.value_span {
self.session.span_note(span,
"conflicting value here");
Expand All @@ -1849,7 +1849,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
let msg = format!("import `{}` conflicts with type in \
this module",
token::get_name(name).get());
self.session.span_err(import_span, &msg[]);
span_err!(self.session, import_span, E0256, "{}", &msg[]);
if let Some(span) = ty.type_span {
self.session.span_note(span,
"note conflicting type here")
Expand All @@ -1862,7 +1862,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
let msg = format!("inherent implementations \
are only allowed on types \
defined in the current module");
self.session.span_err(span, &msg[]);
span_err!(self.session, span, E0257, "{}", &msg[]);
self.session.span_note(import_span,
"import from other module here")
}
Expand All @@ -1871,7 +1871,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
let msg = format!("import `{}` conflicts with existing \
submodule",
token::get_name(name).get());
self.session.span_err(import_span, &msg[]);
span_err!(self.session, import_span, E0258, "{}", &msg[]);
if let Some(span) = ty.type_span {
self.session.span_note(span,
"note conflicting module here")
Expand All @@ -1897,11 +1897,10 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
}

if module.external_module_children.borrow().contains_key(&name) {
self.session
.span_err(span,
&format!("an external crate named `{}` has already \
span_err!(self.session, span, E0259,
"an external crate named `{}` has already \
been imported into this module",
token::get_name(name).get())[]);
token::get_name(name).get());
}
}

Expand All @@ -1915,12 +1914,11 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
}

if module.external_module_children.borrow().contains_key(&name) {
self.session
.span_err(span,
&format!("the name `{}` conflicts with an external \
span_err!(self.session, span, E0260,
"the name `{}` conflicts with an external \
crate that has been imported into this \
module",
token::get_name(name).get())[]);
token::get_name(name).get());
}
}

Expand Down

0 comments on commit cf629e7

Please sign in to comment.