1
- use std:: ops:: ControlFlow ;
2
-
3
1
use rustc_hir:: def_id:: LocalDefId ;
4
2
use rustc_middle:: mir;
5
3
use rustc_middle:: mir:: interpret:: { AllocInit , Allocation , InterpResult , Pointer } ;
6
4
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 } ;
10
6
use tracing:: debug;
11
7
12
8
use super :: { InterpCx , MPlaceTy , MemoryKind , interp_ok, throw_inval} ;
@@ -20,44 +16,10 @@ where
20
16
T : TypeVisitable < TyCtxt < ' tcx > > ,
21
17
{
22
18
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 ( ) {
57
20
throw_inval ! ( TooGeneric ) ;
58
- } else {
59
- interp_ok ( ( ) )
60
21
}
22
+ interp_ok ( ( ) )
61
23
}
62
24
63
25
impl < ' tcx > InterpretationResult < ' tcx > for mir:: interpret:: ConstAllocation < ' tcx > {
0 commit comments