Skip to content

Fix useless_attribute FP on exported_private_dependencies lint attributes#16470

Merged
samueltardieu merged 1 commit intorust-lang:masterfrom
kpreid:useless
Jan 27, 2026
Merged

Fix useless_attribute FP on exported_private_dependencies lint attributes#16470
samueltardieu merged 1 commit intorust-lang:masterfrom
kpreid:useless

Conversation

@kpreid
Copy link
Copy Markdown
Contributor

@kpreid kpreid commented Jan 26, 2026

The exported_private_dependencies lint can fire on any mention of an item from a private dependency, including mentions inside of use. Therefore, useless_attribute should not fire on lint attributes mentioning exported_private_dependencies attached to a use.

changelog: [useless_attribute]: fix false positive on exported_private_dependencies lint attributes

PR #15645 was used as an example for preparing this PR.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Jan 26, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Jan 26, 2026

r? @samueltardieu

rustbot has assigned @samueltardieu.
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

@samueltardieu
Copy link
Copy Markdown
Member

If you don't link to an issue, please describe what the problem is.


// don't lint on exported_private_dependencies for `use` items
#[allow(exported_private_dependencies)]
use {};
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What bothers me a bit here is that this line wouldn't raise exported_private_dependencies (an expect instead of allow would fail), so the attribute would be useless here. Could you come up with an example where this attribute is useful and should not be warned about by Clippy?

Copy link
Copy Markdown
Contributor Author

@kpreid kpreid Jan 27, 2026

Choose a reason for hiding this comment

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

This will require modifying the UI test suite so that at least one of its --extern dependencies is marked priv, which is an unstable feature. Is that acceptable? If so, how should that be done? I took a look at compile-test.rs but I got lost and could not determine where the cargo invocation that pulls in the contents of clippy_test_deps actually occurs so that I could add -Zpublic-dependency to that cargo invocation (as opposed to the clippy-driver invocation).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Indeed, this is overkill. No need to change. Thanks for looking it up!

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties labels Jan 27, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Jan 27, 2026

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@kpreid
Copy link
Copy Markdown
Contributor Author

kpreid commented Jan 27, 2026

If you don't link to an issue, please describe what the problem is.

I have updated the PR description.

@samueltardieu samueltardieu added this pull request to the merge queue Jan 27, 2026
Merged via the queue into rust-lang:master with commit b5f31e2 Jan 27, 2026
13 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants