]> git.lizzy.rs Git - rust.git/commitdiff
Remove some type information.
authorCamille GILLOT <gillot.camille@gmail.com>
Tue, 3 Dec 2019 21:54:44 +0000 (22:54 +0100)
committerCamille GILLOT <gillot.camille@gmail.com>
Thu, 26 Dec 2019 22:40:13 +0000 (23:40 +0100)
src/librustc/hir/lowering.rs
src/librustc/hir/lowering/expr.rs
src/librustc/hir/lowering/item.rs

index c6e2cf4cc9c929324972c4bf08c8eef0e34b3686..432d550a24031da709ecfbb6d5f99d2cbd395249 100644 (file)
@@ -2041,8 +2041,8 @@ fn lower_parenthesized_parameter_data(
                 },
             )
         });
-        let ty = ty.map(|ty| -> &'hir hir::Ty { self.arena.alloc(ty.into_inner()) });
-        let init = l.init.as_ref().map(|e| -> &'hir hir::Expr<'hir> { self.lower_expr(e) });
+        let ty = ty.map(|ty| &*self.arena.alloc(ty.into_inner()));
+        let init = l.init.as_ref().map(|e| self.lower_expr(e));
         (
             hir::Local {
                 hir_id: self.lower_node_id(l.id),
index 8061cf432812c5fb5a270f11da6b7920ce8906ed..8a9614c6cb2c00e9fdb254fccc4ad51389ab4471 100644 (file)
@@ -157,21 +157,19 @@ pub(super) fn lower_expr_mut(&mut self, e: &Expr) -> hir::Expr<'hir> {
                 hir::ExprKind::Path(qpath)
             }
             ExprKind::Break(opt_label, ref opt_expr) => {
-                let opt_expr =
-                    opt_expr.as_ref().map(|x| -> &'hir hir::Expr<'hir> { self.lower_expr(x) });
+                let opt_expr = opt_expr.as_ref().map(|x| self.lower_expr(x));
                 hir::ExprKind::Break(self.lower_jump_destination(e.id, opt_label), opt_expr)
             }
             ExprKind::Continue(opt_label) => {
                 hir::ExprKind::Continue(self.lower_jump_destination(e.id, opt_label))
             }
             ExprKind::Ret(ref e) => {
-                let e = e.as_ref().map(|x| -> &'hir hir::Expr<'hir> { self.lower_expr(x) });
+                let e = e.as_ref().map(|x| self.lower_expr(x));
                 hir::ExprKind::Ret(e)
             }
             ExprKind::InlineAsm(ref asm) => self.lower_expr_asm(asm),
             ExprKind::Struct(ref path, ref fields, ref maybe_expr) => {
-                let maybe_expr =
-                    maybe_expr.as_ref().map(|x| -> &'hir hir::Expr<'hir> { self.lower_expr(x) });
+                let maybe_expr = maybe_expr.as_ref().map(|x| self.lower_expr(x));
                 hir::ExprKind::Struct(
                     self.arena.alloc(self.lower_qpath(
                         e.id,
@@ -431,12 +429,10 @@ fn lower_expr_try_block(&mut self, body: &Block) -> hir::ExprKind<'hir> {
             );
 
             // Final expression of the block (if present) or `()` with span at the end of block
-            let tail_expr = block.expr.take().map_or_else(
-                || -> &'hir hir::Expr<'hir> {
-                    this.expr_unit(this.sess.source_map().end_point(try_span))
-                },
-                |x: &'hir hir::Expr<'hir>| x,
-            );
+            let tail_expr = block
+                .expr
+                .take()
+                .unwrap_or_else(|| this.expr_unit(this.sess.source_map().end_point(try_span)));
 
             let ok_wrapped_span =
                 this.mark_span_with_reason(DesugaringKind::TryBlock, tail_expr.span, None);
index ff7a67fb0ba7b43d878f58b4cff051f95a21b26c..0157e89c96b04a22d747ed2a550a317160ecf9fc 100644 (file)
@@ -797,8 +797,10 @@ fn lower_trait_item(&mut self, i: &AssocItem) -> hir::TraitItem<'hir> {
                 (generics, hir::TraitItemKind::Method(sig, hir::TraitMethod::Provided(body_id)))
             }
             AssocItemKind::TyAlias(ref bounds, ref default) => {
-                let ty = default.as_ref().map(|x| -> &'hir hir::Ty {
-                    self.arena.alloc(self.lower_ty(x, ImplTraitContext::disallowed()).into_inner())
+                let ty = default.as_ref().map(|x| {
+                    &*self
+                        .arena
+                        .alloc(self.lower_ty(x, ImplTraitContext::disallowed()).into_inner())
                 });
                 let generics = self.lower_generics(&i.generics, ImplTraitContext::disallowed());
                 let kind = hir::TraitItemKind::Type(