Skip to main content

Module hir_ty_lowering

Module hir_ty_lowering 

Source
Expand description

HIR ty lowering: Lowers type-system entities1 from the HIR to the rustc_middle::ty representation.

Not to be confused with AST lowering which lowers AST constructs to HIR ones or with THIR / MIR lowering / building which lowers HIR bodies (i.e., β€œexecutable code”) to THIR / MIR.

Most lowering routines are defined on dyn HirTyLowerer directly, like the main routine of this module, lower_ty.

This module used to be called astconv.


  1. This includes types, lifetimes / regions, constants in type positions, trait references and bounds. β†©

Re-exportsΒ§

use std::assert_matches; πŸ”’
use std::slice; πŸ”’
use rustc_abi::FIRST_VARIANT; πŸ”’
use rustc_ast::LitKind; πŸ”’
use rustc_attr_ir::lang_items::LangItem; πŸ”’
use rustc_data_structures::fx::FxHashSet; πŸ”’
use rustc_data_structures::fx::FxIndexMap; πŸ”’
use rustc_data_structures::fx::FxIndexSet; πŸ”’
use rustc_data_structures::sso::SsoHashSet; πŸ”’
use rustc_data_structures::thin_vec::ThinVec; πŸ”’
use rustc_errors::Applicability; πŸ”’
use rustc_errors::Diag; πŸ”’
use rustc_errors::DiagCtxtHandle; πŸ”’
use rustc_errors::ErrorGuaranteed; πŸ”’
use rustc_errors::FatalError; πŸ”’
use rustc_errors::StashKey; πŸ”’
use rustc_errors::struct_span_code_err; πŸ”’
use rustc_hir::def::CtorKind; πŸ”’
use rustc_hir::def::CtorOf; πŸ”’
use rustc_hir::def::DefKind; πŸ”’
use rustc_hir::def::Res; πŸ”’
use rustc_hir::def_id::DefId; πŸ”’
use rustc_hir::def_id::LocalDefId; πŸ”’
use rustc_hir as hir; πŸ”’
use rustc_hir::AnonConst; πŸ”’
use rustc_hir::GenericArg; πŸ”’
use rustc_hir::GenericArgs; πŸ”’
use rustc_hir::HirId; πŸ”’
use rustc_infer::infer::InferCtxt; πŸ”’
use rustc_infer::infer::TyCtxtInferExt; πŸ”’
use rustc_infer::traits::DynCompatibilityViolation; πŸ”’
use rustc_lint_defs::builtin::AMBIGUOUS_ASSOCIATED_ITEMS; πŸ”’
use rustc_macros::TypeFoldable; πŸ”’
use rustc_macros::TypeVisitable; πŸ”’
use rustc_middle::middle::stability::AllowUnstable; πŸ”’
use rustc_middle::ty; πŸ”’
use rustc_middle::ty::Const; πŸ”’
use rustc_middle::ty::FnSigKind; πŸ”’
use rustc_middle::ty::GenericArgKind; πŸ”’
use rustc_middle::ty::GenericArgsRef; πŸ”’
use rustc_middle::ty::GenericParamDefKind; πŸ”’
use rustc_middle::ty::LitToConstInput; πŸ”’
use rustc_middle::ty::Ty; πŸ”’
use rustc_middle::ty::TyCtxt; πŸ”’
use rustc_middle::ty::TypeSuperFoldable; πŸ”’
use rustc_middle::ty::TypeVisitableExt; πŸ”’
use rustc_middle::ty::TypingMode; πŸ”’
use rustc_middle::ty::Unnormalized; πŸ”’
use rustc_middle::ty::Upcast; πŸ”’
use rustc_middle::ty::const_lit_matches_ty; πŸ”’
use rustc_middle::ty::fold_regions; πŸ”’
use rustc_session::diagnostics::feature_err; πŸ”’
use rustc_span::def_id::LocalModId; πŸ”’
use rustc_span::def_id::ModId; πŸ”’
use rustc_span::DUMMY_SP; πŸ”’
use rustc_span::Ident; πŸ”’
use rustc_span::Span; πŸ”’
use rustc_span::bug; πŸ”’
use rustc_span::kw; πŸ”’
use rustc_span::span_bug; πŸ”’
use rustc_span::sym; πŸ”’
use rustc_trait_selection::infer::InferCtxtExt; πŸ”’
use rustc_trait_selection::traits; πŸ”’
use rustc_trait_selection::traits::FulfillmentError; πŸ”’
use tracing::debug; πŸ”’
use tracing::instrument; πŸ”’
use tracing::instrument; πŸ”’
use crate::check::check_abi; πŸ”’
use crate::check_c_variadic_abi; πŸ”’
use crate::diagnostics; πŸ”’
use crate::diagnostics::BadReturnTypeNotation; πŸ”’
use crate::diagnostics::NoFieldOnType; πŸ”’
use crate::diagnostics::NoVariantNamed; πŸ”’
use crate::hir_ty_lowering::errors::GenericsArgsErrExtend; πŸ”’
use crate::hir_ty_lowering::errors::eq_ctxt_suggestion_span; πŸ”’
use crate::hir_ty_lowering::errors::prohibit_assoc_item_constraint; πŸ”’
use crate::hir_ty_lowering::generics::check_generic_arg_count; πŸ”’
use crate::hir_ty_lowering::generics::lower_generic_args; πŸ”’
use crate::middle::resolve_bound_vars as rbv; πŸ”’
use rustc_errors::codes::*; πŸ”’

ModulesΒ§

bounds πŸ”’
cmse πŸ”’
dyn_trait πŸ”’
errors
generics

StructsΒ§

ForbidParamUsesFolder πŸ”’
GenericArgCountMismatch
A marker denoting that the generic arguments that were provided did not match the respective generic parameters.
GenericArgCountResult
Decorates the result of a generic argument count mismatch check with whether explicit late bounds were provided.
GenericPathSegment
A path segment that is semantically allowed to have generic arguments.
InherentAssocCandidate
ResolvedStructPath

EnumsΒ§

AssocItemQSelf πŸ”’
The β€œqualified self” of an associated item path.
ExplicitLateBound
New-typed boolean indicating whether explicit late-bound lifetimes are present in a set of generic arguments.
ForbidParamContext πŸ”’
Context in which ForbidParamUsesFolder is being used, to emit appropriate diagnostics.
GenericArgPosition πŸ”’
Denotes the β€œposition” of a generic argument, indicating if it is a generic type, generic function or generic method call.
ImpliedBoundsContext πŸ”’
The context in which an implied bound is being added to a item being lowered (i.e. a sizedness trait or a default trait)
IsMethodCall
LowerTypeRelativePathMode πŸ”’
OverlappingAsssocItemConstraints πŸ”’
Whether to allow duplicate associated iten constraints in a trait ref, e.g. Trait<Assoc = Ty, Assoc = Ty>. This is forbidden in dyn Trait<...> but allowed everywhere else.
PermitVariants
Whether to permit a path to resolve to an enum variant.
PredicateFilter
RegionInferReason
TypeRelativePath πŸ”’

TraitsΒ§

GenericArgsLowerer
A context which can lower HIR’s GenericArg to rustc_middle’s ty::GenericArg.
HirTyLowerer
A context which can lower type-system entities from the HIR to the rustc_middle::ty representation.