-
Notifications
You must be signed in to change notification settings - Fork 33
Open
Labels
A-LinterRelated to the linter and custom lintsRelated to the linter and custom lintsC-FeatureMake something new possibleMake something new possibleD-ModestA "normal" level of difficulty; suitable for simple features or challenging fixesA "normal" level of difficulty; suitable for simple features or challenging fixes
Description
What problem does this solve or what need does it fill?
Code like this will not trigger unit_in_bundle:
fn bundle_in_array<B: Bundle>(array: [B; 2]) {
// ...
}
fn main() {
// No lint triggered here because we're not passing a bundle, but an array of bundles,
// to the function.
bundle_in_array([(), ()]);
}This is because array is an array type, not a B: Bundle type, so the lint skips it. Code like this as well:
fn spawn_batch<I>(_batch: I)
where
I: IntoIterator + Send + Sync + 'static,
I::Item: Bundle<Effect: NoBundleEffect>,
{
}
fn main() {
let _ = spawn_batch(std::iter::once(()));
}What solution would you like?
unit_in_bundle should inspect the generic parameters of types within the function signature, and use that to look for bundles as well.
What alternative(s) have you considered?
The current solution catches most cases. This feels like a "nice-to-have" feature, as I'm not sure how strong the need is.
Additional context
Raised as part of the #659 review.
Metadata
Metadata
Assignees
Labels
A-LinterRelated to the linter and custom lintsRelated to the linter and custom lintsC-FeatureMake something new possibleMake something new possibleD-ModestA "normal" level of difficulty; suitable for simple features or challenging fixesA "normal" level of difficulty; suitable for simple features or challenging fixes