syntax: Rename P::unwrap into P::into_inner

This commit is contained in:
Vadim Petrochenkov 2017-12-17 02:21:29 +03:00
parent 3bee2b44cf
commit a4aa26aaa0
7 changed files with 17 additions and 17 deletions

View file

@ -2063,9 +2063,9 @@ impl Clean<Type> for hir::Ty {
for (i, ty_param) in generics.ty_params.iter().enumerate() {
let ty_param_def = Def::TyParam(cx.tcx.hir.local_def_id(ty_param.id));
if let Some(ty) = provided_params.types.get(i).cloned() {
ty_substs.insert(ty_param_def, ty.unwrap().clean(cx));
ty_substs.insert(ty_param_def, ty.into_inner().clean(cx));
} else if let Some(default) = ty_param.default.clone() {
ty_substs.insert(ty_param_def, default.unwrap().clean(cx));
ty_substs.insert(ty_param_def, default.into_inner().clean(cx));
}
}
for (i, lt_param) in generics.lifetimes.iter().enumerate() {

View file

@ -284,13 +284,13 @@ impl<'a> fold::Folder for StripUnconfigured<'a> {
}
fn fold_expr(&mut self, expr: P<ast::Expr>) -> P<ast::Expr> {
let mut expr = self.configure_expr(expr).unwrap();
let mut expr = self.configure_expr(expr).into_inner();
expr.node = self.configure_expr_kind(expr.node);
P(fold::noop_fold_expr(expr, self))
}
fn fold_opt_expr(&mut self, expr: P<ast::Expr>) -> Option<P<ast::Expr>> {
let mut expr = configure!(self, expr).unwrap();
let mut expr = configure!(self, expr).into_inner();
expr.node = self.configure_expr_kind(expr.node);
Some(P(fold::noop_fold_expr(expr, self)))
}

View file

@ -85,14 +85,14 @@ impl Annotatable {
pub fn expect_trait_item(self) -> ast::TraitItem {
match self {
Annotatable::TraitItem(i) => i.unwrap(),
Annotatable::TraitItem(i) => i.into_inner(),
_ => panic!("expected Item")
}
}
pub fn expect_impl_item(self) -> ast::ImplItem {
match self {
Annotatable::ImplItem(i) => i.unwrap(),
Annotatable::ImplItem(i) => i.into_inner(),
_ => panic!("expected Item")
}
}

View file

@ -242,7 +242,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
tokens: None,
})));
match self.expand(krate_item).make_items().pop().map(P::unwrap) {
match self.expand(krate_item).make_items().pop().map(P::into_inner) {
Some(ast::Item { attrs, node: ast::ItemKind::Mod(module), .. }) => {
krate.attrs = attrs;
krate.module = module;
@ -504,8 +504,8 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
AttrProcMacro(ref mac) => {
let item_tok = TokenTree::Token(DUMMY_SP, Token::interpolated(match item {
Annotatable::Item(item) => token::NtItem(item),
Annotatable::TraitItem(item) => token::NtTraitItem(item.unwrap()),
Annotatable::ImplItem(item) => token::NtImplItem(item.unwrap()),
Annotatable::TraitItem(item) => token::NtTraitItem(item.into_inner()),
Annotatable::ImplItem(item) => token::NtImplItem(item.into_inner()),
})).into();
let tok_result = mac.expand(self.cx, attr.span, attr.tokens, item_tok);
self.parse_expansion(tok_result, kind, &attr.path, attr.span)
@ -863,7 +863,7 @@ pub fn find_attr_invoc(attrs: &mut Vec<ast::Attribute>) -> Option<ast::Attribute
impl<'a, 'b> Folder for InvocationCollector<'a, 'b> {
fn fold_expr(&mut self, expr: P<ast::Expr>) -> P<ast::Expr> {
let mut expr = self.cfg.configure_expr(expr).unwrap();
let mut expr = self.cfg.configure_expr(expr).into_inner();
expr.node = self.cfg.configure_expr_kind(expr.node);
if let ast::ExprKind::Mac(mac) = expr.node {
@ -875,7 +875,7 @@ impl<'a, 'b> Folder for InvocationCollector<'a, 'b> {
}
fn fold_opt_expr(&mut self, expr: P<ast::Expr>) -> Option<P<ast::Expr>> {
let mut expr = configure!(self, expr).unwrap();
let mut expr = configure!(self, expr).into_inner();
expr.node = self.cfg.configure_expr_kind(expr.node);
if let ast::ExprKind::Mac(mac) = expr.node {
@ -906,7 +906,7 @@ impl<'a, 'b> Folder for InvocationCollector<'a, 'b> {
};
let (mac, style, attrs) = if let StmtKind::Mac(mac) = stmt.node {
mac.unwrap()
mac.into_inner()
} else {
// The placeholder expander gives ids to statements, so we avoid folding the id here.
let ast::Stmt { id, node, span } = stmt;
@ -1056,7 +1056,7 @@ impl<'a, 'b> Folder for InvocationCollector<'a, 'b> {
fn fold_ty(&mut self, ty: P<ast::Ty>) -> P<ast::Ty> {
let ty = match ty.node {
ast::TyKind::Mac(_) => ty.unwrap(),
ast::TyKind::Mac(_) => ty.into_inner(),
_ => return fold::noop_fold_ty(ty, self),
};

View file

@ -1456,7 +1456,7 @@ impl<'a> Parser<'a> {
self.expect(&token::CloseDelim(token::Paren))?;
if ts.len() == 1 && !last_comma {
let ty = ts.into_iter().nth(0).unwrap().unwrap();
let ty = ts.into_iter().nth(0).unwrap().into_inner();
let maybe_bounds = allow_plus && self.token == token::BinOp(token::Plus);
match ty.node {
// `(TY_BOUND_NOPAREN) + BOUND + ...`.
@ -6077,7 +6077,7 @@ impl<'a> Parser<'a> {
fn parse_item_(&mut self, attrs: Vec<Attribute>,
macros_allowed: bool, attributes_allowed: bool) -> PResult<'a, Option<P<Item>>> {
maybe_whole!(self, NtItem, |item| {
let mut item = item.unwrap();
let mut item = item.into_inner();
let mut attrs = attrs;
mem::swap(&mut item.attrs, &mut attrs);
item.attrs.extend(attrs);

View file

@ -68,7 +68,7 @@ impl<T: 'static> P<T> {
f(*self.ptr)
}
/// Equivalent to and_then(|x| x)
pub fn unwrap(self) -> T {
pub fn into_inner(self) -> T {
*self.ptr
}

View file

@ -141,7 +141,7 @@ impl<'a> fold::Folder for TestHarnessGenerator<'a> {
}
}
let mut item = i.unwrap();
let mut item = i.into_inner();
// We don't want to recurse into anything other than mods, since
// mods or tests inside of functions will break things
if let ast::ItemKind::Mod(module) = item.node {