Skip to content

Commit d77248e

Browse files
committed
nits
1 parent 6af8fb7 commit d77248e

File tree

5 files changed

+9
-19
lines changed

5 files changed

+9
-19
lines changed

compiler/rustc_borrowck/src/renumber.rs

+5
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ where
3838
})
3939
}
4040

41+
// FIXME(valtrees): This function is necessary because `fold_regions`
42+
// panics for mir constants in the visitor.
43+
//
44+
// Once `visit_mir_constant` is removed we can also remove this function
45+
// and just use `renumber_regions`.
4146
fn renumber_regions_in_mir_constant<'tcx>(
4247
infcx: &InferCtxt<'_, 'tcx>,
4348
value: ConstantKind<'tcx>,

compiler/rustc_borrowck/src/type_check/mod.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -1816,12 +1816,8 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
18161816
fn check_operand(&mut self, op: &Operand<'tcx>, location: Location) {
18171817
if let Operand::Constant(constant) = op {
18181818
let maybe_uneval = match constant.literal {
1819-
ConstantKind::Ty(ct) => match ct.kind() {
1820-
ty::ConstKind::Unevaluated(uv) => Some(uv.expand()),
1821-
_ => None,
1822-
},
1819+
ConstantKind::Val(..) | ConstantKind::Ty(_) => None,
18231820
ConstantKind::Unevaluated(uv, _) => Some(uv),
1824-
ConstantKind::Val(..) => None,
18251821
};
18261822

18271823
if let Some(uv) = maybe_uneval {

compiler/rustc_codegen_cranelift/src/constant.rs

+1-11
Original file line numberDiff line numberDiff line change
@@ -117,17 +117,7 @@ pub(crate) fn codegen_constant<'tcx>(
117117
constant: &Constant<'tcx>,
118118
) -> CValue<'tcx> {
119119
let (const_val, ty) = match fx.monomorphize(constant.literal) {
120-
ConstantKind::Ty(const_) => match const_.kind() {
121-
ConstKind::Value(valtree) => {
122-
(fx.tcx.valtree_to_const_val((const_.ty(), valtree)), const_.ty())
123-
}
124-
ConstKind::Unevaluated(_) => bug!("expected constant to be evaluated at this stage"),
125-
ConstKind::Param(_)
126-
| ConstKind::Infer(_)
127-
| ConstKind::Bound(_, _)
128-
| ConstKind::Placeholder(_)
129-
| ConstKind::Error(_) => unreachable!("{:?}", const_),
130-
},
120+
ConstantKind::Ty(const_) => unreachable!("{:?}", const_),
131121
ConstantKind::Unevaluated(ty::Unevaluated { def, substs, promoted }, ty)
132122
if fx.tcx.is_static(def.did) =>
133123
{

compiler/rustc_middle/src/mir/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2643,6 +2643,7 @@ impl<'tcx> Display for ConstantKind<'tcx> {
26432643
match *self {
26442644
ConstantKind::Ty(c) => pretty_print_const(c, fmt, true),
26452645
ConstantKind::Val(val, ty) => pretty_print_const_value(val, ty, fmt, true),
2646+
// FIXME(valtrees): Correctly print mir constants.
26462647
ConstantKind::Unevaluated(..) => {
26472648
fmt.write_str("_")?;
26482649
Ok(())

compiler/rustc_mir_transform/src/const_prop_lint.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -307,9 +307,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
307307
// Promoteds must lint and not error as the user didn't ask for them
308308
true
309309
}
310-
ConstantKind::Unevaluated(_, ty) | ConstantKind::Val(_, ty) => {
311-
ty.needs_subst()
312-
}
310+
ConstantKind::Unevaluated(..) | ConstantKind::Val(..) => c.needs_subst(),
313311
};
314312
if lint_only {
315313
// Out of backwards compatibility we cannot report hard errors in unused

0 commit comments

Comments
 (0)