Fix large_include_file lint being triggered all the time by doc comments

This commit is contained in:
Guillaume Gomez 2024-11-09 13:51:46 +01:00
parent f712eb5cdc
commit 223bffd0d2
3 changed files with 7 additions and 1 deletions

View file

@ -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

View file

@ -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() {}