@@ -1581,34 +1581,12 @@ impl Stability {
1581
1581
1582
1582
cx. span_lint ( lint, span, msg. as_slice ( ) ) ;
1583
1583
}
1584
- }
1585
-
1586
- impl LintPass for Stability {
1587
- fn get_lints ( & self ) -> LintArray {
1588
- lint_array ! ( DEPRECATED , EXPERIMENTAL , UNSTABLE )
1589
- }
1590
-
1591
- fn check_view_item ( & mut self , cx : & Context , item : & ast:: ViewItem ) {
1592
- // compiler-generated `extern crate` statements have a dummy span.
1593
- if item. span == DUMMY_SP { return }
1594
-
1595
- let id = match item. node {
1596
- ast:: ViewItemExternCrate ( _, _, id) => id,
1597
- ast:: ViewItemUse ( ..) => return ,
1598
- } ;
1599
- let cnum = match cx. tcx . sess . cstore . find_extern_mod_stmt_cnum ( id) {
1600
- Some ( cnum) => cnum,
1601
- None => return ,
1602
- } ;
1603
- let id = ast:: DefId { krate : cnum, node : ast:: CRATE_NODE_ID } ;
1604
- self . lint ( cx, id, item. span ) ;
1605
- }
1606
1584
1607
- fn check_expr ( & mut self , cx : & Context , e : & ast :: Expr ) {
1585
+ fn is_internal ( & self , cx : & Context , span : Span ) -> bool {
1608
1586
// first, check if the given expression was generated by a macro or not
1609
1587
// we need to go back the expn_info tree to check only the arguments
1610
1588
// of the initial macro call, not the nested ones.
1611
- let mut expnid = e . span . expn_id ;
1589
+ let mut expnid = span. expn_id ;
1612
1590
let mut is_internal = false ;
1613
1591
while cx. tcx . sess . codemap ( ) . with_expn_info ( expnid, |expninfo| {
1614
1592
match expninfo {
@@ -1623,15 +1601,41 @@ impl LintPass for Stability {
1623
1601
true // continue looping
1624
1602
} else {
1625
1603
// was this expression from the current macro arguments ?
1626
- is_internal = !( e . span . lo > info. call_site . lo &&
1627
- e . span . hi < info. call_site . hi ) ;
1604
+ is_internal = !( span. lo > info. call_site . lo &&
1605
+ span. hi < info. call_site . hi ) ;
1628
1606
true // continue looping
1629
1607
}
1630
1608
} ,
1631
1609
_ => false // stop looping
1632
1610
}
1633
1611
} ) { /* empty while loop body */ }
1634
- if is_internal { return ; }
1612
+ return is_internal;
1613
+ }
1614
+ }
1615
+
1616
+ impl LintPass for Stability {
1617
+ fn get_lints ( & self ) -> LintArray {
1618
+ lint_array ! ( DEPRECATED , EXPERIMENTAL , UNSTABLE )
1619
+ }
1620
+
1621
+ fn check_view_item ( & mut self , cx : & Context , item : & ast:: ViewItem ) {
1622
+ // compiler-generated `extern crate` statements have a dummy span.
1623
+ if item. span == DUMMY_SP { return }
1624
+
1625
+ let id = match item. node {
1626
+ ast:: ViewItemExternCrate ( _, _, id) => id,
1627
+ ast:: ViewItemUse ( ..) => return ,
1628
+ } ;
1629
+ let cnum = match cx. tcx . sess . cstore . find_extern_mod_stmt_cnum ( id) {
1630
+ Some ( cnum) => cnum,
1631
+ None => return ,
1632
+ } ;
1633
+ let id = ast:: DefId { krate : cnum, node : ast:: CRATE_NODE_ID } ;
1634
+ self . lint ( cx, id, item. span ) ;
1635
+ }
1636
+
1637
+ fn check_expr ( & mut self , cx : & Context , e : & ast:: Expr ) {
1638
+ if self . is_internal ( cx, e. span ) { return ; }
1635
1639
1636
1640
let mut span = e. span ;
1637
1641
@@ -1677,6 +1681,29 @@ impl LintPass for Stability {
1677
1681
} ;
1678
1682
self . lint ( cx, id, span) ;
1679
1683
}
1684
+
1685
+ fn check_item ( & mut self , cx : & Context , item : & ast:: Item ) {
1686
+ if self . is_internal ( cx, item. span ) { return }
1687
+
1688
+ match item. node {
1689
+ ast:: ItemTrait ( _, _, ref supertraits, _) => {
1690
+ for t in supertraits. iter ( ) {
1691
+ match * t {
1692
+ ast:: TraitTyParamBound ( ref t) => {
1693
+ let id = ty:: trait_ref_to_def_id ( cx. tcx , t) ;
1694
+ self . lint ( cx, id, t. path . span ) ;
1695
+ }
1696
+ _ => ( /* pass */ )
1697
+ }
1698
+ }
1699
+ }
1700
+ ast:: ItemImpl ( _, Some ( ref t) , _, _) => {
1701
+ let id = ty:: trait_ref_to_def_id ( cx. tcx , t) ;
1702
+ self . lint ( cx, id, t. path . span ) ;
1703
+ }
1704
+ _ => ( /* pass */ )
1705
+ }
1706
+ }
1680
1707
}
1681
1708
1682
1709
declare_lint ! ( pub UNUSED_IMPORTS , Warn ,
0 commit comments