Skip to content

Commit 9e32a34

Browse files
committed
Implement Spanned for QSelf
1 parent 026a38c commit 9e32a34

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/path.rs

+21
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,10 @@ pub(crate) mod parsing {
648648
pub(crate) mod printing {
649649
use super::*;
650650
use crate::print::TokensOrDefault;
651+
#[cfg(feature = "parsing")]
652+
use crate::spanned::Spanned;
653+
#[cfg(feature = "parsing")]
654+
use proc_macro2::Span;
651655
use proc_macro2::TokenStream;
652656
use quote::ToTokens;
653657
use std::cmp;
@@ -836,4 +840,21 @@ pub(crate) mod printing {
836840
segment.to_tokens(tokens);
837841
}
838842
}
843+
844+
#[cfg(feature = "parsing")]
845+
#[cfg_attr(doc_cfg, doc(cfg(all(feature = "parsing", feature = "printing"))))]
846+
impl Spanned for QSelf {
847+
fn span(&self) -> Span {
848+
struct QSelfDelimiters<'a>(&'a QSelf);
849+
850+
impl<'a> ToTokens for QSelfDelimiters<'a> {
851+
fn to_tokens(&self, tokens: &mut TokenStream) {
852+
self.0.lt_token.to_tokens(tokens);
853+
self.0.gt_token.to_tokens(tokens);
854+
}
855+
}
856+
857+
QSelfDelimiters(self).span()
858+
}
859+
}
839860
}

src/spanned.rs

+3
Original file line numberDiff line numberDiff line change
@@ -112,4 +112,7 @@ mod private {
112112

113113
pub trait Sealed {}
114114
impl<T: ?Sized + ToTokens> Sealed for T {}
115+
116+
#[cfg(any(feature = "full", feature = "derive"))]
117+
impl Sealed for crate::QSelf {}
115118
}

0 commit comments

Comments
 (0)