Lines Matching +full:broken +full:- +full:turn +full:- +full:around

1 // SPDX-License-Identifier: Apache-2.0 OR MIT
3 …ub]](https://github.com/dtolnay/proc-macro2) [![crates-io]](https://crates.io/crates/proc-mac…
5 //! [github]: https://img.shields.io/badge/github-8da0cb?style=for-the-badge&labelColor=555555&logo…
6 //! [crates-io]: https://img.shields.io/badge/crates.io-fc8d62?style=for-the-badge&labelColor=55555…
7 //! [docs-rs]: https://img.shields.io/badge/docs.rs-66c2a5?style=for-the-badge&labelColor=555555&lo…
11 //! A wrapper around the procedural macro API of the compiler's [`proc_macro`]
14 //! - **Bring proc-macro-like functionality to other contexts like build.rs and
17 //! Meanwhile `proc_macro2` types may exist anywhere including non-macro code.
21 //! reimplementing non-macro equivalents of those libraries.
23 //! - **Make procedural macros unit testable.** As a consequence of being
43 //! pub fn my_derive(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
62 //! The default feature set of proc-macro2 tracks the most recent stable
64 //! exposed by proc-macro2 by default.
68 //! rustc. We will polyfill those nightly-only APIs back to Rust 1.56.0. As
70 //! proc-macro2 may make breaking changes to them at any time.
73 //! RUSTFLAGS='--cfg procmacro2_semver_exempt' cargo build
80 //! Semver exempt methods are marked as such in the proc-macro2 documentation.
82 //! # Thread-Safety
85 //! types make use of thread-local memory, meaning they cannot be accessed from
88 // Proc-macro2 types in rustdoc of other crates get linked to here.
89 #![doc(html_root_url = "https://docs.rs/proc-macro2/1.0.101")]
124 Something is not right. If you've tried to turn on \
126 is turned on for the compilation of the proc-macro2 \
132 feature = "proc-macro",
141 #[cfg(feature = "proc-macro")]
183 #[cfg_attr(docsrs, doc(cfg(feature = "span-locations")))]
206 fn _new(inner: imp::TokenStream) -> Self { in _new()
213 fn _new_fallback(inner: fallback::TokenStream) -> Self { in _new_fallback()
221 pub fn new() -> Self { in new()
226 pub fn is_empty(&self) -> bool { in is_empty()
234 fn default() -> Self { in default()
250 fn from_str(src: &str) -> Result<TokenStream, LexError> { in from_str()
261 #[cfg(feature = "proc-macro")]
262 #[cfg_attr(docsrs, doc(cfg(feature = "proc-macro")))]
264 fn from(inner: proc_macro::TokenStream) -> Self { in from()
269 #[cfg(feature = "proc-macro")]
270 #[cfg_attr(docsrs, doc(cfg(feature = "proc-macro")))]
272 fn from(inner: TokenStream) -> Self { in from()
278 fn from(token: TokenTree) -> Self { in from()
298 fn from_iter<I: IntoIterator<Item = TokenTree>>(streams: I) -> Self { in from_iter()
303 fn from_iter<I: IntoIterator<Item = TokenStream>>(streams: I) -> Self { in from_iter()
313 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { in fmt()
320 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { in fmt()
326 pub fn span(&self) -> Span { in span()
332 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { in fmt()
338 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { in fmt()
353 fn _new(inner: imp::Span) -> Self { in _new()
360 fn _new_fallback(inner: fallback::Span) -> Self { in _new_fallback()
370 /// written directly at the macro call location (call-site hygiene) and
372 pub fn call_site() -> Self { in call_site()
379 pub fn mixed_site() -> Self { in mixed_site()
388 pub fn def_site() -> Self { in def_site()
394 pub fn resolved_at(&self, other: Span) -> Span { in resolved_at()
400 pub fn located_at(&self, other: Span) -> Span { in located_at()
415 pub fn unwrap(self) -> proc_macro::Span { in unwrap()
422 pub fn unstable(self) -> proc_macro::Span { in unstable()
428 /// This method requires the `"span-locations"` feature to be enabled.
436 #[cfg_attr(docsrs, doc(cfg(feature = "span-locations")))]
437 pub fn byte_range(&self) -> Range<usize> { in byte_range()
443 /// This method requires the `"span-locations"` feature to be enabled.
451 #[cfg_attr(docsrs, doc(cfg(feature = "span-locations")))]
452 pub fn start(&self) -> LineColumn { in start()
458 /// This method requires the `"span-locations"` feature to be enabled.
466 #[cfg_attr(docsrs, doc(cfg(feature = "span-locations")))]
467 pub fn end(&self) -> LineColumn { in end()
477 #[cfg_attr(docsrs, doc(cfg(feature = "span-locations")))]
478 pub fn file(&self) -> String { in file()
489 #[cfg_attr(docsrs, doc(cfg(feature = "span-locations")))]
490 pub fn local_file(&self) -> Option<PathBuf> { in local_file()
499 /// nightly-only. When called from within a procedural macro not using a
501 pub fn join(&self, other: Span) -> Option<Span> { in join()
510 pub fn eq(&self, other: &Span) -> bool { in eq()
521 pub fn source_text(&self) -> Option<String> { in source_text()
528 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { in fmt()
549 pub fn span(&self) -> Span { in span()
574 fn from(g: Group) -> Self { in from()
580 fn from(g: Ident) -> Self { in from()
586 fn from(g: Punct) -> Self { in from()
592 fn from(g: Literal) -> Self { in from()
602 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { in fmt()
614 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { in fmt()
651 /// An invisible delimiter, that may, for example, appear around tokens
660 /// of a proc_macro. Only `None`-delimited groups created by a macro_rules macro in the input
662 /// Any `None`-delimited groups (re)created by a proc_macro will therefore not preserve
665 /// [rust-lang/rust#67062](https://github.com/rust-lang/rust/issues/67062).
672 fn _new(inner: imp::Group) -> Self { in _new()
676 fn _new_fallback(inner: fallback::Group) -> Self { in _new_fallback()
687 pub fn new(delimiter: Delimiter, stream: TokenStream) -> Self { in new()
695 pub fn delimiter(&self) -> Delimiter { in delimiter()
703 pub fn stream(&self) -> TokenStream { in stream()
711 /// pub fn span(&self) -> Span {
714 pub fn span(&self) -> Span { in span()
721 /// pub fn span_open(&self) -> Span {
724 pub fn span_open(&self) -> Span { in span_open()
731 /// pub fn span_close(&self) -> Span {
734 pub fn span_close(&self) -> Span { in span_close()
741 pub fn delim_span(&self) -> DelimSpan { in delim_span()
760 fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { in fmt()
766 fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { in fmt()
771 /// A `Punct` is a single punctuation character like `+`, `-` or `#`.
803 pub fn new(ch: char, spacing: Spacing) -> Self { in new()
804 if let '!' | '#' | '$' | '%' | '&' | '\'' | '*' | '+' | ',' | '-' | '.' | '/' | ':' | ';' in new()
818 pub fn as_char(&self) -> char { in as_char()
827 pub fn spacing(&self) -> Spacing { in spacing()
832 pub fn span(&self) -> Span { in span()
845 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { in fmt()
851 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { in fmt()
866 /// - The empty string is not an identifier. Use `Option<Ident>`.
867 /// - A lifetime is not an identifier. Use `syn::Lifetime` instead.
931 fn _new(inner: imp::Ident) -> Self { in _new()
938 fn _new_fallback(inner: fallback::Ident) -> Self { in _new_fallback()
954 /// As of this time `Span::call_site()` explicitly opts-in to "call-site"
959 /// Later spans like `Span::def_site()` will allow to opt-in to
960 /// "definition-site" hygiene meaning that identifiers created with this
973 /// style="padding-right:0;">syn::parse_str</code></a><code
974 /// style="padding-left:0;">::&lt;Ident&gt;</code>
977 pub fn new(string: &str, span: Span) -> Self { in new()
987 pub fn new_raw(string: &str, span: Span) -> Self { in new_raw()
992 pub fn span(&self) -> Span { in span()
1004 fn eq(&self, other: &Ident) -> bool { in eq()
1013 fn eq(&self, other: &T) -> bool { in eq()
1021 fn partial_cmp(&self, other: &Ident) -> Option<Ordering> { in partial_cmp()
1027 fn cmp(&self, other: &Ident) -> Ordering { in cmp()
1041 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { in fmt()
1047 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { in fmt()
1072 /// broken into two tokens (`-` and positive literal).
1077 pub fn $name(n: $kind) -> Literal {
1093 /// be broken into two tokens (`-` and positive literal).
1098 pub fn $name(n: $kind) -> Literal {
1105 fn _new(inner: imp::Literal) -> Self { in _new()
1112 fn _new_fallback(inner: fallback::Literal) -> Self { in _new_fallback()
1149 /// Creates a new unsuffixed floating-point literal.
1154 /// Literals created from negative numbers may not survive round-trips
1155 /// through `TokenStream` or strings and may be broken into two tokens (`-`
1162 pub fn f64_unsuffixed(f: f64) -> Literal { in f64_unsuffixed()
1167 /// Creates a new suffixed floating-point literal.
1173 /// round-trips through `TokenStream` or strings and may be broken into two
1174 /// tokens (`-` and positive literal).
1180 pub fn f64_suffixed(f: f64) -> Literal { in f64_suffixed()
1185 /// Creates a new unsuffixed floating-point literal.
1190 /// Literals created from negative numbers may not survive round-trips
1191 /// through `TokenStream` or strings and may be broken into two tokens (`-`
1198 pub fn f32_unsuffixed(f: f32) -> Literal { in f32_unsuffixed()
1203 /// Creates a new suffixed floating-point literal.
1209 /// round-trips through `TokenStream` or strings and may be broken into two
1210 /// tokens (`-` and positive literal).
1216 pub fn f32_suffixed(f: f32) -> Literal { in f32_suffixed()
1222 pub fn string(string: &str) -> Literal { in string()
1227 pub fn character(ch: char) -> Literal { in character()
1232 pub fn byte_character(byte: u8) -> Literal { in byte_character()
1237 pub fn byte_string(bytes: &[u8]) -> Literal { in byte_string()
1242 pub fn c_string(string: &CStr) -> Literal { in c_string()
1247 pub fn span(&self) -> Span { in span()
1257 /// the source bytes in range `range`. Returns `None` if the would-be
1261 /// nightly-only. When called from within a procedural macro not using a
1263 pub fn subspan<R: RangeBounds<usize>>(&self, range: R) -> Option<Span> { in subspan()
1267 // Intended for the `quote!` macro to use when constructing a proc-macro2
1272 pub unsafe fn from_str_unchecked(repr: &str) -> Self { in from_str_unchecked()
1280 fn from_str(repr: &str) -> Result<Self, LexError> { in from_str()
1292 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { in fmt()
1298 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { in fmt()
1324 fn next(&mut self) -> Option<TokenTree> { in next()
1328 fn size_hint(&self) -> (usize, Option<usize>) { in size_hint()
1334 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { in fmt()
1344 fn into_iter(self) -> IntoIter { in into_iter()