@@ -1417,72 +1417,70 @@ impl<'a> Resolver<'a> {
1417
1417
fn build_reduced_graph_for_view_item ( & mut self , view_item : & ViewItem ,
1418
1418
parent : ReducedGraphParent ) {
1419
1419
match view_item. node {
1420
- ViewItemUse ( ref view_paths) => {
1421
- for view_path in view_paths. iter ( ) {
1422
- // Extract and intern the module part of the path. For
1423
- // globs and lists, the path is found directly in the AST;
1424
- // for simple paths we have to munge the path a little.
1425
-
1426
- let mut module_path = Vec :: new ( ) ;
1427
- match view_path. node {
1428
- ViewPathSimple ( _, ref full_path, _) => {
1429
- let path_len = full_path. segments . len ( ) ;
1430
- assert ! ( path_len != 0 ) ;
1431
-
1432
- for ( i, segment) in full_path. segments
1433
- . iter ( )
1434
- . enumerate ( ) {
1435
- if i != path_len - 1 {
1436
- module_path. push ( segment. identifier )
1437
- }
1438
- }
1439
- }
1440
-
1441
- ViewPathGlob ( ref module_ident_path, _) |
1442
- ViewPathList ( ref module_ident_path, _, _) => {
1443
- for segment in module_ident_path. segments . iter ( ) {
1420
+ ViewItemUse ( ref view_path) => {
1421
+ // Extract and intern the module part of the path. For
1422
+ // globs and lists, the path is found directly in the AST;
1423
+ // for simple paths we have to munge the path a little.
1424
+
1425
+ let mut module_path = Vec :: new ( ) ;
1426
+ match view_path. node {
1427
+ ViewPathSimple ( _, ref full_path, _) => {
1428
+ let path_len = full_path. segments . len ( ) ;
1429
+ assert ! ( path_len != 0 ) ;
1430
+
1431
+ for ( i, segment) in full_path. segments
1432
+ . iter ( )
1433
+ . enumerate ( ) {
1434
+ if i != path_len - 1 {
1444
1435
module_path. push ( segment. identifier )
1445
1436
}
1446
1437
}
1447
1438
}
1448
1439
1449
- // Build up the import directives.
1450
- let module_ = parent. module ( ) ;
1451
- let is_public = view_item. vis == ast:: Public ;
1452
- match view_path. node {
1453
- ViewPathSimple ( binding, ref full_path, id) => {
1454
- let source_ident =
1455
- full_path. segments . last ( ) . unwrap ( ) . identifier ;
1456
- let subclass = SingleImport ( binding,
1457
- source_ident) ;
1458
- self . build_import_directive ( & * module_,
1459
- module_path,
1460
- subclass,
1461
- view_path. span ,
1462
- id,
1463
- is_public) ;
1440
+ ViewPathGlob ( ref module_ident_path, _) |
1441
+ ViewPathList ( ref module_ident_path, _, _) => {
1442
+ for segment in module_ident_path. segments . iter ( ) {
1443
+ module_path. push ( segment. identifier )
1464
1444
}
1465
- ViewPathList ( _, ref source_idents, _) => {
1466
- for source_ident in source_idents. iter ( ) {
1467
- let name = source_ident. node . name ;
1468
- self . build_import_directive (
1469
- & * module_,
1470
- module_path. clone ( ) ,
1471
- SingleImport ( name, name) ,
1472
- source_ident. span ,
1473
- source_ident. node . id ,
1474
- is_public) ;
1475
- }
1476
- }
1477
- ViewPathGlob ( _, id) => {
1478
- self . build_import_directive ( & * module_,
1479
- module_path,
1480
- GlobImport ,
1481
- view_path. span ,
1482
- id,
1483
- is_public) ;
1445
+ }
1446
+ }
1447
+
1448
+ // Build up the import directives.
1449
+ let module_ = parent. module ( ) ;
1450
+ let is_public = view_item. vis == ast:: Public ;
1451
+ match view_path. node {
1452
+ ViewPathSimple ( binding, ref full_path, id) => {
1453
+ let source_ident =
1454
+ full_path. segments . last ( ) . unwrap ( ) . identifier ;
1455
+ let subclass = SingleImport ( binding,
1456
+ source_ident) ;
1457
+ self . build_import_directive ( & * module_,
1458
+ module_path,
1459
+ subclass,
1460
+ view_path. span ,
1461
+ id,
1462
+ is_public) ;
1463
+ }
1464
+ ViewPathList ( _, ref source_idents, _) => {
1465
+ for source_ident in source_idents. iter ( ) {
1466
+ let name = source_ident. node . name ;
1467
+ self . build_import_directive (
1468
+ & * module_,
1469
+ module_path. clone ( ) ,
1470
+ SingleImport ( name, name) ,
1471
+ source_ident. span ,
1472
+ source_ident. node . id ,
1473
+ is_public) ;
1484
1474
}
1485
1475
}
1476
+ ViewPathGlob ( _, id) => {
1477
+ self . build_import_directive ( & * module_,
1478
+ module_path,
1479
+ GlobImport ,
1480
+ view_path. span ,
1481
+ id,
1482
+ is_public) ;
1483
+ }
1486
1484
}
1487
1485
}
1488
1486
@@ -5226,23 +5224,21 @@ impl<'a> Resolver<'a> {
5226
5224
5227
5225
match vi. node {
5228
5226
ViewItemExternCrate ( ..) => { } // ignore
5229
- ViewItemUse ( ref path) => {
5230
- for p in path. iter ( ) {
5231
- match p. node {
5232
- ViewPathSimple ( _, _, id) => self . finalize_import ( id, p. span ) ,
5233
- ViewPathList ( _, ref list, _) => {
5234
- for i in list. iter ( ) {
5235
- self . finalize_import ( i. node . id , i. span ) ;
5236
- }
5237
- } ,
5238
- ViewPathGlob ( _, id) => {
5239
- if !self . used_imports . contains ( & ( id, TypeNS ) ) &&
5240
- !self . used_imports . contains ( & ( id, ValueNS ) ) {
5241
- self . session . add_lint ( UnusedImports , id, p. span ,
5242
- "unused import" . to_owned ( ) ) ;
5243
- }
5244
- } ,
5245
- }
5227
+ ViewItemUse ( ref p) => {
5228
+ match p. node {
5229
+ ViewPathSimple ( _, _, id) => self . finalize_import ( id, p. span ) ,
5230
+ ViewPathList ( _, ref list, _) => {
5231
+ for i in list. iter ( ) {
5232
+ self . finalize_import ( i. node . id , i. span ) ;
5233
+ }
5234
+ } ,
5235
+ ViewPathGlob ( _, id) => {
5236
+ if !self . used_imports . contains ( & ( id, TypeNS ) ) &&
5237
+ !self . used_imports . contains ( & ( id, ValueNS ) ) {
5238
+ self . session . add_lint ( UnusedImports , id, p. span ,
5239
+ "unused import" . to_owned ( ) ) ;
5240
+ }
5241
+ } ,
5246
5242
}
5247
5243
}
5248
5244
}
0 commit comments