From a4aa26aaa076ce732f2c26803d9d48459aa2046a Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Sun, 17 Dec 2017 02:21:29 +0300 Subject: [PATCH] syntax: Rename `P::unwrap` into `P::into_inner` --- src/librustdoc/clean/mod.rs | 4 ++-- src/libsyntax/config.rs | 4 ++-- src/libsyntax/ext/base.rs | 4 ++-- src/libsyntax/ext/expand.rs | 14 +++++++------- src/libsyntax/parse/parser.rs | 4 ++-- src/libsyntax/ptr.rs | 2 +- src/libsyntax/test.rs | 2 +- 7 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 91908de98a6..5499351e951 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -2063,9 +2063,9 @@ impl Clean 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() { diff --git a/src/libsyntax/config.rs b/src/libsyntax/config.rs index 0909eec6269..fc82357455b 100644 --- a/src/libsyntax/config.rs +++ b/src/libsyntax/config.rs @@ -284,13 +284,13 @@ impl<'a> fold::Folder for StripUnconfigured<'a> { } fn fold_expr(&mut self, expr: P) -> P { - 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) -> Option> { - 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))) } diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index bb1b7da7dba..0eb4ec23d08 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -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") } } diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index edf3d40be94..f2346ed19de 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -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) -> Option Folder for InvocationCollector<'a, 'b> { fn fold_expr(&mut self, expr: P) -> P { - 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) -> Option> { - 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) -> P { let ty = match ty.node { - ast::TyKind::Mac(_) => ty.unwrap(), + ast::TyKind::Mac(_) => ty.into_inner(), _ => return fold::noop_fold_ty(ty, self), }; diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 2158c4a4fe4..09a65046e20 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -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, macros_allowed: bool, attributes_allowed: bool) -> PResult<'a, Option>> { 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); diff --git a/src/libsyntax/ptr.rs b/src/libsyntax/ptr.rs index d51ff9860ac..25d916af77d 100644 --- a/src/libsyntax/ptr.rs +++ b/src/libsyntax/ptr.rs @@ -68,7 +68,7 @@ impl P { f(*self.ptr) } /// Equivalent to and_then(|x| x) - pub fn unwrap(self) -> T { + pub fn into_inner(self) -> T { *self.ptr } diff --git a/src/libsyntax/test.rs b/src/libsyntax/test.rs index 9f097169d97..694a9c1f472 100644 --- a/src/libsyntax/test.rs +++ b/src/libsyntax/test.rs @@ -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 {