Skip to content

Commit 4667439

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 fc7c38f commit 4667439

File tree

6 files changed

+6
-17
lines changed

6 files changed

+6
-17
lines changed

src/librustc_mir/build/expr/as_rvalue.rs

Lines changed: 0 additions & 2 deletions
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

Lines changed: 0 additions & 2 deletions
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
}
@@ -117,7 +116,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
117116
expr_span,
118117
temp_lifetime,
119118
temp,
120-
expr_ty,
121119
DropKind::Value,
122120
);
123121
}

src/librustc_mir/build/matches/mod.rs

Lines changed: 1 addition & 4 deletions
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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -812,12 +812,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
812812
// Function arguments always get the first Local indices after the return place
813813
let local = Local::new(index + 1);
814814
let place = Place::from(local);
815-
let &ArgInfo(ty, opt_ty_info, arg_opt, ref self_binding) = arg_info;
815+
let &ArgInfo(_, opt_ty_info, arg_opt, ref self_binding) = arg_info;
816816

817817
// Make sure we drop (parts of) the argument even when not matched on.
818818
self.schedule_drop(
819819
arg_opt.as_ref().map_or(ast_body.span, |arg| arg.pat.span),
820-
argument_scope, local, ty, DropKind::Value,
820+
argument_scope, local, DropKind::Value,
821821
);
822822

823823
if let Some(arg) = arg_opt {

src/librustc_mir/build/scope.rs

Lines changed: 2 additions & 4 deletions
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::{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};
@@ -483,10 +482,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
483482
span: Span,
484483
region_scope: region::Scope,
485484
local: Local,
486-
place_ty: Ty<'tcx>,
487485
) {
488-
self.schedule_drop(span, region_scope, local, place_ty, DropKind::Storage);
489-
self.schedule_drop(span, region_scope, local, place_ty, DropKind::Value);
486+
self.schedule_drop(span, region_scope, local, DropKind::Storage);
487+
self.schedule_drop(span, region_scope, local, DropKind::Value);
490488
}
491489

492490
// Other

src/librustc_mir/build/scope/stack.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use crate::hair::Expr;
44
use rustc::middle::region;
55
use rustc::mir::{BasicBlock, Local, Operand, Place, PlaceBase, SourceScope};
66
use rustc::mir::{SourceInfo, Statement, StatementKind, START_BLOCK, TerminatorKind};
7-
use rustc::ty::Ty;
87
use syntax_pos::Span;
98
use rustc_data_structures::fx::FxHashMap;
109
use std::mem;
@@ -301,11 +300,10 @@ impl<'tcx> Builder<'_, 'tcx> {
301300
span: Span,
302301
region_scope: region::Scope,
303302
local: Local,
304-
place_ty: Ty<'tcx>,
305303
drop_kind: DropKind,
306304
) {
307305
match drop_kind {
308-
DropKind::Value => if !self.hir.needs_drop(place_ty) { return },
306+
DropKind::Value => if !self.hir.needs_drop(self.local_decls[local].ty) { return },
309307
DropKind::Storage => {
310308
if local.index() <= self.arg_count {
311309
span_bug!(

0 commit comments

Comments
 (0)