about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEduardo Broto <ebroto@tutanota.com>2020-12-17 15:24:44 +0100
committerEduardo Broto <ebroto@tutanota.com>2020-12-17 15:28:05 +0100
commitbb68ec6cfc76a6ec69d21c0f64dbc4aa99158958 (patch)
tree9bad48213b806529455a9a4ea51a377591bcd0fd
parent41b5ebebfdc583d9e3702dd61c8d897999d1e7f5 (diff)
downloadrust-bb68ec6cfc76a6ec69d21c0f64dbc4aa99158958.tar.gz
rust-bb68ec6cfc76a6ec69d21c0f64dbc4aa99158958.zip
Apply suggestion from PR review
-rw-r--r--clippy_lints/src/doc.rs21
1 files changed, 12 insertions, 9 deletions
diff --git a/clippy_lints/src/doc.rs b/clippy_lints/src/doc.rs
index 08134cc16c0..aba65532795 100644
--- a/clippy_lints/src/doc.rs
+++ b/clippy_lints/src/doc.rs
@@ -407,15 +407,18 @@ fn check_doc<'a, Events: Iterator<Item = (pulldown_cmark::Event<'a>, Range<usize
             Start(CodeBlock(ref kind)) => {
                 in_code = true;
                 if let CodeBlockKind::Fenced(lang) = kind {
-                    let infos = lang.split(',').collect::<Vec<_>>();
-                    is_rust = !infos.iter().any(|&i| i == "ignore")
-                        && infos
-                            .iter()
-                            .any(|i| i.is_empty() || i.starts_with("edition") || RUST_CODE.contains(&i));
-                    edition = infos
-                        .iter()
-                        .find_map(|i| i.starts_with("edition").then(|| i[7..].parse::<Edition>().ok()))
-                        .flatten();
+                    for item in lang.split(',') {
+                        if item == "ignore" {
+                            is_rust = false;
+                            break;
+                        }
+                        if let Some(stripped) = item.strip_prefix("edition") {
+                            is_rust = true;
+                            edition = stripped.parse::<Edition>().ok();
+                        } else if item.is_empty() || RUST_CODE.contains(&item) {
+                            is_rust = true;
+                        }
+                    }
                 }
             },
             End(CodeBlock(_)) => {