-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.

Description
The compiler gives no warning for an unused struct member if explicitly ignored.
This code:
struct MyStruct { foo: i32, bar: i32 }
fn main() {
let my_struct = MyStruct { foo: 2, bar: 3 };
match my_struct {
MyStruct { foo, .. } => println!("foo is {}", foo)
}
}
yields a warning:
<anon>:1:29: 1:37 warning: struct field is never used: `bar`, #[warn(dead_code)] on by default
<anon>:1 struct MyStruct { foo: i32, bar: i32 }
^~~~~~~~
While this code does not:
struct MyStruct { foo: i32, bar: i32 }
fn main() {
let my_struct = MyStruct { foo: 2, bar: 3 };
match my_struct {
MyStruct { foo, bar: _ } => println!("foo is {}", foo)
}
}
Meta
rustc --version --verbose
:
rustc 1.0.0 (a59de37 2015-05-13) (built 2015-05-14)
binary: rustc
commit-hash: a59de37
commit-date: 2015-05-13
build-date: 2015-05-14
host: x86_64-unknown-linux-gnu
release: 1.0.0
Metadata
Metadata
Assignees
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.