Skip to content

Commit

Permalink
Remove default()
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e committed May 29, 2019
1 parent da7f1cf commit 906b11e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions core/src/auto_enum/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ use std::cell::RefCell;
use proc_macro2::{Ident, TokenStream};
use quote::ToTokens;
use smallvec::{smallvec, SmallVec};
use syn::{Attribute, Expr, ExprCall, ExprPath, ItemEnum, Macro, Result};
use syn::{token, Attribute, Expr, ExprCall, ExprPath, ItemEnum, Macro, Result};

use crate::utils::{default, ident, path, Stack};
use crate::utils::{ident, path, Stack};

use super::{
visitor::{Dummy, FindTry, Visitor},
Expand Down Expand Up @@ -262,7 +262,7 @@ impl Builder {
qself: None,
path: path(segments),
})),
paren_token: default(),
paren_token: token::Paren::default(),
args: Some(expr).into_iter().collect(),
})
}
Expand Down
4 changes: 2 additions & 2 deletions core/src/auto_enum/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use syn::{
*,
};

use crate::utils::{default, expr_block, replace_block, replace_expr, OptionExt};
use crate::utils::{expr_block, replace_block, replace_expr, OptionExt};

use super::*;

Expand Down Expand Up @@ -209,7 +209,7 @@ impl VisitLast<()> for ExprMatch {

self.arms.iter_mut().try_for_each(|arm| {
if !skip(arm, cx)? {
arm.comma = Some(default());
arm.comma = Some(token::Comma::default());
replace_expr(&mut *arm.body, |x| cx.next_expr(x));
}

Expand Down
16 changes: 8 additions & 8 deletions core/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use std::mem;
use proc_macro2::{Ident, Span, TokenStream};
use smallvec::SmallVec;
use syn::{
punctuated::Punctuated, Block, Expr, ExprBlock, ExprTuple, ExprVerbatim, Path, PathSegment,
Stmt,
punctuated::Punctuated, token, Block, Expr, ExprBlock, ExprTuple, ExprVerbatim, Path,
PathSegment, Stmt,
};

pub(crate) type Stack<T> = SmallVec<[T; 4]>;
Expand Down Expand Up @@ -41,10 +41,6 @@ impl<T> VecExt<T> for Vec<T> {
// =============================================================================
// Functions

pub(crate) fn default<T: Default>() -> T {
T::default()
}

pub(crate) fn ident<S: AsRef<str>>(s: S) -> Ident {
Ident::new(s.as_ref(), Span::call_site())
}
Expand All @@ -54,15 +50,19 @@ pub(crate) fn path<I: IntoIterator<Item = PathSegment>>(segments: I) -> Path {
}

pub(crate) fn block(stmts: Vec<Stmt>) -> Block {
Block { brace_token: default(), stmts }
Block { brace_token: token::Brace::default(), stmts }
}

pub(crate) fn expr_block(block: Block) -> Expr {
Expr::Block(ExprBlock { attrs: Vec::new(), label: None, block })
}

pub(crate) fn unit() -> Expr {
Expr::Tuple(ExprTuple { attrs: Vec::new(), paren_token: default(), elems: Punctuated::new() })
Expr::Tuple(ExprTuple {
attrs: Vec::new(),
paren_token: token::Paren::default(),
elems: Punctuated::new(),
})
}

pub(crate) fn replace_expr<F: FnOnce(Expr) -> Expr>(this: &mut Expr, op: F) {
Expand Down

0 comments on commit 906b11e

Please sign in to comment.