diff --git a/xtask/src/test_lint.rs b/xtask/src/test_lint.rs index 1c69802987..423b919d88 100644 --- a/xtask/src/test_lint.rs +++ b/xtask/src/test_lint.rs @@ -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")],