about summary refs log tree commit diff
path: root/compiler/rustc_const_eval/src/interpret/util.rs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_const_eval/src/interpret/util.rs')
-rw-r--r--compiler/rustc_const_eval/src/interpret/util.rs34
1 files changed, 6 insertions, 28 deletions
diff --git a/compiler/rustc_const_eval/src/interpret/util.rs b/compiler/rustc_const_eval/src/interpret/util.rs
index 8bb5f173a56..ecb7c3fc93c 100644
--- a/compiler/rustc_const_eval/src/interpret/util.rs
+++ b/compiler/rustc_const_eval/src/interpret/util.rs
@@ -14,10 +14,8 @@ use crate::const_eval::{CompileTimeInterpCx, CompileTimeMachine, InterpretationR
 
 /// Checks whether a type contains generic parameters which must be instantiated.
 ///
-/// In case it does, returns a `TooGeneric` const eval error. Note that due to polymorphization
-/// types may be "concrete enough" even though they still contain generic parameters in
-/// case these parameters are unused.
-pub(crate) fn ensure_monomorphic_enough<'tcx, T>(tcx: TyCtxt<'tcx>, ty: T) -> InterpResult<'tcx>
+/// In case it does, returns a `TooGeneric` const eval error.
+pub(crate) fn ensure_monomorphic_enough<'tcx, T>(_tcx: TyCtxt<'tcx>, ty: T) -> InterpResult<'tcx>
 where
     T: TypeVisitable<TyCtxt<'tcx>>,
 {
@@ -27,11 +25,9 @@ where
     }
 
     struct FoundParam;
-    struct UsedParamsNeedInstantiationVisitor<'tcx> {
-        tcx: TyCtxt<'tcx>,
-    }
+    struct UsedParamsNeedInstantiationVisitor {}
 
-    impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for UsedParamsNeedInstantiationVisitor<'tcx> {
+    impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for UsedParamsNeedInstantiationVisitor {
         type Result = ControlFlow<FoundParam>;
 
         fn visit_ty(&mut self, ty: Ty<'tcx>) -> Self::Result {
@@ -41,25 +37,7 @@ where
 
             match *ty.kind() {
                 ty::Param(_) => ControlFlow::Break(FoundParam),
-                ty::Closure(def_id, args)
-                | ty::CoroutineClosure(def_id, args, ..)
-                | ty::Coroutine(def_id, args, ..)
-                | ty::FnDef(def_id, args) => {
-                    let instance = ty::InstanceKind::Item(def_id);
-                    let unused_params = self.tcx.unused_generic_params(instance);
-                    for (index, arg) in args.into_iter().enumerate() {
-                        let index = index
-                            .try_into()
-                            .expect("more generic parameters than can fit into a `u32`");
-                        // Only recurse when generic parameters in fns, closures and coroutines
-                        // are used and have to be instantiated.
-                        //
-                        // Just in case there are closures or coroutines within this arg,
-                        // recurse.
-                        if unused_params.is_used(index) && arg.has_param() {
-                            return arg.visit_with(self);
-                        }
-                    }
+                ty::Closure(..) | ty::CoroutineClosure(..) | ty::Coroutine(..) | ty::FnDef(..) => {
                     ControlFlow::Continue(())
                 }
                 _ => ty.super_visit_with(self),
@@ -74,7 +52,7 @@ where
         }
     }
 
-    let mut vis = UsedParamsNeedInstantiationVisitor { tcx };
+    let mut vis = UsedParamsNeedInstantiationVisitor {};
     if matches!(ty.visit_with(&mut vis), ControlFlow::Break(FoundParam)) {
         throw_inval!(TooGeneric);
     } else {