Trait rustc_hir_analysis::astconv::AstConv
source · pub trait AstConv<'tcx> {
Show 13 methods
// Required methods
fn tcx(&self) -> TyCtxt<'tcx>;
fn item_def_id(&self) -> DefId;
fn get_type_parameter_bounds(
&self,
span: Span,
def_id: LocalDefId,
assoc_name: Ident
) -> GenericPredicates<'tcx>;
fn re_infer(
&self,
param: Option<&GenericParamDef>,
span: Span
) -> Option<Region<'tcx>>;
fn ty_infer(&self, param: Option<&GenericParamDef>, span: Span) -> Ty<'tcx>;
fn allow_ty_infer(&self) -> bool;
fn ct_infer(
&self,
ty: Ty<'tcx>,
param: Option<&GenericParamDef>,
span: Span
) -> Const<'tcx>;
fn projected_ty_from_poly_trait_ref(
&self,
span: Span,
item_def_id: DefId,
item_segment: &PathSegment<'tcx>,
poly_trait_ref: PolyTraitRef<'tcx>
) -> Ty<'tcx>;
fn probe_adt(&self, span: Span, ty: Ty<'tcx>) -> Option<AdtDef<'tcx>>;
fn set_tainted_by_errors(&self, e: ErrorGuaranteed);
fn record_ty(&self, hir_id: HirId, ty: Ty<'tcx>, span: Span);
fn infcx(&self) -> Option<&InferCtxt<'tcx>>;
// Provided method
fn astconv(&self) -> &dyn AstConv<'tcx>
where Self: Sized { ... }
}
Required Methods§
fn tcx(&self) -> TyCtxt<'tcx>
fn item_def_id(&self) -> DefId
sourcefn get_type_parameter_bounds(
&self,
span: Span,
def_id: LocalDefId,
assoc_name: Ident
) -> GenericPredicates<'tcx>
fn get_type_parameter_bounds( &self, span: Span, def_id: LocalDefId, assoc_name: Ident ) -> GenericPredicates<'tcx>
Returns predicates in scope of the form X: Foo<T>
, where X
is a type parameter X
with the given id def_id
and T
matches assoc_name
. This is a subset of the full set of
predicates.
This is used for one specific purpose: resolving “short-hand”
associated type references like T::Item
. 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”.
sourcefn re_infer(
&self,
param: Option<&GenericParamDef>,
span: Span
) -> Option<Region<'tcx>>
fn re_infer( &self, param: Option<&GenericParamDef>, span: Span ) -> Option<Region<'tcx>>
Returns the lifetime to use when a lifetime is omitted (and not elided).
sourcefn ty_infer(&self, param: Option<&GenericParamDef>, span: Span) -> Ty<'tcx>
fn ty_infer(&self, param: Option<&GenericParamDef>, span: Span) -> Ty<'tcx>
Returns the type to use when a type is omitted.
sourcefn allow_ty_infer(&self) -> bool
fn allow_ty_infer(&self) -> bool
Returns true
if _
is allowed in type signatures in the current context.
sourcefn ct_infer(
&self,
ty: Ty<'tcx>,
param: Option<&GenericParamDef>,
span: Span
) -> Const<'tcx>
fn ct_infer( &self, ty: Ty<'tcx>, param: Option<&GenericParamDef>, span: Span ) -> Const<'tcx>
Returns the const to use when a const is omitted.
sourcefn projected_ty_from_poly_trait_ref(
&self,
span: Span,
item_def_id: DefId,
item_segment: &PathSegment<'tcx>,
poly_trait_ref: PolyTraitRef<'tcx>
) -> Ty<'tcx>
fn projected_ty_from_poly_trait_ref( &self, span: Span, item_def_id: DefId, item_segment: &PathSegment<'tcx>, poly_trait_ref: PolyTraitRef<'tcx> ) -> Ty<'tcx>
Projecting an associated type from a (potentially) higher-ranked trait reference is more complicated, because of the possibility of late-bound regions appearing in the associated type binding. This is not legal in function signatures for that reason. In a function body, we can always handle it because we can use inference variables to remove the late-bound regions.
sourcefn probe_adt(&self, span: Span, ty: Ty<'tcx>) -> Option<AdtDef<'tcx>>
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 projection 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.
sourcefn set_tainted_by_errors(&self, e: ErrorGuaranteed)
fn set_tainted_by_errors(&self, e: ErrorGuaranteed)
Invoked when we encounter an error from some prior pass (e.g., resolve) that is translated into a ty-error. This is used to help suppress derived errors typeck might otherwise report.
fn record_ty(&self, hir_id: HirId, ty: Ty<'tcx>, span: Span)
fn infcx(&self) -> Option<&InferCtxt<'tcx>>
Provided Methods§
Implementations§
source§impl<'tcx> dyn AstConv<'tcx> + '_
impl<'tcx> dyn AstConv<'tcx> + '_
sourcepub(crate) fn add_implicitly_sized(
&self,
bounds: &mut Bounds<'tcx>,
self_ty: Ty<'tcx>,
ast_bounds: &'tcx [GenericBound<'tcx>],
self_ty_where_predicates: Option<(LocalDefId, &'tcx [WherePredicate<'tcx>])>,
span: Span
)
pub(crate) fn add_implicitly_sized( &self, bounds: &mut Bounds<'tcx>, self_ty: Ty<'tcx>, ast_bounds: &'tcx [GenericBound<'tcx>], self_ty_where_predicates: Option<(LocalDefId, &'tcx [WherePredicate<'tcx>])>, span: Span )
Sets implicitly_sized
to true on Bounds
if necessary
sourcepub(crate) fn add_bounds<'hir, I: Iterator<Item = &'hir GenericBound<'tcx>>>(
&self,
param_ty: Ty<'tcx>,
ast_bounds: I,
bounds: &mut Bounds<'tcx>,
bound_vars: &'tcx List<BoundVariableKind>,
only_self_bounds: OnlySelfBounds
)where
'tcx: 'hir,
pub(crate) fn add_bounds<'hir, I: Iterator<Item = &'hir GenericBound<'tcx>>>(
&self,
param_ty: Ty<'tcx>,
ast_bounds: I,
bounds: &mut Bounds<'tcx>,
bound_vars: &'tcx List<BoundVariableKind>,
only_self_bounds: OnlySelfBounds
)where
'tcx: 'hir,
This helper takes a converted parameter type (param_ty
)
and an unconverted list of bounds:
fn foo<T: Debug>
^ ^^^^^ `ast_bounds` parameter, in HIR form
|
`param_ty`, in ty form
It adds these ast_bounds
into the bounds
structure.
A note on binders: there is an implied binder around
param_ty
and ast_bounds
. See instantiate_poly_trait_ref
for more details.
sourcepub(crate) fn compute_bounds(
&self,
param_ty: Ty<'tcx>,
ast_bounds: &[GenericBound<'tcx>],
filter: PredicateFilter
) -> Bounds<'tcx>
pub(crate) fn compute_bounds( &self, param_ty: Ty<'tcx>, ast_bounds: &[GenericBound<'tcx>], filter: PredicateFilter ) -> Bounds<'tcx>
Translates a list of bounds from the HIR into the Bounds
data structure.
The self-type for the bounds is given by param_ty
.
Example:
fn foo<T: Bar + Baz>() { }
// ^ ^^^^^^^^^ ast_bounds
// param_ty
The sized_by_default
parameter indicates if, in this context, the param_ty
should be
considered Sized
unless there is an explicit ?Sized
bound. This would be true in the
example above, but is not true in supertrait listings like trait Foo: Bar + Baz
.
span
should be the declaration size of the parameter.
sourcepub(super) fn add_predicates_for_ast_type_binding(
&self,
hir_ref_id: HirId,
trait_ref: PolyTraitRef<'tcx>,
binding: &TypeBinding<'tcx>,
bounds: &mut Bounds<'tcx>,
speculative: bool,
dup_bindings: &mut FxIndexMap<DefId, Span>,
path_span: Span,
only_self_bounds: OnlySelfBounds
) -> Result<(), ErrorGuaranteed>
pub(super) fn add_predicates_for_ast_type_binding( &self, hir_ref_id: HirId, trait_ref: PolyTraitRef<'tcx>, binding: &TypeBinding<'tcx>, bounds: &mut Bounds<'tcx>, speculative: bool, dup_bindings: &mut FxIndexMap<DefId, Span>, path_span: Span, only_self_bounds: OnlySelfBounds ) -> Result<(), ErrorGuaranteed>
Given an HIR binding like Item = Foo
or Item: Foo
, pushes the corresponding predicates
onto 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 binding
data however is from inside
the binder (e.g., &'a u32
) and hence may reference bound regions.
source§impl<'tcx> dyn AstConv<'tcx> + '_
impl<'tcx> dyn AstConv<'tcx> + '_
sourcepub(crate) fn complain_about_missing_type_params(
&self,
missing_type_params: Vec<Symbol>,
def_id: DefId,
span: Span,
empty_generic_args: bool
)
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.
sourcepub(crate) fn complain_about_internal_fn_trait(
&self,
span: Span,
trait_def_id: DefId,
trait_segment: &PathSegment<'_>,
is_impl: bool
)
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.
pub(super) fn complain_about_assoc_item_not_found<I>(
&self,
all_candidates: impl Fn() -> I,
ty_param_name: &str,
ty_param_def_id: Option<LocalDefId>,
assoc_kind: AssocKind,
assoc_name: Ident,
span: Span,
binding: Option<&TypeBinding<'tcx>>
) -> ErrorGuaranteedwhere
I: Iterator<Item = PolyTraitRef<'tcx>>,
fn complain_about_assoc_kind_mismatch( &self, assoc_item: &AssocItem, assoc_kind: AssocKind, ident: Ident, span: Span, binding: Option<&TypeBinding<'tcx>> ) -> ErrorGuaranteed
pub(super) fn report_ambiguous_associated_type( &self, span: Span, types: &[String], traits: &[String], name: Symbol ) -> ErrorGuaranteed
pub(crate) fn complain_about_ambiguous_inherent_assoc_type( &self, name: Ident, candidates: Vec<DefId>, span: Span ) -> ErrorGuaranteed
fn note_ambiguous_inherent_assoc_type( &self, err: &mut Diag<'_>, candidates: Vec<DefId>, span: Span )
pub(crate) fn complain_about_inherent_assoc_type_not_found( &self, name: Ident, self_ty: Ty<'tcx>, candidates: Vec<(DefId, (DefId, DefId))>, fulfillment_errors: Vec<FulfillmentError<'tcx>>, span: Span ) -> ErrorGuaranteed
sourcepub(crate) fn complain_about_missing_associated_types(
&self,
associated_types: FxIndexMap<Span, FxIndexSet<DefId>>,
potential_assoc_types: Vec<Span>,
trait_bounds: &[PolyTraitRef<'_>]
)
pub(crate) fn complain_about_missing_associated_types( &self, associated_types: FxIndexMap<Span, FxIndexSet<DefId>>, potential_assoc_types: Vec<Span>, 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.
sourcepub(crate) fn maybe_report_similar_assoc_fn(
&self,
span: Span,
qself_ty: Ty<'tcx>,
qself: &Ty<'_>
) -> Result<(), ErrorGuaranteed>
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§impl<'tcx> dyn AstConv<'tcx> + '_
impl<'tcx> dyn AstConv<'tcx> + '_
sourcepub(super) fn maybe_lint_blanket_trait_impl<G: EmissionGuarantee>(
&self,
self_ty: &Ty<'_>,
diag: &mut Diag<'_, G>
)
pub(super) fn maybe_lint_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.
fn add_generic_param_suggestion( &self, generics: &Generics<'_>, self_ty_span: Span, impl_trait_name: &str ) -> Vec<(Span, String)>
sourcefn maybe_lint_impl_trait(&self, self_ty: &Ty<'_>, diag: &mut Diag<'_>) -> bool
fn maybe_lint_impl_trait(&self, self_ty: &Ty<'_>, diag: &mut Diag<'_>) -> bool
Make sure that we are in the condition to suggest impl Trait
.
pub(super) fn maybe_lint_bare_trait(&self, self_ty: &Ty<'_>, in_path: bool)
source§impl<'tcx> dyn AstConv<'tcx> + '_
impl<'tcx> dyn AstConv<'tcx> + '_
pub(super) fn conv_object_ty_poly_trait_ref( &self, span: Span, hir_id: HirId, hir_trait_bounds: &[PolyTraitRef<'tcx>], lifetime: &Lifetime, borrowed: bool, representation: DynKind ) -> Ty<'tcx>
source§impl<'tcx> dyn AstConv<'tcx> + '_
impl<'tcx> dyn AstConv<'tcx> + '_
pub fn ast_region_to_region( &self, lifetime: &Lifetime, def: Option<&GenericParamDef> ) -> Region<'tcx>
sourcepub fn ast_path_args_for_ty(
&self,
span: Span,
def_id: DefId,
item_segment: &PathSegment<'tcx>
) -> GenericArgsRef<'tcx>
pub fn ast_path_args_for_ty( &self, span: Span, def_id: DefId, item_segment: &PathSegment<'tcx> ) -> GenericArgsRef<'tcx>
Given a path path
that refers to an item I
with the declared generics decl_generics
,
returns an appropriate set of generic arguments for this particular reference to I
.
sourcefn create_args_for_ast_path(
&self,
span: Span,
def_id: DefId,
parent_args: &[GenericArg<'tcx>],
segment: &PathSegment<'tcx>,
self_ty: Option<Ty<'tcx>>,
constness: BoundConstness
) -> (GenericArgsRef<'tcx>, GenericArgCountResult)
fn create_args_for_ast_path( &self, span: Span, def_id: DefId, parent_args: &[GenericArg<'tcx>], segment: &PathSegment<'tcx>, self_ty: Option<Ty<'tcx>>, constness: BoundConstness ) -> (GenericArgsRef<'tcx>, GenericArgCountResult)
Given the type/lifetime/const arguments provided to some path (along with
an implicit Self
, if this is a trait reference), returns the complete
set of generic arguments. This may involve applying defaulted type parameters.
Constraints on associated types are not converted here but
separately in add_predicates_for_ast_type_binding
.
Example:
T: std::ops::Index<usize, Output = u32>
// ^1 ^^^^^^^^^^^^^^2 ^^^^3 ^^^^^^^^^^^4
- The
self_ty
here would refer to the typeT
. - The path in question is the path to the trait
std::ops::Index
, which will have been resolved to adef_id
- The
generic_args
contains info on the<...>
contents. Theusize
type parameters are returned in theGenericArgsRef
- Associated type bindings like
Output = u32
are contained ingeneric_args.bindings
.
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]
.
pub fn create_args_for_associated_item( &self, span: Span, item_def_id: DefId, item_segment: &PathSegment<'tcx>, parent_args: GenericArgsRef<'tcx> ) -> GenericArgsRef<'tcx>
sourcepub fn instantiate_mono_trait_ref(
&self,
trait_ref: &TraitRef<'tcx>,
self_ty: Ty<'tcx>
) -> TraitRef<'tcx>
pub fn instantiate_mono_trait_ref( &self, trait_ref: &TraitRef<'tcx>, self_ty: Ty<'tcx> ) -> TraitRef<'tcx>
Instantiates the path for the given trait reference, assuming that it’s
bound to a valid trait type. Returns the DefId
of the defining trait.
The type cannot be a type other than a trait type.
If the projections
argument is None
, then assoc type bindings like Foo<T = X>
are disallowed. Otherwise, they are pushed onto the vector given.
sourcepub(crate) fn instantiate_poly_trait_ref(
&self,
trait_ref: &TraitRef<'tcx>,
span: Span,
constness: BoundConstness,
polarity: ImplPolarity,
self_ty: Ty<'tcx>,
bounds: &mut Bounds<'tcx>,
speculative: bool,
only_self_bounds: OnlySelfBounds
) -> GenericArgCountResult
pub(crate) fn instantiate_poly_trait_ref( &self, trait_ref: &TraitRef<'tcx>, span: Span, constness: BoundConstness, polarity: ImplPolarity, self_ty: Ty<'tcx>, bounds: &mut Bounds<'tcx>, speculative: bool, only_self_bounds: OnlySelfBounds ) -> GenericArgCountResult
Given a trait bound like Debug
, applies that trait bound the given self-type to construct
a full trait reference. The resulting trait reference is returned. This may also generate
auxiliary bounds, which are added to bounds
.
Example:
poly_trait_ref = Iterator<Item = u32>
self_ty = Foo
this would return Foo: Iterator
and add <Foo as Iterator>::Item = u32
into bounds
.
A note on binders: against our usual convention, there is an implied binder around
the self_ty
and poly_trait_ref
parameters here. So they may reference bound regions.
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 poly_trait_ref
would be
Bar<'a>
. The returned poly-trait-ref will have this binder instantiated explicitly,
however.
fn ast_path_to_mono_trait_ref( &self, span: Span, trait_def_id: DefId, self_ty: Ty<'tcx>, trait_segment: &PathSegment<'tcx>, is_impl: bool, constness: BoundConstness ) -> TraitRef<'tcx>
fn trait_defines_associated_item_named( &self, trait_def_id: DefId, assoc_kind: AssocKind, assoc_name: Ident ) -> bool
fn ast_path_to_ty( &self, span: Span, did: DefId, item_segment: &PathSegment<'tcx> ) -> Ty<'tcx>
fn find_bound_for_assoc_item( &self, ty_param_def_id: LocalDefId, assoc_name: Ident, span: Span ) -> Result<PolyTraitRef<'tcx>, ErrorGuaranteed>
fn one_bound_for_assoc_item<I>(
&self,
all_candidates: impl Fn() -> I,
ty_param_name: impl Display,
ty_param_def_id: Option<LocalDefId>,
assoc_kind: AssocKind,
assoc_name: Ident,
span: Span,
binding: Option<&TypeBinding<'tcx>>
) -> Result<PolyTraitRef<'tcx>, ErrorGuaranteed>where
I: Iterator<Item = PolyTraitRef<'tcx>>,
pub fn associated_path_to_ty( &self, hir_ref_id: HirId, span: Span, qself_ty: Ty<'tcx>, qself: &Ty<'_>, assoc_segment: &PathSegment<'tcx>, permit_variants: bool ) -> Result<(Ty<'tcx>, DefKind, DefId), ErrorGuaranteed>
fn lookup_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>
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>
fn lookup_assoc_ty( &self, name: Ident, block: HirId, span: Span, scope: DefId ) -> Option<DefId>
fn lookup_assoc_ty_unchecked( &self, name: Ident, block: HirId, scope: DefId ) -> Option<(DefId, DefId)>
fn check_assoc_ty( &self, item: DefId, name: Ident, def_scope: DefId, block: HirId, span: Span )
fn probe_traits_that_match_assoc_ty( &self, qself_ty: Ty<'tcx>, assoc_ident: Ident ) -> Vec<String>
fn qpath_to_ty( &self, span: Span, opt_self_ty: Option<Ty<'tcx>>, item_def_id: DefId, trait_segment: &PathSegment<'tcx>, item_segment: &PathSegment<'tcx>, constness: BoundConstness ) -> Ty<'tcx>
pub fn prohibit_generics<'a>( &self, segments: impl Iterator<Item = &'a PathSegment<'a>> + Clone, extend: impl Fn(&mut Diag<'_>) ) -> bool
pub fn def_ids_for_value_path_segments( &self, segments: &[PathSegment<'_>], self_ty: Option<Ty<'tcx>>, kind: DefKind, def_id: DefId, span: Span ) -> Vec<PathSeg>
sourcepub fn res_to_ty(
&self,
opt_self_ty: Option<Ty<'tcx>>,
path: &Path<'tcx>,
hir_id: HirId,
permit_variants: bool
) -> Ty<'tcx>
pub fn res_to_ty( &self, opt_self_ty: Option<Ty<'tcx>>, path: &Path<'tcx>, hir_id: HirId, permit_variants: bool ) -> Ty<'tcx>
Check a type Path
and convert it to a Ty
.
pub(crate) fn hir_id_to_bound_ty(&self, hir_id: HirId) -> Ty<'tcx>
pub(crate) fn hir_id_to_bound_const( &self, hir_id: HirId, param_ty: Ty<'tcx> ) -> Const<'tcx>
sourcepub fn ast_ty_to_ty(&self, ast_ty: &Ty<'tcx>) -> Ty<'tcx>
pub fn ast_ty_to_ty(&self, ast_ty: &Ty<'tcx>) -> Ty<'tcx>
Parses the programmer’s textual representation of a type into our internal notion of a type.
sourcepub fn ast_ty_to_ty_in_path(&self, ast_ty: &Ty<'tcx>) -> Ty<'tcx>
pub fn ast_ty_to_ty_in_path(&self, ast_ty: &Ty<'tcx>) -> Ty<'tcx>
Parses the programmer’s textual representation of a type into our internal notion of a type. This is meant to be used within a path.
fn check_delegation_constraints( &self, sig_id: DefId, span: Span, emit: bool ) -> bool
fn ty_from_delegation( &self, sig_id: DefId, idx: InferDelegationKind, span: Span ) -> Ty<'tcx>
sourcefn ast_ty_to_ty_inner(
&self,
ast_ty: &Ty<'tcx>,
borrowed: bool,
in_path: bool
) -> Ty<'tcx>
fn ast_ty_to_ty_inner( &self, ast_ty: &Ty<'tcx>, borrowed: bool, in_path: bool ) -> Ty<'tcx>
Turns a hir::Ty
into a Ty
. For diagnostics’ purposes we keep track of whether trait
objects are borrowed like &dyn Trait
to avoid emitting redundant errors.
fn impl_trait_ty_to_ty( &self, def_id: DefId, lifetimes: &[GenericArg<'_>], in_trait: bool ) -> Ty<'tcx>
pub fn ty_of_arg( &self, ty: &Ty<'tcx>, expected_ty: Option<Ty<'tcx>> ) -> Ty<'tcx>
pub fn ty_of_fn( &self, hir_id: HirId, unsafety: Unsafety, abi: Abi, decl: &FnDecl<'tcx>, generics: Option<&Generics<'_>>, hir_ty: Option<&Ty<'_>> ) -> PolyFnSig<'tcx>
sourcefn suggest_trait_fn_ty_for_impl_fn_infer(
&self,
fn_hir_id: HirId,
arg_idx: Option<usize>
) -> Option<Ty<'tcx>>
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.
fn validate_late_bound_regions( &self, constrained_regions: FxHashSet<BoundRegionKind>, referenced_regions: FxHashSet<BoundRegionKind>, generate_err: impl Fn(&str) -> Diag<'tcx> )
sourcefn compute_object_lifetime_bound(
&self,
span: Span,
existential_predicates: &'tcx List<PolyExistentialPredicate<'tcx>>
) -> Option<Region<'tcx>>
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
.