-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
A-lintArea: New lintsArea: New lintsL-restrictionLint: Belongs in the restriction lint groupLint: Belongs in the restriction lint groupgood first issueThese issues are a good way to get started with ClippyThese issues are a good way to get started with Clippy
Description
I think Clippy should start suggesting the usage of NonZeroU#::from
from smaller NonZeroU#
, as in code like:
#![allow(unused_variables)]
use std::num::{NonZeroU32, NonZeroU64};
fn main() {
let x: u64 = 100;
let y = NonZeroU32::new(10).unwrap();
// Given code:
let r1 = x / u64::from(y.get());
let r2 = x % u64::from(y.get());
// Clippy should suggest:
let r1 = x / NonZeroU64::from(y);
let r2 = x % NonZeroU64::from(y);
}
Metadata
Metadata
Assignees
Labels
A-lintArea: New lintsArea: New lintsL-restrictionLint: Belongs in the restriction lint groupLint: Belongs in the restriction lint groupgood first issueThese issues are a good way to get started with ClippyThese issues are a good way to get started with Clippy
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
marekdownar commentedon Jan 21, 2022
@rustbot claim
Samarth1696 commentedon Jul 22, 2024
@rustbot claim
non_zero_suggestions
lint #13167Auto merge of #13167 - Samarth1696:tests, r=llogiq
y21 commentedon Oct 19, 2024
Closing as this was implemented in #13167
leonardo-m commentedon Oct 19, 2024
Now we have the generic num::NonZero too, so perhaps suggesting this is better?