mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-12-04 13:02:50 -05:00
xtask: test-lint census rule reads a loop label with a space before its colon
Rust allows whitespace between a loop label and its colon ('inner : for), so the label is stripped from the loop head in that form too.
This commit is contained in:
1 parent
2e1b575fdc
commit
8cea13d8a4
1 file changed
+6
-1
@@ -2582,7 +2582,7 @@ fn runs_with_assertion_within(b: &[u8], from: usize, to: usize, start: usize, ac
|
||||
let prefix = prefix
|
||||
.strip_prefix(b"'")
|
||||
.map(|rest| rest.split_at(rest.iter().take_while(|&&c| is_ident(c)).count()))
|
||||
.and_then(|(label, rest)| rest.strip_prefix(b":").filter(|r| !label.is_empty() && r.first() != Some(&b':')))
|
||||
.and_then(|(label, rest)| rest.trim_ascii_start().strip_prefix(b":").filter(|r| !label.is_empty() && r.first() != Some(&b':')))
|
||||
.map_or(prefix, <[u8]>::trim_ascii_start);
|
||||
let nested_for = prefix.starts_with(b"for") && prefix.get(3).is_some_and(u8::is_ascii_whitespace);
|
||||
if prefix.ends_with(b"||") || prefix.ends_with(b"&&") {
|
||||
@@ -10360,6 +10360,11 @@ mod tests {
|
||||
[(2, "census")],
|
||||
"a labeled empty loop does not run its body"
|
||||
);
|
||||
assert_eq!(
|
||||
census("'inner : for _ in 0..0 { app.run(c); } assert!(menu(c).is_some());"),
|
||||
[(2, "census")],
|
||||
"a label with a space before its colon"
|
||||
);
|
||||
assert_eq!(
|
||||
census("let run = || app.run(c); other::run(); assert!(menu(c).is_some());"),
|
||||
[(2, "census")],
|
||||
|
||||
Reference in new issue
Block a user