File tree Expand file tree Collapse file tree 5 files changed +34
-170
lines changed
lib/codeql/rust/controlflow/internal Expand file tree Collapse file tree 5 files changed +34
-170
lines changed Original file line number Diff line number Diff line change @@ -126,8 +126,11 @@ private predicate cannotCauseMatchFailure(Pat pat) {
126126 pat instanceof RangePat or
127127 // Identifier patterns that are in fact path patterns can cause failures. For
128128 // instance `None`. Only if an `@ ...` part is present can we be sure that
129- // it's an actual identifier pattern.
130- pat = any ( IdentPat p | p .hasPat ( ) ) or
129+ // it's an actual identifier pattern. As a heuristic, if the identifier starts
130+ // with a lower case letter, then we assume that it's an identifier. This
131+ // works for code that follows the Rust naming convention for enums and
132+ // constants.
133+ pat = any ( IdentPat p | p .hasPat ( ) or p .getName ( ) .getText ( ) .charAt ( 0 ) .isLowercase ( ) ) or
131134 pat instanceof WildcardPat or
132135 pat instanceof RestPat or
133136 pat instanceof RefPat or
Original file line number Diff line number Diff line change 1919| test.rs:6:17:6:31 | let ... = b | test.rs:6:31:6:31 | b | |
2020| test.rs:6:21:6:27 | Some(...) | test.rs:6:12:6:31 | [boolean(false)] ... && ... | no-match |
2121| test.rs:6:21:6:27 | Some(...) | test.rs:6:26:6:26 | d | match |
22- | test.rs:6:26:6:26 | d | test.rs:6:12:6:31 | [boolean(false)] ... && ... | no-match |
2322| test.rs:6:26:6:26 | d | test.rs:6:12:6:31 | [boolean(true)] ... && ... | match |
2423| test.rs:6:26:6:26 | d | test.rs:6:26:6:26 | d | |
2524| test.rs:6:31:6:31 | b | test.rs:6:21:6:27 | Some(...) | |
4746| test.rs:14:12:15:16 | [boolean(false)] ... && ... | test.rs:19:13:19:17 | false | false |
4847| test.rs:14:12:15:16 | [boolean(true)] ... && ... | test.rs:17:13:17:13 | d | true |
4948| test.rs:14:17:14:25 | let ... = b | test.rs:14:25:14:25 | b | |
50- | test.rs:14:21:14:21 | d | test.rs:14:12:14:25 | [boolean(false)] ... && ... | no-match |
5149| test.rs:14:21:14:21 | d | test.rs:14:12:14:25 | [boolean(true)] ... && ... | match |
5250| test.rs:14:21:14:21 | d | test.rs:14:21:14:21 | d | |
5351| test.rs:14:25:14:25 | b | test.rs:14:21:14:21 | d | |
You can’t perform that action at this time.
0 commit comments