diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2024-11-09 16:01:12 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-11-09 16:01:12 +0000 |
| commit | 4f0e46b74dbc8441daf084b6f141a7fe414672a2 (patch) | |
| tree | aad9b69e8f1bb9c9381fcc73e52ebc3e9200293c | |
| parent | 8cfb95959b740405b2b85e28d86091b5424de870 (diff) | |
| parent | 223bffd0d2c7f26145d2e7861dbe5cbb0aff830e (diff) | |
| download | rust-4f0e46b74dbc8441daf084b6f141a7fe414672a2.tar.gz rust-4f0e46b74dbc8441daf084b6f141a7fe414672a2.zip | |
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
| -rw-r--r-- | clippy_lints/src/large_include_file.rs | 2 | ||||
| -rw-r--r-- | tests/ui-toml/large_include_file/empty.txt | 0 | ||||
| -rw-r--r-- | tests/ui-toml/large_include_file/large_include_file.rs | 6 |
3 files changed, 7 insertions, 1 deletions
diff --git a/clippy_lints/src/large_include_file.rs b/clippy_lints/src/large_include_file.rs index ab3d19f89c3..4f22931a4de 100644 --- a/clippy_lints/src/large_include_file.rs +++ b/clippy_lints/src/large_include_file.rs @@ -94,6 +94,8 @@ impl LateLintPass<'_> for LargeIncludeFile { // Currently, rustc limits the usage of macro at the top-level of attributes, // so we don't need to recurse into each level. && let AttrKind::Normal(ref normal) = attr.kind + && let Some(doc) = attr.doc_str() + && doc.as_str().len() as u64 > self.max_file_size && let AttrArgs::Eq(_, AttrArgsEq::Hir(ref meta)) = normal.item.args && !attr.span.contains(meta.span) // Since the `include_str` is already expanded at this point, we can only take the diff --git a/tests/ui-toml/large_include_file/empty.txt b/tests/ui-toml/large_include_file/empty.txt new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/tests/ui-toml/large_include_file/empty.txt diff --git a/tests/ui-toml/large_include_file/large_include_file.rs b/tests/ui-toml/large_include_file/large_include_file.rs index dc9349f75a0..8a6dd36501c 100644 --- a/tests/ui-toml/large_include_file/large_include_file.rs +++ b/tests/ui-toml/large_include_file/large_include_file.rs @@ -15,5 +15,9 @@ const TOO_BIG_INCLUDE_BYTES: &[u8; 654] = include_bytes!("too_big.txt"); const TOO_BIG_INCLUDE_STR: &str = include_str!("too_big.txt"); //~^ large_include_file -#[doc = include_str!("too_big.txt")] //~ large_include_file +#[doc = include_str!("too_big.txt")] +//~^ large_include_file +// Should not lint! +// Regression test for <https://github.com/rust-lang/rust-clippy/issues/13670>. +#[doc = include_str!("empty.txt")] fn main() {} |
