Skip to content

Commit 7d1a944

Browse files
committed
Extract semantic constant
1 parent 6d1aaac commit 7d1a944

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

clippy_lints/src/strings.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,9 @@ fn is_add(cx: &LateContext<'_, '_>, src: &Expr, target: &Expr) -> bool {
138138
}
139139
}
140140

141+
// Max length a b"foo" string can take
142+
const MAX_LENGTH_BYTE_STRING_LIT: usize = 32;
143+
141144
declare_lint_pass!(StringLitAsBytes => [STRING_LIT_AS_BYTES]);
142145

143146
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for StringLitAsBytes {
@@ -173,7 +176,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for StringLitAsBytes {
173176
);
174177
} else if callsite == expanded
175178
&& lit_content.as_str().chars().all(|c| c.is_ascii())
176-
&& lit_content.as_str().len() <= 32
179+
&& lit_content.as_str().len() <= MAX_LENGTH_BYTE_STRING_LIT
177180
&& !in_macro_or_desugar(args[0].span)
178181
{
179182
span_lint_and_sugg(

0 commit comments

Comments
 (0)