1
Fork 0

Avoid needless_doctest_main on 'extern crate'

This commit is contained in:
Andre Bogus 2019-12-23 13:11:20 +01:00
parent 2730d64d77
commit 129d0cd0f4
2 changed files with 12 additions and 1 deletions

View file

@ -390,8 +390,10 @@ fn check_doc<'a, Events: Iterator<Item = (pulldown_cmark::Event<'a>, Range<usize
headers
}
static LEAVE_MAIN_PATTERNS: &[&str] = &["static", "fn main() {}", "extern crate"];
fn check_code(cx: &LateContext<'_, '_>, text: &str, span: Span) {
if text.contains("fn main() {") && !(text.contains("static") || text.contains("fn main() {}")) {
if text.contains("fn main() {") && !LEAVE_MAIN_PATTERNS.iter().any(|p| text.contains(p)) {
span_lint(cx, NEEDLESS_DOCTEST_MAIN, span, "needless `fn main` in doctest");
}
}