-
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 thingI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when appliedIssue: The suggestions provided by this Lint cause an ICE/error when applied
Description
Summary
Suggested code causes compilation error. See reproducer for details.
Lint Name
clippy::unnecessary_cast
Reproducer
I tried this code:
fn polynomial(nums: &[usize], degree: usize) -> impl FnOnce(usize) -> usize {
// suggests *b
let A: Vec<_> = nums[0..=degree].iter().map(|b|(0..=degree).map(|p| ( *b as usize ).pow(p as u32)).collect::<Vec<_>>()).collect();
let mut b= nums[0..=degree].to_vec();
gaussian_elimination(A, &mut b);
move |x| b.iter().enumerate().fold(0,|acc,(p,b)| acc + b*x.pow(p as u32))
}
I saw this happen:
I expected suggestion to be just b
, rather than *b
, since *b
causes a compilation error, since usize
cannot be dereferenced.
Version
rustc 1.75.0-nightly (1c05d50c8 2023-10-21)
binary: rustc
commit-hash: 1c05d50c8403c56d9a8b6fb871f15aaa26fb5d07
commit-date: 2023-10-21
host: x86_64-unknown-linux-gnu
release: 1.75.0-nightly
LLVM version: 17.0.3
Additional Labels
No response
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when appliedIssue: The suggestions provided by this Lint cause an ICE/error when applied