Open
Description
I really don't get this diagnostic. It says that U is unused, but removing U causes a " cannot find type U
in this scope" diagnostic. Is U used or not? I feel like this diagnostic could be improved.
(btw, I arrived at this code while reading https://doc.rust-lang.org/book/2018-edition/ch13-01-closures.html#limitations-of-the-cacher-implementation)
struct Cacher<T, U: Copy>
where T: Fn(U) -> U
{
calculation: T,
value: Option<u32>,
}
fn main() {
let c = Cacher::new(|x| x);
println!("Hello, world!");
}
Errors:
Compiling playground v0.0.1 (file:///playground)
error[E0392]: parameter `U` is never used
--> src/main.rs:2:18
|
2 | struct Cacher<T, U: Copy>
| ^ unused type parameter
|
= help: consider removing `U` or using a marker such as `std::marker::PhantomData`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0392`.
error: Could not compile `playground`.
To learn more, run the command again with --verbose.
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsArea: Suggestions generated by the compiler applied by `cargo fix`Category: An issue proposing an enhancement or a PR with one.Diagnostics: An error or lint that needs small tweaks.Relevant to the compiler team, which will review and decide on the PR/issue.