This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +39
-9
lines changed
compiler/rustc_mir/src/monomorphize Expand file tree Collapse file tree 1 file changed +39
-9
lines changed Original file line number Diff line number Diff line change @@ -107,18 +107,48 @@ fn mark_used_by_default_parameters<'tcx>(
107107 generics : & ' tcx ty:: Generics ,
108108 unused_parameters : & mut FiniteBitSet < u32 > ,
109109) {
110- if !tcx. is_trait ( def_id) && ( tcx. is_closure ( def_id) || tcx. type_of ( def_id) . is_generator ( ) ) {
111- for param in & generics. params {
112- debug ! ( ?param, "(closure/gen)" ) ;
113- unused_parameters. clear ( param. index ) ;
114- }
115- } else {
116- for param in & generics. params {
117- debug ! ( ?param, "(other)" ) ;
118- if let ty:: GenericParamDefKind :: Lifetime = param. kind {
110+ match tcx. def_kind ( def_id) {
111+ DefKind :: Closure | DefKind :: Generator => {
112+ for param in & generics. params {
113+ debug ! ( ?param, "(closure/gen)" ) ;
119114 unused_parameters. clear ( param. index ) ;
120115 }
121116 }
117+ DefKind :: Mod
118+ | DefKind :: Struct
119+ | DefKind :: Union
120+ | DefKind :: Enum
121+ | DefKind :: Variant
122+ | DefKind :: Trait
123+ | DefKind :: TyAlias
124+ | DefKind :: ForeignTy
125+ | DefKind :: TraitAlias
126+ | DefKind :: AssocTy
127+ | DefKind :: TyParam
128+ | DefKind :: Fn
129+ | DefKind :: Const
130+ | DefKind :: ConstParam
131+ | DefKind :: Static
132+ | DefKind :: Ctor ( _, _)
133+ | DefKind :: AssocFn
134+ | DefKind :: AssocConst
135+ | DefKind :: Macro ( _)
136+ | DefKind :: ExternCrate
137+ | DefKind :: Use
138+ | DefKind :: ForeignMod
139+ | DefKind :: AnonConst
140+ | DefKind :: OpaqueTy
141+ | DefKind :: Field
142+ | DefKind :: LifetimeParam
143+ | DefKind :: GlobalAsm
144+ | DefKind :: Impl => {
145+ for param in & generics. params {
146+ debug ! ( ?param, "(other)" ) ;
147+ if let ty:: GenericParamDefKind :: Lifetime = param. kind {
148+ unused_parameters. clear ( param. index ) ;
149+ }
150+ }
151+ }
122152 }
123153
124154 if let Some ( parent) = generics. parent {
You can’t perform that action at this time.
0 commit comments