about summary refs log tree commit diff
path: root/compiler/rustc_attr_parsing/src/parser.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2025-06-23 12:38:27 +0000
committerbors <bors@rust-lang.org>2025-06-23 12:38:27 +0000
commit42245d34d22ade32b3f276dcf74deb826841594c (patch)
tree8b813764cf5705a92cf4be577b8ec223d1875b61 /compiler/rustc_attr_parsing/src/parser.rs
parentae2fc9722f08ef131407c1dc8057768868f65e8e (diff)
parent3e8e06545e8152c98f0d5ec75a6116b8070d9f8e (diff)
downloadrust-42245d34d22ade32b3f276dcf74deb826841594c.tar.gz
rust-42245d34d22ade32b3f276dcf74deb826841594c.zip
Auto merge of #142906 - jdonszelmann:rollup-togt1dl, r=jdonszelmann
Rollup of 5 pull requests

Successful merges:

 - rust-lang/rust#142493 (rework `#[naked]` attribute parser)
 - rust-lang/rust#142636 (bootstrap.example.toml: use less contextual format)
 - rust-lang/rust#142822 (Make `PartialEq` a `const_trait`)
 - rust-lang/rust#142892 (Fix ICE on debug builds where lints are delayed on the crate root)
 - rust-lang/rust#142904 (notify me when rdg is touched)

Failed merges:

 - rust-lang/rust#142827 (Move error code explanation removal check into tidy)

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_attr_parsing/src/parser.rs')
-rw-r--r--compiler/rustc_attr_parsing/src/parser.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/compiler/rustc_attr_parsing/src/parser.rs b/compiler/rustc_attr_parsing/src/parser.rs
index 1edbe3a9d27..e02dc098127 100644
--- a/compiler/rustc_attr_parsing/src/parser.rs
+++ b/compiler/rustc_attr_parsing/src/parser.rs
@@ -87,6 +87,14 @@ impl<'a> PathParser<'a> {
     pub fn word_is(&self, sym: Symbol) -> bool {
         self.word().map(|i| i.name == sym).unwrap_or(false)
     }
+
+    /// Checks whether the first segments match the givens.
+    ///
+    /// Unlike [`segments_is`](Self::segments_is),
+    /// `self` may contain more segments than the number matched  against.
+    pub fn starts_with(&self, segments: &[Symbol]) -> bool {
+        segments.len() < self.len() && self.segments().zip(segments).all(|(a, b)| a.name == *b)
+    }
 }
 
 impl Display for PathParser<'_> {