Skip to content

Commit 2309f8e

Browse files
committed
manual_non_exhaustive: Delay msrv check.
1 parent f46c981 commit 2309f8e

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

clippy_lints/src/manual_non_exhaustive.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,19 +97,15 @@ impl_lint_pass!(ManualNonExhaustiveEnum => [MANUAL_NON_EXHAUSTIVE]);
9797

9898
impl EarlyLintPass for ManualNonExhaustiveStruct {
9999
fn check_item(&mut self, cx: &EarlyContext<'_>, item: &ast::Item) {
100-
if !self.msrv.meets(msrvs::NON_EXHAUSTIVE) {
101-
return;
102-
}
103-
104-
if let ast::ItemKind::Struct(variant_data, _) = &item.kind {
105-
let (fields, delimiter) = match variant_data {
100+
if let ast::ItemKind::Struct(variant_data, _) = &item.kind
101+
&& let (fields, delimiter) = match variant_data {
106102
ast::VariantData::Struct { fields, .. } => (&**fields, '{'),
107103
ast::VariantData::Tuple(fields, _) => (&**fields, '('),
108104
ast::VariantData::Unit(_) => return,
109-
};
110-
if fields.len() <= 1 {
111-
return;
112105
}
106+
&& fields.len() > 1
107+
&& self.msrv.meets(msrvs::NON_EXHAUSTIVE)
108+
{
113109
let mut iter = fields.iter().filter_map(|f| match f.vis.kind {
114110
VisibilityKind::Public => None,
115111
VisibilityKind::Inherited => Some(Ok(f)),

0 commit comments

Comments
 (0)