From 17d445b66d76efa88d67ea37bd154cded316379b Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Mon, 2 Sep 2019 20:38:40 +0700 Subject: [PATCH] Fix index out of bound in case of empty snippet --- clippy_lints/src/misc_early.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/clippy_lints/src/misc_early.rs b/clippy_lints/src/misc_early.rs index 6ff2a404579..b90307af8ff 100644 --- a/clippy_lints/src/misc_early.rs +++ b/clippy_lints/src/misc_early.rs @@ -393,7 +393,8 @@ fn check_lit(self, cx: &EarlyContext<'_>, lit: &Lit) { // The `line!()` macro is compiler built-in and a special case for these lints. let lit_snip = match snippet_opt(cx, lit.span) { Some(snip) => { - if snip.contains('!') { + // The snip could be empty in case of expand from procedure macro + if snip.is_empty() || snip.contains('!') { return; } snip -- 2.44.0