Skip to content

Commit 3ee7601

Browse files
committed
fix: missing_inline_in_public_items fail to fulfill expect in --test build
1 parent 1db89a1 commit 3ee7601

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

clippy_lints/src/missing_inline.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use clippy_utils::diagnostics::span_lint;
2+
use clippy_utils::fulfill_or_allowed;
23
use rustc_attr_data_structures::{AttributeKind, find_attr};
34
use rustc_hir::def_id::DefId;
45
use rustc_hir::{self as hir, Attribute};
@@ -88,7 +89,14 @@ declare_lint_pass!(MissingInline => [MISSING_INLINE_IN_PUBLIC_ITEMS]);
8889

8990
impl<'tcx> LateLintPass<'tcx> for MissingInline {
9091
fn check_item(&mut self, cx: &LateContext<'tcx>, it: &'tcx hir::Item<'_>) {
91-
if it.span.in_external_macro(cx.sess().source_map()) || is_executable_or_proc_macro(cx) {
92+
if it.span.in_external_macro(cx.sess().source_map()) {
93+
return;
94+
}
95+
96+
if is_executable_or_proc_macro(cx)
97+
// Allow the lint if it is expected, when building with `--test`
98+
&& !(cx.sess().is_test_crate() && fulfill_or_allowed(cx, MISSING_INLINE_IN_PUBLIC_ITEMS, [it.hir_id()]))
99+
{
92100
return;
93101
}
94102

tests/ui/missing_inline_test_crate.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//@compile-flags: --test
2+
//@check-pass
3+
#![warn(clippy::missing_inline_in_public_items)]
4+
5+
#[expect(clippy::missing_inline_in_public_items)]
6+
pub fn foo() -> u32 {
7+
0
8+
}

0 commit comments

Comments
 (0)