Skip to content

Commit

Permalink
Rename TokenStream::empty to TokenStream::new
Browse files Browse the repository at this point in the history
There is no precedent for the `empty` name -- we do not have
`Vec::empty` or `HashMap::empty` etc.
  • Loading branch information
dtolnay committed May 26, 2018
1 parent 07c415c commit a49bc9c
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/libproc_macro/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}

Expand Down
4 changes: 2 additions & 2 deletions src/libproc_macro/quote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ macro_rules! quote_tree {
}

macro_rules! quote {
() => { TokenStream::empty() };
() => { TokenStream::new() };
($($t:tt)*) => {
[$(quote_tree!($t),)*].iter()
.cloned()
Expand Down Expand Up @@ -104,7 +104,7 @@ impl<T: Quote> Quote for Option<T> {
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| {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions src/test/run-pass-fulldeps/proc-macro/auxiliary/not-joint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ use proc_macro::*;
#[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) {
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui-fulldeps/proc-macro/auxiliary/three-equals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit a49bc9c

Please sign in to comment.