Skip to content

Commit 7b9f0cb

Browse files
Type level consts can show up in MIR type checker
1 parent 45e08a5 commit 7b9f0cb

File tree

2 files changed

+7
-4
lines changed
  • compiler

2 files changed

+7
-4
lines changed

compiler/rustc_borrowck/src/type_check/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -349,8 +349,8 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
349349
let tcx = self.tcx();
350350
let maybe_uneval = match constant.const_ {
351351
Const::Ty(_, ct) => match ct.kind() {
352-
ty::ConstKind::Unevaluated(_) => {
353-
bug!("should not encounter unevaluated Const::Ty here, got {:?}", ct)
352+
ty::ConstKind::Unevaluated(uv) => {
353+
Some(UnevaluatedConst { def: uv.def, args: uv.args, promoted: None })
354354
}
355355
_ => None,
356356
},

compiler/rustc_mir_build/src/builder/expr/as_place.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -651,8 +651,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
651651
// though. FIXME: Do we really *need* to count this as a use?
652652
// Could partial array tracking work off something else instead?
653653
self.cfg.push_fake_read(block, source_info, FakeReadCause::ForIndex, place);
654-
let const_ = Const::from_ty_const(*len_const, self.tcx.types.usize, self.tcx);
655-
Operand::Constant(Box::new(ConstOperand { span, user_ty: None, const_ }))
654+
Operand::Constant(Box::new(ConstOperand {
655+
span,
656+
user_ty: None,
657+
const_: Const::Ty(self.tcx.types.usize, *len_const),
658+
}))
656659
}
657660
ty::Slice(_elem_ty) => {
658661
let ptr_or_ref = if let [PlaceElem::Deref] = place.projection[..]

0 commit comments

Comments
 (0)