Skip to content

Commit 1da1a46

Browse files
committed
Rollup merge of rust-lang#26898 - GuillaumeGomez:fixup, r=eddyb
r? @eddyb First part of the improvement. I then intend to improve resolve_error as indicated by @eddyb. Do not merge for now (please !).
2 parents 38e875a + 60133aa commit 1da1a46

File tree

4 files changed

+539
-216
lines changed

4 files changed

+539
-216
lines changed

src/librustc_resolve/build_reduced_graph.rs

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ use ParentLink::{self, ModuleParentLink, BlockParentLink};
2626
use Resolver;
2727
use resolve_imports::Shadowable;
2828
use TypeNsDef;
29+
use {resolve_error, ResolutionError};
2930

3031
use self::DuplicateCheckingMode::*;
3132
use self::NamespaceError::*;
@@ -208,10 +209,13 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
208209
// Return an error here by looking up the namespace that
209210
// had the duplicate.
210211
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)));
212+
resolve_error(
213+
self,
214+
sp,
215+
ResolutionError::DuplicateDefinition(
216+
namespace_error_to_string(duplicate_type),
217+
name)
218+
);
215219
{
216220
let r = child.span_for_namespace(ns);
217221
if let Some(sp) = r {
@@ -304,8 +308,10 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
304308
full_path.segments.last().unwrap().identifier.name;
305309
if &token::get_name(source_name)[..] == "mod" ||
306310
&token::get_name(source_name)[..] == "self" {
307-
self.resolve_error(view_path.span,
308-
"`self` imports are only allowed within a { } list");
311+
resolve_error(self,
312+
view_path.span,
313+
ResolutionError::SelfImportsOnlyAllowedWithin
314+
);
309315
}
310316

311317
let subclass = SingleImport(binding.name,
@@ -325,8 +331,11 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
325331
_ => None
326332
}).collect::<Vec<Span>>();
327333
if mod_spans.len() > 1 {
328-
self.resolve_error(mod_spans[0],
329-
"`self` import can only appear once in the list");
334+
resolve_error(
335+
self,
336+
mod_spans[0],
337+
ResolutionError::SelfImportCanOnlyAppearOnceInTheList
338+
);
330339
for other_span in mod_spans.iter().skip(1) {
331340
self.session.span_note(*other_span,
332341
"another `self` import appears here");
@@ -341,9 +350,12 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
341350
let name = match module_path.last() {
342351
Some(name) => *name,
343352
None => {
344-
self.resolve_error(source_item.span,
345-
"`self` import can only appear in an import list \
346-
with a non-empty prefix");
353+
resolve_error(
354+
self,
355+
source_item.span,
356+
ResolutionError::
357+
SelfImportOnlyInImportListWithNonEmptyPrefix
358+
);
347359
continue;
348360
}
349361
};

src/librustc_resolve/diagnostics.rs

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,12 +202,52 @@ http://doc.rust-lang.org/reference.html#types
202202
}
203203

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

0 commit comments

Comments
 (0)