Debian Codegraph @

src/change_span.rs

raw symbols SCIP
1 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/::FromIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/FromIterator#;
2
3 use proc_macro2rust-analyzer cargo proc-macro2 1.0.107 crate/::{Grouprust-analyzer cargo proc-macro2 1.0.107 Group#, Spanrust-analyzer cargo proc-macro2 1.0.107 Span#, TokenStreamrust-analyzer cargo proc-macro2 1.0.107 TokenStream#, TokenTreerust-analyzer cargo proc-macro2 1.0.107 TokenTree#};
4
5 /// Deeply change the span of some tokens, ensuring that the output only references `span`.
6 ///
7 /// Macros such as `quote_spanned` preserve the spans of interpolated tokens, which is useful.
8 /// However, in some very specific scenarios it is desirable to suppress the original span
9 /// information in favor of a different one.
10 ///
11 /// For more information, see [dtolnay/syn#309](https://github.com/dtolnay/syn/issues/309).
12 pub(craterust-analyzer cargo derive_builder_core 0.20.2 crate/) fn change_spanrust-analyzer cargo derive_builder_core 0.20.2 change_span/change_span().(tokens: TokenStreamrust-analyzer cargo proc-macro2 1.0.107 TokenStream#, span: Spanrust-analyzer cargo proc-macro2 1.0.107 Span#) -> TokenStreamrust-analyzer cargo proc-macro2 1.0.107 TokenStream# {
13 let mut result = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![];
14 for mut token in tokens {
15 match token {
16 TokenTreerust-analyzer cargo proc-macro2 1.0.107 TokenTree#::Grouprust-analyzer cargo proc-macro2 1.0.107 TokenTree#Group#(group) => {
17 let mut new_group =
18 Grouprust-analyzer cargo proc-macro2 1.0.107 Group#::newrust-analyzer cargo proc-macro2 1.0.107 impl#[Group]new().(group.delimiterrust-analyzer cargo proc-macro2 1.0.107 impl#[Group]delimiter().(), change_spanrust-analyzer cargo derive_builder_core 0.20.2 change_span/change_span().(group.streamrust-analyzer cargo proc-macro2 1.0.107 impl#[Group]stream().(), span));
19 new_group.set_spanrust-analyzer cargo proc-macro2 1.0.107 impl#[Group]set_span().(span);
20 result.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(TokenTreerust-analyzer cargo proc-macro2 1.0.107 TokenTree#::Grouprust-analyzer cargo proc-macro2 1.0.107 TokenTree#Group#(new_group));
21 }
22 _ => {
23 token.set_spanrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenTree]set_span().(span);
24 result.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(token);
25 }
26 }
27 }
28 FromIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/FromIterator#::from_iterrust-analyzer cargo proc-macro2 1.0.107 impl#[TokenStream][`FromIterator<TokenTree>`]from_iter().(result)
29 }