]> git.lizzy.rs Git - rust.git/commitdiff
Fix index out of bound in case of empty snippet
authorLzu Tao <taolzu@gmail.com>
Mon, 2 Sep 2019 13:38:40 +0000 (20:38 +0700)
committerLzu Tao <taolzu@gmail.com>
Mon, 2 Sep 2019 13:38:40 +0000 (20:38 +0700)
clippy_lints/src/misc_early.rs

index 6ff2a404579767025bac63c71c4cdedbfa9b9d4b..b90307af8ffcf3310d7270afbf505b5a75053dea 100644 (file)
@@ -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