rustc_ast: replace some len-checks + indexing with slice patterns etc. 🧹
This commit is contained in:
parent
15c6f7e1a3
commit
614446887e
4 changed files with 10 additions and 10 deletions
|
@ -100,7 +100,7 @@ pub struct Path {
|
|||
impl PartialEq<Symbol> for Path {
|
||||
#[inline]
|
||||
fn eq(&self, symbol: &Symbol) -> bool {
|
||||
self.segments.len() == 1 && { self.segments[0].ident.name == *symbol }
|
||||
matches!(&self.segments[..], [segment] if segment.ident.name == *symbol)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -121,13 +121,13 @@ impl Path {
|
|||
}
|
||||
|
||||
pub fn is_global(&self) -> bool {
|
||||
!self.segments.is_empty() && self.segments[0].ident.name == kw::PathRoot
|
||||
self.segments.first().is_some_and(|segment| segment.ident.name == kw::PathRoot)
|
||||
}
|
||||
|
||||
/// If this path is a single identifier with no arguments, does not ensure
|
||||
/// that the path resolves to a const param, the caller should check this.
|
||||
pub fn is_potential_trivial_const_arg(&self) -> bool {
|
||||
self.segments.len() == 1 && self.segments[0].args.is_none()
|
||||
matches!(self.segments[..], [PathSegment { args: None, .. }])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue