Skip to content

Commit 17d445b

Browse files
committed
Fix index out of bound in case of empty snippet
1 parent 1f99937 commit 17d445b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

clippy_lints/src/misc_early.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,8 @@ impl MiscEarlyLints {
393393
// The `line!()` macro is compiler built-in and a special case for these lints.
394394
let lit_snip = match snippet_opt(cx, lit.span) {
395395
Some(snip) => {
396-
if snip.contains('!') {
396+
// The snip could be empty in case of expand from procedure macro
397+
if snip.is_empty() || snip.contains('!') {
397398
return;
398399
}
399400
snip

0 commit comments

Comments
 (0)