Skip to content

Commit 63ecba7

Browse files
author
Lukas Markeffsky
committed
fix ensure_monomorphic_enough
1 parent 4bb6ec0 commit 63ecba7

File tree

1 file changed

+3
-41
lines changed
  • compiler/rustc_const_eval/src/interpret

1 file changed

+3
-41
lines changed

compiler/rustc_const_eval/src/interpret/util.rs

Lines changed: 3 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
use std::ops::ControlFlow;
2-
31
use rustc_hir::def_id::LocalDefId;
42
use rustc_middle::mir;
53
use rustc_middle::mir::interpret::{AllocInit, Allocation, InterpResult, Pointer};
64
use rustc_middle::ty::layout::TyAndLayout;
7-
use rustc_middle::ty::{
8-
self, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor,
9-
};
5+
use rustc_middle::ty::{TyCtxt, TypeVisitable, TypeVisitableExt};
106
use tracing::debug;
117

128
use super::{InterpCx, MPlaceTy, MemoryKind, interp_ok, throw_inval};
@@ -20,44 +16,10 @@ where
2016
T: TypeVisitable<TyCtxt<'tcx>>,
2117
{
2218
debug!("ensure_monomorphic_enough: ty={:?}", ty);
23-
if !ty.has_param() {
24-
return interp_ok(());
25-
}
26-
27-
struct FoundParam;
28-
struct UsedParamsNeedInstantiationVisitor {}
29-
30-
impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for UsedParamsNeedInstantiationVisitor {
31-
type Result = ControlFlow<FoundParam>;
32-
33-
fn visit_ty(&mut self, ty: Ty<'tcx>) -> Self::Result {
34-
if !ty.has_param() {
35-
return ControlFlow::Continue(());
36-
}
37-
38-
match *ty.kind() {
39-
ty::Param(_) => ControlFlow::Break(FoundParam),
40-
ty::Closure(..) | ty::CoroutineClosure(..) | ty::Coroutine(..) | ty::FnDef(..) => {
41-
ControlFlow::Continue(())
42-
}
43-
_ => ty.super_visit_with(self),
44-
}
45-
}
46-
47-
fn visit_const(&mut self, c: ty::Const<'tcx>) -> Self::Result {
48-
match c.kind() {
49-
ty::ConstKind::Param(..) => ControlFlow::Break(FoundParam),
50-
_ => c.super_visit_with(self),
51-
}
52-
}
53-
}
54-
55-
let mut vis = UsedParamsNeedInstantiationVisitor {};
56-
if matches!(ty.visit_with(&mut vis), ControlFlow::Break(FoundParam)) {
19+
if ty.has_param() {
5720
throw_inval!(TooGeneric);
58-
} else {
59-
interp_ok(())
6021
}
22+
interp_ok(())
6123
}
6224

6325
impl<'tcx> InterpretationResult<'tcx> for mir::interpret::ConstAllocation<'tcx> {

0 commit comments

Comments
 (0)