mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-19 03:03:21 +00:00
Do not apply rest_pat_in_fully_bound_structs
on #[non_exhaustive]
structs
This commit is contained in:
parent
bc069efb1f
commit
739f273739
@ -14,6 +14,7 @@ pub(crate) fn check(cx: &LateContext<'_>, pat: &Pat<'_>) {
|
||||
if let ty::Adt(def, _) = ty.kind();
|
||||
if def.is_struct() || def.is_union();
|
||||
if fields.len() == def.non_enum_variant().fields.len();
|
||||
if !def.non_enum_variant().is_field_list_non_exhaustive();
|
||||
|
||||
then {
|
||||
span_lint_and_help(
|
||||
|
@ -39,4 +39,19 @@ fn main() {
|
||||
|
||||
// No lint
|
||||
foo!(a_struct);
|
||||
|
||||
#[non_exhaustive]
|
||||
struct B {
|
||||
a: u32,
|
||||
b: u32,
|
||||
c: u64,
|
||||
}
|
||||
|
||||
let b_struct = B { a: 5, b: 42, c: 342 };
|
||||
|
||||
match b_struct {
|
||||
B { a: 5, b: 42, .. } => {},
|
||||
B { a: 0, b: 0, c: 128, .. } => {}, // No Lint
|
||||
_ => {},
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user