Skip to content

Commit 4f0e46b

Browse files
authored
Fix large_include_file lint being triggered all the time by doc comments (#13672)
Fixes #13670. Bug was that I forgot to add the comparison with the included file content length... changelog: Fix `large_include_file` lint being triggered all the time by doc comments
2 parents 8cfb959 + 223bffd commit 4f0e46b

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

clippy_lints/src/large_include_file.rs

+2
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ impl LateLintPass<'_> for LargeIncludeFile {
9494
// Currently, rustc limits the usage of macro at the top-level of attributes,
9595
// so we don't need to recurse into each level.
9696
&& let AttrKind::Normal(ref normal) = attr.kind
97+
&& let Some(doc) = attr.doc_str()
98+
&& doc.as_str().len() as u64 > self.max_file_size
9799
&& let AttrArgs::Eq(_, AttrArgsEq::Hir(ref meta)) = normal.item.args
98100
&& !attr.span.contains(meta.span)
99101
// Since the `include_str` is already expanded at this point, we can only take the

tests/ui-toml/large_include_file/empty.txt

Whitespace-only changes.

tests/ui-toml/large_include_file/large_include_file.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,9 @@ const TOO_BIG_INCLUDE_BYTES: &[u8; 654] = include_bytes!("too_big.txt");
1515
const TOO_BIG_INCLUDE_STR: &str = include_str!("too_big.txt");
1616
//~^ large_include_file
1717

18-
#[doc = include_str!("too_big.txt")] //~ large_include_file
18+
#[doc = include_str!("too_big.txt")]
19+
//~^ large_include_file
20+
// Should not lint!
21+
// Regression test for <https://github.com/rust-lang/rust-clippy/issues/13670>.
22+
#[doc = include_str!("empty.txt")]
1923
fn main() {}

0 commit comments

Comments
 (0)