diff options
| author | Yotam Ofek <yotam.ofek@gmail.com> | 2025-01-26 16:25:47 +0000 |
|---|---|---|
| committer | Yotam Ofek <yotam.ofek@gmail.com> | 2025-01-26 16:26:52 +0000 |
| commit | 614446887ea4e5708f85dac9db008b4f3a20f004 (patch) | |
| tree | cedf3d83d154efbada91c8b48b24ec9c096ad8bc /compiler/rustc_ast/src/attr | |
| parent | 15c6f7e1a3a0e51c9b18ce5b9a391e0c324b751c (diff) | |
rustc_ast: replace some len-checks + indexing with slice patterns etc. 🧹
Diffstat (limited to 'compiler/rustc_ast/src/attr')
| -rw-r--r-- | compiler/rustc_ast/src/attr/mod.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/compiler/rustc_ast/src/attr/mod.rs b/compiler/rustc_ast/src/attr/mod.rs index 51f18580013..df2f4b88712 100644 --- a/compiler/rustc_ast/src/attr/mod.rs +++ b/compiler/rustc_ast/src/attr/mod.rs @@ -302,7 +302,7 @@ impl AttrItem { impl MetaItem { /// For a single-segment meta item, returns its name; otherwise, returns `None`. pub fn ident(&self) -> Option<Ident> { - if self.path.segments.len() == 1 { Some(self.path.segments[0].ident) } else { None } + if let [PathSegment { ident, .. }] = self.path.segments[..] { Some(ident) } else { None } } pub fn name_or_empty(&self) -> Symbol { |
