]> git.lizzy.rs Git - rust.git/commitdiff
Rename TokenStream::empty to TokenStream::new
authorDavid Tolnay <dtolnay@gmail.com>
Sat, 26 May 2018 02:44:07 +0000 (19:44 -0700)
committerDavid Tolnay <dtolnay@gmail.com>
Sat, 26 May 2018 02:44:10 +0000 (19:44 -0700)
There is no precedent for the `empty` name -- we do not have
`Vec::empty` or `HashMap::empty` etc.

src/libproc_macro/lib.rs
src/libproc_macro/quote.rs
src/test/run-pass-fulldeps/proc-macro/auxiliary/modify-ast.rs
src/test/run-pass-fulldeps/proc-macro/auxiliary/not-joint.rs
src/test/ui-fulldeps/proc-macro/auxiliary/three-equals.rs

index bcab61680965afc3aa1b381216e5ac4d1aebaf30..35e2d6b23167e658391eb3a2f9b703f66410b08e 100644 (file)
@@ -93,7 +93,7 @@ impl !Sync for LexError {}
 impl TokenStream {
     /// Returns an empty `TokenStream` containing no token trees.
     #[unstable(feature = "proc_macro", issue = "38356")]
-    pub fn empty() -> TokenStream {
+    pub fn new() -> TokenStream {
         TokenStream(tokenstream::TokenStream::empty())
     }
 
index 390d4bc08682509e9352d442bceec6b7f66db4d8..c9d0bc1405fc01dcb17fcf6432590a0f32864786 100644 (file)
@@ -71,7 +71,7 @@ macro_rules! quote_tree {
 }
 
 macro_rules! quote {
-    () => { TokenStream::empty() };
+    () => { TokenStream::new() };
     ($($t:tt)*) => {
         [$(quote_tree!($t),)*].iter()
             .cloned()
@@ -104,7 +104,7 @@ fn quote(self) -> TokenStream {
 impl Quote for TokenStream {
     fn quote(self) -> TokenStream {
         if self.is_empty() {
-            return quote!(::TokenStream::empty());
+            return quote!(::TokenStream::new());
         }
         let mut after_dollar = false;
         let tokens = self.into_iter().filter_map(|tree| {
index fb505755792321d7d3b156816daca4d96d8a449a..c37682220da3358d40da13e9906f03d546cb164f 100644 (file)
@@ -26,7 +26,7 @@ pub fn assert1(_a: TokenStream, b: TokenStream) -> TokenStream {
 #[proc_macro_derive(Foo, attributes(foo))]
 pub fn assert2(a: TokenStream) -> TokenStream {
     assert_eq(a, "pub struct MyStructc { _a: i32, }".parse().unwrap());
-    TokenStream::empty()
+    TokenStream::new()
 }
 
 fn assert_eq(a: TokenStream, b: TokenStream) {
index 062a914534f13c13082a9d87ba82675d9042f95d..a640fabe04fac7f0a0bccc31f9e814c9f1126335 100644 (file)
 #[proc_macro]
 pub fn tokens(input: TokenStream) -> TokenStream {
     assert_nothing_joint(input);
-    TokenStream::empty()
+    TokenStream::new()
 }
 
 #[proc_macro_attribute]
 pub fn nothing(_: TokenStream, input: TokenStream) -> TokenStream {
     assert_nothing_joint(input);
-    TokenStream::empty()
+    TokenStream::new()
 }
 
 fn assert_nothing_joint(s: TokenStream) {
index 8dfb9cb4fb751b6e971fa4d24379b36597db4b6a..5b8fcab0baaa70903b112f1c93918adf843f7752 100644 (file)
@@ -50,7 +50,7 @@ fn parse(input: TokenStream) -> Result<(), Diagnostic> {
 pub fn three_equals(input: TokenStream) -> TokenStream {
     if let Err(diag) = parse(input) {
         diag.emit();
-        return TokenStream::empty();
+        return TokenStream::new();
     }
 
     "3".parse().unwrap()