Remove some type information.

This commit is contained in:
Camille GILLOT 2019-12-03 22:54:44 +01:00
parent 1984ec5d20
commit 75632c5ffe
3 changed files with 13 additions and 15 deletions

View File

@ -2041,8 +2041,8 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
},
)
});
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),

View File

@ -157,21 +157,19 @@ impl<'hir> LoweringContext<'_, '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 @@ impl<'hir> LoweringContext<'_, '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);

View File

@ -797,8 +797,10 @@ impl<'hir> LoweringContext<'_, '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(