@@ -122,6 +122,8 @@ enum SuggestionType {
122
122
}
123
123
124
124
pub enum ResolutionError < ' a > {
125
+ /// error E0260: name conflicts with an extern crate
126
+ NameConflictsWithExternCrate ( Name ) ,
125
127
/// error E0401: can't use type parameters from outer function
126
128
TypeParametersFromOuterFunction ,
127
129
/// error E0402: cannot use an outer type parameter in this context
@@ -228,6 +230,14 @@ fn resolve_struct_error<'b, 'a: 'b, 'tcx: 'a>(resolver: &'b Resolver<'a, 'tcx>,
228
230
}
229
231
230
232
match resolution_error {
233
+ ResolutionError :: NameConflictsWithExternCrate ( name) => {
234
+ struct_span_err ! ( resolver. session,
235
+ span,
236
+ E0260 ,
237
+ "the name `{}` conflicts with an external crate \
238
+ that has been imported into this module",
239
+ name)
240
+ }
231
241
ResolutionError :: TypeParametersFromOuterFunction => {
232
242
struct_span_err ! ( resolver. session,
233
243
span,
@@ -1292,19 +1302,23 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
1292
1302
}
1293
1303
}
1294
1304
1295
- /// Checks that the names of external crates don't collide with other
1296
- /// external crates.
1297
- fn check_for_conflicts_between_external_crates ( & self ,
1298
- module : & Module ,
1299
- name : Name ,
1300
- span : Span ) {
1305
+ /// Check that an external crate doesn't collide with items or other external crates.
1306
+ fn check_for_conflicts_for_external_crate ( & self , module : & Module , name : Name , span : Span ) {
1301
1307
if module. external_module_children . borrow ( ) . contains_key ( & name) {
1302
1308
span_err ! ( self . session,
1303
1309
span,
1304
1310
E0259 ,
1305
1311
"an external crate named `{}` has already been imported into this module" ,
1306
1312
name) ;
1307
1313
}
1314
+ match module. children . borrow ( ) . get ( & name) {
1315
+ Some ( name_bindings) if name_bindings. type_ns . defined ( ) => {
1316
+ resolve_error ( self ,
1317
+ name_bindings. type_ns . span ( ) . unwrap_or ( codemap:: DUMMY_SP ) ,
1318
+ ResolutionError :: NameConflictsWithExternCrate ( name) ) ;
1319
+ }
1320
+ _ => { } ,
1321
+ }
1308
1322
}
1309
1323
1310
1324
/// Checks that the names of items don't collide with external crates.
@@ -1313,12 +1327,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
1313
1327
name : Name ,
1314
1328
span : Span ) {
1315
1329
if module. external_module_children . borrow ( ) . contains_key ( & name) {
1316
- span_err ! ( self . session,
1317
- span,
1318
- E0260 ,
1319
- "the name `{}` conflicts with an external crate that has been imported \
1320
- into this module",
1321
- name) ;
1330
+ resolve_error ( self , span, ResolutionError :: NameConflictsWithExternCrate ( name) ) ;
1322
1331
}
1323
1332
}
1324
1333
0 commit comments