diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2023-10-26 14:51:26 +1100 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2023-10-31 08:01:01 +1100 |
| commit | dcb72e705fccc17ca4f865708e6ba69dc680c71f (patch) | |
| tree | e4dd2b57b433b23ecabc6ad7b372647898968257 | |
| parent | 531b38ac2329b8078ca925d9373a5734abea0bf1 (diff) | |
| download | rust-dcb72e705fccc17ca4f865708e6ba69dc680c71f.tar.gz rust-dcb72e705fccc17ca4f865708e6ba69dc680c71f.zip | |
Use a slice pattern to neaten a condition.
| -rw-r--r-- | compiler/rustc_ast_passes/src/feature_gate.rs | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/compiler/rustc_ast_passes/src/feature_gate.rs b/compiler/rustc_ast_passes/src/feature_gate.rs index 5ccdedc76ca..12f3d8b9e75 100644 --- a/compiler/rustc_ast_passes/src/feature_gate.rs +++ b/compiler/rustc_ast_passes/src/feature_gate.rs @@ -199,17 +199,12 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { } } if !attr.is_doc_comment() - && attr.get_normal_item().path.segments.len() == 2 - && attr.get_normal_item().path.segments[0].ident.name == sym::diagnostic + && let [seg, _] = attr.get_normal_item().path.segments.as_slice() + && seg.ident.name == sym::diagnostic && !self.features.diagnostic_namespace { let msg = "`#[diagnostic]` attribute name space is experimental"; - gate_feature_post!( - self, - diagnostic_namespace, - attr.get_normal_item().path.segments[0].ident.span, - msg - ); + gate_feature_post!(self, diagnostic_namespace, seg.ident.span, msg); } // Emit errors for non-staged-api crates. |
