Skip to content

Commit dcb72e7

Browse files
committed
Use a slice pattern to neaten a condition.
1 parent 531b38a commit dcb72e7

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

compiler/rustc_ast_passes/src/feature_gate.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -199,17 +199,12 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
199199
}
200200
}
201201
if !attr.is_doc_comment()
202-
&& attr.get_normal_item().path.segments.len() == 2
203-
&& attr.get_normal_item().path.segments[0].ident.name == sym::diagnostic
202+
&& let [seg, _] = attr.get_normal_item().path.segments.as_slice()
203+
&& seg.ident.name == sym::diagnostic
204204
&& !self.features.diagnostic_namespace
205205
{
206206
let msg = "`#[diagnostic]` attribute name space is experimental";
207-
gate_feature_post!(
208-
self,
209-
diagnostic_namespace,
210-
attr.get_normal_item().path.segments[0].ident.span,
211-
msg
212-
);
207+
gate_feature_post!(self, diagnostic_namespace, seg.ident.span, msg);
213208
}
214209

215210
// Emit errors for non-staged-api crates.

0 commit comments

Comments
 (0)