-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Fix false positives for extra_unused_type_parameters
#10321
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
r? @llogiq (rustbot has picked a reviewer for you, use r? to override) |
Triggers false positives. See discussion in rust-lang/rust-clippy#10319. Possibly fixed in rust-lang/rust-clippy#10321. Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
Triggers false positives. See discussion in rust-lang/rust-clippy#10319. Possibly fixed in rust-lang/rust-clippy#10321. Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
@bors r+ Thanks! |
This also makes me wonder if we should lint type params with bounds in the first place or if that is a bit too much for a warn-by-default lint. We could make this configurable. Nominating for the next meeting. |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
Result of the meeting: With this fix, this should be good to go as-is into |
Sounds good - is |
Yes, exactly. There is a predefined list in the |
FP in CXX: /// `CxxString` is not constructible via `new`. Instead, use the
/// [`let_cxx_string!`] macro.
pub fn new<T: Private>() -> Self {
unreachable!()
}
Pretty much the same thing in /// Decide how many threads to use in each loop
pub(crate) fn new<K>(m: usize, k: usize, n: usize, max_threads: usize) -> Self
where K: GemmKernel
In pub fn new<O>(name: &'static str) -> GeneratedOneofDescriptorData
where
O: OneofFull, I think this can be removed. Maybe it is in generated code and that's why it is there? 🤔 However, this made me notice that this lint should respect the Tokio-io: pub use self::async_read::AsyncRead;
pub use self::async_write::AsyncWrite;
fn _assert_objects() {
fn _assert<T>() {}
_assert::<Box<dyn AsyncRead>>();
_assert::<Box<dyn AsyncWrite>>();
} My best guess is, that this asserts that the So maybe extend the fix in this PR to not only type params with bounds, but general params. @mkrasnitski Will you get to fixing the above issues today / tomorrow before the sync? If not, I would move it to pedantic for now and then we will make it warn-by-default ( I ran this lint on the most popular > 400 crates regarding downloads and dependencies that are out there. |
Thanks for finding these. I can take care of this today (don't want to wait another 6 weeks to have the fix land). |
I'm unsure how to get the required |
I don't think the So, I think I should maybe check for cases where the function is exported but the bound is not - this by itself is pretty rare I would guess, since you can't just bound on a private trait, as that produces a compiler error saying you aren't allowed to leak the private trait. I'm actually surprised that you're allowed to leak the trait if it's inside of a private module. |
I think that would be overkill. Just checking if the bound is exported should be enough. Maybe this introduces a FN in this case, but as you said, this is pretty rare and then we err on the safe side.
That sounds reasonable to me. |
Opened #10392 to address the new FPs. |
Fix more false positives for `extra_unused_type_parameters` Builds on #10321. All empty functions are no longer linted, instead of just those that have trait bounds on them. Also, if a trait bound contains a non-public trait (un-exported, but still potentially reachable), then the corresponding type parameter isn't linted. Finally, added support for the `avoid_breaking_exported_api` config option. r? `@flip1995` changelog: none
Triggers false positives. See discussion in rust-lang/rust-clippy#10319. Possibly fixed in rust-lang/rust-clippy#10321. Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
Don't lint external macros. Also, if the function body is empty, any type parameters with bounds on them are not linted. Note that only the body needs be empty - this rule still applies if the function takes any arguments.
fixes #10318
fixes #10319
changelog: none