Skip to content

Commit d86deda

Browse files
committed
Constants carry their type with them
1 parent ae7c585 commit d86deda

File tree

4 files changed

+5
-9
lines changed

4 files changed

+5
-9
lines changed

src/librustc/ty/sty.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2060,10 +2060,9 @@ impl<'tcx> Const<'tcx> {
20602060
pub fn unwrap_bits(
20612061
&self,
20622062
tcx: TyCtxt<'_, '_, '_>,
2063-
ty: ParamEnvAnd<'tcx, Ty<'tcx>>,
20642063
) -> u128 {
2065-
self.assert_bits(tcx, ty).unwrap_or_else(||
2066-
bug!("expected bits of {}, got {:#?}", ty.value, self))
2064+
self.assert_bits(tcx, ParamEnv::empty().and(self.ty)).unwrap_or_else(||
2065+
bug!("expected bits of {}, got {:#?}", self.ty, self))
20672066
}
20682067

20692068
#[inline]

src/librustc_mir/build/matches/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -978,15 +978,14 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
978978
// available
979979
match test.kind {
980980
TestKind::SwitchInt {
981-
switch_ty,
982981
ref mut options,
983982
ref mut indices,
983+
..
984984
} => {
985985
for candidate in candidates.iter() {
986986
if !self.add_cases_to_switch(
987987
&match_pair.place,
988988
candidate,
989-
switch_ty,
990989
options,
991990
indices,
992991
) {

src/librustc_mir/build/matches/test.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
112112
pub fn add_cases_to_switch<'pat>(&mut self,
113113
test_place: &Place<'tcx>,
114114
candidate: &Candidate<'pat, 'tcx>,
115-
switch_ty: Ty<'tcx>,
116115
options: &mut Vec<u128>,
117116
indices: &mut FxHashMap<&'tcx ty::Const<'tcx>, usize>)
118117
-> bool
@@ -124,10 +123,9 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
124123

125124
match *match_pair.pattern.kind {
126125
PatternKind::Constant { value } => {
127-
let switch_ty = ty::ParamEnv::empty().and(switch_ty);
128126
indices.entry(value)
129127
.or_insert_with(|| {
130-
options.push(value.unwrap_bits(self.hir.tcx(), switch_ty));
128+
options.push(value.unwrap_bits(self.hir.tcx()));
131129
options.len() - 1
132130
});
133131
true

src/librustc_mir/hair/pattern/_match.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1364,7 +1364,7 @@ fn slice_pat_covered_by_constructor<'tcx>(
13641364
{
13651365
match pat.kind {
13661366
box PatternKind::Constant { value } => {
1367-
let b = value.unwrap_bits(tcx, ty::ParamEnv::empty().and(pat.ty));
1367+
let b = value.unwrap_bits(tcx);
13681368
assert_eq!(b as u8 as u128, b);
13691369
if b as u8 != *ch {
13701370
return Ok(false);

0 commit comments

Comments
 (0)