From 0baa1007100fd72ec6c2b5760e3df74bd4da3fa1 Mon Sep 17 00:00:00 2001 From: Yotam Ofek Date: Tue, 28 Jan 2025 22:14:44 +0000 Subject: [PATCH] rustc_hir: replace `is_empty()`+indexing with `first()` --- compiler/rustc_hir/src/hir.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index a396d705cbb6..3fea6cdbcf72 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -206,7 +206,7 @@ pub type UsePath<'hir> = Path<'hir, SmallVec<[Res; 3]>>; 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) } }