astconv-no-mo: AstConvHirTyLowerer

Guiding Principles

Mapping

Below you can find an exhaustive alphabetically sorted mapping from old to new name together with an optional comment justifying the respective renaming grouped by module (with one exception).

Old Name New Name Comment
rustc_hir_analysis
astconvhir_ty_lowering
hir_ty_to_tylower_ty
hir_ty_lowering
AstConvHirTyLowering
PathSegGenericPathSegmentSee the comment over at probe_generic_path_segments for more context. This type doesn't represent arbitrary path segments but specifically only ones that are semantically allowed to have generic arguments.
HirTyLowerer
allow_ty_inferallow_inferThis isn't specifically about type variables but generally about any kind of inference variables.
astconvlowerer
get_type_parameter_boundsprobe_ty_param_bounds
projected_ty_from_poly_trait_reflower_assoc_tyThe new name describes what the method does conceptually, while the old one describes what it does internally.
dyn HirTyLowerer<'tcx> + '_
add_boundslower_poly_bounds

The old naming scheme is nondescript, the new one is slightly more descriptive: {compute,add}_bounds vs. lower_{mono,poly}_bounds.

This method lowers polymorphic bounds in the sense that they are potentially collectively quantified universally by an overarching / outer binder. If not, individual bounds may still be universally quantified by inner binders.

The terminology poly is preexisting, consider PolyTraitRef for example.

add_implicitly_sizedadd_sized_bound

If I can trust my non-native English skills, the old name is beyond ungrammatical even if we include rustc jargon since adverbs cannot modify nouns.

More noteworthily, I strongly lean towards dropping the word implicit here since it violates the layers of abstraction. Indeed, some entities have implicit Sized bounds. However, we are at the lowering / elaboration layer, there's no need to state this information.

Rephrased, the hypothetical alternative name add_implicit_sized_bound wouldn't make sense semantically since one cannot add something that is implicit, add and implicit are contradictory. And if we were to make a case for implicitly add, that wouldn't make much sense either: The very action of adding is explicit — at least at this semantic layer.

add_predicates_for_ast_type_bindinglower_assoc_item_binding

The new name describes what the method does conceptually (specification-wise), while the old one describes what it does internally (implementation-wise).

Regarding item over type: This method not only lowers assoc type bindings but also assoc const bindings as well as RTN (assoc functions). Note that TypeBinding should probably renamed, too, at some point (to AssocItemBinding).

associated_path_to_tylower_assoc_path
ast_path_args_for_tylower_generic_args_of_path_segment
ast_path_to_mono_trait_reflower_mono_trait_ref
ast_path_to_tylower_path_segment
ast_region_to_regionlower_lifetimeWe lower HIR lifetimes (to middle regions), not “HIR regions” (those don't exist).
ast_ty_to_tylower_ty
ast_ty_to_ty_in_pathlower_ty_in_path
ast_ty_to_ty_innerlower_ty_commonInspired by the terminology of the parser.
compute_boundslower_mono_bounds

The old naming scheme is nondescript, the new one is slightly more descriptive: {compute,add}_bounds vs. lower_{mono,poly}_bounds.

This method lowers monomorphic bounds in the sense that they aren't collectively quantified universally by an overarching / outer binder. However, individual bounds may still be universally quantified by inner binders.

Therefore the term mono could be regarded as confusing by some. Note however that this is consistent with the preexisting ast_path_to_mono_trait_ref (renamed to lower_mono_trait_ref).

conv_object_ty_poly_trait_reflower_trait_object_tyMore succinct.
create_args_for_associated_itemlower_generic_args_of_assoc_item
create_args_for_ast_pathlower_generic_args_of_path
def_ids_for_value_path_segmentsprobe_generic_path_segments

The old name is super nondescript. I had no idea what its job was until I read the comments and the implementation and looked at the usage sites. While the contained lengthy comment is somewhat true, namely that there is some work involved in recovering DefIds from HIR path segments and that this method implements this step, the name and the comment are misleading:

More significantly, this methods searches for path segments that are semantically allowed to have generic arguments. For example, it extracts the necessary information to reject Option::<()>::None::<()> and to accept Option::None::<()>.

find_bound_for_assoc_itemprobe_single_ty_param_bound_for_assoc_ty

Only cares about assoc types, not arbitrary assoc items.

Name disambiguated to differentiate it from probe_single_bound_for_assoc_item. Only has a single usage site, therefore length doesn't matter. It's more descriptive, too.

hir_id_to_bound_constlower_const_paramThe old name is nondescript and inaccurate. Not only we do we lower to ty::ConstKind::Bound but also to ty::ConstKind::Param depending on the boundness (early vs. late).
hir_id_to_bound_tylower_ty_paramThe old name is nondescript and inaccurate. Not only do we lower to ty::Bound but also to ty::Param depending on the boundness (early vs. late).
impl_trait_ty_to_tylower_opaque_tyThe HIR type kind is called OpaqueDef, so we should keep this nomenclature. It's the right semantic level. “impl-Trait” is ambiguous (universial vs. existential) and more appropriate in contexts concerning the surface syntax.
instantiate_mono_trait_reflower_impl_trait_refIt's not instantiating anything, it's just lowering. Furthermore, the new name is more descriptive: This method lowers impl trait refs (preexisting terminology), i.e., the main trait ref inside impl headers to the left of keyword for.
instantiate_poly_trait_reflower_poly_trait_refIt's not instantiating anything, it's just lowering.
lookup_assoc_typrobe_assoc_ty
lookup_assoc_ty_uncheckedprobe_assoc_ty_unchecked
lookup_inherent_assoc_typrobe_inherent_assoc_ty
one_bound_for_assoc_itemprobe_single_bound_for_assoc_item
prohibit_assoc_ty_bindingprohibit_assoc_item_bindingRegarding item over type: This method not only prohibits assoc type bindings but also assoc const bindings as well as RTN (assoc functions). Note that TypeBinding should probably renamed, too, at some point (to AssocItemBinding).
prohibit_genericsprohibit_generic_argsGenerics typically stands for generic parameters not arguments — in the compiler at least — and this function prohibits the latter.
qpath_to_tylower_qpath
res_to_tylower_pathConceptually speaking, this method lowers paths. The fact that it utilizes the Res to achieve this is an implementation detail and shouldn't be mentioned as part of its name.
trait_defines_associated_item_namedprobe_trait_that_defines_assoc_item
ty_from_delegationlower_delegation_ty
ty_of_arglower_arg_ty
ty_of_fnlower_fn_ty
hir::GenericArgs<'hir>ty::GenericArgs<'tcx>
create_args_for_parent_generic_argslower_generic_args

Before the “substs → generic args” renaming, this used to be called create_substs_for_generic_args which was more accurate.

The current name create_args_for_parent_generic_args is absolutely incorrect and confusing! We're not “creating generic args for parent generics args” but we're lowering generic args for the item whose DefId was provided (with the help of a GenericArgsLowerer) which also requires the pre-lowered parent generic args to be passed (that however is a secondary matter).

Respectfully, I think the author of the renaming PR saw the parent_args parameter and thought that the parent args were being lowered.

CreateCtorInstantiationsContextCtorGenericArgsCtxtLocal struct in rustc_hir_typeck. Consistent with {Fn,Item}Ctxt.
CreateInstantiationsForGenericArgsCtxtGenericArgsLowerer

Before the “substs → generic args” renaming, this used to be called CreateSubstsForGenericArgsCtxt which was more accurate. Respectfully, the author of the renaming PR shouldn't have chosen the word “instantiations” here (I noted that on the PR after it was merged).

This trait models contexts that can lower hir::GenericArgs to ty::GenericArgs. The new name is succinct and mirrors the naming of trait HirTyLowerer.

InstantiationsForAstPathCtxtGenericArgsCtxtLocal struct in rustc_hir_analysis. Consistent with {Fn,Item}Ctxt.
MethodInstantiationsCtxtGenericArgsCtxtLocal struct in rustc_hir_typeck. Consistent with {Fn,Item}Ctxt.
dyn HirTyLowerer<'tcx> + '_ in hir_ty_lowering::errors
complain_about_inherent_assoc_type_not_foundcomplain_about_inherent_assoc_ty_not_found
complain_about_ambiguous_inherent_assoc_typecomplain_about_ambiguous_inherent_assoc_ty
complain_about_missing_associated_typescomplain_about_missing_assoc_tys
note_ambiguous_inherent_assoc_typenote_ambiguous_inherent_assoc_ty
report_ambiguous_associated_typereport_ambiguous_assoc_ty
rustc_hir_analysis::collect::ItemCtxt
to_tylower_ty
type_parameter_bounds_in_genericsprobe_ty_param_bounds_in_generics
rustc_hir_typeck::FnCtxt
array_length_to_constlower_array_length
const_arg_to_tylower_const_arg
to_tylower_ty
to_ty_saving_user_provided_tylower_ty_saving_user_provided_ty
rustc_hir_analysis::collect
convert_⟨item⟩lower_⟨item⟩
rustc_trait_selection::traits
astconv_object_safety_violationshir_ty_lowering_object_safety_violations
resolve_bound_vars::is_late_bound_map
ConstrainedCollectorPostAstConvConstrainedCollectorPostHirTyLowering

Non-Exhaustive Reverse Mapping

To properly demonstrate the beauty of the new naming scheme, below there's a non-exhaustive logically sorted mapping from new to old name of the main lowering methods only.

New Name Old Name
 
add_sized_boundadd_implicitly_sized
 
lower_arg_tyty_of_arg
lower_assoc_typrojected_ty_from_poly_trait_ref
lower_delegation_tyty_from_delegation
lower_fn_tyty_of_fn
lower_opaque_tyimpl_trait_ty_to_ty
lower_trait_object_tyconv_object_ty_poly_trait_ref
 
lower_assoc_item_bindingadd_predicates_for_ast_type_binding
 
lower_assoc_pathassociated_path_to_ty
lower_path_segmentast_path_to_ty
lower_pathres_to_ty
lower_qpathqpath_to_ty
 
lower_const_paramhir_id_to_bound_const
lower_ty_paramhir_id_to_bound_ty
 
lower_generic_args_of_assoc_itemcreate_args_for_associated_item
lower_generic_args_of_path_segmentast_path_args_for_ty
lower_generic_args_of_pathcreate_args_for_ast_path
 
lower_impl_trait_refinstantiate_mono_trait_ref
lower_mono_trait_refast_path_to_mono_trait_ref
lower_poly_trait_refinstantiate_poly_trait_ref
 
lower_lifetimeast_region_to_region
 
lower_mono_boundscompute_bounds
lower_poly_boundsadd_bounds
 
lower_tyast_ty_to_ty
lower_ty_commonast_ty_to_ty_inner
lower_ty_in_pathast_ty_to_ty_in_path
 
probe_assoc_ty_uncheckedlookup_assoc_ty_unchecked
probe_assoc_tylookup_assoc_ty
probe_generic_path_segmentsdef_ids_for_value_path_segments
probe_inherent_assoc_tylookup_inherent_assoc_ty
probe_single_bound_for_assoc_itemone_bound_for_assoc_item
probe_single_ty_param_bound_for_assoc_tyfind_bound_for_assoc_item
probe_trait_that_defines_assoc_itemtrait_defines_associated_item_named
probe_ty_param_boundsget_type_parameter_bounds
 
prohibit_assoc_item_bindingprohibit_assoc_ty_binding
prohibit_generic_argsprohibit_generics