@@ -42,12 +42,12 @@ impl LintPass for CyclomaticComplexity {
4242}
4343
4444impl CyclomaticComplexity {
45- fn check < ' a , ' tcx > ( & mut self , cx : & ' a LateContext < ' a , ' tcx > , block : & Block , span : Span ) {
45+ fn check < ' a , ' tcx > ( & mut self , cx : & ' a LateContext < ' a , ' tcx > , expr : & Expr , span : Span ) {
4646 if in_macro ( cx, span) {
4747 return ;
4848 }
4949
50- let cfg = CFG :: new ( cx. tcx , block ) ;
50+ let cfg = CFG :: new ( cx. tcx , expr ) ;
5151 let n = cfg. graph . len_nodes ( ) as u64 ;
5252 let e = cfg. graph . len_edges ( ) as u64 ;
5353 if e + 2 < n {
@@ -62,9 +62,9 @@ impl CyclomaticComplexity {
6262 returns : 0 ,
6363 tcx : & cx. tcx ,
6464 } ;
65- helper. visit_block ( block ) ;
65+ helper. visit_expr ( expr ) ;
6666 let CCHelper { match_arms, divergence, short_circuits, returns, .. } = helper;
67- let ret_ty = cx. tcx . node_id_to_type ( block . id ) ;
67+ let ret_ty = cx. tcx . tables ( ) . node_id_to_type ( expr . id ) ;
6868 let ret_adjust = if match_type ( cx, ret_ty, & paths:: RESULT ) {
6969 returns
7070 } else {
@@ -92,22 +92,22 @@ impl CyclomaticComplexity {
9292
9393impl LateLintPass for CyclomaticComplexity {
9494 fn check_item ( & mut self , cx : & LateContext , item : & Item ) {
95- if let ItemFn ( _, _, _, _, _, ref block ) = item. node {
95+ if let ItemFn ( _, _, _, _, _, ref expr ) = item. node {
9696 if !attr:: contains_name ( & item. attrs , "test" ) {
97- self . check ( cx, block , item. span ) ;
97+ self . check ( cx, expr , item. span ) ;
9898 }
9999 }
100100 }
101101
102102 fn check_impl_item ( & mut self , cx : & LateContext , item : & ImplItem ) {
103- if let ImplItemKind :: Method ( _, ref block ) = item. node {
104- self . check ( cx, block , item. span ) ;
103+ if let ImplItemKind :: Method ( _, ref expr ) = item. node {
104+ self . check ( cx, expr , item. span ) ;
105105 }
106106 }
107107
108108 fn check_trait_item ( & mut self , cx : & LateContext , item : & TraitItem ) {
109- if let MethodTraitItem ( _, Some ( ref block ) ) = item. node {
110- self . check ( cx, block , item. span ) ;
109+ if let MethodTraitItem ( _, Some ( ref expr ) ) = item. node {
110+ self . check ( cx, expr , item. span ) ;
111111 }
112112 }
113113
@@ -139,7 +139,7 @@ impl<'a, 'b, 'tcx, 'gcx> Visitor<'a> for CCHelper<'b, 'gcx, 'tcx> {
139139 }
140140 ExprCall ( ref callee, _) => {
141141 walk_expr ( self , e) ;
142- let ty = self . tcx . node_id_to_type ( callee. id ) ;
142+ let ty = self . tcx . tables ( ) . node_id_to_type ( callee. id ) ;
143143 match ty. sty {
144144 ty:: TyFnDef ( _, _, ty) |
145145 ty:: TyFnPtr ( ty) if ty. sig . skip_binder ( ) . output . sty == ty:: TyNever => {
0 commit comments