• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

xd009642 / tarpaulin / #692

24 Oct 2025 07:10PM UTC coverage: 84.27% (+8.9%) from 75.356%
#692

push

xd009642
Release 0.34.1

44 of 47 new or added lines in 4 files covered. (93.62%)

34 existing lines in 7 files now uncovered.

4602 of 5461 relevant lines covered (84.27%)

252235.65 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

86.44
/src/source_analysis/statements.rs
1
use crate::source_analysis::prelude::*;
2
use syn::*;
3

4
impl SourceAnalysis {
5
    pub(crate) fn process_statements(&mut self, stmts: &[Stmt], ctx: &Context) -> SubResult {
656✔
6
        // in a list of statements, if any of them is unreachable, the whole list is
7
        // unreachable
8
        let mut unreachable = false;
1,312✔
9
        let mut definite = false;
1,312✔
10
        for stmt in stmts.iter() {
2,335✔
11
            let res = match stmt {
2,046✔
12
                Stmt::Item(i) => self.process_items(&[i.clone()], ctx),
25✔
13
                Stmt::Expr(i, _) => self.process_expr(i, ctx),
3,205✔
14
                Stmt::Local(i) => self.process_local(i, ctx),
935✔
15
                Stmt::Macro(i) => self.process_macro(i, ctx),
950✔
16
            };
17
            unreachable |= res.is_unreachable();
1,023✔
18
            if SubResult::Definite == res {
1,122✔
19
                definite = true;
99✔
20
            }
21
        }
22
        // We must be in a block, the parent will handle marking the span as unreachable
23
        if unreachable && !definite {
675✔
24
            SubResult::Unreachable
14✔
25
        } else if definite {
642✔
26
            SubResult::Definite
67✔
27
        } else {
28
            SubResult::Ok
575✔
29
        }
30
    }
31

32
    fn process_macro(&mut self, mac: &StmtMacro, ctx: &Context) -> SubResult {
190✔
33
        let check_cover = self.check_attr_list(&mac.attrs, ctx);
950✔
34
        if check_cover {
190✔
35
            if let Some(macro_name) = mac.mac.path.segments.last() {
380✔
36
                let (sub, should_ignore) = ignore_macro_name(&macro_name.ident, ctx);
760✔
37
                let analysis = self.get_line_analysis(ctx.file.to_path_buf());
950✔
38
                if should_ignore {
205✔
39
                    analysis.ignore_tokens(mac);
30✔
40
                } else {
41
                    // lets just merge the macros into one big logical line
42
                    let start = mac.span().start().line;
350✔
43
                    for i in start..mac.span().end().line {
358✔
44
                        analysis.logical_lines.insert(i + 1, start);
12✔
45
                    }
46
                }
47
                sub
190✔
48
            } else {
49
                SubResult::Ok
×
50
            }
51
        } else {
52
            let analysis = self.get_line_analysis(ctx.file.to_path_buf());
×
UNCOV
53
            analysis.ignore_tokens(mac);
×
UNCOV
54
            SubResult::Ok
×
55
        }
56
    }
57

58
    fn process_local(&mut self, local: &Local, ctx: &Context) -> SubResult {
187✔
59
        let mut result = SubResult::Ok;
374✔
60
        if let Some(init) = &local.init {
374✔
61
            // Process if the local wasn't ignored with an attribute
62
            let check_cover = self.check_attr_list(&local.attrs, ctx);
935✔
63
            let analysis = self.get_line_analysis(ctx.file.to_path_buf());
935✔
64

65
            if check_cover {
187✔
66
                for a in &local.attrs {
187✔
UNCOV
67
                    analysis.ignore_tokens(a);
×
68
                }
69
                let spn = local.span();
561✔
70
                let base_line = local.let_token.span().start().line;
374✔
71
                if base_line != spn.end().line {
374✔
72
                    // Now check the other lines
73
                    let lhs = local.pat.span();
114✔
74
                    if lhs.start().line != base_line {
38✔
75
                        analysis.logical_lines.insert(lhs.start().line, base_line);
×
76
                    }
77
                    let eq = init.eq_token.span();
114✔
78
                    if eq.start().line != base_line {
47✔
79
                        analysis.logical_lines.insert(eq.start().line, base_line);
27✔
80
                    }
81
                    if init.expr.span().start().line != base_line {
53✔
82
                        analysis
30✔
83
                            .logical_lines
30✔
84
                            .insert(init.expr.span().start().line, base_line);
30✔
85
                    }
86
                    result += self.process_expr(&init.expr, ctx);
152✔
87
                    if let Some((_, expr)) = &init.diverge {
38✔
UNCOV
88
                        self.process_expr(expr, ctx);
×
89
                    }
90
                }
91
            } else {
92
                analysis.ignore_tokens(local);
×
93
            }
94
        }
95
        result
187✔
96
    }
97
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc