@@ -17,7 +17,7 @@ use crate::const_eval::{CompileTimeInterpCx, CompileTimeMachine, InterpretationR
17
17
/// In case it does, returns a `TooGeneric` const eval error. Note that due to polymorphization
18
18
/// types may be "concrete enough" even though they still contain generic parameters in
19
19
/// case these parameters are unused.
20
- pub ( crate ) fn ensure_monomorphic_enough < ' tcx , T > ( tcx : TyCtxt < ' tcx > , ty : T ) -> InterpResult < ' tcx >
20
+ pub ( crate ) fn ensure_monomorphic_enough < ' tcx , T > ( _tcx : TyCtxt < ' tcx > , ty : T ) -> InterpResult < ' tcx >
21
21
where
22
22
T : TypeVisitable < TyCtxt < ' tcx > > ,
23
23
{
27
27
}
28
28
29
29
struct FoundParam ;
30
- struct UsedParamsNeedInstantiationVisitor < ' tcx > {
31
- tcx : TyCtxt < ' tcx > ,
32
- }
30
+ struct UsedParamsNeedInstantiationVisitor { }
33
31
34
- impl < ' tcx > TypeVisitor < TyCtxt < ' tcx > > for UsedParamsNeedInstantiationVisitor < ' tcx > {
32
+ impl < ' tcx > TypeVisitor < TyCtxt < ' tcx > > for UsedParamsNeedInstantiationVisitor {
35
33
type Result = ControlFlow < FoundParam > ;
36
34
37
35
fn visit_ty ( & mut self , ty : Ty < ' tcx > ) -> Self :: Result {
41
39
42
40
match * ty. kind ( ) {
43
41
ty:: Param ( _) => ControlFlow :: Break ( FoundParam ) ,
44
- ty:: Closure ( def_id, args)
45
- | ty:: CoroutineClosure ( def_id, args, ..)
46
- | ty:: Coroutine ( def_id, args, ..)
47
- | ty:: FnDef ( def_id, args) => {
48
- let instance = ty:: InstanceKind :: Item ( def_id) ;
49
- let unused_params = self . tcx . unused_generic_params ( instance) ;
50
- for ( index, arg) in args. into_iter ( ) . enumerate ( ) {
51
- let index = index
52
- . try_into ( )
53
- . expect ( "more generic parameters than can fit into a `u32`" ) ;
54
- // Only recurse when generic parameters in fns, closures and coroutines
55
- // are used and have to be instantiated.
56
- //
57
- // Just in case there are closures or coroutines within this arg,
58
- // recurse.
59
- if unused_params. is_used ( index) && arg. has_param ( ) {
60
- return arg. visit_with ( self ) ;
61
- }
62
- }
42
+ ty:: Closure ( ..) | ty:: CoroutineClosure ( ..) | ty:: Coroutine ( ..) | ty:: FnDef ( ..) => {
63
43
ControlFlow :: Continue ( ( ) )
64
44
}
65
45
_ => ty. super_visit_with ( self ) ,
74
54
}
75
55
}
76
56
77
- let mut vis = UsedParamsNeedInstantiationVisitor { tcx } ;
57
+ let mut vis = UsedParamsNeedInstantiationVisitor { } ;
78
58
if matches ! ( ty. visit_with( & mut vis) , ControlFlow :: Break ( FoundParam ) ) {
79
59
throw_inval ! ( TooGeneric ) ;
80
60
} else {
0 commit comments