Skip to content

Fix large_include_file lint being triggered all the time by doc comments #13672

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions clippy_lints/src/large_include_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Empty file.
6 changes: 5 additions & 1 deletion tests/ui-toml/large_include_file/large_include_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}