Skip to content

Fix missing_inline_in_public_items fail to fulfill expect in --test build #15320

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

profetia
Copy link
Contributor

@profetia profetia commented Jul 21, 2025

Closes #13394

changelog: [missing_inline_in_public_items] fix failure to fulfill expect in --test build

@rustbot
Copy link
Collaborator

rustbot commented Jul 21, 2025

r? @y21

rustbot has assigned @y21.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Jul 21, 2025
Copy link
Member

@y21 y21 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does mean that something like #[expect(clippy::missing_inline_in_public_items)] fn private_function() {} passes the expectation with --test even though the lint would never emit a warning there, but I'm not really sure how we could avoid that so this seems fine


if is_executable_or_proc_macro(cx)
// Allow the lint if it is expected, when building with `--test`
&& !(cx.sess().is_test_crate() && lint_is_expected(cx, it.owner_id, MISSING_INLINE_IN_PUBLIC_ITEMS))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this use clippy_utils::fulfill_or_allowed? Then it wouldn't need the new util function. The existing one will return true for #[allow] but I don't think that makes a difference

Comment on lines +4 to +7
#![crate_type = "dylib"]
// When denying at the crate level, be sure to not get random warnings from the
// injected intrinsics by the compiler.
#![allow(dead_code)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these two attributes necessary? I'm pretty sure they're both implicitly set. At least for me it passes just fine without them

@Alexendoo
Copy link
Member

This looks like a symptom rather than the root of the issue, that the following is a false negative when ran with cargo clippy --tests

#![warn(clippy::missing_inline_in_public_items)]

pub fn foo() -> u32 {
    0
}

It should still lint foo as it would for cargo clippy

@profetia
Copy link
Contributor Author

Hmm.. Im confused. What is the expected behavior in --test ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

In test builds, expect(clippy::missing_inline_in_public_items) does not function properly
4 participants