summaryrefslogtreecommitdiffstats
path: root/vendor/syn/src/path.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:59:24 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:59:24 +0000
commit023939b627b7dc93b01471f7d41fb8553ddb4ffa (patch)
tree60fc59477c605c72b0a1051409062ddecc43f877 /vendor/syn/src/path.rs
parentAdding debian version 1.72.1+dfsg1-1. (diff)
downloadrustc-023939b627b7dc93b01471f7d41fb8553ddb4ffa.tar.xz
rustc-023939b627b7dc93b01471f7d41fb8553ddb4ffa.zip
Merging upstream version 1.73.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/syn/src/path.rs')
-rw-r--r--vendor/syn/src/path.rs42
1 files changed, 37 insertions, 5 deletions
diff --git a/vendor/syn/src/path.rs b/vendor/syn/src/path.rs
index e99a3f87d..883f179f5 100644
--- a/vendor/syn/src/path.rs
+++ b/vendor/syn/src/path.rs
@@ -53,8 +53,9 @@ impl Path {
/// }
/// }
/// ```
- pub fn is_ident<I: ?Sized>(&self, ident: &I) -> bool
+ pub fn is_ident<I>(&self, ident: &I) -> bool
where
+ I: ?Sized,
Ident: PartialEq<I>,
{
match self.get_ident() {
@@ -368,7 +369,6 @@ pub(crate) mod parsing {
return Ok(Expr::Lit(lit));
}
- #[cfg(feature = "full")]
if input.peek(Ident) {
let ident: Ident = input.parse()?;
return Ok(Expr::Path(ExprPath {
@@ -391,7 +391,7 @@ pub(crate) mod parsing {
let content;
braced!(content in input);
content.parse::<Expr>()?;
- let verbatim = verbatim::between(begin, input);
+ let verbatim = verbatim::between(&begin, input);
return Ok(Expr::Verbatim(verbatim));
}
}
@@ -649,6 +649,10 @@ pub(crate) mod parsing {
pub(crate) mod printing {
use super::*;
use crate::print::TokensOrDefault;
+ #[cfg(feature = "parsing")]
+ use crate::spanned::Spanned;
+ #[cfg(feature = "parsing")]
+ use proc_macro2::Span;
use proc_macro2::TokenStream;
use quote::ToTokens;
use std::cmp;
@@ -692,10 +696,21 @@ pub(crate) mod printing {
GenericArgument::Lifetime(lt) => lt.to_tokens(tokens),
GenericArgument::Type(ty) => ty.to_tokens(tokens),
GenericArgument::Const(expr) => match expr {
- Expr::Lit(_) => expr.to_tokens(tokens),
+ Expr::Lit(expr) => expr.to_tokens(tokens),
+
+ Expr::Path(expr)
+ if expr.attrs.is_empty()
+ && expr.qself.is_none()
+ && expr.path.get_ident().is_some() =>
+ {
+ expr.to_tokens(tokens);
+ }
#[cfg(feature = "full")]
- Expr::Block(_) => expr.to_tokens(tokens),
+ Expr::Block(expr) => expr.to_tokens(tokens),
+
+ #[cfg(not(feature = "full"))]
+ Expr::Verbatim(expr) => expr.to_tokens(tokens),
// ERROR CORRECTION: Add braces to make sure that the
// generated code is valid.
@@ -826,4 +841,21 @@ pub(crate) mod printing {
segment.to_tokens(tokens);
}
}
+
+ #[cfg(feature = "parsing")]
+ #[cfg_attr(doc_cfg, doc(cfg(all(feature = "parsing", feature = "printing"))))]
+ impl Spanned for QSelf {
+ fn span(&self) -> Span {
+ struct QSelfDelimiters<'a>(&'a QSelf);
+
+ impl<'a> ToTokens for QSelfDelimiters<'a> {
+ fn to_tokens(&self, tokens: &mut TokenStream) {
+ self.0.lt_token.to_tokens(tokens);
+ self.0.gt_token.to_tokens(tokens);
+ }
+ }
+
+ QSelfDelimiters(self).span()
+ }
+ }
}