Skip to main content

Module generics

Module generics 

Source

Structsยง

GenericsGenerationResult ๐Ÿ”’
GenericsGenerationResults ๐Ÿ”’

Enumsยง

DelegationGenerics ๐Ÿ”’
HirOrAstGenerics ๐Ÿ”’
Used for storing either AST generics or their lowered HIR version. Firstly we obtain AST generics either from local function from AST index or from external function through tcx. Next, at some point of generics processing we need to lower those generics to HIR, for this purpose we use into_hir_generics that lowers AST generics and replaces Ast variant with Hir. Such approach is useful as we can call this method at any time knowing that lowering will occur at most only once. Then, in order to obtain generic params or args we use hir_generics_or_empty or into_generic_args functions. There also may be situations when we obtained AST generics but never lowered them to HIR, meaning we did not propagate them and thus we do not need to generate generic params (i.e., method call scenarios), in such a case this approach helps a lot as if into_hir_generics will not be called then lowering will not happen.