mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-06 12:04:36 +00:00
Remove hidden code lines in Clippy's lint list
This commit is contained in:
parent
075996efd7
commit
dea940259e
@ -512,12 +512,21 @@ fn extract_attr_docs(cx: &LateContext<'_>, item: &Item<'_>) -> Option<String> {
|
||||
let mut lines = attrs.iter().filter_map(ast::Attribute::doc_str);
|
||||
let mut docs = String::from(&*lines.next()?.as_str());
|
||||
let mut in_code_block = false;
|
||||
let mut is_code_block_rust = false;
|
||||
for line in lines {
|
||||
docs.push('\n');
|
||||
let line = line.as_str();
|
||||
let line = &*line;
|
||||
|
||||
// Rustdoc hides code lines starting with `# ` and this removes them from Clippy's lint list :)
|
||||
if is_code_block_rust && line.trim_start().starts_with("# ") {
|
||||
continue;
|
||||
}
|
||||
|
||||
// The line should be represented in the lint list, even if it's just an empty line
|
||||
docs.push('\n');
|
||||
if let Some(info) = line.trim_start().strip_prefix("```") {
|
||||
in_code_block = !in_code_block;
|
||||
is_code_block_rust = false;
|
||||
if in_code_block {
|
||||
let lang = info
|
||||
.trim()
|
||||
@ -528,6 +537,8 @@ fn extract_attr_docs(cx: &LateContext<'_>, item: &Item<'_>) -> Option<String> {
|
||||
.unwrap_or("rust");
|
||||
docs.push_str("```");
|
||||
docs.push_str(lang);
|
||||
|
||||
is_code_block_rust = lang == "rust";
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user