]> git.lizzy.rs Git - rust.git/commitdiff
CFG::new now wants Body instead of Expr
authorEnrico Schmitz <enrico@schmitz.link>
Sun, 5 Mar 2017 02:10:46 +0000 (02:10 +0000)
committerEnrico Schmitz <enrico@schmitz.link>
Sun, 5 Mar 2017 02:15:39 +0000 (02:15 +0000)
clippy_lints/src/cyclomatic_complexity.rs

index 33c27b53b835e8a905a6afa88875343a152891ea..03882a0acf5bdf7b67c8d475e7f003354e2ad8d6 100644 (file)
@@ -41,12 +41,13 @@ fn get_lints(&self) -> LintArray {
 }
 
 impl CyclomaticComplexity {
-    fn check<'a, 'tcx: 'a>(&mut self, cx: &'a LateContext<'a, 'tcx>, expr: &'tcx Expr, span: Span) {
+    fn check<'a, 'tcx: 'a>(&mut self, cx: &'a LateContext<'a, 'tcx>, body: &'tcx Body, span: Span) {
         if in_macro(cx, span) {
             return;
         }
 
-        let cfg = CFG::new(cx.tcx, expr);
+        let cfg = CFG::new(cx.tcx, body);
+        let expr = &body.value;
         let n = cfg.graph.len_nodes() as u64;
         let e = cfg.graph.len_edges() as u64;
         if e + 2 < n {
@@ -101,7 +102,7 @@ fn check_fn(
     ) {
         let def_id = cx.tcx.hir.local_def_id(node_id);
         if !cx.tcx.has_attr(def_id, "test") {
-            self.check(cx, &body.value, span);
+            self.check(cx, body, span);
         }
     }