From a8f5053a432071ef92731b9946bec07f12099ec8 Mon Sep 17 00:00:00 2001 From: Chih-Hung Hsieh Date: Fri, 20 Mar 2020 12:42:34 -0700 Subject: Update to latest quote-1.0.3 * fill back missing NOTICE,METADATA,*LICENSE* files Bug: 150877376 Test: make Test: atest --host -c --include-subdirs external/rust/crates Change-Id: I7c9c7d922a0fef4939ffda8bf36eff0402086cc3 --- .cargo_vcs_info.json | 2 +- Android.bp | 4 ++ Cargo.toml | 10 ++-- Cargo.toml.orig | 9 ++-- LICENSE | 1 + METADATA | 18 +++++++ MODULE_LICENSE_APACHE2 | 0 NOTICE | 1 + src/format.rs | 8 +-- src/ident_fragment.rs | 4 +- src/lib.rs | 138 ++++++++++++++++++++++++++----------------------- src/runtime.rs | 39 +++++--------- tests/test.rs | 8 ++- 13 files changed, 131 insertions(+), 111 deletions(-) create mode 120000 LICENSE create mode 100644 METADATA create mode 100644 MODULE_LICENSE_APACHE2 create mode 120000 NOTICE diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json index c5b6105..5388292 100644 --- a/.cargo_vcs_info.json +++ b/.cargo_vcs_info.json @@ -1,5 +1,5 @@ { "git": { - "sha1": "727436c6c137b20f0f34dde5d8fda2679b9747ad" + "sha1": "e0300930fa4a8b448c4ff39f499dd4d2fcb0f17d" } } diff --git a/Android.bp b/Android.bp index 2a3cb09..2fbcffe 100644 --- a/Android.bp +++ b/Android.bp @@ -13,3 +13,7 @@ rust_library_host_rlib { "libproc_macro2", ], } + +// dependent_library ["feature_list"] +// proc-macro2-1.0.9 "default,proc-macro" +// unicode-xid-0.2.0 "default" diff --git a/Cargo.toml b/Cargo.toml index a7a956d..fa5dc59 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ [package] edition = "2018" name = "quote" -version = "1.0.2" +version = "1.0.3" authors = ["David Tolnay "] include = ["Cargo.toml", "src/**/*.rs", "tests/**/*.rs", "README.md", "LICENSE-APACHE", "LICENSE-MIT"] description = "Quasi-quoting macro quote!(...)" @@ -23,17 +23,15 @@ keywords = ["syn"] categories = ["development-tools::procedural-macro-helpers"] license = "MIT OR Apache-2.0" repository = "https://github.com/dtolnay/quote" - -[lib] -name = "quote" [dependencies.proc-macro2] version = "1.0" default-features = false [dev-dependencies.rustversion] -version = "0.1" +version = "1.0" [dev-dependencies.trybuild] -version = "1.0" +version = "1.0.19" +features = ["diff"] [features] default = ["proc-macro"] diff --git a/Cargo.toml.orig b/Cargo.toml.orig index c052022..ae3963f 100644 --- a/Cargo.toml.orig +++ b/Cargo.toml.orig @@ -1,6 +1,6 @@ [package] name = "quote" -version = "1.0.2" # don't forget to update html_root_url, version in readme for breaking changes +version = "1.0.3" # don't forget to update html_root_url, version in readme for breaking changes authors = ["David Tolnay "] license = "MIT OR Apache-2.0" description = "Quasi-quoting macro quote!(...)" @@ -12,15 +12,12 @@ readme = "README.md" include = ["Cargo.toml", "src/**/*.rs", "tests/**/*.rs", "README.md", "LICENSE-APACHE", "LICENSE-MIT"] edition = "2018" -[lib] -name = "quote" - [dependencies] proc-macro2 = { version = "1.0", default-features = false } [dev-dependencies] -rustversion = "0.1" -trybuild = "1.0" +rustversion = "1.0" +trybuild = { version = "1.0.19", features = ["diff"] } [features] default = ["proc-macro"] diff --git a/LICENSE b/LICENSE new file mode 120000 index 0000000..6b579aa --- /dev/null +++ b/LICENSE @@ -0,0 +1 @@ +LICENSE-APACHE \ No newline at end of file diff --git a/METADATA b/METADATA new file mode 100644 index 0000000..3684f12 --- /dev/null +++ b/METADATA @@ -0,0 +1,18 @@ +name: "quote" +description: "This crate provides the quote! macro for turning Rust syntax tree data structures into tokens of source code." +third_party { + url { + type: HOMEPAGE + value: "https://crates.io/crates/quote" + } + url { + type: GIT + value: "https://github.com/dtolnay/quote" + } + version: "1.0.3" + last_upgrade_date { + year: 2020 + month: 3 + day: 20 + } +} diff --git a/MODULE_LICENSE_APACHE2 b/MODULE_LICENSE_APACHE2 new file mode 100644 index 0000000..e69de29 diff --git a/NOTICE b/NOTICE new file mode 120000 index 0000000..7a694c9 --- /dev/null +++ b/NOTICE @@ -0,0 +1 @@ +LICENSE \ No newline at end of file diff --git a/src/format.rs b/src/format.rs index 13c8811..745cb5d 100644 --- a/src/format.rs +++ b/src/format.rs @@ -128,7 +128,7 @@ macro_rules! format_ident { macro_rules! format_ident_impl { // Final state ([$span:expr, $($fmt:tt)*]) => { - $crate::__rt::mk_ident(&format!($($fmt)*), $span) + $crate::__private::mk_ident(&format!($($fmt)*), $span) }; // Span argument @@ -137,7 +137,7 @@ macro_rules! format_ident_impl { }; ([$old:expr, $($fmt:tt)*] span = $span:expr, $($rest:tt)*) => { $crate::format_ident_impl!([ - ::std::option::Option::Some::<$crate::__rt::Span>($span), + ::std::option::Option::Some::<$crate::__private::Span>($span), $($fmt)* ] $($rest)*) }; @@ -147,7 +147,7 @@ macro_rules! format_ident_impl { $crate::format_ident_impl!([$span, $($fmt)*] $name = $arg,) }; ([$span:expr, $($fmt:tt)*] $name:ident = $arg:expr, $($rest:tt)*) => { - match $crate::__rt::IdentFragmentAdapter(&$arg) { + match $crate::__private::IdentFragmentAdapter(&$arg) { arg => $crate::format_ident_impl!([$span.or(arg.span()), $($fmt)*, $name = arg] $($rest)*), } }; @@ -157,7 +157,7 @@ macro_rules! format_ident_impl { $crate::format_ident_impl!([$span, $($fmt)*] $arg,) }; ([$span:expr, $($fmt:tt)*] $arg:expr, $($rest:tt)*) => { - match $crate::__rt::IdentFragmentAdapter(&$arg) { + match $crate::__private::IdentFragmentAdapter(&$arg) { arg => $crate::format_ident_impl!([$span.or(arg.span()), $($fmt)*, arg] $($rest)*), } }; diff --git a/src/ident_fragment.rs b/src/ident_fragment.rs index 09ead65..7e5d376 100644 --- a/src/ident_fragment.rs +++ b/src/ident_fragment.rs @@ -19,7 +19,7 @@ pub trait IdentFragment { } } -impl<'a, T: IdentFragment + ?Sized> IdentFragment for &'a T { +impl IdentFragment for &T { fn span(&self) -> Option { ::span(*self) } @@ -29,7 +29,7 @@ impl<'a, T: IdentFragment + ?Sized> IdentFragment for &'a T { } } -impl<'a, T: IdentFragment + ?Sized> IdentFragment for &'a mut T { +impl IdentFragment for &mut T { fn span(&self) -> Option { ::span(*self) } diff --git a/src/lib.rs b/src/lib.rs index 3341a16..ad12230 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -72,8 +72,10 @@ //! }; //! ``` +#![forbid(unsafe_code)] + // Quote types in rustdoc of other crates get linked to here. -#![doc(html_root_url = "https://docs.rs/quote/1.0.2")] +#![doc(html_root_url = "https://docs.rs/quote/1.0.3")] #[cfg(all( not(all(target_arch = "wasm32", target_os = "unknown")), @@ -89,7 +91,7 @@ mod to_tokens; // Not public API. #[doc(hidden)] #[path = "runtime.rs"] -pub mod __rt; +pub mod __private; pub use crate::ext::TokenStreamExt; pub use crate::ident_fragment::IdentFragment; @@ -463,7 +465,7 @@ pub mod spanned; #[macro_export] macro_rules! quote { ($($tt:tt)*) => { - $crate::quote_spanned!($crate::__rt::Span::call_site()=> $($tt)*) + $crate::quote_spanned!($crate::__private::Span::call_site()=> $($tt)*) }; } @@ -566,8 +568,8 @@ macro_rules! quote { #[macro_export] macro_rules! quote_spanned { ($span:expr=> $($tt:tt)*) => {{ - let mut _s = $crate::__rt::TokenStream::new(); - let _span: $crate::__rt::Span = $span; + let mut _s = $crate::__private::TokenStream::new(); + let _span: $crate::__private::Span = $span; $crate::quote_each_token!(_s _span $($tt)*); _s }}; @@ -638,7 +640,7 @@ macro_rules! quote_bind_into_iter { macro_rules! quote_bind_next_or_break { ($var:ident) => { let $var = match $var.next() { - Some(_x) => $crate::__rt::RepInterp(_x), + Some(_x) => $crate::__private::RepInterp(_x), None => break, }; }; @@ -680,10 +682,10 @@ macro_rules! quote_token_with_context { ($tokens:ident $span:ident $b3:tt $b2:tt $b1:tt @ $a1:tt $a2:tt $a3:tt) => {}; ($tokens:ident $span:ident $b3:tt $b2:tt $b1:tt (#) ( $($inner:tt)* ) * $a3:tt) => {{ - use $crate::__rt::ext::*; - let has_iter = $crate::__rt::ThereIsNoIteratorInRepetition; + use $crate::__private::ext::*; + let has_iter = $crate::__private::ThereIsNoIteratorInRepetition; $crate::pounded_var_names!(quote_bind_into_iter!(has_iter) () $($inner)*); - let _: $crate::__rt::HasIterator = has_iter; + let _: $crate::__private::HasIterator = has_iter; // This is `while true` instead of `loop` because if there are no // iterators used inside of this repetition then the body would not // contain any `break`, so the compiler would emit unreachable code @@ -699,11 +701,11 @@ macro_rules! quote_token_with_context { ($tokens:ident $span:ident $b3:tt # ( $($inner:tt)* ) (*) $a1:tt $a2:tt $a3:tt) => {}; ($tokens:ident $span:ident $b3:tt $b2:tt $b1:tt (#) ( $($inner:tt)* ) $sep:tt *) => {{ - use $crate::__rt::ext::*; + use $crate::__private::ext::*; let mut _i = 0usize; - let has_iter = $crate::__rt::ThereIsNoIteratorInRepetition; + let has_iter = $crate::__private::ThereIsNoIteratorInRepetition; $crate::pounded_var_names!(quote_bind_into_iter!(has_iter) () $($inner)*); - let _: $crate::__rt::HasIterator = has_iter; + let _: $crate::__private::HasIterator = has_iter; while true { $crate::pounded_var_names!(quote_bind_next_or_break!() () $($inner)*); if _i > 0 { @@ -735,214 +737,218 @@ macro_rules! quote_token_with_context { macro_rules! quote_token { ($tokens:ident $span:ident ( $($inner:tt)* )) => { $tokens.extend({ - let mut g = $crate::__rt::Group::new( - $crate::__rt::Delimiter::Parenthesis, + let mut g = $crate::__private::Group::new( + $crate::__private::Delimiter::Parenthesis, $crate::quote_spanned!($span=> $($inner)*), ); g.set_span($span); - Some($crate::__rt::TokenTree::from(g)) + Some($crate::__private::TokenTree::from(g)) }); }; ($tokens:ident $span:ident [ $($inner:tt)* ]) => { $tokens.extend({ - let mut g = $crate::__rt::Group::new( - $crate::__rt::Delimiter::Bracket, + let mut g = $crate::__private::Group::new( + $crate::__private::Delimiter::Bracket, $crate::quote_spanned!($span=> $($inner)*), ); g.set_span($span); - Some($crate::__rt::TokenTree::from(g)) + Some($crate::__private::TokenTree::from(g)) }); }; ($tokens:ident $span:ident { $($inner:tt)* }) => { $tokens.extend({ - let mut g = $crate::__rt::Group::new( - $crate::__rt::Delimiter::Brace, + let mut g = $crate::__private::Group::new( + $crate::__private::Delimiter::Brace, $crate::quote_spanned!($span=> $($inner)*), ); g.set_span($span); - Some($crate::__rt::TokenTree::from(g)) + Some($crate::__private::TokenTree::from(g)) }); }; ($tokens:ident $span:ident +) => { - $crate::__rt::push_add(&mut $tokens, $span); + $crate::__private::push_add(&mut $tokens, $span); }; ($tokens:ident $span:ident +=) => { - $crate::__rt::push_add_eq(&mut $tokens, $span); + $crate::__private::push_add_eq(&mut $tokens, $span); }; ($tokens:ident $span:ident &) => { - $crate::__rt::push_and(&mut $tokens, $span); + $crate::__private::push_and(&mut $tokens, $span); }; ($tokens:ident $span:ident &&) => { - $crate::__rt::push_and_and(&mut $tokens, $span); + $crate::__private::push_and_and(&mut $tokens, $span); }; ($tokens:ident $span:ident &=) => { - $crate::__rt::push_and_eq(&mut $tokens, $span); + $crate::__private::push_and_eq(&mut $tokens, $span); }; ($tokens:ident $span:ident @) => { - $crate::__rt::push_at(&mut $tokens, $span); + $crate::__private::push_at(&mut $tokens, $span); }; ($tokens:ident $span:ident !) => { - $crate::__rt::push_bang(&mut $tokens, $span); + $crate::__private::push_bang(&mut $tokens, $span); }; ($tokens:ident $span:ident ^) => { - $crate::__rt::push_caret(&mut $tokens, $span); + $crate::__private::push_caret(&mut $tokens, $span); }; ($tokens:ident $span:ident ^=) => { - $crate::__rt::push_caret_eq(&mut $tokens, $span); + $crate::__private::push_caret_eq(&mut $tokens, $span); }; ($tokens:ident $span:ident :) => { - $crate::__rt::push_colon(&mut $tokens, $span); + $crate::__private::push_colon(&mut $tokens, $span); }; ($tokens:ident $span:ident ::) => { - $crate::__rt::push_colon2(&mut $tokens, $span); + $crate::__private::push_colon2(&mut $tokens, $span); }; ($tokens:ident $span:ident ,) => { - $crate::__rt::push_comma(&mut $tokens, $span); + $crate::__private::push_comma(&mut $tokens, $span); }; ($tokens:ident $span:ident /) => { - $crate::__rt::push_div(&mut $tokens, $span); + $crate::__private::push_div(&mut $tokens, $span); }; ($tokens:ident $span:ident /=) => { - $crate::__rt::push_div_eq(&mut $tokens, $span); + $crate::__private::push_div_eq(&mut $tokens, $span); }; ($tokens:ident $span:ident .) => { - $crate::__rt::push_dot(&mut $tokens, $span); + $crate::__private::push_dot(&mut $tokens, $span); }; ($tokens:ident $span:ident ..) => { - $crate::__rt::push_dot2(&mut $tokens, $span); + $crate::__private::push_dot2(&mut $tokens, $span); }; ($tokens:ident $span:ident ...) => { - $crate::__rt::push_dot3(&mut $tokens, $span); + $crate::__private::push_dot3(&mut $tokens, $span); }; ($tokens:ident $span:ident ..=) => { - $crate::__rt::push_dot_dot_eq(&mut $tokens, $span); + $crate::__private::push_dot_dot_eq(&mut $tokens, $span); }; ($tokens:ident $span:ident =) => { - $crate::__rt::push_eq(&mut $tokens, $span); + $crate::__private::push_eq(&mut $tokens, $span); }; ($tokens:ident $span:ident ==) => { - $crate::__rt::push_eq_eq(&mut $tokens, $span); + $crate::__private::push_eq_eq(&mut $tokens, $span); }; ($tokens:ident $span:ident >=) => { - $crate::__rt::push_ge(&mut $tokens, $span); + $crate::__private::push_ge(&mut $tokens, $span); }; ($tokens:ident $span:ident >) => { - $crate::__rt::push_gt(&mut $tokens, $span); + $crate::__private::push_gt(&mut $tokens, $span); }; ($tokens:ident $span:ident <=) => { - $crate::__rt::push_le(&mut $tokens, $span); + $crate::__private::push_le(&mut $tokens, $span); }; ($tokens:ident $span:ident <) => { - $crate::__rt::push_lt(&mut $tokens, $span); + $crate::__private::push_lt(&mut $tokens, $span); }; ($tokens:ident $span:ident *=) => { - $crate::__rt::push_mul_eq(&mut $tokens, $span); + $crate::__private::push_mul_eq(&mut $tokens, $span); }; ($tokens:ident $span:ident !=) => { - $crate::__rt::push_ne(&mut $tokens, $span); + $crate::__private::push_ne(&mut $tokens, $span); }; ($tokens:ident $span:ident |) => { - $crate::__rt::push_or(&mut $tokens, $span); + $crate::__private::push_or(&mut $tokens, $span); }; ($tokens:ident $span:ident |=) => { - $crate::__rt::push_or_eq(&mut $tokens, $span); + $crate::__private::push_or_eq(&mut $tokens, $span); }; ($tokens:ident $span:ident ||) => { - $crate::__rt::push_or_or(&mut $tokens, $span); + $crate::__private::push_or_or(&mut $tokens, $span); }; ($tokens:ident $span:ident #) => { - $crate::__rt::push_pound(&mut $tokens, $span); + $crate::__private::push_pound(&mut $tokens, $span); }; ($tokens:ident $span:ident ?) => { - $crate::__rt::push_question(&mut $tokens, $span); + $crate::__private::push_question(&mut $tokens, $span); }; ($tokens:ident $span:ident ->) => { - $crate::__rt::push_rarrow(&mut $tokens, $span); + $crate::__private::push_rarrow(&mut $tokens, $span); }; ($tokens:ident $span:ident <-) => { - $crate::__rt::push_larrow(&mut $tokens, $span); + $crate::__private::push_larrow(&mut $tokens, $span); }; ($tokens:ident $span:ident %) => { - $crate::__rt::push_rem(&mut $tokens, $span); + $crate::__private::push_rem(&mut $tokens, $span); }; ($tokens:ident $span:ident %=) => { - $crate::__rt::push_rem_eq(&mut $tokens, $span); + $crate::__private::push_rem_eq(&mut $tokens, $span); }; ($tokens:ident $span:ident =>) => { - $crate::__rt::push_fat_arrow(&mut $tokens, $span); + $crate::__private::push_fat_arrow(&mut $tokens, $span); }; ($tokens:ident $span:ident ;) => { - $crate::__rt::push_semi(&mut $tokens, $span); + $crate::__private::push_semi(&mut $tokens, $span); }; ($tokens:ident $span:ident <<) => { - $crate::__rt::push_shl(&mut $tokens, $span); + $crate::__private::push_shl(&mut $tokens, $span); }; ($tokens:ident $span:ident <<=) => { - $crate::__rt::push_shl_eq(&mut $tokens, $span); + $crate::__private::push_shl_eq(&mut $tokens, $span); }; ($tokens:ident $span:ident >>) => { - $crate::__rt::push_shr(&mut $tokens, $span); + $crate::__private::push_shr(&mut $tokens, $span); }; ($tokens:ident $span:ident >>=) => { - $crate::__rt::push_shr_eq(&mut $tokens, $span); + $crate::__private::push_shr_eq(&mut $tokens, $span); }; ($tokens:ident $span:ident *) => { - $crate::__rt::push_star(&mut $tokens, $span); + $crate::__private::push_star(&mut $tokens, $span); }; ($tokens:ident $span:ident -) => { - $crate::__rt::push_sub(&mut $tokens, $span); + $crate::__private::push_sub(&mut $tokens, $span); }; ($tokens:ident $span:ident -=) => { - $crate::__rt::push_sub_eq(&mut $tokens, $span); + $crate::__private::push_sub_eq(&mut $tokens, $span); + }; + + ($tokens:ident $span:ident $ident:ident) => { + $crate::__private::push_ident(&mut $tokens, $span, stringify!($ident)); }; ($tokens:ident $span:ident $other:tt) => { - $crate::__rt::parse(&mut $tokens, $span, stringify!($other)); + $crate::__private::parse(&mut $tokens, $span, stringify!($other)); }; } diff --git a/src/runtime.rs b/src/runtime.rs index 4a1c14c..bbdeb61 100644 --- a/src/runtime.rs +++ b/src/runtime.rs @@ -180,31 +180,23 @@ impl ToTokens for RepInterp { } } -fn is_ident_start(c: u8) -> bool { - (b'a' <= c && c <= b'z') || (b'A' <= c && c <= b'Z') || c == b'_' -} - -fn is_ident_continue(c: u8) -> bool { - (b'a' <= c && c <= b'z') || (b'A' <= c && c <= b'Z') || c == b'_' || (b'0' <= c && c <= b'9') -} - -fn is_ident(token: &str) -> bool { - let mut iter = token.bytes(); - let first_ok = iter.next().map(is_ident_start).unwrap_or(false); - - first_ok && iter.all(is_ident_continue) +pub fn parse(tokens: &mut TokenStream, span: Span, s: &str) { + let s: TokenStream = s.parse().expect("invalid token stream"); + tokens.extend(s.into_iter().map(|mut t| { + t.set_span(span); + t + })); } -pub fn parse(tokens: &mut TokenStream, span: Span, s: &str) { - if is_ident(s) { - // Fast path, since idents are the most common token. - tokens.append(Ident::new(s, span)); +pub fn push_ident(tokens: &mut TokenStream, span: Span, s: &str) { + // Optimization over `mk_ident`, as `s` is guaranteed to be a valid ident. + // + // FIXME: When `Ident::new_raw` becomes stable, this method should be + // updated to call it when available. + if s.starts_with("r#") { + parse(tokens, span, s); } else { - let s: TokenStream = s.parse().expect("invalid token stream"); - tokens.extend(s.into_iter().map(|mut t| { - t.set_span(span); - t - })); + tokens.append(Ident::new(s, span)); } } @@ -293,9 +285,6 @@ push_punct!(push_sub_eq '-' '='); // although the input string was invalid, due to ignored characters such as // whitespace and comments. Instead, we always create a non-raw identifier // to validate that the string is OK, and only parse again if needed. -// -// The `is_ident` method defined above is insufficient for validation, as it -// will reject non-ASCII identifiers. pub fn mk_ident(id: &str, span: Option) -> Ident { let span = span.unwrap_or_else(Span::call_site); diff --git a/tests/test.rs b/tests/test.rs index 957d470..be2b66b 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -160,7 +160,7 @@ fn test_char() { let tokens = quote! { #zero #pound #quote #apost #newline #heart }; - let expected = "'\\u{0}' '#' '\"' '\\'' '\\n' '\\u{2764}'"; + let expected = "'\\u{0}' '#' '\"' '\\'' '\\n' '\u{2764}'"; assert_eq!(expected, tokens.to_string()); } @@ -427,3 +427,9 @@ fn test_star_after_repetition() { let expected = "f ( '0' ) ; f ( '1' ) ; * out = None ;"; assert_eq!(expected, tokens.to_string()); } + +#[test] +fn test_quote_raw_id() { + let id = quote!(r#raw_id); + assert_eq!(id.to_string(), "r#raw_id"); +} -- cgit v1.2.3 From 215cedeea103de547c0b4093920c0dd376d021e9 Mon Sep 17 00:00:00 2001 From: Bob Badour Date: Wed, 25 Mar 2020 12:22:30 -0700 Subject: Remove redundant NOTICE symbolic link. Now that http://aosp/1235427 and http://aosp/1238719 are in, NOTICE symbolic links are no longer needed. Bug: 67772237 Bug: 68860345 Test: manually built and diffed before and after system image notices Change-Id: I07afdde05c2667e744d57a08dced24775a11ed4c --- NOTICE | 1 - 1 file changed, 1 deletion(-) delete mode 120000 NOTICE diff --git a/NOTICE b/NOTICE deleted file mode 120000 index 7a694c9..0000000 --- a/NOTICE +++ /dev/null @@ -1 +0,0 @@ -LICENSE \ No newline at end of file -- cgit v1.2.3 From c1045e20314cf598e812821e8ba58e8e4a449841 Mon Sep 17 00:00:00 2001 From: Chih-Hung Hsieh Date: Mon, 6 Apr 2020 10:29:08 -0700 Subject: Add OWNERS to quote Test: make Change-Id: Ia28b3b9359938af5432c2158d4c9d553d5d2aba3 --- OWNERS | 1 + 1 file changed, 1 insertion(+) create mode 100644 OWNERS diff --git a/OWNERS b/OWNERS new file mode 100644 index 0000000..46fc303 --- /dev/null +++ b/OWNERS @@ -0,0 +1 @@ +include platform/prebuilts/rust:/OWNERS -- cgit v1.2.3 From 40ad1c7a56b086e1b8dbaa7e9d29106ab7296c48 Mon Sep 17 00:00:00 2001 From: Bob Badour Date: Thu, 23 Apr 2020 15:49:43 -0700 Subject: Add license type: Apache2+MIT are NOTICE licenses Bug: 68860345 Bug: 69058154 Bug: 151953481 Test: no code changes Change-Id: I1a2d68436f55e74be69ea2c834121461cdd9be96 --- METADATA | 1 + 1 file changed, 1 insertion(+) diff --git a/METADATA b/METADATA index 3684f12..13a9707 100644 --- a/METADATA +++ b/METADATA @@ -10,6 +10,7 @@ third_party { value: "https://github.com/dtolnay/quote" } version: "1.0.3" + license_type: NOTICE last_upgrade_date { year: 2020 month: 3 -- cgit v1.2.3 From ca558528b731939862b915b4b69df8a5baf51308 Mon Sep 17 00:00:00 2001 From: Ivan Lozano Date: Wed, 29 Apr 2020 15:46:09 -0400 Subject: Only compile libquote for the host primary arch. Bug: 154730212 Test: mma Change-Id: I771265d3dc9908ecd18ffc677ebce001feb13d3b --- Android.bp | 1 + 1 file changed, 1 insertion(+) diff --git a/Android.bp b/Android.bp index 2fbcffe..8ce0072 100644 --- a/Android.bp +++ b/Android.bp @@ -12,6 +12,7 @@ rust_library_host_rlib { rlibs: [ "libproc_macro2", ], + compile_multilib: "first", // added } // dependent_library ["feature_list"] -- cgit v1.2.3 From 202ace9be4d0ec43af388871745b6ef762206b75 Mon Sep 17 00:00:00 2001 From: Haibo Huang Date: Thu, 30 Apr 2020 15:57:56 -0700 Subject: Upgrade rust/crates/quote to 1.0.4 Test: None Change-Id: Iee109ac0114bc58fcda22d7969272cd856ed5397 --- .cargo_vcs_info.json | 2 +- Cargo.toml | 4 +++- Cargo.toml.orig | 5 ++++- METADATA | 6 +++--- README.md | 3 +-- src/ident_fragment.rs | 2 +- src/lib.rs | 2 +- 7 files changed, 14 insertions(+), 10 deletions(-) diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json index 5388292..476b5b3 100644 --- a/.cargo_vcs_info.json +++ b/.cargo_vcs_info.json @@ -1,5 +1,5 @@ { "git": { - "sha1": "e0300930fa4a8b448c4ff39f499dd4d2fcb0f17d" + "sha1": "cc50e29dad9ed20ceb1c3a3e42ad914b1a1f9bda" } } diff --git a/Cargo.toml b/Cargo.toml index fa5dc59..9ccce1c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ [package] edition = "2018" name = "quote" -version = "1.0.3" +version = "1.0.4" authors = ["David Tolnay "] include = ["Cargo.toml", "src/**/*.rs", "tests/**/*.rs", "README.md", "LICENSE-APACHE", "LICENSE-MIT"] description = "Quasi-quoting macro quote!(...)" @@ -23,6 +23,8 @@ keywords = ["syn"] categories = ["development-tools::procedural-macro-helpers"] license = "MIT OR Apache-2.0" repository = "https://github.com/dtolnay/quote" +[package.metadata.docs.rs] +targets = ["x86_64-unknown-linux-gnu"] [dependencies.proc-macro2] version = "1.0" default-features = false diff --git a/Cargo.toml.orig b/Cargo.toml.orig index ae3963f..f40411a 100644 --- a/Cargo.toml.orig +++ b/Cargo.toml.orig @@ -1,6 +1,6 @@ [package] name = "quote" -version = "1.0.3" # don't forget to update html_root_url, version in readme for breaking changes +version = "1.0.4" # don't forget to update html_root_url, version in readme for breaking changes authors = ["David Tolnay "] license = "MIT OR Apache-2.0" description = "Quasi-quoting macro quote!(...)" @@ -27,3 +27,6 @@ proc-macro = ["proc-macro2/proc-macro"] [badges] travis-ci = { repository = "dtolnay/quote" } + +[package.metadata.docs.rs] +targets = ["x86_64-unknown-linux-gnu"] diff --git a/METADATA b/METADATA index 13a9707..3b70652 100644 --- a/METADATA +++ b/METADATA @@ -9,11 +9,11 @@ third_party { type: GIT value: "https://github.com/dtolnay/quote" } - version: "1.0.3" + version: "1.0.4" license_type: NOTICE last_upgrade_date { year: 2020 - month: 3 - day: 20 + month: 4 + day: 30 } } diff --git a/README.md b/README.md index 7c7f743..8d6bd39 100644 --- a/README.md +++ b/README.md @@ -28,8 +28,7 @@ This crate is motivated by the procedural macro use case, but is a general-purpose Rust quasi-quoting library and is not specific to procedural macros. -*Version requirement: Quote supports any compiler version back to Rust's very -first support for procedural macros in Rust 1.15.0.* +*Version requirement: Quote supports rustc 1.31 and up.* [*Release notes*](https://github.com/dtolnay/quote/releases) diff --git a/src/ident_fragment.rs b/src/ident_fragment.rs index 7e5d376..c8198cc 100644 --- a/src/ident_fragment.rs +++ b/src/ident_fragment.rs @@ -68,5 +68,5 @@ macro_rules! ident_fragment_display { } } -ident_fragment_display!(bool, str, String); +ident_fragment_display!(bool, str, String, char); ident_fragment_display!(u8, u16, u32, u64, u128, usize); diff --git a/src/lib.rs b/src/lib.rs index ad12230..86d91eb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -75,7 +75,7 @@ #![forbid(unsafe_code)] // Quote types in rustdoc of other crates get linked to here. -#![doc(html_root_url = "https://docs.rs/quote/1.0.3")] +#![doc(html_root_url = "https://docs.rs/quote/1.0.4")] #[cfg(all( not(all(target_arch = "wasm32", target_os = "unknown")), -- cgit v1.2.3 From 99abfd3beeec967676101445c54079f19c1bae78 Mon Sep 17 00:00:00 2001 From: Haibo Huang Date: Wed, 13 May 2020 03:48:13 -0700 Subject: Upgrade rust/crates/quote to 1.0.5 Test: None Change-Id: I25ce6c83f1b7ba85ee4fd50589e96a6ba2df7480 --- .cargo_vcs_info.json | 2 +- Cargo.toml | 4 +--- Cargo.toml.orig | 5 +---- METADATA | 6 +++--- README.md | 7 ++++--- src/lib.rs | 10 +++++++++- 6 files changed, 19 insertions(+), 15 deletions(-) diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json index 476b5b3..cb4ee7b 100644 --- a/.cargo_vcs_info.json +++ b/.cargo_vcs_info.json @@ -1,5 +1,5 @@ { "git": { - "sha1": "cc50e29dad9ed20ceb1c3a3e42ad914b1a1f9bda" + "sha1": "b4f1671357770f8422a0b4d5e299267d0c48fd97" } } diff --git a/Cargo.toml b/Cargo.toml index 9ccce1c..c9e1d15 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ [package] edition = "2018" name = "quote" -version = "1.0.4" +version = "1.0.5" authors = ["David Tolnay "] include = ["Cargo.toml", "src/**/*.rs", "tests/**/*.rs", "README.md", "LICENSE-APACHE", "LICENSE-MIT"] description = "Quasi-quoting macro quote!(...)" @@ -38,5 +38,3 @@ features = ["diff"] [features] default = ["proc-macro"] proc-macro = ["proc-macro2/proc-macro"] -[badges.travis-ci] -repository = "dtolnay/quote" diff --git a/Cargo.toml.orig b/Cargo.toml.orig index f40411a..1153bbb 100644 --- a/Cargo.toml.orig +++ b/Cargo.toml.orig @@ -1,6 +1,6 @@ [package] name = "quote" -version = "1.0.4" # don't forget to update html_root_url, version in readme for breaking changes +version = "1.0.5" # don't forget to update html_root_url, version in readme for breaking changes authors = ["David Tolnay "] license = "MIT OR Apache-2.0" description = "Quasi-quoting macro quote!(...)" @@ -25,8 +25,5 @@ default = ["proc-macro"] # libproc_macro in the rustc compiler. proc-macro = ["proc-macro2/proc-macro"] -[badges] -travis-ci = { repository = "dtolnay/quote" } - [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] diff --git a/METADATA b/METADATA index 3b70652..401eaa8 100644 --- a/METADATA +++ b/METADATA @@ -9,11 +9,11 @@ third_party { type: GIT value: "https://github.com/dtolnay/quote" } - version: "1.0.4" + version: "1.0.5" license_type: NOTICE last_upgrade_date { year: 2020 - month: 4 - day: 30 + month: 5 + day: 13 } } diff --git a/README.md b/README.md index 8d6bd39..dce12f7 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,10 @@ Rust Quasi-Quoting ================== -[![Build Status](https://api.travis-ci.org/dtolnay/quote.svg?branch=master)](https://travis-ci.org/dtolnay/quote) -[![Latest Version](https://img.shields.io/crates/v/quote.svg)](https://crates.io/crates/quote) -[![Rust Documentation](https://img.shields.io/badge/api-rustdoc-blue.svg)](https://docs.rs/quote/) +[github](https://github.com/dtolnay/quote) +[crates.io](https://crates.io/crates/quote) +[docs.rs](https://docs.rs/quote) +[build status](https://github.com/dtolnay/quote/actions?query=branch%3Amaster) This crate provides the [`quote!`] macro for turning Rust syntax tree data structures into tokens of source code. diff --git a/src/lib.rs b/src/lib.rs index 86d91eb..7339134 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,11 @@ +//! [![github]](https://github.com/dtolnay/quote) [![crates-io]](https://crates.io/crates/quote) [![docs-rs]](https://docs.rs/quote) +//! +//! [github]: https://img.shields.io/badge/github-8da0cb?style=for-the-badge&labelColor=555555&logo=github +//! [crates-io]: https://img.shields.io/badge/crates.io-fc8d62?style=for-the-badge&labelColor=555555&logo=rust +//! [docs-rs]: https://img.shields.io/badge/docs.rs-66c2a5?style=for-the-badge&labelColor=555555&logoColor=white&logo=data:image/svg+xml;base64,PHN2ZyByb2xlPSJpbWciIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDUxMiA1MTIiPjxwYXRoIGZpbGw9IiNmNWY1ZjUiIGQ9Ik00ODguNiAyNTAuMkwzOTIgMjE0VjEwNS41YzAtMTUtOS4zLTI4LjQtMjMuNC0zMy43bC0xMDAtMzcuNWMtOC4xLTMuMS0xNy4xLTMuMS0yNS4zIDBsLTEwMCAzNy41Yy0xNC4xIDUuMy0yMy40IDE4LjctMjMuNCAzMy43VjIxNGwtOTYuNiAzNi4yQzkuMyAyNTUuNSAwIDI2OC45IDAgMjgzLjlWMzk0YzAgMTMuNiA3LjcgMjYuMSAxOS45IDMyLjJsMTAwIDUwYzEwLjEgNS4xIDIyLjEgNS4xIDMyLjIgMGwxMDMuOS01MiAxMDMuOSA1MmMxMC4xIDUuMSAyMi4xIDUuMSAzMi4yIDBsMTAwLTUwYzEyLjItNi4xIDE5LjktMTguNiAxOS45LTMyLjJWMjgzLjljMC0xNS05LjMtMjguNC0yMy40LTMzLjd6TTM1OCAyMTQuOGwtODUgMzEuOXYtNjguMmw4NS0zN3Y3My4zek0xNTQgMTA0LjFsMTAyLTM4LjIgMTAyIDM4LjJ2LjZsLTEwMiA0MS40LTEwMi00MS40di0uNnptODQgMjkxLjFsLTg1IDQyLjV2LTc5LjFsODUtMzguOHY3NS40em0wLTExMmwtMTAyIDQxLjQtMTAyLTQxLjR2LS42bDEwMi0zOC4yIDEwMiAzOC4ydi42em0yNDAgMTEybC04NSA0Mi41di03OS4xbDg1LTM4Ljh2NzUuNHptMC0xMTJsLTEwMiA0MS40LTEwMi00MS40di0uNmwxMDItMzguMiAxMDIgMzguMnYuNnoiPjwvcGF0aD48L3N2Zz4K +//! +//!
+//! //! This crate provides the [`quote!`] macro for turning Rust syntax tree data //! structures into tokens of source code. //! @@ -75,7 +83,7 @@ #![forbid(unsafe_code)] // Quote types in rustdoc of other crates get linked to here. -#![doc(html_root_url = "https://docs.rs/quote/1.0.4")] +#![doc(html_root_url = "https://docs.rs/quote/1.0.5")] #[cfg(all( not(all(target_arch = "wasm32", target_os = "unknown")), -- cgit v1.2.3 From 73bab92726803ec94c2e670cc201b60eca4fe2e5 Mon Sep 17 00:00:00 2001 From: Haibo Huang Date: Mon, 18 May 2020 02:38:46 -0700 Subject: Upgrade rust/crates/quote to 1.0.6 Test: None Change-Id: Ib889d8215aed93497bdf06b8621eb9bb98f9425f --- .cargo_vcs_info.json | 2 +- Cargo.toml | 2 +- Cargo.toml.orig | 2 +- METADATA | 4 ++-- README.md | 32 ++++++++++++++++++++++++++++---- src/ident_fragment.rs | 14 ++++++++++++++ src/lib.rs | 2 +- tests/test.rs | 2 ++ 8 files changed, 50 insertions(+), 10 deletions(-) diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json index cb4ee7b..067bf7b 100644 --- a/.cargo_vcs_info.json +++ b/.cargo_vcs_info.json @@ -1,5 +1,5 @@ { "git": { - "sha1": "b4f1671357770f8422a0b4d5e299267d0c48fd97" + "sha1": "d67d687aebbc7d6f1692951a15ffff5cb2c33673" } } diff --git a/Cargo.toml b/Cargo.toml index c9e1d15..6a004f9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ [package] edition = "2018" name = "quote" -version = "1.0.5" +version = "1.0.6" authors = ["David Tolnay "] include = ["Cargo.toml", "src/**/*.rs", "tests/**/*.rs", "README.md", "LICENSE-APACHE", "LICENSE-MIT"] description = "Quasi-quoting macro quote!(...)" diff --git a/Cargo.toml.orig b/Cargo.toml.orig index 1153bbb..793de24 100644 --- a/Cargo.toml.orig +++ b/Cargo.toml.orig @@ -1,6 +1,6 @@ [package] name = "quote" -version = "1.0.5" # don't forget to update html_root_url, version in readme for breaking changes +version = "1.0.6" # don't forget to update html_root_url, version in readme for breaking changes authors = ["David Tolnay "] license = "MIT OR Apache-2.0" description = "Quasi-quoting macro quote!(...)" diff --git a/METADATA b/METADATA index 401eaa8..6cef131 100644 --- a/METADATA +++ b/METADATA @@ -9,11 +9,11 @@ third_party { type: GIT value: "https://github.com/dtolnay/quote" } - version: "1.0.5" + version: "1.0.6" license_type: NOTICE last_upgrade_date { year: 2020 month: 5 - day: 13 + day: 18 } } diff --git a/README.md b/README.md index dce12f7..57b2a62 100644 --- a/README.md +++ b/README.md @@ -29,15 +29,16 @@ This crate is motivated by the procedural macro use case, but is a general-purpose Rust quasi-quoting library and is not specific to procedural macros. -*Version requirement: Quote supports rustc 1.31 and up.* - -[*Release notes*](https://github.com/dtolnay/quote/releases) - ```toml [dependencies] quote = "1.0" ``` +*Version requirement: Quote supports rustc 1.31 and up.*
+[*Release notes*](https://github.com/dtolnay/quote/releases) + +
+ ## Syntax The quote crate provides a [`quote!`] macro within which you can write Rust code @@ -76,6 +77,8 @@ let tokens = quote! { }; ``` +
+ ## Repetition Repetition is done using `#(...)*` or `#(...),*` similar to `macro_rules!`. This @@ -93,6 +96,8 @@ Note that there is a difference between `#(#var ,)*` and `#(#var),*`—the latte does not produce a trailing comma. This matches the behavior of delimiters in `macro_rules!`. +
+ ## Returning tokens to the compiler The `quote!` macro evaluates to an expression of type @@ -112,6 +117,8 @@ There is a [`From`]-conversion in both directions so returning the output of [`From`]: https://doc.rust-lang.org/std/convert/trait.From.html +
+ ## Examples ### Combining quoted fragments @@ -206,6 +213,8 @@ quote! { } ``` +
+ ## Hygiene Any interpolated tokens preserve the `Span` information provided by their @@ -221,6 +230,21 @@ macro.
+## Non-macro code generators + +When using `quote` in a build.rs or main.rs and writing the output out to a +file, consider having the code generator pass the tokens through [rustfmt] +before writing (either by shelling out to the `rustfmt` binary or by pulling in +the `rustfmt` library as a dependency). This way if an error occurs in the +generated code it is convenient for a human to read and debug. + +Be aware that no kind of hygiene or span information is retained when tokens are +written to a file; the conversion from tokens to source code is lossy. + +[rustfmt]: https://github.com/rust-lang/rustfmt + +
+ #### License diff --git a/src/ident_fragment.rs b/src/ident_fragment.rs index c8198cc..e7472fe 100644 --- a/src/ident_fragment.rs +++ b/src/ident_fragment.rs @@ -1,4 +1,5 @@ use proc_macro2::{Ident, Span}; +use std::borrow::Cow; use std::fmt; /// Specialized formatting trait used by `format_ident!`. @@ -54,6 +55,19 @@ impl IdentFragment for Ident { } } +impl IdentFragment for Cow<'_, T> +where + T: IdentFragment + ToOwned + ?Sized, +{ + fn span(&self) -> Option { + T::span(self) + } + + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + T::fmt(self, f) + } +} + // Limited set of types which this is implemented for, as we want to avoid types // which will often include non-identifier characters in their `Display` impl. macro_rules! ident_fragment_display { diff --git a/src/lib.rs b/src/lib.rs index 7339134..dd7ef3c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -83,7 +83,7 @@ #![forbid(unsafe_code)] // Quote types in rustdoc of other crates get linked to here. -#![doc(html_root_url = "https://docs.rs/quote/1.0.5")] +#![doc(html_root_url = "https://docs.rs/quote/1.0.6")] #[cfg(all( not(all(target_arch = "wasm32", target_os = "unknown")), diff --git a/tests/test.rs b/tests/test.rs index be2b66b..df857fd 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -341,12 +341,14 @@ fn test_format_ident() { let id2 = format_ident!("Hello{x}", x = 5usize); let id3 = format_ident!("Hello{}_{x}", id0, x = 10usize); let id4 = format_ident!("Aa", span = Span::call_site()); + let id5 = format_ident!("Hello{}", Cow::Borrowed("World")); assert_eq!(id0, "Aa"); assert_eq!(id1, "HelloAa"); assert_eq!(id2, "Hello5"); assert_eq!(id3, "HelloAa_10"); assert_eq!(id4, "Aa"); + assert_eq!(id5, "HelloWorld"); } #[test] -- cgit v1.2.3 From f6c26ee7ca6b50742ed1925d9ce1e9e3b5d465e7 Mon Sep 17 00:00:00 2001 From: Matthew Maurer Date: Mon, 6 Jul 2020 13:34:16 -0700 Subject: Support building all variants. Bug: 143217452 Test: cd external/rust; mma; atest in all TEST_MAPPING subdirs Change-Id: I02c2c83176d15d24b43794d7de20d82a434e3716 --- Android.bp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Android.bp b/Android.bp index 8ce0072..2bf74a9 100644 --- a/Android.bp +++ b/Android.bp @@ -1,6 +1,6 @@ // This file is generated by cargo2android.py. -rust_library_host_rlib { +rust_library_host { name: "libquote", crate_name: "quote", srcs: ["src/lib.rs"], @@ -9,7 +9,7 @@ rust_library_host_rlib { "default", "proc-macro", ], - rlibs: [ + rustlibs: [ "libproc_macro2", ], compile_multilib: "first", // added -- cgit v1.2.3 From ebd269220e400c04811dc5dfe9af4b8ae97c237f Mon Sep 17 00:00:00 2001 From: Haibo Huang Date: Fri, 10 Jul 2020 20:24:12 -0700 Subject: Upgrade rust/crates/quote to 1.0.7 Change-Id: I6207c5dd2c118a71e231970e0b07e7d809bb19e8 --- .cargo_vcs_info.json | 2 +- Cargo.toml | 2 +- Cargo.toml.orig | 2 +- METADATA | 6 +- src/lib.rs | 464 ++++++++++++++++++++++++++++++++++++++++++--------- src/runtime.rs | 150 +++++++++++------ tests/test.rs | 26 ++- 7 files changed, 509 insertions(+), 143 deletions(-) diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json index 067bf7b..e5a01fc 100644 --- a/.cargo_vcs_info.json +++ b/.cargo_vcs_info.json @@ -1,5 +1,5 @@ { "git": { - "sha1": "d67d687aebbc7d6f1692951a15ffff5cb2c33673" + "sha1": "9de44cd86e7feae4abba33c3392a2c37725527f9" } } diff --git a/Cargo.toml b/Cargo.toml index 6a004f9..c6dc281 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ [package] edition = "2018" name = "quote" -version = "1.0.6" +version = "1.0.7" authors = ["David Tolnay "] include = ["Cargo.toml", "src/**/*.rs", "tests/**/*.rs", "README.md", "LICENSE-APACHE", "LICENSE-MIT"] description = "Quasi-quoting macro quote!(...)" diff --git a/Cargo.toml.orig b/Cargo.toml.orig index 793de24..6c418fe 100644 --- a/Cargo.toml.orig +++ b/Cargo.toml.orig @@ -1,6 +1,6 @@ [package] name = "quote" -version = "1.0.6" # don't forget to update html_root_url, version in readme for breaking changes +version = "1.0.7" # don't forget to update html_root_url, version in readme for breaking changes authors = ["David Tolnay "] license = "MIT OR Apache-2.0" description = "Quasi-quoting macro quote!(...)" diff --git a/METADATA b/METADATA index 6cef131..d23a56e 100644 --- a/METADATA +++ b/METADATA @@ -9,11 +9,11 @@ third_party { type: GIT value: "https://github.com/dtolnay/quote" } - version: "1.0.6" + version: "1.0.7" license_type: NOTICE last_upgrade_date { year: 2020 - month: 5 - day: 18 + month: 7 + day: 10 } } diff --git a/src/lib.rs b/src/lib.rs index dd7ef3c..6242909 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -81,9 +81,8 @@ //! ``` #![forbid(unsafe_code)] - // Quote types in rustdoc of other crates get linked to here. -#![doc(html_root_url = "https://docs.rs/quote/1.0.6")] +#![doc(html_root_url = "https://docs.rs/quote/1.0.7")] #[cfg(all( not(all(target_arch = "wasm32", target_os = "unknown")), @@ -472,9 +471,14 @@ pub mod spanned; /// ``` #[macro_export] macro_rules! quote { - ($($tt:tt)*) => { - $crate::quote_spanned!($crate::__private::Span::call_site()=> $($tt)*) + () => { + $crate::__private::TokenStream::new() }; + ($($tt:tt)*) => {{ + let mut _s = $crate::__private::TokenStream::new(); + $crate::quote_each_token!(_s $($tt)*); + _s + }}; } /// Same as `quote!`, but applies a given span to all tokens originating within @@ -575,10 +579,14 @@ macro_rules! quote { /// placed appropriately by the compiler. #[macro_export] macro_rules! quote_spanned { + ($span:expr=>) => {{ + let _: $crate::__private::Span = $span; + $crate::__private::TokenStream::new() + }}; ($span:expr=> $($tt:tt)*) => {{ let mut _s = $crate::__private::TokenStream::new(); let _span: $crate::__private::Span = $span; - $crate::quote_each_token!(_s _span $($tt)*); + $crate::quote_each_token_spanned!(_s _span $($tt)*); _s }}; } @@ -657,8 +665,24 @@ macro_rules! quote_bind_next_or_break { #[macro_export] #[doc(hidden)] macro_rules! quote_each_token { + ($tokens:ident $($tts:tt)*) => { + $crate::quote_tokens_with_context!($tokens + (@ @ @ @ @ @ $($tts)*) + (@ @ @ @ @ $($tts)* @) + (@ @ @ @ $($tts)* @ @) + (@ @ @ $(($tts))* @ @ @) + (@ @ $($tts)* @ @ @ @) + (@ $($tts)* @ @ @ @ @) + ($($tts)* @ @ @ @ @ @) + ); + }; +} + +#[macro_export] +#[doc(hidden)] +macro_rules! quote_each_token_spanned { ($tokens:ident $span:ident $($tts:tt)*) => { - $crate::quote_tokens_with_context!($tokens $span + $crate::quote_tokens_with_context_spanned!($tokens $span (@ @ @ @ @ @ $($tts)*) (@ @ @ @ @ $($tts)* @) (@ @ @ @ $($tts)* @ @) @@ -673,13 +697,27 @@ macro_rules! quote_each_token { #[macro_export] #[doc(hidden)] macro_rules! quote_tokens_with_context { + ($tokens:ident + ($($b3:tt)*) ($($b2:tt)*) ($($b1:tt)*) + ($($curr:tt)*) + ($($a1:tt)*) ($($a2:tt)*) ($($a3:tt)*) + ) => { + $( + $crate::quote_token_with_context!($tokens $b3 $b2 $b1 $curr $a1 $a2 $a3); + )* + }; +} + +#[macro_export] +#[doc(hidden)] +macro_rules! quote_tokens_with_context_spanned { ($tokens:ident $span:ident ($($b3:tt)*) ($($b2:tt)*) ($($b1:tt)*) ($($curr:tt)*) ($($a1:tt)*) ($($a2:tt)*) ($($a3:tt)*) ) => { $( - $crate::quote_token_with_context!($tokens $span $b3 $b2 $b1 $curr $a1 $a2 $a3); + $crate::quote_token_with_context_spanned!($tokens $span $b3 $b2 $b1 $curr $a1 $a2 $a3); )* }; } @@ -687,6 +725,62 @@ macro_rules! quote_tokens_with_context { #[macro_export] #[doc(hidden)] macro_rules! quote_token_with_context { + ($tokens:ident $b3:tt $b2:tt $b1:tt @ $a1:tt $a2:tt $a3:tt) => {}; + + ($tokens:ident $b3:tt $b2:tt $b1:tt (#) ( $($inner:tt)* ) * $a3:tt) => {{ + use $crate::__private::ext::*; + let has_iter = $crate::__private::ThereIsNoIteratorInRepetition; + $crate::pounded_var_names!(quote_bind_into_iter!(has_iter) () $($inner)*); + let _: $crate::__private::HasIterator = has_iter; + // This is `while true` instead of `loop` because if there are no + // iterators used inside of this repetition then the body would not + // contain any `break`, so the compiler would emit unreachable code + // warnings on anything below the loop. We use has_iter to detect and + // fail to compile when there are no iterators, so here we just work + // around the unneeded extra warning. + while true { + $crate::pounded_var_names!(quote_bind_next_or_break!() () $($inner)*); + $crate::quote_each_token!($tokens $($inner)*); + } + }}; + ($tokens:ident $b3:tt $b2:tt # (( $($inner:tt)* )) * $a2:tt $a3:tt) => {}; + ($tokens:ident $b3:tt # ( $($inner:tt)* ) (*) $a1:tt $a2:tt $a3:tt) => {}; + + ($tokens:ident $b3:tt $b2:tt $b1:tt (#) ( $($inner:tt)* ) $sep:tt *) => {{ + use $crate::__private::ext::*; + let mut _i = 0usize; + let has_iter = $crate::__private::ThereIsNoIteratorInRepetition; + $crate::pounded_var_names!(quote_bind_into_iter!(has_iter) () $($inner)*); + let _: $crate::__private::HasIterator = has_iter; + while true { + $crate::pounded_var_names!(quote_bind_next_or_break!() () $($inner)*); + if _i > 0 { + $crate::quote_token!($tokens $sep); + } + _i += 1; + $crate::quote_each_token!($tokens $($inner)*); + } + }}; + ($tokens:ident $b3:tt $b2:tt # (( $($inner:tt)* )) $sep:tt * $a3:tt) => {}; + ($tokens:ident $b3:tt # ( $($inner:tt)* ) ($sep:tt) * $a2:tt $a3:tt) => {}; + ($tokens:ident # ( $($inner:tt)* ) * (*) $a1:tt $a2:tt $a3:tt) => { + // https://github.com/dtolnay/quote/issues/130 + $crate::quote_token!($tokens *); + }; + ($tokens:ident # ( $($inner:tt)* ) $sep:tt (*) $a1:tt $a2:tt $a3:tt) => {}; + + ($tokens:ident $b3:tt $b2:tt $b1:tt (#) $var:ident $a2:tt $a3:tt) => { + $crate::ToTokens::to_tokens(&$var, &mut $tokens); + }; + ($tokens:ident $b3:tt $b2:tt # ($var:ident) $a1:tt $a2:tt $a3:tt) => {}; + ($tokens:ident $b3:tt $b2:tt $b1:tt ($curr:tt) $a1:tt $a2:tt $a3:tt) => { + $crate::quote_token!($tokens $curr); + }; +} + +#[macro_export] +#[doc(hidden)] +macro_rules! quote_token_with_context_spanned { ($tokens:ident $span:ident $b3:tt $b2:tt $b1:tt @ $a1:tt $a2:tt $a3:tt) => {}; ($tokens:ident $span:ident $b3:tt $b2:tt $b1:tt (#) ( $($inner:tt)* ) * $a3:tt) => {{ @@ -702,7 +796,7 @@ macro_rules! quote_token_with_context { // around the unneeded extra warning. while true { $crate::pounded_var_names!(quote_bind_next_or_break!() () $($inner)*); - $crate::quote_each_token!($tokens $span $($inner)*); + $crate::quote_each_token_spanned!($tokens $span $($inner)*); } }}; ($tokens:ident $span:ident $b3:tt $b2:tt # (( $($inner:tt)* )) * $a2:tt $a3:tt) => {}; @@ -717,17 +811,17 @@ macro_rules! quote_token_with_context { while true { $crate::pounded_var_names!(quote_bind_next_or_break!() () $($inner)*); if _i > 0 { - $crate::quote_token!($tokens $span $sep); + $crate::quote_token_spanned!($tokens $span $sep); } _i += 1; - $crate::quote_each_token!($tokens $span $($inner)*); + $crate::quote_each_token_spanned!($tokens $span $($inner)*); } }}; ($tokens:ident $span:ident $b3:tt $b2:tt # (( $($inner:tt)* )) $sep:tt * $a3:tt) => {}; ($tokens:ident $span:ident $b3:tt # ( $($inner:tt)* ) ($sep:tt) * $a2:tt $a3:tt) => {}; ($tokens:ident $span:ident # ( $($inner:tt)* ) * (*) $a1:tt $a2:tt $a3:tt) => { // https://github.com/dtolnay/quote/issues/130 - $crate::quote_token!($tokens $span *); + $crate::quote_token_spanned!($tokens $span *); }; ($tokens:ident $span:ident # ( $($inner:tt)* ) $sep:tt (*) $a1:tt $a2:tt $a3:tt) => {}; @@ -736,227 +830,433 @@ macro_rules! quote_token_with_context { }; ($tokens:ident $span:ident $b3:tt $b2:tt # ($var:ident) $a1:tt $a2:tt $a3:tt) => {}; ($tokens:ident $span:ident $b3:tt $b2:tt $b1:tt ($curr:tt) $a1:tt $a2:tt $a3:tt) => { - $crate::quote_token!($tokens $span $curr); + $crate::quote_token_spanned!($tokens $span $curr); }; } #[macro_export] #[doc(hidden)] macro_rules! quote_token { + ($tokens:ident ( $($inner:tt)* )) => { + $crate::__private::push_group( + &mut $tokens, + $crate::__private::Delimiter::Parenthesis, + $crate::quote!($($inner)*), + ); + }; + + ($tokens:ident [ $($inner:tt)* ]) => { + $crate::__private::push_group( + &mut $tokens, + $crate::__private::Delimiter::Bracket, + $crate::quote!($($inner)*), + ); + }; + + ($tokens:ident { $($inner:tt)* }) => { + $crate::__private::push_group( + &mut $tokens, + $crate::__private::Delimiter::Brace, + $crate::quote!($($inner)*), + ); + }; + + ($tokens:ident +) => { + $crate::__private::push_add(&mut $tokens); + }; + + ($tokens:ident +=) => { + $crate::__private::push_add_eq(&mut $tokens); + }; + + ($tokens:ident &) => { + $crate::__private::push_and(&mut $tokens); + }; + + ($tokens:ident &&) => { + $crate::__private::push_and_and(&mut $tokens); + }; + + ($tokens:ident &=) => { + $crate::__private::push_and_eq(&mut $tokens); + }; + + ($tokens:ident @) => { + $crate::__private::push_at(&mut $tokens); + }; + + ($tokens:ident !) => { + $crate::__private::push_bang(&mut $tokens); + }; + + ($tokens:ident ^) => { + $crate::__private::push_caret(&mut $tokens); + }; + + ($tokens:ident ^=) => { + $crate::__private::push_caret_eq(&mut $tokens); + }; + + ($tokens:ident :) => { + $crate::__private::push_colon(&mut $tokens); + }; + + ($tokens:ident ::) => { + $crate::__private::push_colon2(&mut $tokens); + }; + + ($tokens:ident ,) => { + $crate::__private::push_comma(&mut $tokens); + }; + + ($tokens:ident /) => { + $crate::__private::push_div(&mut $tokens); + }; + + ($tokens:ident /=) => { + $crate::__private::push_div_eq(&mut $tokens); + }; + + ($tokens:ident .) => { + $crate::__private::push_dot(&mut $tokens); + }; + + ($tokens:ident ..) => { + $crate::__private::push_dot2(&mut $tokens); + }; + + ($tokens:ident ...) => { + $crate::__private::push_dot3(&mut $tokens); + }; + + ($tokens:ident ..=) => { + $crate::__private::push_dot_dot_eq(&mut $tokens); + }; + + ($tokens:ident =) => { + $crate::__private::push_eq(&mut $tokens); + }; + + ($tokens:ident ==) => { + $crate::__private::push_eq_eq(&mut $tokens); + }; + + ($tokens:ident >=) => { + $crate::__private::push_ge(&mut $tokens); + }; + + ($tokens:ident >) => { + $crate::__private::push_gt(&mut $tokens); + }; + + ($tokens:ident <=) => { + $crate::__private::push_le(&mut $tokens); + }; + + ($tokens:ident <) => { + $crate::__private::push_lt(&mut $tokens); + }; + + ($tokens:ident *=) => { + $crate::__private::push_mul_eq(&mut $tokens); + }; + + ($tokens:ident !=) => { + $crate::__private::push_ne(&mut $tokens); + }; + + ($tokens:ident |) => { + $crate::__private::push_or(&mut $tokens); + }; + + ($tokens:ident |=) => { + $crate::__private::push_or_eq(&mut $tokens); + }; + + ($tokens:ident ||) => { + $crate::__private::push_or_or(&mut $tokens); + }; + + ($tokens:ident #) => { + $crate::__private::push_pound(&mut $tokens); + }; + + ($tokens:ident ?) => { + $crate::__private::push_question(&mut $tokens); + }; + + ($tokens:ident ->) => { + $crate::__private::push_rarrow(&mut $tokens); + }; + + ($tokens:ident <-) => { + $crate::__private::push_larrow(&mut $tokens); + }; + + ($tokens:ident %) => { + $crate::__private::push_rem(&mut $tokens); + }; + + ($tokens:ident %=) => { + $crate::__private::push_rem_eq(&mut $tokens); + }; + + ($tokens:ident =>) => { + $crate::__private::push_fat_arrow(&mut $tokens); + }; + + ($tokens:ident ;) => { + $crate::__private::push_semi(&mut $tokens); + }; + + ($tokens:ident <<) => { + $crate::__private::push_shl(&mut $tokens); + }; + + ($tokens:ident <<=) => { + $crate::__private::push_shl_eq(&mut $tokens); + }; + + ($tokens:ident >>) => { + $crate::__private::push_shr(&mut $tokens); + }; + + ($tokens:ident >>=) => { + $crate::__private::push_shr_eq(&mut $tokens); + }; + + ($tokens:ident *) => { + $crate::__private::push_star(&mut $tokens); + }; + + ($tokens:ident -) => { + $crate::__private::push_sub(&mut $tokens); + }; + + ($tokens:ident -=) => { + $crate::__private::push_sub_eq(&mut $tokens); + }; + + ($tokens:ident $ident:ident) => { + $crate::__private::push_ident(&mut $tokens, stringify!($ident)); + }; + + ($tokens:ident $other:tt) => { + $crate::__private::parse(&mut $tokens, stringify!($other)); + }; +} + +#[macro_export] +#[doc(hidden)] +macro_rules! quote_token_spanned { ($tokens:ident $span:ident ( $($inner:tt)* )) => { - $tokens.extend({ - let mut g = $crate::__private::Group::new( - $crate::__private::Delimiter::Parenthesis, - $crate::quote_spanned!($span=> $($inner)*), - ); - g.set_span($span); - Some($crate::__private::TokenTree::from(g)) - }); + $crate::__private::push_group_spanned( + &mut $tokens, + $span, + $crate::__private::Delimiter::Parenthesis, + $crate::quote_spanned!($span=> $($inner)*), + ); }; ($tokens:ident $span:ident [ $($inner:tt)* ]) => { - $tokens.extend({ - let mut g = $crate::__private::Group::new( - $crate::__private::Delimiter::Bracket, - $crate::quote_spanned!($span=> $($inner)*), - ); - g.set_span($span); - Some($crate::__private::TokenTree::from(g)) - }); + $crate::__private::push_group_spanned( + &mut $tokens, + $span, + $crate::__private::Delimiter::Bracket, + $crate::quote_spanned!($span=> $($inner)*), + ); }; ($tokens:ident $span:ident { $($inner:tt)* }) => { - $tokens.extend({ - let mut g = $crate::__private::Group::new( - $crate::__private::Delimiter::Brace, - $crate::quote_spanned!($span=> $($inner)*), - ); - g.set_span($span); - Some($crate::__private::TokenTree::from(g)) - }); + $crate::__private::push_group_spanned( + &mut $tokens, + $span, + $crate::__private::Delimiter::Brace, + $crate::quote_spanned!($span=> $($inner)*), + ); }; ($tokens:ident $span:ident +) => { - $crate::__private::push_add(&mut $tokens, $span); + $crate::__private::push_add_spanned(&mut $tokens, $span); }; ($tokens:ident $span:ident +=) => { - $crate::__private::push_add_eq(&mut $tokens, $span); + $crate::__private::push_add_eq_spanned(&mut $tokens, $span); }; ($tokens:ident $span:ident &) => { - $crate::__private::push_and(&mut $tokens, $span); + $crate::__private::push_and_spanned(&mut $tokens, $span); }; ($tokens:ident $span:ident &&) => { - $crate::__private::push_and_and(&mut $tokens, $span); + $crate::__private::push_and_and_spanned(&mut $tokens, $span); }; ($tokens:ident $span:ident &=) => { - $crate::__private::push_and_eq(&mut $tokens, $span); + $crate::__private::push_and_eq_spanned(&mut $tokens, $span); }; ($tokens:ident $span:ident @) => { - $crate::__private::push_at(&mut $tokens, $span); + $crate::__private::push_at_spanned(&mut $tokens, $span); }; ($tokens:ident $span:ident !) => { - $crate::__private::push_bang(&mut $tokens, $span); + $crate::__private::push_bang_spanned(&mut $tokens, $span); }; ($tokens:ident $span:ident ^) => { - $crate::__private::push_caret(&mut $tokens, $span); + $crate::__private::push_caret_spanned(&mut $tokens, $span); }; ($tokens:ident $span:ident ^=) => { - $crate::__private::push_caret_eq(&mut $tokens, $span); + $crate::__private::push_caret_eq_spanned(&mut $tokens, $span); }; ($tokens:ident $span:ident :) => { - $crate::__private::push_colon(&mut $tokens, $span); + $crate::__private::push_colon_spanned(&mut $tokens, $span); }; ($tokens:ident $span:ident ::) => { - $crate::__private::push_colon2(&mut $tokens, $span); + $crate::__private::push_colon2_spanned(&mut $tokens, $span); }; ($tokens:ident $span:ident ,) => { - $crate::__private::push_comma(&mut $tokens, $span); + $crate::__private::push_comma_spanned(&mut $tokens, $span); }; ($tokens:ident $span:ident /) => { - $crate::__private::push_div(&mut $tokens, $span); + $crate::__private::push_div_spanned(&mut $tokens, $span); }; ($tokens:ident $span:ident /=) => { - $crate::__private::push_div_eq(&mut $tokens, $span); + $crate::__private::push_div_eq_spanned(&mut $tokens, $span); }; ($tokens:ident $span:ident .) => { - $crate::__private::push_dot(&mut $tokens, $span); + $crate::__private::push_dot_spanned(&mut $tokens, $span); }; ($tokens:ident $span:ident ..) => { - $crate::__private::push_dot2(&mut $tokens, $span); + $crate::__private::push_dot2_spanned(&mut $tokens, $span); }; ($tokens:ident $span:ident ...) => { - $crate::__private::push_dot3(&mut $tokens, $span); + $crate::__private::push_dot3_spanned(&mut $tokens, $span); }; ($tokens:ident $span:ident ..=) => { - $crate::__private::push_dot_dot_eq(&mut $tokens, $span); + $crate::__private::push_dot_dot_eq_spanned(&mut $tokens, $span); }; ($tokens:ident $span:ident =) => { - $crate::__private::push_eq(&mut $tokens, $span); + $crate::__private::push_eq_spanned(&mut $tokens, $span); }; ($tokens:ident $span:ident ==) => { - $crate::__private::push_eq_eq(&mut $tokens, $span); + $crate::__private::push_eq_eq_spanned(&mut $tokens, $span); }; ($tokens:ident $span:ident >=) => { - $crate::__private::push_ge(&mut $tokens, $span); + $crate::__private::push_ge_spanned(&mut $tokens, $span); }; ($tokens:ident $span:ident >) => { - $crate::__private::push_gt(&mut $tokens, $span); + $crate::__private::push_gt_spanned(&mut $tokens, $span); }; ($tokens:ident $span:ident <=) => { - $crate::__private::push_le(&mut $tokens, $span); + $crate::__private::push_le_spanned(&mut $tokens, $span); }; ($tokens:ident $span:ident <) => { - $crate::__private::push_lt(&mut $tokens, $span); + $crate::__private::push_lt_spanned(&mut $tokens, $span); }; ($tokens:ident $span:ident *=) => { - $crate::__private::push_mul_eq(&mut $tokens, $span); + $crate::__private::push_mul_eq_spanned(&mut $tokens, $span); }; ($tokens:ident $span:ident !=) => { - $crate::__private::push_ne(&mut $tokens, $span); + $crate::__private::push_ne_spanned(&mut $tokens, $span); }; ($tokens:ident $span:ident |) => { - $crate::__private::push_or(&mut $tokens, $span); + $crate::__private::push_or_spanned(&mut $tokens, $span); }; ($tokens:ident $span:ident |=) => { - $crate::__private::push_or_eq(&mut $tokens, $span); + $crate::__private::push_or_eq_spanned(&mut $tokens, $span); }; ($tokens:ident $span:ident ||) => { - $crate::__private::push_or_or(&mut $tokens, $span); + $crate::__private::push_or_or_spanned(&mut $tokens, $span); }; ($tokens:ident $span:ident #) => { - $crate::__private::push_pound(&mut $tokens, $span); + $crate::__private::push_pound_spanned(&mut $tokens, $span); }; ($tokens:ident $span:ident ?) => { - $crate::__private::push_question(&mut $tokens, $span); + $crate::__private::push_question_spanned(&mut $tokens, $span); }; ($tokens:ident $span:ident ->) => { - $crate::__private::push_rarrow(&mut $tokens, $span); + $crate::__private::push_rarrow_spanned(&mut $tokens, $span); }; ($tokens:ident $span:ident <-) => { - $crate::__private::push_larrow(&mut $tokens, $span); + $crate::__private::push_larrow_spanned(&mut $tokens, $span); }; ($tokens:ident $span:ident %) => { - $crate::__private::push_rem(&mut $tokens, $span); + $crate::__private::push_rem_spanned(&mut $tokens, $span); }; ($tokens:ident $span:ident %=) => { - $crate::__private::push_rem_eq(&mut $tokens, $span); + $crate::__private::push_rem_eq_spanned(&mut $tokens, $span); }; ($tokens:ident $span:ident =>) => { - $crate::__private::push_fat_arrow(&mut $tokens, $span); + $crate::__private::push_fat_arrow_spanned(&mut $tokens, $span); }; ($tokens:ident $span:ident ;) => { - $crate::__private::push_semi(&mut $tokens, $span); + $crate::__private::push_semi_spanned(&mut $tokens, $span); }; ($tokens:ident $span:ident <<) => { - $crate::__private::push_shl(&mut $tokens, $span); + $crate::__private::push_shl_spanned(&mut $tokens, $span); }; ($tokens:ident $span:ident <<=) => { - $crate::__private::push_shl_eq(&mut $tokens, $span); + $crate::__private::push_shl_eq_spanned(&mut $tokens, $span); }; ($tokens:ident $span:ident >>) => { - $crate::__private::push_shr(&mut $tokens, $span); + $crate::__private::push_shr_spanned(&mut $tokens, $span); }; ($tokens:ident $span:ident >>=) => { - $crate::__private::push_shr_eq(&mut $tokens, $span); + $crate::__private::push_shr_eq_spanned(&mut $tokens, $span); }; ($tokens:ident $span:ident *) => { - $crate::__private::push_star(&mut $tokens, $span); + $crate::__private::push_star_spanned(&mut $tokens, $span); }; ($tokens:ident $span:ident -) => { - $crate::__private::push_sub(&mut $tokens, $span); + $crate::__private::push_sub_spanned(&mut $tokens, $span); }; ($tokens:ident $span:ident -=) => { - $crate::__private::push_sub_eq(&mut $tokens, $span); + $crate::__private::push_sub_eq_spanned(&mut $tokens, $span); }; ($tokens:ident $span:ident $ident:ident) => { - $crate::__private::push_ident(&mut $tokens, $span, stringify!($ident)); + $crate::__private::push_ident_spanned(&mut $tokens, $span, stringify!($ident)); }; ($tokens:ident $span:ident $other:tt) => { - $crate::__private::parse(&mut $tokens, $span, stringify!($other)); + $crate::__private::parse_spanned(&mut $tokens, $span, stringify!($other)); }; } diff --git a/src/runtime.rs b/src/runtime.rs index bbdeb61..fe72687 100644 --- a/src/runtime.rs +++ b/src/runtime.rs @@ -180,7 +180,27 @@ impl ToTokens for RepInterp { } } -pub fn parse(tokens: &mut TokenStream, span: Span, s: &str) { +pub fn push_group(tokens: &mut TokenStream, delimiter: Delimiter, inner: TokenStream) { + tokens.append(Group::new(delimiter, inner)); +} + +pub fn push_group_spanned( + tokens: &mut TokenStream, + span: Span, + delimiter: Delimiter, + inner: TokenStream, +) { + let mut g = Group::new(delimiter, inner); + g.set_span(span); + tokens.append(g); +} + +pub fn parse(tokens: &mut TokenStream, s: &str) { + let s: TokenStream = s.parse().expect("invalid token stream"); + tokens.extend(s); +} + +pub fn parse_spanned(tokens: &mut TokenStream, span: Span, s: &str) { let s: TokenStream = s.parse().expect("invalid token stream"); tokens.extend(s.into_iter().map(|mut t| { t.set_span(span); @@ -188,28 +208,47 @@ pub fn parse(tokens: &mut TokenStream, span: Span, s: &str) { })); } -pub fn push_ident(tokens: &mut TokenStream, span: Span, s: &str) { +pub fn push_ident(tokens: &mut TokenStream, s: &str) { // Optimization over `mk_ident`, as `s` is guaranteed to be a valid ident. // // FIXME: When `Ident::new_raw` becomes stable, this method should be // updated to call it when available. if s.starts_with("r#") { - parse(tokens, span, s); + parse(tokens, s); + } else { + tokens.append(Ident::new(s, Span::call_site())); + } +} + +pub fn push_ident_spanned(tokens: &mut TokenStream, span: Span, s: &str) { + // Optimization over `mk_ident`, as `s` is guaranteed to be a valid ident. + // + // FIXME: When `Ident::new_raw` becomes stable, this method should be + // updated to call it when available. + if s.starts_with("r#") { + parse_spanned(tokens, span, s); } else { tokens.append(Ident::new(s, span)); } } macro_rules! push_punct { - ($name:ident $char1:tt) => { - pub fn $name(tokens: &mut TokenStream, span: Span) { + ($name:ident $spanned:ident $char1:tt) => { + pub fn $name(tokens: &mut TokenStream) { + tokens.append(Punct::new($char1, Spacing::Alone)); + } + pub fn $spanned(tokens: &mut TokenStream, span: Span) { let mut punct = Punct::new($char1, Spacing::Alone); punct.set_span(span); tokens.append(punct); } }; - ($name:ident $char1:tt $char2:tt) => { - pub fn $name(tokens: &mut TokenStream, span: Span) { + ($name:ident $spanned:ident $char1:tt $char2:tt) => { + pub fn $name(tokens: &mut TokenStream) { + tokens.append(Punct::new($char1, Spacing::Joint)); + tokens.append(Punct::new($char2, Spacing::Alone)); + } + pub fn $spanned(tokens: &mut TokenStream, span: Span) { let mut punct = Punct::new($char1, Spacing::Joint); punct.set_span(span); tokens.append(punct); @@ -218,8 +257,13 @@ macro_rules! push_punct { tokens.append(punct); } }; - ($name:ident $char1:tt $char2:tt $char3:tt) => { - pub fn $name(tokens: &mut TokenStream, span: Span) { + ($name:ident $spanned:ident $char1:tt $char2:tt $char3:tt) => { + pub fn $name(tokens: &mut TokenStream) { + tokens.append(Punct::new($char1, Spacing::Joint)); + tokens.append(Punct::new($char2, Spacing::Joint)); + tokens.append(Punct::new($char3, Spacing::Alone)); + } + pub fn $spanned(tokens: &mut TokenStream, span: Span) { let mut punct = Punct::new($char1, Spacing::Joint); punct.set_span(span); tokens.append(punct); @@ -233,50 +277,50 @@ macro_rules! push_punct { }; } -push_punct!(push_add '+'); -push_punct!(push_add_eq '+' '='); -push_punct!(push_and '&'); -push_punct!(push_and_and '&' '&'); -push_punct!(push_and_eq '&' '='); -push_punct!(push_at '@'); -push_punct!(push_bang '!'); -push_punct!(push_caret '^'); -push_punct!(push_caret_eq '^' '='); -push_punct!(push_colon ':'); -push_punct!(push_colon2 ':' ':'); -push_punct!(push_comma ','); -push_punct!(push_div '/'); -push_punct!(push_div_eq '/' '='); -push_punct!(push_dot '.'); -push_punct!(push_dot2 '.' '.'); -push_punct!(push_dot3 '.' '.' '.'); -push_punct!(push_dot_dot_eq '.' '.' '='); -push_punct!(push_eq '='); -push_punct!(push_eq_eq '=' '='); -push_punct!(push_ge '>' '='); -push_punct!(push_gt '>'); -push_punct!(push_le '<' '='); -push_punct!(push_lt '<'); -push_punct!(push_mul_eq '*' '='); -push_punct!(push_ne '!' '='); -push_punct!(push_or '|'); -push_punct!(push_or_eq '|' '='); -push_punct!(push_or_or '|' '|'); -push_punct!(push_pound '#'); -push_punct!(push_question '?'); -push_punct!(push_rarrow '-' '>'); -push_punct!(push_larrow '<' '-'); -push_punct!(push_rem '%'); -push_punct!(push_rem_eq '%' '='); -push_punct!(push_fat_arrow '=' '>'); -push_punct!(push_semi ';'); -push_punct!(push_shl '<' '<'); -push_punct!(push_shl_eq '<' '<' '='); -push_punct!(push_shr '>' '>'); -push_punct!(push_shr_eq '>' '>' '='); -push_punct!(push_star '*'); -push_punct!(push_sub '-'); -push_punct!(push_sub_eq '-' '='); +push_punct!(push_add push_add_spanned '+'); +push_punct!(push_add_eq push_add_eq_spanned '+' '='); +push_punct!(push_and push_and_spanned '&'); +push_punct!(push_and_and push_and_and_spanned '&' '&'); +push_punct!(push_and_eq push_and_eq_spanned '&' '='); +push_punct!(push_at push_at_spanned '@'); +push_punct!(push_bang push_bang_spanned '!'); +push_punct!(push_caret push_caret_spanned '^'); +push_punct!(push_caret_eq push_caret_eq_spanned '^' '='); +push_punct!(push_colon push_colon_spanned ':'); +push_punct!(push_colon2 push_colon2_spanned ':' ':'); +push_punct!(push_comma push_comma_spanned ','); +push_punct!(push_div push_div_spanned '/'); +push_punct!(push_div_eq push_div_eq_spanned '/' '='); +push_punct!(push_dot push_dot_spanned '.'); +push_punct!(push_dot2 push_dot2_spanned '.' '.'); +push_punct!(push_dot3 push_dot3_spanned '.' '.' '.'); +push_punct!(push_dot_dot_eq push_dot_dot_eq_spanned '.' '.' '='); +push_punct!(push_eq push_eq_spanned '='); +push_punct!(push_eq_eq push_eq_eq_spanned '=' '='); +push_punct!(push_ge push_ge_spanned '>' '='); +push_punct!(push_gt push_gt_spanned '>'); +push_punct!(push_le push_le_spanned '<' '='); +push_punct!(push_lt push_lt_spanned '<'); +push_punct!(push_mul_eq push_mul_eq_spanned '*' '='); +push_punct!(push_ne push_ne_spanned '!' '='); +push_punct!(push_or push_or_spanned '|'); +push_punct!(push_or_eq push_or_eq_spanned '|' '='); +push_punct!(push_or_or push_or_or_spanned '|' '|'); +push_punct!(push_pound push_pound_spanned '#'); +push_punct!(push_question push_question_spanned '?'); +push_punct!(push_rarrow push_rarrow_spanned '-' '>'); +push_punct!(push_larrow push_larrow_spanned '<' '-'); +push_punct!(push_rem push_rem_spanned '%'); +push_punct!(push_rem_eq push_rem_eq_spanned '%' '='); +push_punct!(push_fat_arrow push_fat_arrow_spanned '=' '>'); +push_punct!(push_semi push_semi_spanned ';'); +push_punct!(push_shl push_shl_spanned '<' '<'); +push_punct!(push_shl_eq push_shl_eq_spanned '<' '<' '='); +push_punct!(push_shr push_shr_spanned '>' '>'); +push_punct!(push_shr_eq push_shr_eq_spanned '>' '>' '='); +push_punct!(push_star push_star_spanned '*'); +push_punct!(push_sub push_sub_spanned '-'); +push_punct!(push_sub_eq push_sub_eq_spanned '-' '='); // Helper method for constructing identifiers from the `format_ident!` macro, // handling `r#` prefixes. diff --git a/tests/test.rs b/tests/test.rs index df857fd..6580bcd 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -4,7 +4,7 @@ use std::borrow::Cow; use std::collections::BTreeSet; use proc_macro2::{Ident, Span, TokenStream}; -use quote::{format_ident, quote, TokenStreamExt}; +use quote::{format_ident, quote, quote_spanned, TokenStreamExt}; struct X; @@ -35,6 +35,28 @@ fn test_quote_impl() { assert_eq!(expected, tokens.to_string()); } +#[test] +fn test_quote_spanned_impl() { + let span = Span::call_site(); + let tokens = quote_spanned! {span=> + impl<'a, T: ToTokens> ToTokens for &'a T { + fn to_tokens(&self, tokens: &mut TokenStream) { + (**self).to_tokens(tokens) + } + } + }; + + let expected = concat!( + "impl < 'a , T : ToTokens > ToTokens for & 'a T { ", + "fn to_tokens ( & self , tokens : & mut TokenStream ) { ", + "( * * self ) . to_tokens ( tokens ) ", + "} ", + "}" + ); + + assert_eq!(expected, tokens.to_string()); +} + #[test] fn test_substitution() { let x = X; @@ -130,7 +152,7 @@ fn test_integer() { #ii8 #ii16 #ii32 #ii64 #ii128 #iisize #uu8 #uu16 #uu32 #uu64 #uu128 #uusize }; - let expected = "-1i8 -1i16 -1i32 -1i64 -1i128 -1isize 1u8 1u16 1u32 1u64 1u128 1usize"; + let expected = "- 1i8 - 1i16 - 1i32 - 1i64 - 1i128 - 1isize 1u8 1u16 1u32 1u64 1u128 1usize"; assert_eq!(expected, tokens.to_string()); } -- cgit v1.2.3 From f88f73bea86a5bf0fca9b181932a0eee83d6242c Mon Sep 17 00:00:00 2001 From: Chih-Hung Hsieh Date: Sun, 12 Jul 2020 14:30:36 -0700 Subject: Regenerate Android.bp with new cargo2android.py Test: make Change-Id: Ib4c105f7828fe2c2f7466b55d3892cfd6f3e10b3 --- Android.bp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Android.bp b/Android.bp index 2bf74a9..b157073 100644 --- a/Android.bp +++ b/Android.bp @@ -1,4 +1,4 @@ -// This file is generated by cargo2android.py. +// This file is generated by cargo2android.py --run --dependencies --host-first-multilib. rust_library_host { name: "libquote", @@ -12,9 +12,9 @@ rust_library_host { rustlibs: [ "libproc_macro2", ], - compile_multilib: "first", // added + compile_multilib: "first", } // dependent_library ["feature_list"] -// proc-macro2-1.0.9 "default,proc-macro" -// unicode-xid-0.2.0 "default" +// proc-macro2-1.0.18 "default,proc-macro" +// unicode-xid-0.2.1 "default" -- cgit v1.2.3 From 7f23594645a1638814329b216278967c3efb9c79 Mon Sep 17 00:00:00 2001 From: Chih-Hung Hsieh Date: Tue, 25 Aug 2020 20:49:25 -0700 Subject: Fix quote/METADATA Bug: 166324735 Test: make Change-Id: Ic37e42a7587b83f4d2ae8b2e46f24d05d256a863 --- METADATA | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/METADATA b/METADATA index d23a56e..879f0ef 100644 --- a/METADATA +++ b/METADATA @@ -6,8 +6,8 @@ third_party { value: "https://crates.io/crates/quote" } url { - type: GIT - value: "https://github.com/dtolnay/quote" + type: ARCHIVE + value: "https://static.crates.io/crates/quote/quote-1.0.7.crate" } version: "1.0.7" license_type: NOTICE -- cgit v1.2.3 From 0e8d95c6b2e6a032aba5614a2be76beed4630167 Mon Sep 17 00:00:00 2001 From: Chih-Hung Hsieh Date: Mon, 12 Oct 2020 00:51:04 -0700 Subject: Copy description from Cargo.toml to METADATA Test: make Change-Id: Id5892124ed5d5c28fea7e81e06dd885bb52fb8a0 --- METADATA | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/METADATA b/METADATA index 879f0ef..8e3e8e8 100644 --- a/METADATA +++ b/METADATA @@ -1,5 +1,5 @@ name: "quote" -description: "This crate provides the quote! macro for turning Rust syntax tree data structures into tokens of source code." +description: "Quasi-quoting macro quote!(...)" third_party { url { type: HOMEPAGE -- cgit v1.2.3 From f30cf2c335634a54ce1f2e3237f4ad202a53328f Mon Sep 17 00:00:00 2001 From: Jeff Vander Stoep Date: Thu, 5 Nov 2020 15:27:22 +0100 Subject: TEST_MAPPING: test dependers of this crate Bug: 168167373 Test: TH Change-Id: I52c4fe2256613579d3effaf49cf65dc0e71f0938 --- TEST_MAPPING | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 TEST_MAPPING diff --git a/TEST_MAPPING b/TEST_MAPPING new file mode 100644 index 0000000..7f523cc --- /dev/null +++ b/TEST_MAPPING @@ -0,0 +1,43 @@ +// Generated by cargo2android.py for tests in Android.bp +{ + "presubmit": [ + { + "host": true, + "name": "pin-project-internal_host_test_src_lib" + }, + { + "host": true, + "name": "futures-util_host_test_src_lib" + }, + { + "name": "futures-util_device_test_src_lib" + }, + { + "host": true, + "name": "proc-macro2_host_test_src_lib" + }, + { + "host": true, + "name": "structopt-derive_host_test_src_lib" + }, + { + "host": true, + "name": "tokio-macros_host_test_src_lib" + }, + { + "host": true, + "name": "proc-macro-error-attr_host_test_src_lib" + }, + { + "host": true, + "name": "libsqlite3-sys_host_test_src_lib" + }, + { + "name": "libsqlite3-sys_device_test_src_lib" + }, + { + "host": true, + "name": "syn-mid_host_test_src_lib" + } + ] +} -- cgit v1.2.3 From 4c4795d72b5c020bc64c0552f3b800b4c8595ea7 Mon Sep 17 00:00:00 2001 From: Haibo Huang Date: Tue, 22 Dec 2020 18:16:25 -0800 Subject: Upgrade rust/crates/quote to 1.0.8 Test: make Change-Id: Ib9916006424df7991cf6495e5dd15ade26ce5a80 --- .cargo_vcs_info.json | 2 +- Android.bp | 2 +- Cargo.toml | 4 ++-- Cargo.toml.orig | 4 ++-- METADATA | 8 ++++---- src/lib.rs | 4 ++-- src/runtime.rs | 18 +++++++----------- tests/test.rs | 28 ++++++++++++++-------------- tests/ui/not-repeatable.rs | 5 +++-- 9 files changed, 36 insertions(+), 39 deletions(-) diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json index e5a01fc..0471c91 100644 --- a/.cargo_vcs_info.json +++ b/.cargo_vcs_info.json @@ -1,5 +1,5 @@ { "git": { - "sha1": "9de44cd86e7feae4abba33c3392a2c37725527f9" + "sha1": "8294929b39387e6eab18173fef7d28f66071e973" } } diff --git a/Android.bp b/Android.bp index b157073..3cb8de7 100644 --- a/Android.bp +++ b/Android.bp @@ -16,5 +16,5 @@ rust_library_host { } // dependent_library ["feature_list"] -// proc-macro2-1.0.18 "default,proc-macro" +// proc-macro2-1.0.24 "default,proc-macro" // unicode-xid-0.2.1 "default" diff --git a/Cargo.toml b/Cargo.toml index c6dc281..8311673 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ [package] edition = "2018" name = "quote" -version = "1.0.7" +version = "1.0.8" authors = ["David Tolnay "] include = ["Cargo.toml", "src/**/*.rs", "tests/**/*.rs", "README.md", "LICENSE-APACHE", "LICENSE-MIT"] description = "Quasi-quoting macro quote!(...)" @@ -26,7 +26,7 @@ repository = "https://github.com/dtolnay/quote" [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] [dependencies.proc-macro2] -version = "1.0" +version = "1.0.20" default-features = false [dev-dependencies.rustversion] version = "1.0" diff --git a/Cargo.toml.orig b/Cargo.toml.orig index 6c418fe..4b4a185 100644 --- a/Cargo.toml.orig +++ b/Cargo.toml.orig @@ -1,6 +1,6 @@ [package] name = "quote" -version = "1.0.7" # don't forget to update html_root_url, version in readme for breaking changes +version = "1.0.8" # don't forget to update html_root_url, version in readme for breaking changes authors = ["David Tolnay "] license = "MIT OR Apache-2.0" description = "Quasi-quoting macro quote!(...)" @@ -13,7 +13,7 @@ include = ["Cargo.toml", "src/**/*.rs", "tests/**/*.rs", "README.md", "LICENSE-A edition = "2018" [dependencies] -proc-macro2 = { version = "1.0", default-features = false } +proc-macro2 = { version = "1.0.20", default-features = false } [dev-dependencies] rustversion = "1.0" diff --git a/METADATA b/METADATA index 8e3e8e8..54872cc 100644 --- a/METADATA +++ b/METADATA @@ -7,13 +7,13 @@ third_party { } url { type: ARCHIVE - value: "https://static.crates.io/crates/quote/quote-1.0.7.crate" + value: "https://static.crates.io/crates/quote/quote-1.0.8.crate" } - version: "1.0.7" + version: "1.0.8" license_type: NOTICE last_upgrade_date { year: 2020 - month: 7 - day: 10 + month: 12 + day: 22 } } diff --git a/src/lib.rs b/src/lib.rs index 6242909..fb09b5d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -82,7 +82,7 @@ #![forbid(unsafe_code)] // Quote types in rustdoc of other crates get linked to here. -#![doc(html_root_url = "https://docs.rs/quote/1.0.7")] +#![doc(html_root_url = "https://docs.rs/quote/1.0.8")] #[cfg(all( not(all(target_arch = "wasm32", target_os = "unknown")), @@ -564,7 +564,7 @@ macro_rules! quote { /// ``` /// /// If the assertion fails, the user will see an error like the following. The -/// input span of their type is hightlighted in the error. +/// input span of their type is highlighted in the error. /// /// ```text /// error[E0277]: the trait bound `*const (): std::marker::Sync` is not satisfied diff --git a/src/runtime.rs b/src/runtime.rs index fe72687..db3b6a9 100644 --- a/src/runtime.rs +++ b/src/runtime.rs @@ -345,19 +345,15 @@ pub fn mk_ident(id: &str, span: Option) -> Ident { // // FIXME: When `Ident::new_raw` becomes stable, this method should be // updated to call it when available. - match id.parse::() { - Ok(ts) => { - let mut iter = ts.into_iter(); - match (iter.next(), iter.next()) { - (Some(TokenTree::Ident(mut id)), None) => { - id.set_span(span); - id - } - _ => unreachable!("valid raw ident fails to parse"), - } + if let Ok(ts) = id.parse::() { + let mut iter = ts.into_iter(); + if let (Some(TokenTree::Ident(mut id)), None) = (iter.next(), iter.next()) { + id.set_span(span); + return id; } - Err(_) => unreachable!("valid raw ident fails to parse"), } + + panic!("not allowed as a raw identifier: `{}`", id); } // Adapts from `IdentFragment` to `fmt::Display` for use by the `format_ident!` diff --git a/tests/test.rs b/tests/test.rs index 6580bcd..d5a3490 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -26,8 +26,8 @@ fn test_quote_impl() { let expected = concat!( "impl < 'a , T : ToTokens > ToTokens for & 'a T { ", - "fn to_tokens ( & self , tokens : & mut TokenStream ) { ", - "( * * self ) . to_tokens ( tokens ) ", + "fn to_tokens (& self , tokens : & mut TokenStream) { ", + "(* * self) . to_tokens (tokens) ", "} ", "}" ); @@ -48,8 +48,8 @@ fn test_quote_spanned_impl() { let expected = concat!( "impl < 'a , T : ToTokens > ToTokens for & 'a T { ", - "fn to_tokens ( & self , tokens : & mut TokenStream ) { ", - "( * * self ) . to_tokens ( tokens ) ", + "fn to_tokens (& self , tokens : & mut TokenStream) { ", + "(* * self) . to_tokens (tokens) ", "} ", "}" ); @@ -62,7 +62,7 @@ fn test_substitution() { let x = X; let tokens = quote!(#x <#x> (#x) [#x] {#x}); - let expected = "X < X > ( X ) [ X ] { X }"; + let expected = "X < X > (X) [X] { X }"; assert_eq!(expected, tokens.to_string()); } @@ -118,10 +118,10 @@ fn test_advanced() { "phantom : :: std :: marker :: PhantomData < Cow < 'a , str > > , ", "} ", "impl < 'a , T > :: serde :: Serialize for SerializeWith < 'a , T > where T : Serialize { ", - "fn serialize < S > ( & self , s : & mut S ) -> Result < ( ) , S :: Error > ", + "fn serialize < S > (& self , s : & mut S) -> Result < () , S :: Error > ", "where S : :: serde :: Serializer ", "{ ", - "SomeTrait :: serialize_with ( self . value , s ) ", + "SomeTrait :: serialize_with (self . value , s) ", "} ", "} ", "SerializeWith { ", @@ -389,7 +389,7 @@ fn test_outer_line_comment() { let tokens = quote! { /// doc }; - let expected = "# [ doc = r\" doc\" ]"; + let expected = "# [doc = r\" doc\"]"; assert_eq!(expected, tokens.to_string()); } @@ -398,7 +398,7 @@ fn test_inner_line_comment() { let tokens = quote! { //! doc }; - let expected = "# ! [ doc = r\" doc\" ]"; + let expected = "# ! [doc = r\" doc\"]"; assert_eq!(expected, tokens.to_string()); } @@ -407,7 +407,7 @@ fn test_outer_block_comment() { let tokens = quote! { /** doc */ }; - let expected = "# [ doc = r\" doc \" ]"; + let expected = "# [doc = r\" doc \"]"; assert_eq!(expected, tokens.to_string()); } @@ -416,7 +416,7 @@ fn test_inner_block_comment() { let tokens = quote! { /*! doc */ }; - let expected = "# ! [ doc = r\" doc \" ]"; + let expected = "# ! [doc = r\" doc \"]"; assert_eq!(expected, tokens.to_string()); } @@ -425,7 +425,7 @@ fn test_outer_attr() { let tokens = quote! { #[inline] }; - let expected = "# [ inline ]"; + let expected = "# [inline]"; assert_eq!(expected, tokens.to_string()); } @@ -434,7 +434,7 @@ fn test_inner_attr() { let tokens = quote! { #![no_std] }; - let expected = "# ! [ no_std ]"; + let expected = "# ! [no_std]"; assert_eq!(expected, tokens.to_string()); } @@ -448,7 +448,7 @@ fn test_star_after_repetition() { )* *out = None; }; - let expected = "f ( '0' ) ; f ( '1' ) ; * out = None ;"; + let expected = "f ('0') ; f ('1') ; * out = None ;"; assert_eq!(expected, tokens.to_string()); } diff --git a/tests/ui/not-repeatable.rs b/tests/ui/not-repeatable.rs index ff18060..a8f0fe7 100644 --- a/tests/ui/not-repeatable.rs +++ b/tests/ui/not-repeatable.rs @@ -1,7 +1,8 @@ use quote::quote; -use std::net::Ipv4Addr; + +struct Ipv4Addr; fn main() { - let ip = Ipv4Addr::LOCALHOST; + let ip = Ipv4Addr; let _ = quote! { #(#ip)* }; } -- cgit v1.2.3 From 4f7803731ef66fea959c10fa9149037da2f6e386 Mon Sep 17 00:00:00 2001 From: Haibo Huang Date: Fri, 12 Feb 2021 00:27:13 -0800 Subject: Upgrade rust/crates/quote to 1.0.9 Test: make Change-Id: Ibbf4ed4276dd85754a3ea365b657d3cdf8919557 --- .cargo_vcs_info.json | 2 +- Cargo.toml | 2 +- Cargo.toml.orig | 2 +- METADATA | 10 ++++----- TEST_MAPPING | 63 ++++++++++++++++++++++++++++++++++++---------------- src/lib.rs | 9 ++++++-- 6 files changed, 59 insertions(+), 29 deletions(-) diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json index 0471c91..e15e24e 100644 --- a/.cargo_vcs_info.json +++ b/.cargo_vcs_info.json @@ -1,5 +1,5 @@ { "git": { - "sha1": "8294929b39387e6eab18173fef7d28f66071e973" + "sha1": "68ebadbc1b4242531c5a78fbba01c648bd58c8e7" } } diff --git a/Cargo.toml b/Cargo.toml index 8311673..411f943 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ [package] edition = "2018" name = "quote" -version = "1.0.8" +version = "1.0.9" authors = ["David Tolnay "] include = ["Cargo.toml", "src/**/*.rs", "tests/**/*.rs", "README.md", "LICENSE-APACHE", "LICENSE-MIT"] description = "Quasi-quoting macro quote!(...)" diff --git a/Cargo.toml.orig b/Cargo.toml.orig index 4b4a185..b95c6c5 100644 --- a/Cargo.toml.orig +++ b/Cargo.toml.orig @@ -1,6 +1,6 @@ [package] name = "quote" -version = "1.0.8" # don't forget to update html_root_url, version in readme for breaking changes +version = "1.0.9" # don't forget to update html_root_url, version in readme for breaking changes authors = ["David Tolnay "] license = "MIT OR Apache-2.0" description = "Quasi-quoting macro quote!(...)" diff --git a/METADATA b/METADATA index 54872cc..ee587f2 100644 --- a/METADATA +++ b/METADATA @@ -7,13 +7,13 @@ third_party { } url { type: ARCHIVE - value: "https://static.crates.io/crates/quote/quote-1.0.8.crate" + value: "https://static.crates.io/crates/quote/quote-1.0.9.crate" } - version: "1.0.8" + version: "1.0.9" license_type: NOTICE last_upgrade_date { - year: 2020 - month: 12 - day: 22 + year: 2021 + month: 2 + day: 12 } } diff --git a/TEST_MAPPING b/TEST_MAPPING index 7f523cc..a1620b5 100644 --- a/TEST_MAPPING +++ b/TEST_MAPPING @@ -1,43 +1,68 @@ -// Generated by cargo2android.py for tests in Android.bp +// Generated by update_crate_tests.py for tests that depend on this crate. { "presubmit": [ { - "host": true, - "name": "pin-project-internal_host_test_src_lib" + "name": "url_device_test_src_lib" }, { - "host": true, - "name": "futures-util_host_test_src_lib" + "name": "anyhow_device_test_tests_test_downcast" }, { - "name": "futures-util_device_test_src_lib" + "name": "anyhow_device_test_tests_test_repr" }, { - "host": true, - "name": "proc-macro2_host_test_src_lib" + "name": "keystore2_selinux_test" }, { - "host": true, - "name": "structopt-derive_host_test_src_lib" + "name": "anyhow_device_test_tests_test_fmt" }, { - "host": true, - "name": "tokio-macros_host_test_src_lib" + "name": "libm_device_test_src_lib" }, { - "host": true, - "name": "proc-macro-error-attr_host_test_src_lib" + "name": "anyhow_device_test_tests_test_convert" }, { - "host": true, - "name": "libsqlite3-sys_host_test_src_lib" + "name": "libsqlite3-sys_device_test_src_lib" }, { - "name": "libsqlite3-sys_device_test_src_lib" + "name": "anyhow_device_test_tests_test_source" + }, + { + "name": "unicode-bidi_device_test_src_lib" + }, + { + "name": "anyhow_device_test_src_lib" + }, + { + "name": "anyhow_device_test_tests_test_autotrait" + }, + { + "name": "anyhow_device_test_tests_test_context" + }, + { + "name": "anyhow_device_test_tests_test_macros" + }, + { + "name": "anyhow_device_test_tests_test_chain" + }, + { + "name": "anyhow_device_test_tests_test_ffi" + }, + { + "name": "serde_test_device_test_src_lib" + }, + { + "name": "futures-util_device_test_src_lib" + }, + { + "name": "keystore2_test" + }, + { + "name": "anyhow_device_test_tests_test_boxed" }, { - "host": true, - "name": "syn-mid_host_test_src_lib" + "name": "keystore2_crypto_test_rust" } ] } diff --git a/src/lib.rs b/src/lib.rs index fb09b5d..356e43a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -80,9 +80,14 @@ //! }; //! ``` -#![forbid(unsafe_code)] // Quote types in rustdoc of other crates get linked to here. -#![doc(html_root_url = "https://docs.rs/quote/1.0.8")] +#![doc(html_root_url = "https://docs.rs/quote/1.0.9")] +#![allow( + clippy::doc_markdown, + clippy::missing_errors_doc, + clippy::missing_panics_doc, + clippy::module_name_repetitions +)] #[cfg(all( not(all(target_arch = "wasm32", target_os = "unknown")), -- cgit v1.2.3 From c7d1b71820aeeecda03affe20b09191872e0fe77 Mon Sep 17 00:00:00 2001 From: Bob Badour Date: Fri, 12 Feb 2021 18:25:38 -0800 Subject: [LSC] Add LOCAL_LICENSE_KINDS to external/rust/crates/quote Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-MIT to: Android.bp Bug: 68860345 Bug: 151177513 Bug: 151953481 Test: m all Exempt-From-Owner-Approval: janitorial work Change-Id: Ie02affe834437fae32cb7f639d551b6bd0d329da --- Android.bp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/Android.bp b/Android.bp index 3cb8de7..c894868 100644 --- a/Android.bp +++ b/Android.bp @@ -1,5 +1,41 @@ // This file is generated by cargo2android.py --run --dependencies --host-first-multilib. +package { + default_applicable_licenses: ["external_rust_crates_quote_license"], +} + +// Added automatically by a large-scale-change that took the approach of +// 'apply every license found to every target'. While this makes sure we respect +// every license restriction, it may not be entirely correct. +// +// e.g. GPL in an MIT project might only apply to the contrib/ directory. +// +// Please consider splitting the single license below into multiple licenses, +// taking care not to lose any license_kind information, and overriding the +// default license using the 'licenses: [...]' property on targets as needed. +// +// For unused files, consider creating a 'fileGroup' with "//visibility:private" +// to attach the license to, and including a comment whether the files may be +// used in the current project. +// +// large-scale-change included anything that looked like it might be a license +// text as a license_text. e.g. LICENSE, NOTICE, COPYING etc. +// +// Please consider removing redundant or irrelevant files from 'license_text:'. +// See: http://go/android-license-faq +license { + name: "external_rust_crates_quote_license", + visibility: [":__subpackages__"], + license_kinds: [ + "SPDX-license-identifier-Apache-2.0", + "SPDX-license-identifier-MIT", + ], + license_text: [ + "LICENSE-APACHE", + "LICENSE-MIT", + ], +} + rust_library_host { name: "libquote", crate_name: "quote", -- cgit v1.2.3