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) {
126
126
pat instanceof RangePat or
127
127
// Identifier patterns that are in fact path patterns can cause failures. For
128
128
// 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
131
134
pat instanceof WildcardPat or
132
135
pat instanceof RestPat or
133
136
pat instanceof RefPat or
Original file line number Diff line number Diff line change 19
19
| test.rs:6:17:6:31 | let ... = b | test.rs:6:31:6:31 | b | |
20
20
| test.rs:6:21:6:27 | Some(...) | test.rs:6:12:6:31 | [boolean(false)] ... && ... | no-match |
21
21
| 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 |
23
22
| test.rs:6:26:6:26 | d | test.rs:6:12:6:31 | [boolean(true)] ... && ... | match |
24
23
| test.rs:6:26:6:26 | d | test.rs:6:26:6:26 | d | |
25
24
| test.rs:6:31:6:31 | b | test.rs:6:21:6:27 | Some(...) | |
47
46
| test.rs:14:12:15:16 | [boolean(false)] ... && ... | test.rs:19:13:19:17 | false | false |
48
47
| test.rs:14:12:15:16 | [boolean(true)] ... && ... | test.rs:17:13:17:13 | d | true |
49
48
| 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 |
51
49
| test.rs:14:21:14:21 | d | test.rs:14:12:14:25 | [boolean(true)] ... && ... | match |
52
50
| test.rs:14:21:14:21 | d | test.rs:14:21:14:21 | d | |
53
51
| 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