Skip to content

Commit b42f87c

Browse files
committed
fix: missing_inline_in_public_items fail to fulfill expect in --test build
1 parent 0c592df commit b42f87c

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, span_lint_hir};
2+
use clippy_utils::fulfill_or_allowed;
23
use rustc_hir::attrs::AttributeKind;
34
use rustc_hir::def_id::DefId;
45
use rustc_hir::{self as hir, Attribute, find_attr};
@@ -94,7 +95,14 @@ declare_lint_pass!(MissingInline => [MISSING_INLINE_IN_PUBLIC_ITEMS]);
9495

9596
impl<'tcx> LateLintPass<'tcx> for MissingInline {
9697
fn check_item(&mut self, cx: &LateContext<'tcx>, it: &'tcx hir::Item<'_>) {
97-
if it.span.in_external_macro(cx.sess().source_map()) || is_executable_or_proc_macro(cx) {
98+
if it.span.in_external_macro(cx.sess().source_map()) {
99+
return;
100+
}
101+
102+
if is_executable_or_proc_macro(cx)
103+
// Allow the lint if it is expected, when building with `--test`
104+
&& !(cx.sess().is_test_crate() && fulfill_or_allowed(cx, MISSING_INLINE_IN_PUBLIC_ITEMS, [it.hir_id()]))
105+
{
98106
return;
99107
}
100108

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)