9
9
10
10
#[ macro_use] extern crate rustc;
11
11
#[ macro_use] extern crate syntax;
12
+ #[ macro_use] extern crate log;
12
13
extern crate rustc_typeck;
13
14
extern crate syntax_pos;
14
15
extern crate rustc_data_structures;
@@ -1451,6 +1452,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ObsoleteVisiblePrivateTypesVisitor<'a, 'tcx> {
1451
1452
1452
1453
struct SearchInterfaceForPrivateItemsVisitor < ' a , ' tcx : ' a > {
1453
1454
tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
1455
+ item_id : ast:: NodeId ,
1454
1456
item_def_id : DefId ,
1455
1457
span : Span ,
1456
1458
/// The visitor checks that each component type is at least this visible.
@@ -1516,16 +1518,18 @@ impl<'a, 'tcx: 'a> SearchInterfaceForPrivateItemsVisitor<'a, 'tcx> {
1516
1518
& format ! ( "{} (error {})" , msg, err_code) ) ;
1517
1519
}
1518
1520
1519
- if self . leaks_private_dep ( trait_ref. def_id ) {
1520
- self . tcx . lint_node ( lint:: builtin:: LEAKED_PRIVATE_DEPENDENCY ,
1521
- node_id,
1522
- self . span ,
1523
- & format ! ( "trait `{}` from private dependency '{}' in public \
1524
- interface", trait_ref,
1525
- trait_ref. def_id. krate) ) ;
1521
+ }
1522
+
1523
+ if self . leaks_private_dep ( trait_ref. def_id ) {
1524
+ self . tcx . lint_node ( lint:: builtin:: LEAKED_PRIVATE_DEPENDENCY ,
1525
+ self . item_id ,
1526
+ self . span ,
1527
+ & format ! ( "trait `{}` from private dependency '{}' in public \
1528
+ interface", trait_ref,
1529
+ self . tcx. crate_name( trait_ref. def_id. krate) ) ) ;
1526
1530
1527
- }
1528
1531
}
1532
+
1529
1533
}
1530
1534
1531
1535
/// An item is 'leaked' from a private dependency if all
@@ -1537,9 +1541,13 @@ impl<'a, 'tcx: 'a> SearchInterfaceForPrivateItemsVisitor<'a, 'tcx> {
1537
1541
if !self . tcx . features ( ) . public_private_dependencies {
1538
1542
return false
1539
1543
}
1540
- self . required_visibility == ty:: Visibility :: Public &&
1544
+ let ret = self . required_visibility == ty:: Visibility :: Public &&
1541
1545
!item_id. is_local ( ) &&
1542
- !self . public_crates . contains ( & item_id. krate )
1546
+ !self . public_crates . contains ( & item_id. krate ) ;
1547
+
1548
+
1549
+ debug ! ( "leaks_private_dep(item_id={:?})={}" , item_id, ret) ;
1550
+ return ret;
1543
1551
}
1544
1552
}
1545
1553
@@ -1601,14 +1609,17 @@ impl<'a, 'tcx: 'a> TypeVisitor<'tcx> for SearchInterfaceForPrivateItemsVisitor<'
1601
1609
}
1602
1610
}
1603
1611
1604
- if self . leaks_private_dep ( def_id) {
1605
- self . tcx . lint_node ( lint:: builtin:: LEAKED_PRIVATE_DEPENDENCY ,
1606
- node_id,
1607
- self . span ,
1608
- & format ! ( "type '{}' from private dependency '{}' in \
1609
- public interface", ty, def_id. krate) ) ;
1610
- }
1611
1612
}
1613
+
1614
+ if self . leaks_private_dep ( def_id) {
1615
+ self . tcx . lint_node ( lint:: builtin:: LEAKED_PRIVATE_DEPENDENCY ,
1616
+ self . item_id ,
1617
+ self . span ,
1618
+ & format ! ( "type '{}' from private dependency '{}' in \
1619
+ public interface", ty,
1620
+ self . tcx. crate_name( def_id. krate) ) ) ;
1621
+ }
1622
+
1612
1623
}
1613
1624
1614
1625
ty. super_visit_with ( self )
@@ -1673,6 +1684,7 @@ impl<'a, 'tcx> PrivateItemsInPublicInterfacesVisitor<'a, 'tcx> {
1673
1684
1674
1685
SearchInterfaceForPrivateItemsVisitor {
1675
1686
tcx : self . tcx ,
1687
+ item_id,
1676
1688
item_def_id : self . tcx . hir ( ) . local_def_id ( item_id) ,
1677
1689
span : self . tcx . hir ( ) . span ( item_id) ,
1678
1690
required_visibility,
0 commit comments