Skip to content

Commit 84b2e14

Browse files
authored
Rollup merge of #51073 - dtolnay:empty, r=alexcrichton
Rename TokenStream::empty to TokenStream::new There is no precedent for the `empty` name -- we do not have `Vec::empty` or `HashMap::empty` etc. I would propose landing this but reflecting it in a non-breaking release of proc-macro2 that provides both `new` and a deprecated `empty` constructor. Tracking issue: #38356 r? @alexcrichton
2 parents 5089ebc + a49bc9c commit 84b2e14

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed

src/libproc_macro/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ impl !Sync for LexError {}
9393
impl TokenStream {
9494
/// Returns an empty `TokenStream` containing no token trees.
9595
#[unstable(feature = "proc_macro", issue = "38356")]
96-
pub fn empty() -> TokenStream {
96+
pub fn new() -> TokenStream {
9797
TokenStream(tokenstream::TokenStream::empty())
9898
}
9999

src/libproc_macro/quote.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ macro_rules! quote_tree {
7171
}
7272

7373
macro_rules! quote {
74-
() => { TokenStream::empty() };
74+
() => { TokenStream::new() };
7575
($($t:tt)*) => {
7676
[$(quote_tree!($t),)*].iter()
7777
.cloned()
@@ -104,7 +104,7 @@ impl<T: Quote> Quote for Option<T> {
104104
impl Quote for TokenStream {
105105
fn quote(self) -> TokenStream {
106106
if self.is_empty() {
107-
return quote!(::TokenStream::empty());
107+
return quote!(::TokenStream::new());
108108
}
109109
let mut after_dollar = false;
110110
let tokens = self.into_iter().filter_map(|tree| {

src/test/run-pass-fulldeps/proc-macro/auxiliary/modify-ast.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub fn assert1(_a: TokenStream, b: TokenStream) -> TokenStream {
2626
#[proc_macro_derive(Foo, attributes(foo))]
2727
pub fn assert2(a: TokenStream) -> TokenStream {
2828
assert_eq(a, "pub struct MyStructc { _a: i32, }".parse().unwrap());
29-
TokenStream::empty()
29+
TokenStream::new()
3030
}
3131

3232
fn assert_eq(a: TokenStream, b: TokenStream) {

src/test/run-pass-fulldeps/proc-macro/auxiliary/not-joint.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ use proc_macro::*;
2020
#[proc_macro]
2121
pub fn tokens(input: TokenStream) -> TokenStream {
2222
assert_nothing_joint(input);
23-
TokenStream::empty()
23+
TokenStream::new()
2424
}
2525

2626
#[proc_macro_attribute]
2727
pub fn nothing(_: TokenStream, input: TokenStream) -> TokenStream {
2828
assert_nothing_joint(input);
29-
TokenStream::empty()
29+
TokenStream::new()
3030
}
3131

3232
fn assert_nothing_joint(s: TokenStream) {

src/test/ui-fulldeps/proc-macro/auxiliary/three-equals.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ fn parse(input: TokenStream) -> Result<(), Diagnostic> {
5050
pub fn three_equals(input: TokenStream) -> TokenStream {
5151
if let Err(diag) = parse(input) {
5252
diag.emit();
53-
return TokenStream::empty();
53+
return TokenStream::new();
5454
}
5555

5656
"3".parse().unwrap()

0 commit comments

Comments
 (0)