Skip to content

Commit ed9227a

Browse files
committed
Make adjustments for comments
1 parent 5c8b3c3 commit ed9227a

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

src/librustc_mir/interpret/operand.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -593,9 +593,13 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M>
593593
let ty = self.monomorphize(val.ty)?;
594594
self.layout_of(ty)
595595
})?;
596-
let op = match val.val {
597-
ConstValue::Param(_) => return Err(EvalErrorKind::TooGeneric.into()),
596+
let val = match val.val {
597+
ConstValue::Param(_) => self.monomorphize(val)?.val,
598598
ConstValue::Infer(_) => bug!(),
599+
val => val,
600+
};
601+
let op = match val {
602+
ConstValue::Param(_) | ConstValue::Infer(_) => unreachable!(),
599603
ConstValue::ByRef(ptr, alloc) => {
600604
// We rely on mutability being set correctly in that allocation to prevent writes
601605
// where none should happen -- and for `static mut`, we copy on demand anyway.

src/librustc_mir/monomorphize/collector.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -467,14 +467,13 @@ fn check_type_length_limit<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
467467
{
468468
let type_length = instance.substs.types().flat_map(|ty| ty.walk()).count();
469469
let const_length = instance.substs.consts()
470-
.filter_map(|ct| {
471-
if let ty::LazyConst::Evaluated(ct) = ct {
472-
Some(ct.ty.walk())
473-
} else {
474-
None
475-
}
470+
.flat_map(|ct| {
471+
let ty = match ct {
472+
ty::LazyConst::Evaluated(ct) => ct.ty,
473+
ty::LazyConst::Unevaluated(def_id, _) => tcx.type_of(*def_id),
474+
};
475+
ty.walk()
476476
})
477-
.flatten()
478477
.count();
479478
debug!(" => type length={}, const length={}", type_length, const_length);
480479

0 commit comments

Comments
 (0)