Skip to content

Commit 21c6133

Browse files
committed
Remove the TypedConstVal
Replace it with ConstUsize instead, which is more appropriate; we are not using the rest of the TypedConstVal anyway
1 parent 3a14e9e commit 21c6133

File tree

8 files changed

+11
-54
lines changed

8 files changed

+11
-54
lines changed

src/librustc/mir/mod.rs

+1-14
Original file line numberDiff line numberDiff line change
@@ -983,7 +983,7 @@ pub enum Rvalue<'tcx> {
983983
Use(Operand<'tcx>),
984984

985985
/// [x; 32]
986-
Repeat(Operand<'tcx>, TypedConstVal<'tcx>),
986+
Repeat(Operand<'tcx>, ConstUsize),
987987

988988
/// &x or &mut x
989989
Ref(&'tcx Region, BorrowKind, Lvalue<'tcx>),
@@ -1203,19 +1203,6 @@ pub struct Constant<'tcx> {
12031203
pub literal: Literal<'tcx>,
12041204
}
12051205

1206-
#[derive(Clone, RustcEncodable, RustcDecodable)]
1207-
pub struct TypedConstVal<'tcx> {
1208-
pub ty: Ty<'tcx>,
1209-
pub span: Span,
1210-
pub value: ConstUsize,
1211-
}
1212-
1213-
impl<'tcx> Debug for TypedConstVal<'tcx> {
1214-
fn fmt(&self, fmt: &mut Formatter) -> fmt::Result {
1215-
write!(fmt, "const {}", ConstInt::Usize(self.value))
1216-
}
1217-
}
1218-
12191206
newtype_index!(Promoted, "promoted");
12201207

12211208
#[derive(Clone, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)]

src/librustc/mir/tcx.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ impl<'tcx> Rvalue<'tcx> {
140140
Rvalue::Use(ref operand) => operand.ty(mir, tcx),
141141
Rvalue::Repeat(ref operand, ref count) => {
142142
let op_ty = operand.ty(mir, tcx);
143-
let count = count.value.as_u64(tcx.sess.target.uint_type);
143+
let count = count.as_u64(tcx.sess.target.uint_type);
144144
assert_eq!(count as usize as u64, count);
145145
tcx.mk_array(op_ty, count as usize)
146146
}

src/librustc/mir/visit.rs

+2-22
Original file line numberDiff line numberDiff line change
@@ -235,12 +235,6 @@ macro_rules! make_mir_visitor {
235235
self.super_const_usize(const_usize);
236236
}
237237

238-
fn visit_typed_const_val(&mut self,
239-
val: & $($mutability)* TypedConstVal<'tcx>,
240-
location: Location) {
241-
self.super_typed_const_val(val, location);
242-
}
243-
244238
fn visit_local_decl(&mut self,
245239
local_decl: & $($mutability)* LocalDecl<'tcx>) {
246240
self.super_local_decl(local_decl);
@@ -467,9 +461,9 @@ macro_rules! make_mir_visitor {
467461
}
468462

469463
Rvalue::Repeat(ref $($mutability)* value,
470-
ref $($mutability)* typed_const_val) => {
464+
ref $($mutability)* length) => {
471465
self.visit_operand(value, location);
472-
self.visit_typed_const_val(typed_const_val, location);
466+
self.visit_const_usize(length, location);
473467
}
474468

475469
Rvalue::Ref(r, bk, ref $($mutability)* path) => {
@@ -648,20 +642,6 @@ macro_rules! make_mir_visitor {
648642
self.visit_literal(literal, location);
649643
}
650644

651-
fn super_typed_const_val(&mut self,
652-
constant: & $($mutability)* TypedConstVal<'tcx>,
653-
location: Location) {
654-
let TypedConstVal {
655-
ref $($mutability)* span,
656-
ref $($mutability)* ty,
657-
ref $($mutability)* value,
658-
} = *constant;
659-
660-
self.visit_span(span);
661-
self.visit_ty(ty);
662-
self.visit_const_usize(value, location);
663-
}
664-
665645
fn super_literal(&mut self,
666646
literal: & $($mutability)* Literal<'tcx>,
667647
location: Location) {

src/librustc_mir/hair/cx/expr.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -602,11 +602,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
602602

603603
ExprKind::Repeat {
604604
value: v.to_ref(),
605-
count: TypedConstVal {
606-
ty: cx.tcx.types.usize,
607-
span: c.span,
608-
value: count
609-
}
605+
count: count,
610606
}
611607
}
612608
hir::ExprRet(ref v) => ExprKind::Return { value: v.to_ref() },

src/librustc_mir/hair/mod.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
//! unit-tested and separated from the Rust source and compiler data
1515
//! structures.
1616
17-
use rustc::mir::{BinOp, BorrowKind, Field, Literal, UnOp, TypedConstVal};
17+
use rustc_const_math::ConstUsize;
18+
use rustc::mir::{BinOp, BorrowKind, Field, Literal, UnOp};
1819
use rustc::hir::def_id::DefId;
1920
use rustc::middle::region::CodeExtent;
2021
use rustc::ty::subst::Substs;
@@ -219,7 +220,7 @@ pub enum ExprKind<'tcx> {
219220
},
220221
Repeat {
221222
value: ExprRef<'tcx>,
222-
count: TypedConstVal<'tcx>,
223+
count: ConstUsize,
223224
},
224225
Array {
225226
fields: Vec<ExprRef<'tcx>>,

src/librustc_passes/mir_stats.rs

+1-8
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use rustc::mir::{Constant, Literal, Location, LocalDecl};
1919
use rustc::mir::{Lvalue, LvalueElem, LvalueProjection};
2020
use rustc::mir::{Mir, Operand, ProjectionElem};
2121
use rustc::mir::{Rvalue, SourceInfo, Statement, StatementKind};
22-
use rustc::mir::{Terminator, TerminatorKind, TypedConstVal, VisibilityScope, VisibilityScopeData};
22+
use rustc::mir::{Terminator, TerminatorKind, VisibilityScope, VisibilityScopeData};
2323
use rustc::mir::visit as mir_visit;
2424
use rustc::mir::visit::Visitor;
2525
use rustc::ty::{ClosureSubsts, TyCtxt};
@@ -297,13 +297,6 @@ impl<'a, 'tcx> mir_visit::Visitor<'tcx> for StatCollector<'a, 'tcx> {
297297
self.super_const_usize(const_usize);
298298
}
299299

300-
fn visit_typed_const_val(&mut self,
301-
val: &TypedConstVal<'tcx>,
302-
location: Location) {
303-
self.record("TypedConstVal", val);
304-
self.super_typed_const_val(val, location);
305-
}
306-
307300
fn visit_local_decl(&mut self,
308301
local_decl: &LocalDecl<'tcx>) {
309302
self.record("LocalDecl", local_decl);

src/librustc_trans/mir/constant.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ impl<'a, 'tcx> MirConstContext<'a, 'tcx> {
529529

530530
mir::Rvalue::Repeat(ref elem, ref count) => {
531531
let elem = self.const_operand(elem, span)?;
532-
let size = count.value.as_u64(tcx.sess.target.uint_type);
532+
let size = count.as_u64(tcx.sess.target.uint_type);
533533
let fields = vec![elem.llval; size as usize];
534534
self.const_array(dest_ty, &fields)
535535
}

src/librustc_trans/mir/rvalue.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> {
9595

9696
mir::Rvalue::Repeat(ref elem, ref count) => {
9797
let tr_elem = self.trans_operand(&bcx, elem);
98-
let size = count.value.as_u64(bcx.tcx().sess.target.uint_type);
98+
let size = count.as_u64(bcx.tcx().sess.target.uint_type);
9999
let size = C_uint(bcx.ccx, size);
100100
let base = base::get_dataptr(&bcx, dest.llval);
101101
tvec::slice_for_each(&bcx, base, tr_elem.ty, size, |bcx, llslot| {

0 commit comments

Comments
 (0)