]> git.lizzy.rs Git - rust.git/commitdiff
syntax: Rename `P::unwrap` into `P::into_inner`
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>
Sat, 16 Dec 2017 23:21:29 +0000 (02:21 +0300)
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>
Sat, 16 Dec 2017 23:21:29 +0000 (02:21 +0300)
src/librustdoc/clean/mod.rs
src/libsyntax/config.rs
src/libsyntax/ext/base.rs
src/libsyntax/ext/expand.rs
src/libsyntax/parse/parser.rs
src/libsyntax/ptr.rs
src/libsyntax/test.rs

index 91908de98a65d89a1117adb9218cbd3a22e45c82..5499351e9514b50e0f0bcf24cfa503058186b056 100644 (file)
@@ -2063,9 +2063,9 @@ fn clean(&self, cx: &DocContext) -> Type {
                         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() {
index 0909eec62691b39f582327f477b6f5914f5c11e9..fc82357455b914ed5385e4ba67caed692fa21f2e 100644 (file)
@@ -284,13 +284,13 @@ fn fold_item_kind(&mut self, item: ast::ItemKind) -> ast::ItemKind {
     }
 
     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)))
     }
index bb1b7da7dbab2c4f9d2a0628b2c277325adb4c36..0eb4ec23d08a20b15d43a75a1002e7a1aa0208f7 100644 (file)
@@ -85,14 +85,14 @@ pub fn map_item_or<F, G>(self, mut f: F, mut or: G) -> 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")
         }
     }
index edf3d40be94a682235b94a7fcdc434eabe0155fa..f2346ed19de429f446a285f96b64eac3f69e0b75 100644 (file)
@@ -242,7 +242,7 @@ pub fn expand_crate(&mut self, mut krate: ast::Crate) -> ast::Crate {
             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 @@ fn expand_attr_invoc(&mut self, invoc: Invocation, ext: Rc<SyntaxExtension>) ->
             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 @@ fn fold_expr(&mut self, expr: P<ast::Expr>) -> P<ast::Expr> {
     }
 
     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 @@ fn fold_stmt(&mut self, stmt: ast::Stmt) -> SmallVector<ast::Stmt> {
         };
 
         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 @@ fn fold_impl_item(&mut self, item: ast::ImplItem) -> SmallVector<ast::ImplItem>
 
     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),
         };
 
index 2158c4a4fe428712c6a518c19a4c2ece7175f943..09a65046e20f0897463983859c2929ff3423cbd1 100644 (file)
@@ -1456,7 +1456,7 @@ fn parse_ty_common(&mut self, allow_plus: bool) -> PResult<'a, P<Ty>> {
             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 @@ fn parse_opt_abi(&mut self) -> PResult<'a, Option<abi::Abi>> {
     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);
index d51ff9860ac8495ec85c8095fabd15536d1da03a..25d916af77d28a8690da64856ba9893925da5234 100644 (file)
@@ -68,7 +68,7 @@ pub fn and_then<U, F>(self, f: F) -> U where
         f(*self.ptr)
     }
     /// Equivalent to and_then(|x| x)
-    pub fn unwrap(self) -> T {
+    pub fn into_inner(self) -> T {
         *self.ptr
     }
 
index 9f097169d973e6ef9aeaa58e06a6bb61435a1dc3..694a9c1f47252ca8b6cb9bd4c879db5476e64eaa 100644 (file)
@@ -141,7 +141,7 @@ fn fold_item(&mut self, i: P<ast::Item>) -> SmallVector<P<ast::Item>> {
             }
         }
 
-        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 {