Skip to content

Commit

Permalink
nits
Browse files Browse the repository at this point in the history
  • Loading branch information
b-naber committed Sep 15, 2022
1 parent 6af8fb7 commit d77248e
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 19 deletions.
5 changes: 5 additions & 0 deletions compiler/rustc_borrowck/src/renumber.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ where
})
}

// FIXME(valtrees): This function is necessary because `fold_regions`
// panics for mir constants in the visitor.
//
// Once `visit_mir_constant` is removed we can also remove this function
// and just use `renumber_regions`.
fn renumber_regions_in_mir_constant<'tcx>(
infcx: &InferCtxt<'_, 'tcx>,
value: ConstantKind<'tcx>,
Expand Down
6 changes: 1 addition & 5 deletions compiler/rustc_borrowck/src/type_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1816,12 +1816,8 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
fn check_operand(&mut self, op: &Operand<'tcx>, location: Location) {
if let Operand::Constant(constant) = op {
let maybe_uneval = match constant.literal {
ConstantKind::Ty(ct) => match ct.kind() {
ty::ConstKind::Unevaluated(uv) => Some(uv.expand()),
_ => None,
},
ConstantKind::Val(..) | ConstantKind::Ty(_) => None,
ConstantKind::Unevaluated(uv, _) => Some(uv),
ConstantKind::Val(..) => None,
};

if let Some(uv) = maybe_uneval {
Expand Down
12 changes: 1 addition & 11 deletions compiler/rustc_codegen_cranelift/src/constant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,17 +117,7 @@ pub(crate) fn codegen_constant<'tcx>(
constant: &Constant<'tcx>,
) -> CValue<'tcx> {
let (const_val, ty) = match fx.monomorphize(constant.literal) {
ConstantKind::Ty(const_) => match const_.kind() {
ConstKind::Value(valtree) => {
(fx.tcx.valtree_to_const_val((const_.ty(), valtree)), const_.ty())
}
ConstKind::Unevaluated(_) => bug!("expected constant to be evaluated at this stage"),
ConstKind::Param(_)
| ConstKind::Infer(_)
| ConstKind::Bound(_, _)
| ConstKind::Placeholder(_)
| ConstKind::Error(_) => unreachable!("{:?}", const_),
},
ConstantKind::Ty(const_) => unreachable!("{:?}", const_),
ConstantKind::Unevaluated(ty::Unevaluated { def, substs, promoted }, ty)
if fx.tcx.is_static(def.did) =>
{
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_middle/src/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2643,6 +2643,7 @@ impl<'tcx> Display for ConstantKind<'tcx> {
match *self {
ConstantKind::Ty(c) => pretty_print_const(c, fmt, true),
ConstantKind::Val(val, ty) => pretty_print_const_value(val, ty, fmt, true),
// FIXME(valtrees): Correctly print mir constants.
ConstantKind::Unevaluated(..) => {
fmt.write_str("_")?;
Ok(())
Expand Down
4 changes: 1 addition & 3 deletions compiler/rustc_mir_transform/src/const_prop_lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
// Promoteds must lint and not error as the user didn't ask for them
true
}
ConstantKind::Unevaluated(_, ty) | ConstantKind::Val(_, ty) => {
ty.needs_subst()
}
ConstantKind::Unevaluated(..) | ConstantKind::Val(..) => c.needs_subst(),
};
if lint_only {
// Out of backwards compatibility we cannot report hard errors in unused
Expand Down

0 comments on commit d77248e

Please sign in to comment.