-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingL-suggestionLint: Improving, adding or fixing lint suggestionsLint: Improving, adding or fixing lint suggestionsgood first issueThese issues are a good way to get started with ClippyThese issues are a good way to get started with Clippy
Description
Lint name: unnecessary_cast
I tried this code:
#[allow(non_camel_case_types)]
pub type size_t = usize;
pub struct Foo {
pub len: size_t,
}
impl Foo {
#[allow(dead_code)]
fn new() -> Foo {
Foo {
len: 0 as size_t,
}
}
}
I expected to see this happen:
No lint triggered, or, ideally, a suggestion to omit the cast completely and write just len: 0,
Instead, this happened:
Clippy suggested using 0_usize
instead of 0 as size_t
.
The suggestion is not good, because then changing size_t
to e.g. u64
causes the compiler error.
Meta
- clippy 0.1.52 (2021-03-16 f5d8117)
- rustc the Stable version: 1.50.0
Krantz-XRF, ChrisJefferson, bluenote10 and rudy-6-4
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingL-suggestionLint: Improving, adding or fixing lint suggestionsLint: Improving, adding or fixing lint suggestionsgood first issueThese issues are a good way to get started with ClippyThese issues are a good way to get started with Clippy