Skip to content

Commit

Permalink
Apply suggestion from PR review
Browse files Browse the repository at this point in the history
  • Loading branch information
ebroto committed Dec 17, 2020
1 parent 41b5ebe commit bb68ec6
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions clippy_lints/src/doc.rs
Expand Up @@ -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(_)) => {
Expand Down

0 comments on commit bb68ec6

Please sign in to comment.