Debian Codegraph @

src/lib.rs

raw symbols SCIP
1 #![doc = include_strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/include_str!!("../README.md")]
2 #![allow(
3 clippy::derive_partial_eq_without_eq,
4 clippy::doc_markdown,
5 clippy::match_same_arms,
6 clippy::module_name_repetitions,
7 clippy::needless_doctest_main,
8 clippy::too_many_lines
9 )]
10 #![cfg_attr(coverage_nightly, feature(coverage_attribute))]
11
12 extern crate proc_macrorust-analyzer cargo pastey 0.2.3 proc_macro/;
13
14 mod attrrust-analyzer cargo pastey 0.2.3 attr/;
15 mod errorrust-analyzer cargo pastey 0.2.3 error/;
16 mod segmentrust-analyzer cargo pastey 0.2.3 segment/;
17 #[cfg(coverage_nightly)]
18 mod test_helpers;
19
20 use craterust-analyzer cargo pastey 0.2.3 crate/::attrrust-analyzer cargo pastey 0.2.3 attr/::expand_attrrust-analyzer cargo pastey 0.2.3 attr/expand_attr().;
21 use craterust-analyzer cargo pastey 0.2.3 crate/::errorrust-analyzer cargo pastey 0.2.3 error/::{Errorrust-analyzer cargo pastey 0.2.3 error/Error#, Resultrust-analyzer cargo pastey 0.2.3 error/Result#};
22 use craterust-analyzer cargo pastey 0.2.3 crate/::segmentrust-analyzer cargo pastey 0.2.3 segment/::Segmentrust-analyzer cargo pastey 0.2.3 segment/Segment#;
23 use proc_macrorust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro crate/::{
24 Delimiterrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro Delimiter#, Grouprust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro Group#, Identrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro Ident#, LexErrorrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro LexError#, Literalrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro Literal#, Punctrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro Punct#, Spacingrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro Spacing#, Spanrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro Span#, TokenStreamrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenStream#, TokenTreerust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenTree#,
25 };
26 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::charrust-analyzer cargo core https://github.com/rust-lang/rust/library/core char/;
27 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/;
28 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std panic/;
29 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/::FromStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr#;
30
31 #[proc_macro]
32 pub fn pasterust-analyzer cargo pastey 0.2.3 paste!(input: TokenStreamrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenStream#) -> TokenStreamrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenStream# {
33 let mut contains_paste = false;
34 let flatten_single_interpolation = true;
35 match expandrust-analyzer cargo pastey 0.2.3 expand().(
36 input.clonerust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro impl#[TokenStream][Clone]clone().(),
37 &mut contains_paste,
38 flatten_single_interpolation,
39 ) {
40 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(expanded) => {
41 if contains_paste {
42 expanded
43 } else {
44 input
45 }
46 }
47 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(err) => err.to_compile_errorrust-analyzer cargo pastey 0.2.3 error/impl#[Error]to_compile_error().(),
48 }
49 }
50
51 #[doc(hidden)]
52 #[proc_macro]
53 pub fn itemrust-analyzer cargo pastey 0.2.3 item!(input: TokenStreamrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenStream#) -> TokenStreamrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenStream# {
54 pasterust-analyzer cargo pastey 0.2.3 paste().(input)
55 }
56
57 #[doc(hidden)]
58 #[proc_macro]
59 pub fn exprrust-analyzer cargo pastey 0.2.3 expr!(input: TokenStreamrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenStream#) -> TokenStreamrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenStream# {
60 pasterust-analyzer cargo pastey 0.2.3 paste().(input)
61 }
62
63 fn expandrust-analyzer cargo pastey 0.2.3 expand().(
64 input: TokenStreamrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenStream#,
65 contains_paste: &mut bool,
66 flatten_single_interpolation: bool,
67 ) -> Resultrust-analyzer cargo pastey 0.2.3 error/Result#<TokenStreamrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenStream#> {
68 let mut expanded = TokenStreamrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenStream#::newrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro impl#[TokenStream]new().();
69 let mut lookbehind = Lookbehindrust-analyzer cargo pastey 0.2.3 Lookbehind#::Otherrust-analyzer cargo pastey 0.2.3 Lookbehind#Other#;
70 let mut prev_none_group = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#::<Grouprust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro Group#>;
71 let mut tokens = input.into_iterrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro token_stream/impl#[TokenStream][IntoIterator]into_iter().().peekablerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#peekable().();
72 loop {
73 let token = tokens.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/peekable/impl#[`Peekable<I>`][Iterator]next().();
74 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(group) = prev_none_group.takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]take().() {
75 if match (&token, tokens.peekrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/peekable/impl#[`Peekable<I>`]peek().()) {
76 (Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(TokenTreerust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenTree#::Punctrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenTree#Punct#(fst)), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(TokenTreerust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenTree#::Punctrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenTree#Punct#(snd))) => {
77 fst.as_charrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro impl#[Punct]as_char().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().':' && snd.as_charrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro impl#[Punct]as_char().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().':' && fst.spacingrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro impl#[Punct]spacing().() rust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro impl#[Spacing][`PartialEq<Self>`]eq().==rust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro impl#[Spacing][`PartialEq<Self>`]eq(). rust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro impl#[Spacing][`PartialEq<Self>`]eq().Spacingrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro Spacing#::Jointrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro Spacing#Joint#
78 }
79 _ => false,
80 } {
81 expanded.extendrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro impl#[TokenStream][`Extend<TokenTree>`]extend().(group.streamrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro impl#[Group]stream().());
82 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().contains_paste = true;
83 } else {
84 expanded.extendrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro impl#[TokenStream][`Extend<TokenTree>`]extend().(iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/::oncerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/sources/once/once().(TokenTreerust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenTree#::Grouprust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenTree#Group#(group)));
85 }
86 }
87 match token {
88 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(TokenTreerust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenTree#::Grouprust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenTree#Group#(group)) => {
89 let delimiter = group.delimiterrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro impl#[Group]delimiter().();
90 let content = group.streamrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro impl#[Group]stream().();
91 let span = group.spanrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro impl#[Group]span().();
92 if delimiter rust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro impl#[Delimiter][`PartialEq<Self>`]eq().==rust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro impl#[Delimiter][`PartialEq<Self>`]eq(). rust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro impl#[Delimiter][`PartialEq<Self>`]eq().Delimiterrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro Delimiter#::Bracketrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro Delimiter#Bracket# && is_paste_operationrust-analyzer cargo pastey 0.2.3 is_paste_operation().(&content) {
93 let segments = parse_bracket_as_segmentsrust-analyzer cargo pastey 0.2.3 parse_bracket_as_segments().(content, span)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
94 let pasted = segmentrust-analyzer cargo pastey 0.2.3 segment/::pasterust-analyzer cargo pastey 0.2.3 segment/paste().(&segments)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
95 let tokens = pasted_to_tokensrust-analyzer cargo pastey 0.2.3 pasted_to_tokens().(pasted, span)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
96 expanded.extendrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro impl#[TokenStream][`Extend<TokenTree>`]extend().(tokens);
97 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().contains_paste = true;
98 } else if flatten_single_interpolation
99 && delimiter rust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro impl#[Delimiter][`PartialEq<Self>`]eq().==rust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro impl#[Delimiter][`PartialEq<Self>`]eq(). rust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro impl#[Delimiter][`PartialEq<Self>`]eq().Delimiterrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro Delimiter#::Nonerust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro Delimiter#None#
100 && is_single_interpolation_grouprust-analyzer cargo pastey 0.2.3 is_single_interpolation_group().(&content)
101 {
102 expanded.extendrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro impl#[TokenStream][`Extend<TokenTree>`]extend().(content);
103 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().contains_paste = true;
104 } else {
105 let mut group_contains_paste = false;
106 let is_attribute = delimiter rust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro impl#[Delimiter][`PartialEq<Self>`]eq().==rust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro impl#[Delimiter][`PartialEq<Self>`]eq(). rust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro impl#[Delimiter][`PartialEq<Self>`]eq().Delimiterrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro Delimiter#::Bracketrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro Delimiter#Bracket#
107 && (lookbehind rust-analyzer cargo pastey 0.2.3 impl#[Lookbehind][`PartialEq<Self>`]eq().==rust-analyzer cargo pastey 0.2.3 impl#[Lookbehind][`PartialEq<Self>`]eq(). rust-analyzer cargo pastey 0.2.3 impl#[Lookbehind][`PartialEq<Self>`]eq().Lookbehindrust-analyzer cargo pastey 0.2.3 Lookbehind#::Poundrust-analyzer cargo pastey 0.2.3 Lookbehind#Pound# || lookbehind rust-analyzer cargo pastey 0.2.3 impl#[Lookbehind][`PartialEq<Self>`]eq().==rust-analyzer cargo pastey 0.2.3 impl#[Lookbehind][`PartialEq<Self>`]eq(). rust-analyzer cargo pastey 0.2.3 impl#[Lookbehind][`PartialEq<Self>`]eq().Lookbehindrust-analyzer cargo pastey 0.2.3 Lookbehind#::PoundBangrust-analyzer cargo pastey 0.2.3 Lookbehind#PoundBang#);
108 let mut nested = expandrust-analyzer cargo pastey 0.2.3 expand().(
109 content,
110 &mut group_contains_paste,
111 flatten_single_interpolation && !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_attribute,
112 )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
113 if is_attribute {
114 nested = expand_attrrust-analyzer cargo pastey 0.2.3 attr/expand_attr().(nested, span, &mut group_contains_paste)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
115 }
116 let group = if group_contains_paste {
117 let mut group = Grouprust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro Group#::newrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro impl#[Group]new().(delimiter, nested);
118 group.set_spanrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro impl#[Group]set_span().(span);
119 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().contains_paste = true;
120 group
121 } else {
122 group.clonerust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro impl#[Group][Clone]clone().()
123 };
124 if delimiter rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#ne().Delimiterrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro Delimiter#::Nonerust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro Delimiter#None# {
125 expanded.extendrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro impl#[TokenStream][`Extend<TokenTree>`]extend().(iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/::oncerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/sources/once/once().(TokenTreerust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenTree#::Grouprust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenTree#Group#(group)));
126 } else if lookbehind rust-analyzer cargo pastey 0.2.3 impl#[Lookbehind][`PartialEq<Self>`]eq().==rust-analyzer cargo pastey 0.2.3 impl#[Lookbehind][`PartialEq<Self>`]eq(). rust-analyzer cargo pastey 0.2.3 impl#[Lookbehind][`PartialEq<Self>`]eq().Lookbehindrust-analyzer cargo pastey 0.2.3 Lookbehind#::DoubleColonrust-analyzer cargo pastey 0.2.3 Lookbehind#DoubleColon# {
127 expanded.extendrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro impl#[TokenStream][`Extend<TokenTree>`]extend().(group.streamrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro impl#[Group]stream().());
128 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().contains_paste = true;
129 } else {
130 prev_none_group = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(group);
131 }
132 }
133 lookbehind = Lookbehindrust-analyzer cargo pastey 0.2.3 Lookbehind#::Otherrust-analyzer cargo pastey 0.2.3 Lookbehind#Other#;
134 }
135 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(TokenTreerust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenTree#::Punctrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenTree#Punct#(punct)) => {
136 lookbehind = match punct.as_charrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro impl#[Punct]as_char().() {
137 ':' if lookbehind rust-analyzer cargo pastey 0.2.3 impl#[Lookbehind][`PartialEq<Self>`]eq().==rust-analyzer cargo pastey 0.2.3 impl#[Lookbehind][`PartialEq<Self>`]eq(). rust-analyzer cargo pastey 0.2.3 impl#[Lookbehind][`PartialEq<Self>`]eq().Lookbehindrust-analyzer cargo pastey 0.2.3 Lookbehind#::JointColonrust-analyzer cargo pastey 0.2.3 Lookbehind#JointColon# => Lookbehindrust-analyzer cargo pastey 0.2.3 Lookbehind#::DoubleColonrust-analyzer cargo pastey 0.2.3 Lookbehind#DoubleColon#,
138 ':' if punct.spacingrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro impl#[Punct]spacing().() rust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro impl#[Spacing][`PartialEq<Self>`]eq().==rust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro impl#[Spacing][`PartialEq<Self>`]eq(). rust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro impl#[Spacing][`PartialEq<Self>`]eq().Spacingrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro Spacing#::Jointrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro Spacing#Joint# => Lookbehindrust-analyzer cargo pastey 0.2.3 Lookbehind#::JointColonrust-analyzer cargo pastey 0.2.3 Lookbehind#JointColon#,
139 '#' => Lookbehindrust-analyzer cargo pastey 0.2.3 Lookbehind#::Poundrust-analyzer cargo pastey 0.2.3 Lookbehind#Pound#,
140 '!' if lookbehind rust-analyzer cargo pastey 0.2.3 impl#[Lookbehind][`PartialEq<Self>`]eq().==rust-analyzer cargo pastey 0.2.3 impl#[Lookbehind][`PartialEq<Self>`]eq(). rust-analyzer cargo pastey 0.2.3 impl#[Lookbehind][`PartialEq<Self>`]eq().Lookbehindrust-analyzer cargo pastey 0.2.3 Lookbehind#::Poundrust-analyzer cargo pastey 0.2.3 Lookbehind#Pound# => Lookbehindrust-analyzer cargo pastey 0.2.3 Lookbehind#::PoundBangrust-analyzer cargo pastey 0.2.3 Lookbehind#PoundBang#,
141 _ => Lookbehindrust-analyzer cargo pastey 0.2.3 Lookbehind#::Otherrust-analyzer cargo pastey 0.2.3 Lookbehind#Other#,
142 };
143 expanded.extendrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro impl#[TokenStream][`Extend<TokenTree>`]extend().(iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/::oncerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/sources/once/once().(TokenTreerust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenTree#::Punctrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenTree#Punct#(punct)));
144 }
145 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(other) => {
146 lookbehind = Lookbehindrust-analyzer cargo pastey 0.2.3 Lookbehind#::Otherrust-analyzer cargo pastey 0.2.3 Lookbehind#Other#;
147 expanded.extendrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro impl#[TokenStream][`Extend<TokenTree>`]extend().(iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/::oncerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/sources/once/once().(other));
148 }
149 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(expanded),
150 }
151 }
152 }
153
154 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:)]
155 enum Lookbehindrust-analyzer cargo pastey 0.2.3 Lookbehind# {
156 JointColonrust-analyzer cargo pastey 0.2.3 Lookbehind#JointColon#,
157 DoubleColonrust-analyzer cargo pastey 0.2.3 Lookbehind#DoubleColon#,
158 Poundrust-analyzer cargo pastey 0.2.3 Lookbehind#Pound#,
159 PoundBangrust-analyzer cargo pastey 0.2.3 Lookbehind#PoundBang#,
160 Otherrust-analyzer cargo pastey 0.2.3 Lookbehind#Other#,
161 }
162
163 // https://github.com/dtolnay/paste/issues/26
164 fn is_single_interpolation_grouprust-analyzer cargo pastey 0.2.3 is_single_interpolation_group().(input: &TokenStreamrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenStream#) -> bool {
165 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:)]
166 enum Staterust-analyzer cargo pastey 0.2.3 State# {
167 Initrust-analyzer cargo pastey 0.2.3 State#Init#,
168 Identrust-analyzer cargo pastey 0.2.3 State#Ident#,
169 Literalrust-analyzer cargo pastey 0.2.3 State#Literal#,
170 Apostropherust-analyzer cargo pastey 0.2.3 State#Apostrophe#,
171 Lifetimerust-analyzer cargo pastey 0.2.3 State#Lifetime#,
172 Colon1rust-analyzer cargo pastey 0.2.3 State#Colon1#,
173 Colon2rust-analyzer cargo pastey 0.2.3 State#Colon2#,
174 }
175
176 let mut state = Staterust-analyzer cargo pastey 0.2.3 State#::Initrust-analyzer cargo pastey 0.2.3 State#Init#;
177 for tt in input.clonerust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro impl#[TokenStream][Clone]clone().() {
178 state = match (state, &tt) {
179 (Staterust-analyzer cargo pastey 0.2.3 State#::Initrust-analyzer cargo pastey 0.2.3 State#Init#, TokenTreerust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenTree#::Identrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenTree#Ident#(_)) => Staterust-analyzer cargo pastey 0.2.3 State#::Identrust-analyzer cargo pastey 0.2.3 State#Ident#,
180 (Staterust-analyzer cargo pastey 0.2.3 State#::Initrust-analyzer cargo pastey 0.2.3 State#Init#, TokenTreerust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenTree#::Literalrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenTree#Literal#(_)) => Staterust-analyzer cargo pastey 0.2.3 State#::Literalrust-analyzer cargo pastey 0.2.3 State#Literal#,
181 (Staterust-analyzer cargo pastey 0.2.3 State#::Initrust-analyzer cargo pastey 0.2.3 State#Init#, TokenTreerust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenTree#::Punctrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenTree#Punct#(punct)) if punct.as_charrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro impl#[Punct]as_char().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().'\'' => Staterust-analyzer cargo pastey 0.2.3 State#::Apostropherust-analyzer cargo pastey 0.2.3 State#Apostrophe#,
182 (Staterust-analyzer cargo pastey 0.2.3 State#::Apostropherust-analyzer cargo pastey 0.2.3 State#Apostrophe#, TokenTreerust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenTree#::Identrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenTree#Ident#(_)) => Staterust-analyzer cargo pastey 0.2.3 State#::Lifetimerust-analyzer cargo pastey 0.2.3 State#Lifetime#,
183 (Staterust-analyzer cargo pastey 0.2.3 State#::Identrust-analyzer cargo pastey 0.2.3 State#Ident#, TokenTreerust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenTree#::Punctrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenTree#Punct#(punct))
184 if punct.as_charrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro impl#[Punct]as_char().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().':' && punct.spacingrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro impl#[Punct]spacing().() rust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro impl#[Spacing][`PartialEq<Self>`]eq().==rust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro impl#[Spacing][`PartialEq<Self>`]eq(). rust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro impl#[Spacing][`PartialEq<Self>`]eq().Spacingrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro Spacing#::Jointrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro Spacing#Joint# =>
185 {
186 Staterust-analyzer cargo pastey 0.2.3 State#::Colon1rust-analyzer cargo pastey 0.2.3 State#Colon1#
187 }
188 (Staterust-analyzer cargo pastey 0.2.3 State#::Colon1rust-analyzer cargo pastey 0.2.3 State#Colon1#, TokenTreerust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenTree#::Punctrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenTree#Punct#(punct))
189 if punct.as_charrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro impl#[Punct]as_char().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().':' && punct.spacingrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro impl#[Punct]spacing().() rust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro impl#[Spacing][`PartialEq<Self>`]eq().==rust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro impl#[Spacing][`PartialEq<Self>`]eq(). rust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro impl#[Spacing][`PartialEq<Self>`]eq().Spacingrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro Spacing#::Alonerust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro Spacing#Alone# =>
190 {
191 Staterust-analyzer cargo pastey 0.2.3 State#::Colon2rust-analyzer cargo pastey 0.2.3 State#Colon2#
192 }
193 (Staterust-analyzer cargo pastey 0.2.3 State#::Colon2rust-analyzer cargo pastey 0.2.3 State#Colon2#, TokenTreerust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenTree#::Identrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenTree#Ident#(_)) => Staterust-analyzer cargo pastey 0.2.3 State#::Identrust-analyzer cargo pastey 0.2.3 State#Ident#,
194 _ => return false,
195 };
196 }
197
198 state rust-analyzer cargo pastey 0.2.3 impl#[State][`PartialEq<Self>`]eq().==rust-analyzer cargo pastey 0.2.3 impl#[State][`PartialEq<Self>`]eq(). rust-analyzer cargo pastey 0.2.3 impl#[State][`PartialEq<Self>`]eq().Staterust-analyzer cargo pastey 0.2.3 State#::Identrust-analyzer cargo pastey 0.2.3 State#Ident# || state rust-analyzer cargo pastey 0.2.3 impl#[State][`PartialEq<Self>`]eq().==rust-analyzer cargo pastey 0.2.3 impl#[State][`PartialEq<Self>`]eq(). rust-analyzer cargo pastey 0.2.3 impl#[State][`PartialEq<Self>`]eq().Staterust-analyzer cargo pastey 0.2.3 State#::Literalrust-analyzer cargo pastey 0.2.3 State#Literal# || state rust-analyzer cargo pastey 0.2.3 impl#[State][`PartialEq<Self>`]eq().==rust-analyzer cargo pastey 0.2.3 impl#[State][`PartialEq<Self>`]eq(). rust-analyzer cargo pastey 0.2.3 impl#[State][`PartialEq<Self>`]eq().Staterust-analyzer cargo pastey 0.2.3 State#::Lifetimerust-analyzer cargo pastey 0.2.3 State#Lifetime#
199 }
200
201 fn is_paste_operationrust-analyzer cargo pastey 0.2.3 is_paste_operation().(input: &TokenStreamrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenStream#) -> bool {
202 let mut tokens = input.clonerust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro impl#[TokenStream][Clone]clone().().into_iterrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro token_stream/impl#[TokenStream][IntoIterator]into_iter().();
203
204 match &tokens.nextrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro token_stream/impl#[IntoIter][Iterator]next().() {
205 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(TokenTreerust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenTree#::Punctrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenTree#Punct#(punct)) if punct.as_charrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro impl#[Punct]as_char().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().'<' => {}
206 _ => return false,
207 }
208
209 let mut has_token = false;
210 loop {
211 match &tokens.nextrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro token_stream/impl#[IntoIter][Iterator]next().() {
212 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(TokenTreerust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenTree#::Punctrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenTree#Punct#(punct)) if punct.as_charrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro impl#[Punct]as_char().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().'>' => {
213 return has_token && tokens.nextrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro token_stream/impl#[IntoIter][Iterator]next().().is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().();
214 }
215 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(_) => has_token = true,
216 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => return false,
217 }
218 }
219 }
220
221 // Coverage note:
222 // Uncovered line -Some(wrong) => return Err(Error::new(wrong.span(), "expected `>`")),
223 //
224 // This line can never be reached because segment::parse stops only when it
225 // sees `>` or runs out of tokens. So the very next token after parse() is
226 // always either `>` or None — never any other token.
227 //
228 // coverage(off) cannot be placed on a single match arm, only on a whole
229 // function. So the match was moved into this helper function so the
230 // attribute can be applied here.
231 #[cfg_attr(coverage_nightly, coverage(off))]
232 fn check_close_angle_tokenrust-analyzer cargo pastey 0.2.3 check_close_angle_token().(token: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<TokenTreerust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenTree#>, scope: Spanrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro Span#) -> Resultrust-analyzer cargo pastey 0.2.3 error/Result#<()> {
233 match token {
234 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(TokenTreerust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenTree#::Punctrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenTree#Punct#(punct)) if punct.as_charrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro impl#[Punct]as_char().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().'>' => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()),
235 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(wrong) => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo pastey 0.2.3 error/Error#::newrust-analyzer cargo pastey 0.2.3 error/impl#[Error]new().(wrong.spanrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro impl#[TokenTree]span().(), "expected `>`")),
236 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo pastey 0.2.3 error/Error#::newrust-analyzer cargo pastey 0.2.3 error/impl#[Error]new().(scope, "expected `[< ... >]`")),
237 }
238 }
239
240 // Coverage note:
241 // Uncovered lines (the fallthrough/else paths of the two if-let checks):
242 // if let Ok(unsigned) = u32::from_str_radix(hex, 16) {
243 // if let Some(ch) = char::from_u32(unsigned) {
244 // ...
245 // }// None path never covered
246 // }// Err path never covered
247 //
248 // These paths can never be reached because:
249 // - The hex string comes from a Literal that the Rust compiler already parsed.
250 // The compiler rejects any non-hex characters in \u{...} at compile time,
251 // so from_str_radix will always succeed (never Err).
252 // - The compiler also rejects surrogate codepoints like \u{D800} at compile
253 // time, so char::from_u32 will always succeed (never None).
254 //
255 // The defensive checks are kept in case this code is called with manually
256 // constructed TokenStreams in the future. The block is moved into this helper
257 // so coverage(off) can be applied at function scope (the only level the
258 // attribute supports). The call site becomes a simple bool check with no
259 // uncoverable branches.
260 //
261 // Returns true if the value was converted (caller should `continue`), false otherwise.
262 #[cfg_attr(coverage_nightly, coverage(off))]
263 fn try_convert_unicode_escaperust-analyzer cargo pastey 0.2.3 try_convert_unicode_escape().(value: &mut Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#) -> bool {
264 if value.starts_withrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]starts_with().("'\\u{") {
265 let hex = &value[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().4..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#value.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().2]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().;
266 if let Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(unsigned) = u32::from_str_radixrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]from_str_radix().(hex, 16) {
267 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ch) = charrust-analyzer cargo core https://github.com/rust-lang/rust/library/core char/::from_u32rust-analyzer cargo core https://github.com/rust-lang/rust/library/core char/from_u32().(unsigned) {
268 value.clearrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]clear().();
269 value.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push().(ch);
270 return true;
271 }
272 }
273 }
274 false
275 }
276
277 fn parse_bracket_as_segmentsrust-analyzer cargo pastey 0.2.3 parse_bracket_as_segments().(input: TokenStreamrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenStream#, scope: Spanrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro Span#) -> Resultrust-analyzer cargo pastey 0.2.3 error/Result#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Segmentrust-analyzer cargo pastey 0.2.3 segment/Segment#>> {
278 let mut tokens = input.into_iterrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro token_stream/impl#[TokenStream][IntoIterator]into_iter().().peekablerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#peekable().();
279
280 match &tokens.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/peekable/impl#[`Peekable<I>`][Iterator]next().() {
281 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(TokenTreerust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenTree#::Punctrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenTree#Punct#(punct)) if punct.as_charrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro impl#[Punct]as_char().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[char][`PartialEq<Self>`]eq().'<' => {}
282 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(wrong) => return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo pastey 0.2.3 error/Error#::newrust-analyzer cargo pastey 0.2.3 error/impl#[Error]new().(wrong.spanrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro impl#[TokenTree]span().(), "expected `<`")),
283 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo pastey 0.2.3 error/Error#::newrust-analyzer cargo pastey 0.2.3 error/impl#[Error]new().(scope, "expected `[< ... >]`")),
284 }
285
286 let mut segments = segmentrust-analyzer cargo pastey 0.2.3 segment/::parserust-analyzer cargo pastey 0.2.3 segment/parse().(&mut tokens)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
287
288 check_close_angle_tokenrust-analyzer cargo pastey 0.2.3 check_close_angle_token().(tokens.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/peekable/impl#[`Peekable<I>`][Iterator]next().(), scope)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
289
290 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(unexpected) = tokens.nextrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/peekable/impl#[`Peekable<I>`][Iterator]next().() {
291 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo pastey 0.2.3 error/Error#::newrust-analyzer cargo pastey 0.2.3 error/impl#[Error]new().(
292 unexpected.spanrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro impl#[TokenTree]span().(),
293 "unexpected input, expected `[< ... >]`",
294 ));
295 }
296
297 for segment in &mut segments {
298 if let Segmentrust-analyzer cargo pastey 0.2.3 segment/Segment#::Stringrust-analyzer cargo pastey 0.2.3 segment/Segment#String#(string) = segment {
299 if try_convert_unicode_escaperust-analyzer cargo pastey 0.2.3 try_convert_unicode_escape().(&mut string.valuerust-analyzer cargo pastey 0.2.3 segment/LitStr#value.) {
300 continue;
301 }
302 if string.valuerust-analyzer cargo pastey 0.2.3 segment/LitStr#value..containsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]contains().(&['\\', '.', '+'][rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().)
303 || string.valuerust-analyzer cargo pastey 0.2.3 segment/LitStr#value..starts_withrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]starts_with().("b'")
304 || string.valuerust-analyzer cargo pastey 0.2.3 segment/LitStr#value..starts_withrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]starts_with().("b\"")
305 || string.valuerust-analyzer cargo pastey 0.2.3 segment/LitStr#value..starts_withrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]starts_with().("br\"")
306 {
307 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo pastey 0.2.3 error/Error#::newrust-analyzer cargo pastey 0.2.3 error/impl#[Error]new().(string.spanrust-analyzer cargo pastey 0.2.3 segment/LitStr#span., "unsupported literal"));
308 }
309 let mut range = 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#string.valuerust-analyzer cargo pastey 0.2.3 segment/LitStr#value..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]len().();
310 if string.valuerust-analyzer cargo pastey 0.2.3 segment/LitStr#value..starts_withrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]starts_with().("r\"") {
311 range.startrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#start. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().2;
312 range.endrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#end. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().-=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().1;
313 } else if string.valuerust-analyzer cargo pastey 0.2.3 segment/LitStr#value..starts_withrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]starts_with().(&['"', '\''][rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().) {
314 range.startrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#start. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1;
315 range.endrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#end. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().-=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().1;
316 }
317 string.valuerust-analyzer cargo pastey 0.2.3 segment/LitStr#value. = string.valuerust-analyzer cargo pastey 0.2.3 segment/LitStr#value.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Index<I>`]index().range]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Index<I>`]index()..replacerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]replace().('-', "_");
318 }
319 }
320
321 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(segments)
322 }
323
324 fn pasted_to_tokensrust-analyzer cargo pastey 0.2.3 pasted_to_tokens().(mut pasted: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, span: Spanrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro Span#) -> Resultrust-analyzer cargo pastey 0.2.3 error/Result#<TokenStreamrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenStream#> {
325 let mut raw_mode = false;
326 let mut tokens = TokenStreamrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenStream#::newrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro impl#[TokenStream]new().();
327
328 if pasted.starts_withrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]starts_with().(|ch: char| ch.is_ascii_digitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core char/methods/impl#[char]is_ascii_digit().()) {
329 let literal = match panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std panic/::catch_unwindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std panic/catch_unwind().(|| Literalrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro Literal#::from_strrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro impl#[Literal][FromStr]from_str().(&pasted)) {
330 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(literal)) => TokenTreerust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenTree#::Literalrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenTree#Literal#(literal),
331 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(LexErrorrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro LexError# { .. })) | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(_) => {
332 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo pastey 0.2.3 error/Error#::newrust-analyzer cargo pastey 0.2.3 error/impl#[Error]new().(
333 span,
334 &formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("`{:?}` is not a valid literal", pasted),
335 ));
336 }
337 };
338 tokens.extendrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro impl#[TokenStream][`Extend<TokenTree>`]extend().(iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/::oncerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/sources/once/once().(literal));
339 return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(tokens);
340 }
341
342 if pasted.starts_withrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]starts_with().('\'') {
343 let mut apostrophe = TokenTreerust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenTree#::Punctrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenTree#Punct#(Punctrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro Punct#::newrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro impl#[Punct]new().('\'', Spacingrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro Spacing#::Jointrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro Spacing#Joint#));
344 apostrophe.set_spanrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro impl#[TokenTree]set_span().(span);
345 tokens.extendrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro impl#[TokenStream][`Extend<TokenTree>`]extend().(iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/::oncerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/sources/once/once().(apostrophe));
346 pasted.removerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]remove().(0);
347 }
348
349 if pasted.starts_withrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]starts_with().("r#") {
350 raw_mode = true;
351 }
352
353 let ident = match panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std panic/::catch_unwindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std panic/catch_unwind().(|| {
354 if raw_mode {
355 let mut spasted = pasted.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Clone]clone().();
356 spasted.removerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]remove().(0);
357 spasted.removerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]remove().(0);
358 Identrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro Ident#::new_rawrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro impl#[Ident]new_raw().(&spasted, span)
359 } else {
360 Identrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro Ident#::newrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro impl#[Ident]new().(&pasted, span)
361 }
362 }) {
363 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(ident) => TokenTreerust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenTree#::Identrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenTree#Ident#(ident),
364 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(_) => {
365 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo pastey 0.2.3 error/Error#::newrust-analyzer cargo pastey 0.2.3 error/impl#[Error]new().(
366 span,
367 &formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("`{:?}` is not a valid identifier", pasted),
368 ));
369 }
370 };
371
372 tokens.extendrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro impl#[TokenStream][`Extend<TokenTree>`]extend().(iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/::oncerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/sources/once/once().(ident));
373 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(tokens)
374 }
375
376 // Below functions and macro is just for testing the internal functions that are not directly exposed
377 // and can not be tested through public paste macro because of pre-validation of most error cases in it,
378 // so we can not cover those error cases through it.
379 // Also some of the inputs for testing those functions can not be constructed directly in tests because of TokenStream,
380 // so we need to construct them using proc_macro functions and then call the functions we want to test.
381 #[cfg(coverage_nightly)]
382 #[coverage(off)]
383 #[proc_macro]
384 #[doc(hidden)]
385 pub fn paste_test(input: TokenStreamrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenStream#) -> TokenStreamrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenStream# {
386 let scope = Spanrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro Span#::call_site();
387 test_helpers::expand_attr_test(scope);
388 test_helpers::parse_bracket_as_segments_test(scope);
389
390 {
391 let mut multi_inner = TokenStreamrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenStream#::new();
392 multi_inner.extend([TokenTreerust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenTree#::Identrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenTree#Ident#(Identrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro Ident#::new("a", scope))]);
393 multi_inner.extend([TokenTreerust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenTree#::Identrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenTree#Ident#(Identrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro Ident#::new("b", scope))]);
394 let multi_none = TokenTreerust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenTree#::Grouprust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenTree#Group#(Grouprust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro Group#::new(Delimiterrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro Delimiter#::Nonerust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro Delimiter#None#, multi_inner));
395 let _ = segmentrust-analyzer cargo pastey 0.2.3 segment/::get_token_tree_string_valuerust-analyzer cargo pastey 0.2.3 segment/get_token_tree_string_value().(&multi_none);
396 }
397
398 {
399 let empty_none = TokenTreerust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenTree#::Grouprust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenTree#Group#(Grouprust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro Group#::new(Delimiterrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro Delimiter#::Nonerust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro Delimiter#None#, TokenStreamrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenStream#::new()));
400 let _ = segmentrust-analyzer cargo pastey 0.2.3 segment/::get_token_tree_string_valuerust-analyzer cargo pastey 0.2.3 segment/get_token_tree_string_value().(&empty_none);
401 }
402
403 // Emit compile_error! unconditionally into the output so any call site that
404 // reaches the compiler gets the intended error message directly.
405 let mut out = TokenStreamrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenStream#::from_str(
406 "compile_error!(\"paste_test! is for internal coverage testing only and must not be called outside of test context\");",
407 )
408 .unwrap();
409 out.extend(input);
410 out
411 }
412
413 #[cfg(doctest)]
414 #[doc(hidden)]
415 mod doc_tests {
416 /// ```compile_fail
417 /// use pastey::paste_test;
418 /// paste_test!("test");
419 /// ```
420 fn paste_test_macro_for_internal_coverage() {}
421
422 /// ```
423 /// use pastey::paste;
424 /// let arr: [u8; 3] = paste!([1u8, 2, 3]);
425 /// ```
426 fn test_non_paste_bracket_returns_input() {}
427
428 /// ```
429 /// use pastey::paste;
430 /// macro_rules! m {
431 /// ($id:ident) => { paste! { fn $id() {} } }
432 /// }
433 /// m!(doc_flatten_fn);
434 /// doc_flatten_fn();
435 /// ```
436 fn test_flatten_single_ident_group() {}
437
438 /// ```
439 /// use pastey::paste;
440 /// macro_rules! m {
441 /// ($life:lifetime) => {
442 /// paste! { struct DocRef<$life>(pub &$life ()); }
443 /// }
444 /// }
445 /// m!('a);
446 /// ```
447 fn test_flatten_lifetime_group() {}
448
449 /// ```
450 /// use pastey::paste;
451 /// macro_rules! m {
452 /// ($t:path) => { paste! { type DocPathAlias = $t; } }
453 /// }
454 /// m!(std::string::String);
455 /// let _: DocPathAlias = String::new();
456 /// ```
457 fn test_flatten_path_group() {}
458
459 /// ```
460 /// use pastey::paste;
461 /// macro_rules! m {
462 /// ($lit:literal) => { paste! { const DOC_LIT: u8 = $lit; } }
463 /// }
464 /// m!(99u8);
465 /// ```
466 fn test_flatten_literal_group() {}
467
468 /// ```
469 /// use pastey::paste;
470 /// paste! { let _: std::string::String = String::new(); }
471 /// ```
472 fn test_double_colon_none_group() {}
473
474 /// ```
475 /// use pastey::paste;
476 /// macro_rules! m {
477 /// ($t:ty) => {
478 /// paste! {
479 /// pub const NONE_GROUP_TY_STR: &str = stringify!($t::method);
480 /// }
481 /// }
482 /// }
483 /// m!(Vec<u8>);
484 /// ```
485 fn test_none_group_complex_type_before_double_colon() {}
486
487 /// ```
488 /// use pastey::paste;
489 /// paste! {
490 /// mod doc_inner_mod {
491 /// #![allow(dead_code)]
492 /// pub struct DocInner;
493 /// }
494 /// }
495 /// ```
496 fn test_inner_mod() {}
497
498 /// ```
499 /// use pastey::paste;
500 /// macro_rules! allow_lint {
501 /// ($lint:ident) => {
502 /// paste! {
503 /// #[allow(clippy::$lint)]
504 /// pub struct DocLintStruct;
505 /// }
506 /// }
507 /// }
508 /// allow_lint!(pedantic);
509 /// ```
510 fn test_double_colon_none_group_in_attr() {}
511
512 /// ```
513 /// use pastey::paste;
514 /// paste! { const _: &str = stringify!([<'\u{48}' ello>]); }
515 /// ```
516 fn test_char_unicode_escape_in_paste() {}
517
518 /// ```
519 /// use pastey::paste;
520 /// paste! { const _: &str = stringify!([<r"hel" lo>]); }
521 /// ```
522 fn test_raw_string_in_paste() {}
523
524 /// ```
525 /// use pastey::paste;
526 /// paste! { struct DocLifeRef<[<'a>]>(pub &[<'a>] ()); }
527 /// ```
528 fn test_lifetime_paste_tokens() {}
529
530 /// ```
531 /// use pastey::paste;
532 /// paste! { #[allow(non_camel_case_types)] struct [<# loop>]; }
533 /// ```
534 fn test_raw_mode_paste_tokens() {}
535
536 /// ```
537 /// use pastey::paste;
538 /// paste! { const _: &str = stringify!([<'\u{41}' bcde>]); }
539 /// ```
540 fn test_char_unicode_paste_tokens() {}
541
542 /// ```
543 /// use pastey::paste;
544 /// macro_rules! m {
545 /// ($t:ty) => {
546 /// paste! { let _: $t = std::string::String::new(); }
547 /// }
548 /// }
549 /// m!(String);
550 /// ```
551 fn test_none_group_not_followed_by_double_colon() {}
552
553 /// ```compile_fail
554 /// use pastey::paste;
555 /// paste! { const _: u32 = [<99 invalid>]; }
556 /// ```
557 fn test_error_invalid_literal_with_trailing_tokens() {}
558
559 /// ```compile_fail
560 /// use pastey::paste;
561 /// paste! { const _: &str = [<@invalid>]; }
562 /// ```
563 fn test_error_invalid_identifier_special_char() {}
564
565 /// ```compile_fail
566 /// use pastey::paste;
567 /// paste! { const _: &str = [identifier]; }
568 /// ```
569 fn test_error_expected_bracket_with_angle() {}
570
571 /// ```compile_fail
572 /// use pastey::paste;
573 /// paste! { const _: &str = [<identifier]; }
574 /// ```
575 fn test_error_expected_closing_angle() {}
576
577 /// ```compile_fail
578 /// use pastey::paste;
579 /// paste! { const _: &str = [<identifier> extra]; }
580 /// ```
581 fn test_error_unexpected_token_after_closing_angle() {}
582
583 /// ```compile_fail
584 /// use pastey::paste;
585 /// paste! { const _: &str = [<"byte\\string">]; }
586 /// ```
587 fn test_error_unsupported_escaped_string() {}
588
589 /// ```compile_fail
590 /// use pastey::paste;
591 /// paste! { const _: &str = [<b"byte_string">]; }
592 /// ```
593 fn test_error_unsupported_byte_string() {}
594
595 /// ```compile_fail
596 /// use pastey::paste;
597 /// paste! { fn [<x b'y'>]() {} }
598 /// ```
599 fn test_error_unsupported_byte_char_literal() {}
600
601 /// ```compile_fail
602 /// use pastey::paste;
603 /// paste! { const _: &str = [<br"raw_byte">]; }
604 /// ```
605 fn test_error_unsupported_raw_byte_string() {}
606
607 /// ```compile_fail
608 /// use pastey::paste;
609 /// paste! { const _: &str = [<"string.with.dots">]; }
610 /// ```
611 fn test_error_unsupported_string_with_dots() {}
612
613 /// ```compile_fail
614 /// use pastey::paste;
615 /// paste! { const _: &str = [<"string+plus">]; }
616 /// ```
617 fn test_error_unsupported_string_with_plus() {}
618
619 /// ```compile_fail
620 /// use pastey::paste;
621 /// paste! { const _: &str = [<>]; }
622 /// ```
623 fn test_error_expected_content_in_brackets() {}
624
625 /// ```compile_fail
626 /// use pastey::paste;
627 /// paste! { const _: &str = [<a..b>]; }
628 /// ```
629 fn test_error_invalid_numeric_literal() {}
630
631 /// ```compile_fail
632 /// use pastey::paste;
633 /// paste! { const _: &str = [< >]; }
634 /// ```
635 fn test_error_no_tokens_in_paste() {}
636
637 /// ```compile_fail
638 /// use pastey::paste;
639 /// paste! { const _: &str = [<'static>]; }
640 /// ```
641 fn test_error_lifetime_without_identifier() {}
642
643 /// ```compile_fail
644 /// use pastey::paste;
645 /// macro_rules! m {
646 /// ($x:ident) => {
647 /// paste! { const _: u32 = [<$x>]; }
648 /// }
649 /// }
650 /// m!(123);
651 /// ```
652 fn test_error_invalid_ident_starting_with_number() {}
653
654 /// ```compile_fail
655 /// use pastey::paste;
656 /// paste! { const _: &str = [<"terminated>]; }
657 /// ```
658 fn test_error_terminated_string_literal() {}
659
660 /// ```compile_fail
661 /// use pastey::paste;
662 /// paste! { let x = [<y z>]; }
663 /// ```
664 fn test_error_multiple_tokens_non_paste() {}
665
666 /// ```compile_fail
667 /// use pastey::paste;
668 /// paste! { let x: i32 = [<not_a_number>]; }
669 /// ```
670 fn test_error_paste_result_type_mismatch() {}
671
672 /// ```compile_fail
673 /// use pastey::paste;
674 /// paste! { const _: &str = [<'a 'b>]; }
675 /// ```
676 fn test_error_multiple_lifetimes() {}
677
678 /// ```compile_fail
679 /// use pastey::paste;
680 /// paste! { const _: &str = [<42 56>]; }
681 /// ```
682 fn test_error_multiple_numeric_tokens() {}
683
684 /// ```compile_fail
685 /// use pastey::paste;
686 /// macro_rules! concat_idents {
687 /// ($a:ident, $b:ident) => { paste! { const TEST: u32 = [<method_ $a>](); } }
688 /// }
689 /// concat_idents!(test, func);
690 /// ```
691 fn test_error_method_call_on_paste_result() {}
692
693 /// ```compile_fail
694 /// use pastey::paste;
695 /// paste! { const _ : &str = [<r# if>]; }
696 /// ```
697 fn test_error_raw_keyword_identifier() {}
698
699 /// ```compile_fail
700 /// use pastey::paste;
701 /// macro_rules! m {
702 /// () => { paste! { const _: u32 = [<>]; } }
703 /// }
704 /// m!();
705 /// ```
706 fn test_error_empty_macro_result() {}
707
708 /// ```compile_fail
709 /// use pastey::paste;
710 /// paste! { const _: &str = [<-identifier>]; }
711 /// ```
712 fn test_error_hyphen_at_start() {}
713
714 /// ```compile_fail
715 /// use pastey::paste;
716 /// paste! { const _: &str = [<'123>]; }
717 /// ```
718 fn test_error_apostrophe_with_number() {}
719
720 /// ```compile_fail
721 /// use pastey::paste;
722 /// macro_rules! m {
723 /// ($lit:literal) => {
724 /// paste! { const _: &str = stringify!([<$lit>]); }
725 /// }
726 /// }
727 /// m!("both" "strings");
728 /// ```
729 fn test_error_invalid_literal_argument() {}
730
731 /// ```compile_fail
732 /// use pastey::paste;
733 /// paste! { const _: &str = [<'\u{D800}>]; }
734 /// ```
735 fn test_error_invalid_unicode_escape() {}
736
737 /// ```compile_fail
738 /// use pastey::paste;
739 /// paste! { const _: u32 = [<0x>]; }
740 /// ```
741 fn test_error_incomplete_hex_literal() {}
742
743 /// ```compile_fail
744 /// use pastey::paste;
745 /// paste! { const _: u32 = [<0b>]; }
746 /// ```
747 fn test_error_incomplete_binary_literal() {}
748
749 /// ```compile_fail
750 /// use pastey::paste;
751 /// paste! { const _: f64 = [<1..5>]; }
752 /// ```
753 fn test_error_range_literal_invalid() {}
754
755 /// ```compile_fail
756 /// use pastey::paste;
757 /// paste! { const _: &str = [<if>]; }
758 /// ```
759 fn test_error_keyword_as_identifier() {}
760
761 /// ```compile_fail
762 /// use pastey::paste;
763 /// paste! { const _: &str = [<fn>]; }
764 /// ```
765 fn test_error_fn_keyword() {}
766
767 /// ```compile_fail
768 /// use pastey::paste;
769 /// paste! { const _: &str = [<match>]; }
770 /// ```
771 fn test_error_match_keyword() {}
772
773 /// ```compile_fail
774 /// use pastey::paste;
775 /// paste! { const _: &str = [<{inner}>]; }
776 /// ```
777 fn test_error_brace_group_in_paste() {}
778
779 /// ```compile_fail
780 /// use pastey::paste;
781 /// paste! { const _: &str = [<(parts)>]; }
782 /// ```
783 fn test_error_paren_group_in_paste() {}
784
785 /// ```compile_fail
786 /// use pastey::paste;
787 /// macro_rules! test {
788 /// () => { paste! { const _: &str = [<&&invalid>]; } }
789 /// }
790 /// test!();
791 /// ```
792 fn test_error_double_ampersand() {}
793
794 /// ```compile_fail
795 /// use pastey::paste;
796 /// macro_rules! test {
797 /// () => { paste! { const _: &str = [<||invalid>]; } }
798 /// }
799 /// test!();
800 /// ```
801 fn test_error_double_pipe() {}
802
803 /// ```compile_fail
804 /// use pastey::paste;
805 /// paste! { const _: &str = [<@#$>]; }
806 /// ```
807 fn test_error_random_special_chars() {}
808
809 /// ```compile_fail
810 /// use pastey::paste;
811 /// paste! { let value: i32 = [<test>]; }
812 /// ```
813 fn test_error_undefined_identifier_value() {}
814
815 /// ```compile_fail
816 /// use pastey::paste;
817 /// paste! { fn doc_err_in_brace() { let _ = [<@>]; } }
818 /// ```
819 fn test_error_invalid_paste_inside_brace_group() {}
820
821 /// ```compile_fail
822 /// use pastey::paste;
823 /// paste! { const _: u32 = [<0 x>]; }
824 /// ```
825 fn test_error_pasted_incomplete_hex_literal() {}
826
827 /// ```compile_fail
828 /// use pastey::paste;
829 /// paste! { #[cfg(test) trailing_token] fn f() {} }
830 /// ```
831 fn test_error_attr_trailing_tokens_after_paren_group() {}
832
833 /// ```compile_fail
834 /// use pastey::paste;
835 /// paste! { struct [<Foo::+Bar>]; }
836 /// ```
837 fn test_error_invalid_colon_sequence() {}
838
839 /// ```compile_fail
840 /// use pastey::paste;
841 /// paste! { fn [<Bar:::Test>]() {} }
842 /// ```
843 fn test_error_invalid_colon_patterns() {}
844
845 /// ```compile_fail
846 /// use pastey::paste;
847 /// paste! { fn [*invalid>]() {} }
848 /// ```
849 fn test_error_bracket_first_token_not_less_than() {}
850
851 /// ```compile_fail
852 /// use pastey::paste;
853 /// paste! { fn [<test]() {} }
854 /// ```
855 fn test_error_bracket_closing_token_not_greater_than() {}
856
857 /// ```compile_fail
858 /// use pastey::paste;
859 /// paste! { fn [<test>extra]() {} }
860 /// ```
861 fn test_error_extra_tokens_after_bracket() {}
862
863 /// ```compile_fail
864 /// use pastey::paste;
865 /// paste! { fn [<test:replace('\u{XY}', 'A')>]() {} }
866 /// ```
867 fn test_error_invalid_hex_unicode() {}
868
869 /// ```
870 /// use pastey::paste;
871 /// macro_rules! test_replace {
872 /// ($a:expr, $b:expr) => {
873 /// paste! { concat!(stringify!($a), stringify!($b)) }
874 /// }
875 /// }
876 /// let result = test_replace!(x, "y");
877 /// ```
878 fn test_macro_group_flattening() {}
879
880 /// ```
881 /// use pastey::paste;
882 /// paste! { fn [<foo_bar>]() {} }
883 /// foo_bar();
884 /// ```
885 fn test_valid_paste_operation() {}
886
887 /// ```
888 /// use pastey::paste;
889 /// paste! { use std::[<vec>]; }
890 /// let v = Vec::<i32>::new();
891 /// assert_eq!(v.len(), 0);
892 /// ```
893 fn test_valid_path_with_double_colon() {}
894
895 /// ```
896 /// use pastey::paste;
897 /// macro_rules! concat_name {
898 /// ($name:ident) => {
899 /// paste! { const [<$name:lower>]: &str = stringify!($name); }
900 /// }
901 /// }
902 /// concat_name!(TEST);
903 /// ```
904 fn test_valid_modifiers() {}
905
906 /// ```
907 /// use pastey::paste;
908 /// macro_rules! test_ident_colon {
909 /// ($param:ident: $ty:ident) => {
910 /// paste! { fn [<test_$param>]($param: $ty) {} }
911 /// }
912 /// }
913 /// test_ident_colon!(x: i32);
914 /// test_x(42i32);
915 /// ```
916 fn test_type_annotation() {}
917 }