From ef24de24a82fe681581cc130f342363c47c0969a Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 7 Jun 2024 07:48:48 +0200 Subject: Merging upstream version 1.75.0+dfsg1. Signed-off-by: Daniel Baumann --- vendor/syn/src/path.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'vendor/syn/src/path.rs') diff --git a/vendor/syn/src/path.rs b/vendor/syn/src/path.rs index 883f179f5..b9d96e669 100644 --- a/vendor/syn/src/path.rs +++ b/vendor/syn/src/path.rs @@ -82,6 +82,19 @@ impl Path { None } } + + /// An error if this path is not a single ident, as defined in `get_ident`. + #[cfg(feature = "parsing")] + #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))] + pub fn require_ident(&self) -> Result<&Ident> { + self.get_ident().ok_or_else(|| { + crate::error::new2( + self.segments.first().unwrap().ident.span(), + self.segments.last().unwrap().ident.span(), + "expected this path to be an identifier", + ) + }) + } } ast_struct! { -- cgit v1.2.3