Open
Description
Code
enum Foo<T> {
Bar {
v23: T,
y: isize
}
}
fn f(x: &Foo) {
match *x {
Foo::Bar { y: y, v23: x } => {
assert_eq!(x, 1);
assert_eq!(y, 2);
}
}
}
pub fn main() {
let x = Foo::Bar { x: 1, y: 2 };
f(&x);
}
Current output
error[E0107]: missing generics for enum `Foo`
--> test.rs:11:10
|
11 | fn f(x: &Foo) {
| ^^^ expected 1 generic argument
|
note: enum defined here, with 1 generic parameter: `T`
--> test.rs:4:6
|
4 | enum Foo<T> {
| ^^^ -
help: add missing generic argument
|
11 | fn f(x: &Foo<T>) {
| +++
error[E0277]: can't compare `&isize` with `{integer}`
--> test.rs:15:13
|
15 | assert_eq!(y, 2);
| ^^^^^^^^^^^^^^^^ no implementation for `&isize == {integer}`
|
= help: the trait `PartialEq<{integer}>` is not implemented for `&isize`
= note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider dereferencing here
--> /home/jl-jiang/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/macros/mod.rs:46:22
|
46 | if !(**left_val == *right_val) {
| +
error[E0559]: variant `Foo<_>::Bar` has no field named `x`
--> test.rs:21:24
|
21 | let x = Foo::Bar { x: 1, y: 2 };
| ^ `Foo<_>::Bar` does not have this field
|
= note: available fields are: `v23`
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0107, E0277, E0559.
For more information about an error, try `rustc --explain E0107`.
Desired output
Rationale and extra context
I'm not entirely sure what the compiler's output should be, but it is inappropriate to suggest modifying the standard library when the issue lies in the user code. This suggestion is clearly flawed.
Other cases
Rust Version
rustc 1.88.0-nightly (e2014e876 2025-04-01)
binary: rustc
commit-hash: e2014e876e3efaa69bf51c19579adb16c3df5f81
commit-date: 2025-04-01
host: x86_64-unknown-linux-gnu
release: 1.88.0-nightly
LLVM version: 20.1.1
Anything else?
No response
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Diagnostics: A structured suggestion resulting in incorrect code.Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustcRelevant to the compiler team, which will review and decide on the PR/issue.