-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Open
Labels
I-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
Using the following flags
--force-warn clippy::unnecessary-operation
this code:
// run-pass
pub struct DescriptorSet<'a> {
pub slots: Vec<AttachInfo<'a, Resources>>
}
pub trait ResourcesTrait<'r>: Sized {
type DescriptorSet: 'r;
}
pub struct Resources;
impl<'a> ResourcesTrait<'a> for Resources {
type DescriptorSet = DescriptorSet<'a>;
}
pub enum AttachInfo<'a, R: ResourcesTrait<'a>> {
NextDescriptorSet(Box<R::DescriptorSet>)
}
fn main() {DescriptorSet {slots: Vec::new()};
}
caused the following diagnostics:
Checking _27c3944bb033e6c8b3e69084c701dc334186ba30 v0.1.0 (/tmp/icemaker_global_tempdir.f0JXFBTcO4io/icemaker_clippyfix_tempdir.sg9S2KgO7lsT/_27c3944bb033e6c8b3e69084c701dc334186ba30)
warning: unnecessary operation
--> src/main.rs:21:12
|
21 | fn main() {DescriptorSet {slots: Vec::new()};
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: statement can be reduced to: `Vec::new();`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_operation
= note: requested on the command line with `--force-warn clippy::unnecessary-operation`
warning: `_27c3944bb033e6c8b3e69084c701dc334186ba30` (bin "_27c3944bb033e6c8b3e69084c701dc334186ba30") generated 1 warning (run `cargo clippy --fix --bin "_27c3944bb033e6c8b3e69084c701dc334186ba30"` to apply 1 suggestion)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.44s
However after applying these diagnostics, the resulting code:
// run-pass
pub struct DescriptorSet<'a> {
pub slots: Vec<AttachInfo<'a, Resources>>
}
pub trait ResourcesTrait<'r>: Sized {
type DescriptorSet: 'r;
}
pub struct Resources;
impl<'a> ResourcesTrait<'a> for Resources {
type DescriptorSet = DescriptorSet<'a>;
}
pub enum AttachInfo<'a, R: ResourcesTrait<'a>> {
NextDescriptorSet(Box<R::DescriptorSet>)
}
fn main() {Vec::<T>::new();
}
no longer compiled:
Checking _27c3944bb033e6c8b3e69084c701dc334186ba30 v0.1.0 (/tmp/icemaker_global_tempdir.f0JXFBTcO4io/icemaker_clippyfix_tempdir.sg9S2KgO7lsT/_27c3944bb033e6c8b3e69084c701dc334186ba30)
error[E0412]: cannot find type `T` in this scope
--> src/main.rs:21:18
|
21 | fn main() {Vec::<T>::new();
| ^ not found in this scope
For more information about this error, try `rustc --explain E0412`.
error: could not compile `_27c3944bb033e6c8b3e69084c701dc334186ba30` (bin "_27c3944bb033e6c8b3e69084c701dc334186ba30" test) due to 1 previous error
warning: build failed, waiting for other jobs to finish...
error: could not compile `_27c3944bb033e6c8b3e69084c701dc334186ba30` (bin "_27c3944bb033e6c8b3e69084c701dc334186ba30") due to 1 previous error
Version:
rustc 1.90.0-nightly (cc0a5b730 2025-07-31)
binary: rustc
commit-hash: cc0a5b73053c62a3df5f84b3ee85079c9b65fa87
commit-date: 2025-07-31
host: x86_64-unknown-linux-gnu
release: 1.90.0-nightly
LLVM version: 20.1.8
Metadata
Metadata
Assignees
Labels
I-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