Skip to content

Commit 1dfc3e7

Browse files
committed
Get the type of a local from local_decls in schedule_drop
Passing around a separate type is unnecessary and error-prone.
1 parent d046ffd commit 1dfc3e7

File tree

5 files changed

+9
-17
lines changed

5 files changed

+9
-17
lines changed

src/librustc_mir/build/expr/as_rvalue.rs

-2
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
128128
expr_span,
129129
scope,
130130
result,
131-
expr.ty,
132131
);
133132
}
134133

@@ -569,7 +568,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
569568
upvar_span,
570569
temp_lifetime,
571570
temp,
572-
upvar_ty,
573571
);
574572
}
575573

src/librustc_mir/build/expr/as_temp.rs

-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
103103
expr_span,
104104
temp_lifetime,
105105
temp,
106-
expr_ty,
107106
DropKind::Storage,
108107
);
109108
}

src/librustc_mir/build/matches/mod.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -535,21 +535,18 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
535535
kind: StatementKind::StorageLive(local_id),
536536
},
537537
);
538-
let var_ty = self.local_decls[local_id].ty;
539538
let region_scope = self.hir.region_scope_tree.var_scope(var.local_id);
540-
self.schedule_drop(span, region_scope, local_id, var_ty, DropKind::Storage);
539+
self.schedule_drop(span, region_scope, local_id, DropKind::Storage);
541540
Place::from(local_id)
542541
}
543542

544543
pub fn schedule_drop_for_binding(&mut self, var: HirId, span: Span, for_guard: ForGuard) {
545544
let local_id = self.var_local_id(var, for_guard);
546-
let var_ty = self.local_decls[local_id].ty;
547545
let region_scope = self.hir.region_scope_tree.var_scope(var.local_id);
548546
self.schedule_drop(
549547
span,
550548
region_scope,
551549
local_id,
552-
var_ty,
553550
DropKind::Value,
554551
);
555552
}

src/librustc_mir/build/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -829,12 +829,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
829829
// Function arguments always get the first Local indices after the return place
830830
let local = Local::new(index + 1);
831831
let place = Place::from(local);
832-
let &ArgInfo(ty, opt_ty_info, arg_opt, ref self_binding) = arg_info;
832+
let &ArgInfo(_, opt_ty_info, arg_opt, ref self_binding) = arg_info;
833833

834834
// Make sure we drop (parts of) the argument even when not matched on.
835835
self.schedule_drop(
836836
arg_opt.as_ref().map_or(ast_body.span, |arg| arg.pat.span),
837-
argument_scope, local, ty, DropKind::Value,
837+
argument_scope, local, DropKind::Value,
838838
);
839839

840840
if let Some(arg) = arg_opt {

src/librustc_mir/build/scope.rs

+6-8
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ should go to.
8585
use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder, CFG};
8686
use crate::hair::{Expr, ExprRef, LintLevel};
8787
use rustc::middle::region;
88-
use rustc::ty::Ty;
8988
use rustc::hir;
9089
use rustc::mir::*;
9190
use syntax_pos::{DUMMY_SP, Span};
@@ -173,11 +172,11 @@ struct BreakableScope<'tcx> {
173172
region_scope: region::Scope,
174173
/// Where the body of the loop begins. `None` if block
175174
continue_block: Option<BasicBlock>,
176-
/// Block to branch into when the loop or block terminates (either by being `break`-en out
177-
/// from, or by having its condition to become false)
175+
/// Block to branch into when the loop or block terminates (either by being
176+
/// `break`-en out from, or by having its condition to become false)
178177
break_block: BasicBlock,
179-
/// The destination of the loop/block expression itself (i.e., where to put the result of a
180-
/// `break` expression)
178+
/// The destination of the loop/block expression itself (i.e., where to put
179+
/// the result of a `break` expression)
181180
break_destination: Place<'tcx>,
182181
}
183182

@@ -728,10 +727,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
728727
span: Span,
729728
region_scope: region::Scope,
730729
local: Local,
731-
place_ty: Ty<'tcx>,
732730
) {
733-
self.schedule_drop(span, region_scope, local, place_ty, DropKind::Storage);
734-
self.schedule_drop(span, region_scope, local, place_ty, DropKind::Value);
731+
self.schedule_drop(span, region_scope, local, DropKind::Storage);
732+
self.schedule_drop(span, region_scope, local, DropKind::Value);
735733
}
736734

737735
/// Indicates that `place` should be dropped on exit from

0 commit comments

Comments
 (0)