Get the type of a local from local_decls in schedule_drop
Passing around a separate type is unnecessary and error-prone.
This commit is contained in:
parent
d046ffddc4
commit
1dfc3e7962
5 changed files with 9 additions and 17 deletions
|
|
@ -128,7 +128,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
expr_span,
|
||||
scope,
|
||||
result,
|
||||
expr.ty,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -569,7 +568,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
upvar_span,
|
||||
temp_lifetime,
|
||||
temp,
|
||||
upvar_ty,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -103,7 +103,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
expr_span,
|
||||
temp_lifetime,
|
||||
temp,
|
||||
expr_ty,
|
||||
DropKind::Storage,
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -535,21 +535,18 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
kind: StatementKind::StorageLive(local_id),
|
||||
},
|
||||
);
|
||||
let var_ty = self.local_decls[local_id].ty;
|
||||
let region_scope = self.hir.region_scope_tree.var_scope(var.local_id);
|
||||
self.schedule_drop(span, region_scope, local_id, var_ty, DropKind::Storage);
|
||||
self.schedule_drop(span, region_scope, local_id, DropKind::Storage);
|
||||
Place::from(local_id)
|
||||
}
|
||||
|
||||
pub fn schedule_drop_for_binding(&mut self, var: HirId, span: Span, for_guard: ForGuard) {
|
||||
let local_id = self.var_local_id(var, for_guard);
|
||||
let var_ty = self.local_decls[local_id].ty;
|
||||
let region_scope = self.hir.region_scope_tree.var_scope(var.local_id);
|
||||
self.schedule_drop(
|
||||
span,
|
||||
region_scope,
|
||||
local_id,
|
||||
var_ty,
|
||||
DropKind::Value,
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -829,12 +829,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
// Function arguments always get the first Local indices after the return place
|
||||
let local = Local::new(index + 1);
|
||||
let place = Place::from(local);
|
||||
let &ArgInfo(ty, opt_ty_info, arg_opt, ref self_binding) = arg_info;
|
||||
let &ArgInfo(_, opt_ty_info, arg_opt, ref self_binding) = arg_info;
|
||||
|
||||
// Make sure we drop (parts of) the argument even when not matched on.
|
||||
self.schedule_drop(
|
||||
arg_opt.as_ref().map_or(ast_body.span, |arg| arg.pat.span),
|
||||
argument_scope, local, ty, DropKind::Value,
|
||||
argument_scope, local, DropKind::Value,
|
||||
);
|
||||
|
||||
if let Some(arg) = arg_opt {
|
||||
|
|
|
|||
|
|
@ -85,7 +85,6 @@ should go to.
|
|||
use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder, CFG};
|
||||
use crate::hair::{Expr, ExprRef, LintLevel};
|
||||
use rustc::middle::region;
|
||||
use rustc::ty::Ty;
|
||||
use rustc::hir;
|
||||
use rustc::mir::*;
|
||||
use syntax_pos::{DUMMY_SP, Span};
|
||||
|
|
@ -173,11 +172,11 @@ struct BreakableScope<'tcx> {
|
|||
region_scope: region::Scope,
|
||||
/// Where the body of the loop begins. `None` if block
|
||||
continue_block: Option<BasicBlock>,
|
||||
/// Block to branch into when the loop or block terminates (either by being `break`-en out
|
||||
/// from, or by having its condition to become false)
|
||||
/// Block to branch into when the loop or block terminates (either by being
|
||||
/// `break`-en out from, or by having its condition to become false)
|
||||
break_block: BasicBlock,
|
||||
/// The destination of the loop/block expression itself (i.e., where to put the result of a
|
||||
/// `break` expression)
|
||||
/// The destination of the loop/block expression itself (i.e., where to put
|
||||
/// the result of a `break` expression)
|
||||
break_destination: Place<'tcx>,
|
||||
}
|
||||
|
||||
|
|
@ -728,10 +727,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
span: Span,
|
||||
region_scope: region::Scope,
|
||||
local: Local,
|
||||
place_ty: Ty<'tcx>,
|
||||
) {
|
||||
self.schedule_drop(span, region_scope, local, place_ty, DropKind::Storage);
|
||||
self.schedule_drop(span, region_scope, local, place_ty, DropKind::Value);
|
||||
self.schedule_drop(span, region_scope, local, DropKind::Storage);
|
||||
self.schedule_drop(span, region_scope, local, DropKind::Value);
|
||||
}
|
||||
|
||||
/// Indicates that `place` should be dropped on exit from
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue