rustc_hir_analysis::hir_ty_lowering

Trait HirTyLowerer

Source
pub trait HirTyLowerer<'tcx> {
Show 13 methods // Required methods fn tcx(&self) -> TyCtxt<'tcx>; fn dcx(&self) -> DiagCtxtHandle<'_>; fn item_def_id(&self) -> LocalDefId; fn re_infer( &self, span: Span, reason: RegionInferReason<'_>, ) -> Region<'tcx>; fn ty_infer(&self, param: Option<&GenericParamDef>, span: Span) -> Ty<'tcx>; fn ct_infer( &self, param: Option<&GenericParamDef>, span: Span, ) -> Const<'tcx>; fn probe_ty_param_bounds( &self, span: Span, def_id: LocalDefId, assoc_name: Ident, ) -> EarlyBinder<'tcx, &'tcx [(Clause<'tcx>, Span)]>; fn lower_assoc_ty( &self, span: Span, item_def_id: DefId, item_segment: &PathSegment<'tcx>, poly_trait_ref: PolyTraitRef<'tcx>, ) -> Ty<'tcx>; fn lower_fn_sig( &self, decl: &FnDecl<'tcx>, generics: Option<&Generics<'_>>, hir_id: HirId, hir_ty: Option<&Ty<'_>>, ) -> (Vec<Ty<'tcx>>, Ty<'tcx>); fn probe_adt(&self, span: Span, ty: Ty<'tcx>) -> Option<AdtDef<'tcx>>; fn record_ty(&self, hir_id: HirId, ty: Ty<'tcx>, span: Span); fn infcx(&self) -> Option<&InferCtxt<'tcx>>; // Provided method fn lowerer(&self) -> &dyn HirTyLowerer<'tcx> where Self: Sized { ... }
}
Expand description

A context which can lower type-system entities from the HIR to the rustc_middle::ty representation.

This trait used to be called AstConv.

Required Methods§

Source

fn tcx(&self) -> TyCtxt<'tcx>

Source

fn dcx(&self) -> DiagCtxtHandle<'_>

Source

fn item_def_id(&self) -> LocalDefId

Returns the LocalDefId of the overarching item whose constituents get lowered.

Source

fn re_infer(&self, span: Span, reason: RegionInferReason<'_>) -> Region<'tcx>

Returns the region to use when a lifetime is omitted (and not elided).

Source

fn ty_infer(&self, param: Option<&GenericParamDef>, span: Span) -> Ty<'tcx>

Returns the type to use when a type is omitted.

Source

fn ct_infer(&self, param: Option<&GenericParamDef>, span: Span) -> Const<'tcx>

Returns the const to use when a const is omitted.

Source

fn probe_ty_param_bounds( &self, span: Span, def_id: LocalDefId, assoc_name: Ident, ) -> EarlyBinder<'tcx, &'tcx [(Clause<'tcx>, Span)]>

Probe bounds in scope where the bounded type coincides with the given type parameter.

Rephrased, this returns bounds of the form T: Trait, where T is a type parameter with the given def_id. This is a subset of the full set of bounds.

This method may use the given assoc_name to disregard bounds whose trait reference doesn’t define an associated item with the provided name.

This is used for one specific purpose: Resolving “short-hand” associated type references like T::Item where T is a type parameter. In principle, we would do that by first getting the full set of predicates in scope and then filtering down to find those that apply to T, but this can lead to cycle errors. The problem is that we have to do this resolution in order to create the predicates in the first place. Hence, we have this “special pass”.

Source

fn lower_assoc_ty( &self, span: Span, item_def_id: DefId, item_segment: &PathSegment<'tcx>, poly_trait_ref: PolyTraitRef<'tcx>, ) -> Ty<'tcx>

Lower an associated type to a projection.

This method has to be defined by the concrete lowering context because dealing with higher-ranked trait references depends on its capabilities:

If the context can make use of type inference, it can simply instantiate any late-bound vars bound by the trait reference with inference variables. If it doesn’t support type inference, there is nothing reasonable it can do except reject the associated type.

The canonical example of this is associated type T::P where T is a type param constrained by T: for<'a> Trait<'a> and where Trait defines P.

Source

fn lower_fn_sig( &self, decl: &FnDecl<'tcx>, generics: Option<&Generics<'_>>, hir_id: HirId, hir_ty: Option<&Ty<'_>>, ) -> (Vec<Ty<'tcx>>, Ty<'tcx>)

Source

fn probe_adt(&self, span: Span, ty: Ty<'tcx>) -> Option<AdtDef<'tcx>>

Returns AdtDef if ty is an ADT.

Note that ty might be a alias type that needs normalization. This used to get the enum variants in scope of the type. For example, Self::A could refer to an associated type or to an enum variant depending on the result of this function.

Source

fn record_ty(&self, hir_id: HirId, ty: Ty<'tcx>, span: Span)

Record the lowered type of a HIR node in this context.

Source

fn infcx(&self) -> Option<&InferCtxt<'tcx>>

The inference context of the lowering context if applicable.

Provided Methods§

Source

fn lowerer(&self) -> &dyn HirTyLowerer<'tcx>
where Self: Sized,

Convenience method for coercing the lowering context into a trait object type.

Most lowering routines are defined on the trait object type directly necessitating a coercion step from the concrete lowering context.

Implementations§

Source§

impl<'tcx> dyn HirTyLowerer<'tcx> + '_

Source

pub(crate) fn add_sized_bound( &self, bounds: &mut Bounds<'tcx>, self_ty: Ty<'tcx>, hir_bounds: &'tcx [GenericBound<'tcx>], self_ty_where_predicates: Option<(LocalDefId, &'tcx [WherePredicate<'tcx>])>, span: Span, )

Add a Sized bound to the bounds if appropriate.

Doesn’t add the bound if the HIR bounds contain any of Sized, ?Sized or !Sized.

Source

pub(crate) fn lower_bounds<'hir, I: IntoIterator<Item = &'hir GenericBound<'tcx>>>( &self, param_ty: Ty<'tcx>, hir_bounds: I, bounds: &mut Bounds<'tcx>, bound_vars: &'tcx List<BoundVariableKind>, predicate_filter: PredicateFilter, )
where 'tcx: 'hir,

Lower HIR bounds into bounds given the self type param_ty and the overarching late-bound vars if any.

§Examples
fn foo<T>() where for<'a> T: Trait<'a> + Copy {}
//                ^^^^^^^ ^  ^^^^^^^^^^^^^^^^ `hir_bounds`, in HIR form
//                |       |
//                |       `param_ty`, in ty form
//                `bound_vars`, in ty form

fn bar<T>() where T: for<'a> Trait<'a> + Copy {} // no overarching `bound_vars` here!
//                ^  ^^^^^^^^^^^^^^^^^^^^^^^^ `hir_bounds`, in HIR form
//                |
//                `param_ty`, in ty form
§A Note on Binders

There is an implied binder around param_ty and hir_bounds. See lower_poly_trait_ref for more details.

Source

pub(super) fn lower_assoc_item_constraint( &self, hir_ref_id: HirId, trait_ref: PolyTraitRef<'tcx>, constraint: &AssocItemConstraint<'tcx>, bounds: &mut Bounds<'tcx>, duplicates: &mut FxIndexMap<DefId, Span>, path_span: Span, predicate_filter: PredicateFilter, ) -> Result<(), ErrorGuaranteed>

Lower an associated item constraint from the HIR into bounds.

§A Note on Binders

Given something like T: for<'a> Iterator<Item = &'a u32>, the trait_ref here will be for<'a> T: Iterator. The constraint data however is from inside the binder (e.g., &'a u32) and hence may reference bound regions.

Source

pub fn lower_ty_maybe_return_type_notation(&self, hir_ty: &Ty<'tcx>) -> Ty<'tcx>

Lower a type, possibly specially handling the type if it’s a return type notation which we otherwise deny in other positions.

Source

fn resolve_type_relative_return_type_notation( &self, qself: &'tcx Ty<'tcx>, item_segment: &'tcx PathSegment<'tcx>, qpath_hir_id: HirId, span: Span, ) -> Result<(PolyTraitRef<'tcx>, DefId), ErrorGuaranteed>

Perform type-dependent lookup for a method for return type notation. This generally mirrors <dyn HirTyLowerer>::lower_assoc_path.

Source

fn lower_return_type_notation_ty( &self, candidate: PolyTraitRef<'tcx>, item_def_id: DefId, path_span: Span, ) -> Result<AliasTy<'tcx>, ErrorGuaranteed>

Do the common parts of lowering an RTN type. This involves extending the candidate binder to include all of the early- and late-bound vars that are defined on the function itself, and constructing a projection to the RPITIT return type of that function.

Source§

impl<'tcx> dyn HirTyLowerer<'tcx> + '_

Source

pub(super) fn lower_trait_object_ty( &self, span: Span, hir_id: HirId, hir_trait_bounds: &[PolyTraitRef<'tcx>], lifetime: &Lifetime, representation: DynKind, ) -> Ty<'tcx>

Lower a trait object type from the HIR to our internal notion of a type.

Source

fn check_elaborated_projection_mentions_input_lifetimes( &self, pred: PolyProjectionPredicate<'tcx>, span: Span, supertrait_span: Span, )

Check that elaborating the principal of a trait ref doesn’t lead to projections that are unconstrained. This can happen because an otherwise unconstrained type variable can be substituted with a type that has late-bound regions. See elaborated-predicates-unconstrained-late-bound.rs for a test.

Source§

impl<'tcx> dyn HirTyLowerer<'tcx> + '_

Source

pub(crate) fn complain_about_missing_type_params( &self, missing_type_params: Vec<Symbol>, def_id: DefId, span: Span, empty_generic_args: bool, )

On missing type parameters, emit an E0393 error and provide a structured suggestion using the type parameter’s name as a placeholder.

Source

pub(crate) fn complain_about_internal_fn_trait( &self, span: Span, trait_def_id: DefId, trait_segment: &PathSegment<'_>, is_impl: bool, )

When the code is using the Fn traits directly, instead of the Fn(A) -> B syntax, emit an error and attempt to build a reasonable structured suggestion.

Source

pub(super) fn complain_about_assoc_item_not_found<I>( &self, all_candidates: impl Fn() -> I, qself: AssocItemQSelf, assoc_kind: AssocKind, assoc_name: Ident, span: Span, constraint: Option<&AssocItemConstraint<'tcx>>, ) -> ErrorGuaranteed
where I: Iterator<Item = PolyTraitRef<'tcx>>,

Source

fn complain_about_assoc_kind_mismatch( &self, assoc_item: &AssocItem, assoc_kind: AssocKind, ident: Ident, span: Span, constraint: Option<&AssocItemConstraint<'tcx>>, ) -> ErrorGuaranteed

Source

pub(super) fn report_ambiguous_assoc_ty( &self, span: Span, types: &[String], traits: &[String], name: Symbol, ) -> ErrorGuaranteed

Source

pub(crate) fn complain_about_ambiguous_inherent_assoc_ty( &self, name: Ident, candidates: Vec<DefId>, span: Span, ) -> ErrorGuaranteed

Source

fn note_ambiguous_inherent_assoc_ty( &self, err: &mut Diag<'_>, candidates: Vec<DefId>, span: Span, )

Source

pub(crate) fn complain_about_inherent_assoc_ty_not_found( &self, name: Ident, self_ty: Ty<'tcx>, candidates: Vec<(DefId, (DefId, DefId))>, fulfillment_errors: Vec<FulfillmentError<'tcx>>, span: Span, ) -> ErrorGuaranteed

Source

pub(crate) fn complain_about_missing_assoc_tys( &self, associated_types: FxIndexMap<Span, FxIndexSet<DefId>>, potential_assoc_types: Vec<usize>, trait_bounds: &[PolyTraitRef<'_>], )

When there are any missing associated types, emit an E0191 error and attempt to supply a reasonable suggestion on how to write it. For the case of multiple associated types in the same trait bound have the same name (as they come from different supertraits), we instead emit a generic note suggesting using a where clause to constraint instead.

Source

pub(crate) fn maybe_report_similar_assoc_fn( &self, span: Span, qself_ty: Ty<'tcx>, qself: &Ty<'_>, ) -> Result<(), ErrorGuaranteed>

On ambiguous associated type, look for an associated function whose name matches the extended path and, if found, emit an E0223 error with a structured suggestion. e.g. for String::from::utf8, suggest String::from_utf8 (#109195)

Source

pub fn report_prohibit_generics_error<'a>( &self, segments: impl Iterator<Item = &'a PathSegment<'a>> + Clone, args_visitors: impl Iterator<Item = &'a GenericArg<'a>> + Clone, err_extend: GenericsArgsErrExtend<'_>, ) -> ErrorGuaranteed

Source

pub fn report_trait_object_addition_traits_error( &self, regular_traits: &Vec<TraitAliasExpansionInfo<'_>>, ) -> ErrorGuaranteed

Source

pub fn report_trait_object_with_no_traits_error( &self, span: Span, trait_bounds: &Vec<(Binder<'tcx, TraitRef<'tcx>>, Span)>, ) -> ErrorGuaranteed

Source§

impl<'tcx> dyn HirTyLowerer<'tcx> + '_

Source

pub(super) fn prohibit_or_lint_bare_trait_object_ty( &self, self_ty: &Ty<'_>, ) -> Option<ErrorGuaranteed>

Prohibit or lint against bare trait object types depending on the edition.

Bare trait object types are ones that aren’t preceded by the keyword dyn. In edition 2021 and onward we emit a hard error for them.

Source

fn maybe_suggest_blanket_trait_impl<G: EmissionGuarantee>( &self, self_ty: &Ty<'_>, diag: &mut Diag<'_, G>, )

Make sure that we are in the condition to suggest the blanket implementation.

Source

fn add_generic_param_suggestion( &self, generics: &Generics<'_>, self_ty_span: Span, impl_trait_name: &str, ) -> Vec<(Span, String)>

Source

fn maybe_suggest_impl_trait( &self, self_ty: &Ty<'_>, diag: &mut Diag<'_>, ) -> bool

Make sure that we are in the condition to suggest impl Trait.

Source

fn maybe_suggest_assoc_ty_bound(&self, self_ty: &Ty<'_>, diag: &mut Diag<'_>)

Source§

impl<'tcx> dyn HirTyLowerer<'tcx> + '_

Source

pub fn lower_lifetime( &self, lifetime: &Lifetime, reason: RegionInferReason<'_>, ) -> Region<'tcx>

Lower a lifetime from the HIR to our internal notion of a lifetime called a region.

Source

pub fn lower_resolved_lifetime(&self, resolved: ResolvedArg) -> Region<'tcx>

Lower a lifetime from the HIR to our internal notion of a lifetime called a region.

Source

pub fn lower_generic_args_of_path_segment( &self, span: Span, def_id: DefId, item_segment: &PathSegment<'tcx>, ) -> GenericArgsRef<'tcx>

Source

fn lower_generic_args_of_path( &self, span: Span, def_id: DefId, parent_args: &[GenericArg<'tcx>], segment: &PathSegment<'tcx>, self_ty: Option<Ty<'tcx>>, ) -> (GenericArgsRef<'tcx>, GenericArgCountResult)

Lower the generic arguments provided to some path.

If this is a trait reference, you also need to pass the self type self_ty. The lowering process may involve applying defaulted type parameters.

Associated item constraints are not handled here! They are either lowered via lower_assoc_item_constraint or rejected via prohibit_assoc_item_constraint.

§Example
   T: std::ops::Index<usize, Output = u32>
// ^1 ^^^^^^^^^^^^^^2 ^^^^3  ^^^^^^^^^^^4
  1. The self_ty here would refer to the type T.
  2. The path in question is the path to the trait std::ops::Index, which will have been resolved to a def_id
  3. The generic_args contains info on the <...> contents. The usize type parameters are returned in the GenericArgsRef
  4. Associated item constraints like Output = u32 are contained in generic_args.constraints.

Note that the type listing given here is exactly what the user provided.

For (generic) associated types

<Vec<u8> as Iterable<u8>>::Iter::<'a>

We have the parent args are the args for the parent trait: [Vec<u8>, u8] and generic_args are the arguments for the associated type itself: ['a]. The returned GenericArgsRef concatenates these two lists: [Vec<u8>, u8, 'a].

Source

pub fn lower_generic_args_of_assoc_item( &self, span: Span, item_def_id: DefId, item_segment: &PathSegment<'tcx>, parent_args: GenericArgsRef<'tcx>, ) -> GenericArgsRef<'tcx>

Source

pub fn lower_impl_trait_ref( &self, trait_ref: &TraitRef<'tcx>, self_ty: Ty<'tcx>, ) -> TraitRef<'tcx>

Lower a trait reference as found in an impl header as the implementee.

The self type self_ty is the implementer of the trait.

Source

pub(crate) fn lower_poly_trait_ref( &self, trait_ref: &TraitRef<'tcx>, span: Span, constness: BoundConstness, polarity: BoundPolarity, self_ty: Ty<'tcx>, bounds: &mut Bounds<'tcx>, predicate_filter: PredicateFilter, ) -> GenericArgCountResult

Lower a polymorphic trait reference given a self type into bounds.

Polymorphic in the sense that it may bind late-bound vars.

This may generate auxiliary bounds iff the trait reference contains associated item constraints.

§Example

Given the trait ref Iterator<Item = u32> and the self type Ty, this will add the

  1. trait predicate <Ty as Iterator> (known as Ty: Iterator in the surface syntax) and the
  2. projection predicate <Ty as Iterator>::Item = u32

to bounds.

§A Note on Binders

Against our usual convention, there is an implied binder around the self_ty and the trait_ref here. So they may reference late-bound vars.

If for example you had for<'a> Foo<'a>: Bar<'a>, then the self_ty would be Foo<'a> where 'a is a bound region at depth 0. Similarly, the trait_ref would be Bar<'a>. The lowered poly-trait-ref will track this binder explicitly, however.

Source

fn lower_mono_trait_ref( &self, span: Span, trait_def_id: DefId, self_ty: Ty<'tcx>, trait_segment: &PathSegment<'tcx>, is_impl: bool, ) -> TraitRef<'tcx>

Lower a monomorphic trait reference given a self type while prohibiting associated item bindings.

Monomorphic in the sense that it doesn’t bind any late-bound vars.

Source

fn probe_trait_that_defines_assoc_item( &self, trait_def_id: DefId, assoc_kind: AssocKind, assoc_name: Ident, ) -> bool

Source

fn lower_path_segment( &self, span: Span, did: DefId, item_segment: &PathSegment<'tcx>, ) -> Ty<'tcx>

Source

fn probe_single_ty_param_bound_for_assoc_item( &self, ty_param_def_id: LocalDefId, ty_param_span: Span, kind: AssocKind, assoc_name: Ident, span: Span, ) -> Result<PolyTraitRef<'tcx>, ErrorGuaranteed>

Search for a trait bound on a type parameter whose trait defines the associated item given by assoc_name and kind.

This fails if there is no such bound in the list of candidates or if there are multiple candidates in which case it reports ambiguity.

ty_param_def_id is the LocalDefId of the type parameter.

Source

fn probe_single_bound_for_assoc_item<I>( &self, all_candidates: impl Fn() -> I, qself: AssocItemQSelf, assoc_kind: AssocKind, assoc_name: Ident, span: Span, constraint: Option<&AssocItemConstraint<'tcx>>, ) -> Result<PolyTraitRef<'tcx>, ErrorGuaranteed>
where I: Iterator<Item = PolyTraitRef<'tcx>>,

Search for a single trait bound whose trait defines the associated item given by assoc_name.

This fails if there is no such bound in the list of candidates or if there are multiple candidates in which case it reports ambiguity.

Source

pub fn lower_assoc_path( &self, hir_ref_id: HirId, span: Span, qself_ty: Ty<'tcx>, qself: &'tcx Ty<'tcx>, assoc_segment: &'tcx PathSegment<'tcx>, permit_variants: bool, ) -> Result<(Ty<'tcx>, DefKind, DefId), ErrorGuaranteed>

Lower a type-relative path referring to an associated type or to an enum variant.

If the path refers to an enum variant and permit_variants holds, the returned type is simply the provided self type qself_ty.

A path like A::B::C::D is understood as <A::B::C>::D. I.e., qself_ty / qself is A::B::C and assoc_segment is D. We return the lowered type and the DefId for the whole path.

We only support associated type paths whose self type is a type parameter or a Self type alias (in a trait impl) like T::Ty (where T is a ty param) or Self::Ty. We don’t support paths whose self type is an arbitrary type like Struct::Ty where struct Struct impls an in-scope trait that defines an associated type called Ty. For the latter case, we report ambiguity. While desirable to support, the implementation would be non-trivial. Tracked in #22519.

At the time of writing, inherent associated types are also resolved here. This however is problematic. A proper implementation would be as non-trivial as the one described in the previous paragraph and their modeling of projections would likely be very similar in nature.

Source

fn probe_inherent_assoc_ty( &self, name: Ident, segment: &PathSegment<'tcx>, adt_did: DefId, self_ty: Ty<'tcx>, block: HirId, span: Span, ) -> Result<Option<(Ty<'tcx>, DefId)>, ErrorGuaranteed>

Source

fn select_inherent_assoc_type_candidates( &self, infcx: &InferCtxt<'tcx>, name: Ident, span: Span, self_ty: Ty<'tcx>, param_env: ParamEnv<'tcx>, candidates: Vec<(DefId, (DefId, DefId))>, ) -> Result<(DefId, (DefId, DefId)), ErrorGuaranteed>

Source

fn probe_assoc_item( &self, ident: Ident, kind: AssocKind, block: HirId, span: Span, scope: DefId, ) -> Option<AssocItem>

Given name and kind search for the assoc item in the provided scope and check if it’s accessible1.


  1. I.e., accessible in the provided scope wrt. visibility and stability. 

Source

fn probe_assoc_item_unchecked( &self, ident: Ident, kind: AssocKind, block: HirId, scope: DefId, ) -> Option<(AssocItem, DefId)>

Given name and kind search for the assoc item in the provided scope without checking if it’s accessible1.


  1. I.e., accessible in the provided scope wrt. visibility and stability. 

Source

fn check_assoc_item( &self, item_def_id: DefId, ident: Ident, scope: DefId, block: HirId, span: Span, )

Check if the given assoc item is accessible in the provided scope wrt. visibility and stability.

Source

fn probe_traits_that_match_assoc_ty( &self, qself_ty: Ty<'tcx>, assoc_ident: Ident, ) -> Vec<String>

Source

fn lower_qpath( &self, span: Span, opt_self_ty: Option<Ty<'tcx>>, item_def_id: DefId, trait_segment: &PathSegment<'tcx>, item_segment: &PathSegment<'tcx>, ) -> Ty<'tcx>

Lower a qualified path to a type.

Source

fn error_missing_qpath_self_ty( &self, trait_def_id: DefId, span: Span, item_segment: &PathSegment<'tcx>, ) -> Ty<'tcx>

Source

pub fn prohibit_generic_args<'a>( &self, segments: impl Iterator<Item = &'a PathSegment<'a>> + Clone, err_extend: GenericsArgsErrExtend<'_>, ) -> Result<(), ErrorGuaranteed>

Source

pub fn probe_generic_path_segments( &self, segments: &[PathSegment<'_>], self_ty: Option<Ty<'tcx>>, kind: DefKind, def_id: DefId, span: Span, ) -> Vec<GenericPathSegment>

Probe path segments that are semantically allowed to have generic arguments.

§Example
   Option::None::<()>
//         ^^^^ permitted to have generic args

// ==> [GenericPathSegment(Option_def_id, 1)]

   Option::<()>::None
// ^^^^^^        ^^^^ *not* permitted to have generic args
// permitted to have generic args

// ==> [GenericPathSegment(Option_def_id, 0)]
Source

pub fn lower_path( &self, opt_self_ty: Option<Ty<'tcx>>, path: &Path<'tcx>, hir_id: HirId, permit_variants: bool, ) -> Ty<'tcx>

Lower a type Path to a type.

Source

pub(crate) fn lower_ty_param(&self, hir_id: HirId) -> Ty<'tcx>

Lower a type parameter from the HIR to our internal notion of a type.

Early-bound type parameters get lowered to ty::Param and late-bound ones to ty::Bound.

Source

pub(crate) fn lower_const_param( &self, param_def_id: DefId, path_hir_id: HirId, ) -> Const<'tcx>

Lower a const parameter from the HIR to our internal notion of a constant.

Early-bound const parameters get lowered to ty::ConstKind::Param and late-bound ones to ty::ConstKind::Bound.

Source

pub fn lower_const_arg( &self, const_arg: &ConstArg<'tcx>, feed: FeedConstTy, ) -> Const<'tcx>

Convert a hir::ConstArg to a ty::Const.

Source

fn lower_const_path_resolved( &self, opt_self_ty: Option<Ty<'tcx>>, path: &Path<'tcx>, hir_id: HirId, ) -> Const<'tcx>

Source

fn lower_delegation_ty(&self, idx: InferDelegationKind) -> Ty<'tcx>

Source

pub fn lower_ty(&self, hir_ty: &Ty<'tcx>) -> Ty<'tcx>

Lower a type from the HIR to our internal notion of a type.

Source

fn lower_opaque_ty(&self, def_id: LocalDefId, in_trait: bool) -> Ty<'tcx>

Lower an opaque type (i.e., an existential impl-Trait type) from the HIR.

Source

pub fn lower_arg_ty( &self, ty: &Ty<'tcx>, expected_ty: Option<Ty<'tcx>>, ) -> Ty<'tcx>

Source

pub fn lower_fn_ty( &self, hir_id: HirId, safety: Safety, abi: ExternAbi, decl: &FnDecl<'tcx>, generics: Option<&Generics<'_>>, hir_ty: Option<&Ty<'_>>, ) -> PolyFnSig<'tcx>

Lower a function type from the HIR to our internal notion of a function signature.

Source

pub(crate) fn suggest_trait_fn_ty_for_impl_fn_infer( &self, fn_hir_id: HirId, arg_idx: Option<usize>, ) -> Option<Ty<'tcx>>

Given a fn_hir_id for a impl function, suggest the type that is found on the corresponding function in the trait that the impl implements, if it exists. If arg_idx is Some, then it corresponds to an input type index, otherwise it corresponds to the return type.

Source

fn validate_late_bound_regions<'cx>( &'cx self, constrained_regions: FxIndexSet<BoundRegionKind>, referenced_regions: FxIndexSet<BoundRegionKind>, generate_err: impl Fn(&str) -> Diag<'cx>, )

Source

fn compute_object_lifetime_bound( &self, span: Span, existential_predicates: &'tcx List<PolyExistentialPredicate<'tcx>>, ) -> Option<Region<'tcx>>

Given the bounds on an object, determines what single region bound (if any) we can use to summarize this type.

The basic idea is that we will use the bound the user provided, if they provided one, and otherwise search the supertypes of trait bounds for region bounds. It may be that we can derive no bound at all, in which case we return None.

Implementors§

Source§

impl<'tcx> HirTyLowerer<'tcx> for ItemCtxt<'tcx>