@@ -2210,23 +2210,39 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
2210
2210
2211
2211
ItemUse ( ref view_path) => {
2212
2212
// check for imports shadowing primitive types
2213
- let check_rename = |id, ident : Ident | {
2214
- match self . def_map . borrow ( ) . get ( & id) . map ( |d| d. full_def ( ) ) {
2213
+ let check_rename = |this : & Self , id, ident : Ident | {
2214
+ match this . def_map . borrow ( ) . get ( & id) . map ( |d| d. full_def ( ) ) {
2215
2215
Some ( DefTy ( ..) ) | Some ( DefStruct ( ..) ) | Some ( DefTrait ( ..) ) | None => {
2216
- self . check_if_primitive_type_name ( ident. name , item. span ) ;
2216
+ this . check_if_primitive_type_name ( ident. name , item. span ) ;
2217
2217
}
2218
2218
_ => { }
2219
2219
}
2220
2220
} ;
2221
2221
2222
2222
match view_path. node {
2223
2223
hir:: ViewPathSimple ( ident, _) => {
2224
- check_rename ( item. id , ident) ;
2224
+ check_rename ( self , item. id , ident) ;
2225
2225
}
2226
- hir:: ViewPathList ( _ , ref items) => {
2226
+ hir:: ViewPathList ( ref prefix , ref items) => {
2227
2227
for item in items {
2228
2228
if let Some ( ident) = item. node . rename ( ) {
2229
- check_rename ( item. node . id ( ) , ident) ;
2229
+ check_rename ( self , item. node . id ( ) , ident) ;
2230
+ }
2231
+ }
2232
+
2233
+ // Resolve prefix of an import with empty braces (issue #28388)
2234
+ if items. is_empty ( ) && !prefix. segments . is_empty ( ) {
2235
+ match self . resolve_crate_relative_path ( prefix. span ,
2236
+ & prefix. segments ,
2237
+ TypeNS ) {
2238
+ Some ( ( def, lp) ) => self . record_def ( item. id ,
2239
+ PathResolution :: new ( def, lp, 0 ) ) ,
2240
+ None => {
2241
+ resolve_error ( self ,
2242
+ prefix. span ,
2243
+ ResolutionError :: FailedToResolve (
2244
+ & path_names_to_string ( prefix, 0 ) ) ) ;
2245
+ }
2230
2246
}
2231
2247
}
2232
2248
}
0 commit comments