Skip to content

Commit cf629e7

Browse files
committed
Add error codes to resolve
1 parent f68029e commit cf629e7

File tree

2 files changed

+25
-17
lines changed

2 files changed

+25
-17
lines changed

src/librustc_resolve/diagnostics.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,17 @@
1212

1313
register_diagnostics! {
1414
E0157,
15-
E0153
15+
E0153,
16+
E0251, // a named type or value has already been imported in this module
17+
E0252, // a named type or value has already been imported in this module
18+
E0253, // not directly importable
19+
E0254, // import conflicts with imported crate in this module
20+
E0255, // import conflicts with value in this module
21+
E0256, // import conflicts with type in this module
22+
E0257, // inherent implementations are only allowen on types defined in the current module
23+
E0258, // import conflicts with existing submodule
24+
E0259, // an extern crate has already been imported into this module
25+
E0260 // name conflicts with an external crate that has been imported into this module
1626
}
1727

1828
__build_diagnostic_array! { DIAGNOSTICS }

src/librustc_resolve/lib.rs

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1722,7 +1722,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
17221722
in this module",
17231723
namespace_name,
17241724
token::get_name(name).get());
1725-
self.session.span_err(import_directive.span, msg.as_slice());
1725+
span_err!(self.session, import_directive.span, E0251, "{}", msg.as_slice());
17261726
} else {
17271727
let target = Target::new(containing_module.clone(),
17281728
name_bindings.clone(),
@@ -1769,7 +1769,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
17691769
ValueNS => "value",
17701770
},
17711771
token::get_name(name).get());
1772-
self.session.span_err(import_span, &msg[]);
1772+
span_err!(self.session, import_span, E0252, "{}", &msg[]);
17731773
}
17741774
Some(_) | None => {}
17751775
}
@@ -1784,7 +1784,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
17841784
if !name_bindings.defined_in_namespace_with(namespace, IMPORTABLE) {
17851785
let msg = format!("`{}` is not directly importable",
17861786
token::get_name(name));
1787-
self.session.span_err(import_span, &msg[]);
1787+
span_err!(self.session, import_span, E0253, "{}", &msg[]);
17881788
}
17891789
}
17901790

@@ -1809,7 +1809,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
18091809
crate in this module \
18101810
(maybe you meant `use {0}::*`?)",
18111811
token::get_name(name).get());
1812-
self.session.span_err(import_span, &msg[]);
1812+
span_err!(self.session, import_span, E0254, "{}", &msg[]);
18131813
}
18141814
Some(_) | None => {}
18151815
}
@@ -1831,7 +1831,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
18311831
let msg = format!("import `{}` conflicts with value \
18321832
in this module",
18331833
token::get_name(name).get());
1834-
self.session.span_err(import_span, &msg[]);
1834+
span_err!(self.session, import_span, E0255, "{}", &msg[]);
18351835
if let Some(span) = value.value_span {
18361836
self.session.span_note(span,
18371837
"conflicting value here");
@@ -1849,7 +1849,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
18491849
let msg = format!("import `{}` conflicts with type in \
18501850
this module",
18511851
token::get_name(name).get());
1852-
self.session.span_err(import_span, &msg[]);
1852+
span_err!(self.session, import_span, E0256, "{}", &msg[]);
18531853
if let Some(span) = ty.type_span {
18541854
self.session.span_note(span,
18551855
"note conflicting type here")
@@ -1862,7 +1862,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
18621862
let msg = format!("inherent implementations \
18631863
are only allowed on types \
18641864
defined in the current module");
1865-
self.session.span_err(span, &msg[]);
1865+
span_err!(self.session, span, E0257, "{}", &msg[]);
18661866
self.session.span_note(import_span,
18671867
"import from other module here")
18681868
}
@@ -1871,7 +1871,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
18711871
let msg = format!("import `{}` conflicts with existing \
18721872
submodule",
18731873
token::get_name(name).get());
1874-
self.session.span_err(import_span, &msg[]);
1874+
span_err!(self.session, import_span, E0258, "{}", &msg[]);
18751875
if let Some(span) = ty.type_span {
18761876
self.session.span_note(span,
18771877
"note conflicting module here")
@@ -1897,11 +1897,10 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
18971897
}
18981898

18991899
if module.external_module_children.borrow().contains_key(&name) {
1900-
self.session
1901-
.span_err(span,
1902-
&format!("an external crate named `{}` has already \
1900+
span_err!(self.session, span, E0259,
1901+
"an external crate named `{}` has already \
19031902
been imported into this module",
1904-
token::get_name(name).get())[]);
1903+
token::get_name(name).get());
19051904
}
19061905
}
19071906

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

19171916
if module.external_module_children.borrow().contains_key(&name) {
1918-
self.session
1919-
.span_err(span,
1920-
&format!("the name `{}` conflicts with an external \
1917+
span_err!(self.session, span, E0260,
1918+
"the name `{}` conflicts with an external \
19211919
crate that has been imported into this \
19221920
module",
1923-
token::get_name(name).get())[]);
1921+
token::get_name(name).get());
19241922
}
19251923
}
19261924

0 commit comments

Comments
 (0)