the Const::eval_bits methods don't need to be given the Ty
This commit is contained in:
parent
0692db1a90
commit
a2374e65aa
13 changed files with 35 additions and 48 deletions
|
@ -100,7 +100,7 @@ impl<'tcx, 'body> ParseCtxt<'tcx, 'body> {
|
|||
expected: "constant pattern".to_string(),
|
||||
});
|
||||
};
|
||||
values.push(value.eval_bits(self.tcx, self.param_env, arm.pattern.ty));
|
||||
values.push(value.eval_bits(self.tcx, self.param_env));
|
||||
targets.push(self.parse_block(arm.body)?);
|
||||
}
|
||||
|
||||
|
@ -301,7 +301,7 @@ impl<'tcx, 'body> ParseCtxt<'tcx, 'body> {
|
|||
| ExprKind::NonHirLiteral { .. }
|
||||
| ExprKind::ConstBlock { .. } => Ok({
|
||||
let value = as_constant_inner(expr, |_| None, self.tcx);
|
||||
value.literal.eval_bits(self.tcx, self.param_env, value.ty())
|
||||
value.literal.eval_bits(self.tcx, self.param_env)
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
|
|
@ -1622,9 +1622,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
// may want to add cases based on the candidates that are
|
||||
// available
|
||||
match test.kind {
|
||||
TestKind::SwitchInt { switch_ty, ref mut options } => {
|
||||
TestKind::SwitchInt { switch_ty: _, ref mut options } => {
|
||||
for candidate in candidates.iter() {
|
||||
if !self.add_cases_to_switch(&match_place, candidate, switch_ty, options) {
|
||||
if !self.add_cases_to_switch(&match_place, candidate, options) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,7 +85,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
&mut self,
|
||||
test_place: &PlaceBuilder<'tcx>,
|
||||
candidate: &Candidate<'pat, 'tcx>,
|
||||
switch_ty: Ty<'tcx>,
|
||||
options: &mut FxIndexMap<ConstantKind<'tcx>, u128>,
|
||||
) -> bool {
|
||||
let Some(match_pair) = candidate.match_pairs.iter().find(|mp| mp.place == *test_place)
|
||||
|
@ -95,9 +94,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
|
||||
match match_pair.pattern.kind {
|
||||
PatKind::Constant { value } => {
|
||||
options
|
||||
.entry(value)
|
||||
.or_insert_with(|| value.eval_bits(self.tcx, self.param_env, switch_ty));
|
||||
options.entry(value).or_insert_with(|| value.eval_bits(self.tcx, self.param_env));
|
||||
true
|
||||
}
|
||||
PatKind::Variant { .. } => {
|
||||
|
|
|
@ -146,7 +146,7 @@ impl IntRange {
|
|||
valtree.unwrap_leaf().to_bits(target_size).ok()
|
||||
},
|
||||
// This is a more general form of the previous case.
|
||||
_ => value.try_eval_bits(tcx, param_env, ty),
|
||||
_ => value.try_eval_bits(tcx, param_env),
|
||||
}?;
|
||||
|
||||
let val = val ^ bias;
|
||||
|
@ -1379,8 +1379,8 @@ impl<'p, 'tcx> DeconstructedPat<'p, 'tcx> {
|
|||
let ty = lo.ty();
|
||||
ctor = if let Some(int_range) = IntRange::from_range(
|
||||
cx.tcx,
|
||||
lo.eval_bits(cx.tcx, cx.param_env, lo.ty()),
|
||||
hi.eval_bits(cx.tcx, cx.param_env, hi.ty()),
|
||||
lo.eval_bits(cx.tcx, cx.param_env),
|
||||
hi.eval_bits(cx.tcx, cx.param_env),
|
||||
ty,
|
||||
&end,
|
||||
) {
|
||||
|
|
|
@ -131,7 +131,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
|
|||
if let Some(hir::Expr { kind: hir::ExprKind::Lit(lit), .. }) = lo_expr
|
||||
&& let rustc_ast::ast::LitKind::Int(val, _) = lit.node
|
||||
{
|
||||
if lo.eval_bits(self.tcx, self.param_env, ty) != val {
|
||||
if lo.eval_bits(self.tcx, self.param_env) != val {
|
||||
lower_overflow = true;
|
||||
self.tcx.sess.emit_err(LiteralOutOfRange { span: lit.span, ty, max: max() });
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
|
|||
if let Some(hir::Expr { kind: hir::ExprKind::Lit(lit), .. }) = hi_expr
|
||||
&& let rustc_ast::ast::LitKind::Int(val, _) = lit.node
|
||||
{
|
||||
if hi.eval_bits(self.tcx, self.param_env, ty) != val {
|
||||
if hi.eval_bits(self.tcx, self.param_env) != val {
|
||||
higher_overflow = true;
|
||||
self.tcx.sess.emit_err(LiteralOutOfRange { span: lit.span, ty, max: max() });
|
||||
}
|
||||
|
@ -162,7 +162,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
|
|||
if let Some(hir::Expr { kind: hir::ExprKind::Lit(lit), .. }) = lo_expr
|
||||
&& let rustc_ast::ast::LitKind::Int(val, _) = lit.node
|
||||
{
|
||||
if lo.eval_bits(self.tcx, self.param_env, ty) != val {
|
||||
if lo.eval_bits(self.tcx, self.param_env) != val {
|
||||
lower_overflow = true;
|
||||
self.tcx.sess.emit_err(LiteralOutOfRange { span: lit.span, ty, max: max() });
|
||||
}
|
||||
|
@ -170,7 +170,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
|
|||
if let Some(hir::Expr { kind: hir::ExprKind::Lit(lit), .. }) = hi_expr
|
||||
&& let rustc_ast::ast::LitKind::Int(val, _) = lit.node
|
||||
{
|
||||
if hi.eval_bits(self.tcx, self.param_env, ty) != val {
|
||||
if hi.eval_bits(self.tcx, self.param_env) != val {
|
||||
higher_overflow = true;
|
||||
self.tcx.sess.emit_err(LiteralOutOfRange { span: lit.span, ty, max: max() });
|
||||
}
|
||||
|
@ -865,8 +865,8 @@ pub(crate) fn compare_const_vals<'tcx>(
|
|||
},
|
||||
}
|
||||
|
||||
let a = a.eval_bits(tcx, param_env, ty);
|
||||
let b = b.eval_bits(tcx, param_env, ty);
|
||||
let a = a.eval_bits(tcx, param_env);
|
||||
let b = b.eval_bits(tcx, param_env);
|
||||
|
||||
use rustc_apfloat::Float;
|
||||
match *ty.kind() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue