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<'_>,
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<'_>,
poly_trait_ref: PolyTraitRef<'tcx>
) -> Ty<'tcx>
fn projected_ty_from_poly_trait_ref( &self, span: Span, item_def_id: DefId, item_segment: &PathSegment<'_>, 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<'hir>>>(
&self,
param_ty: Ty<'tcx>,
ast_bounds: I,
bounds: &mut Bounds<'tcx>,
bound_vars: &'tcx List<BoundVariableKind>,
only_self_bounds: OnlySelfBounds
)
pub(crate) fn add_bounds<'hir, I: Iterator<Item = &'hir GenericBound<'hir>>>( &self, param_ty: Ty<'tcx>, ast_bounds: I, bounds: &mut Bounds<'tcx>, bound_vars: &'tcx List<BoundVariableKind>, only_self_bounds: OnlySelfBounds )
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<'_>],
filter: PredicateFilter
) -> Bounds<'tcx>
pub(crate) fn compute_bounds( &self, param_ty: Ty<'tcx>, ast_bounds: &[GenericBound<'_>], 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: &ConvertedBinding<'_, 'tcx>,
bounds: &mut Bounds<'tcx>,
speculative: bool,
dup_bindings: &mut FxHashMap<DefId, Span>,
path_span: Span,
constness: BoundConstness,
only_self_bounds: OnlySelfBounds,
polarity: ImplPolarity
) -> Result<(), ErrorGuaranteed>
pub(super) fn add_predicates_for_ast_type_binding( &self, hir_ref_id: HirId, trait_ref: PolyTraitRef<'tcx>, binding: &ConvertedBinding<'_, 'tcx>, bounds: &mut Bounds<'tcx>, speculative: bool, dup_bindings: &mut FxHashMap<DefId, Span>, path_span: Span, constness: BoundConstness, only_self_bounds: OnlySelfBounds, polarity: ImplPolarity ) -> 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<'o, 'tcx> dyn AstConv<'tcx> + 'o
impl<'o, 'tcx> dyn AstConv<'tcx> + 'o
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(crate) fn complain_about_assoc_type_not_found<I>( &self, all_candidates: impl Fn() -> I, ty_param_name: &str, assoc_name: Ident, span: Span ) -> ErrorGuaranteedwhere I: Iterator<Item = PolyTraitRef<'tcx>>,
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 Diagnostic, 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: FxHashMap<Span, BTreeSet<DefId>>,
potential_assoc_types: Vec<Span>,
trait_bounds: &[PolyTraitRef<'_>]
)
pub(crate) fn complain_about_missing_associated_types( &self, associated_types: FxHashMap<Span, BTreeSet<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.
source§impl<'o, 'tcx> dyn AstConv<'tcx> + 'o
impl<'o, 'tcx> dyn AstConv<'tcx> + 'o
sourcepub(super) fn maybe_lint_blanket_trait_impl(
&self,
self_ty: &Ty<'_>,
diag: &mut Diagnostic
)
pub(super) fn maybe_lint_blanket_trait_impl( &self, self_ty: &Ty<'_>, diag: &mut Diagnostic )
Make sure that we are in the condition to suggest the blanket implementation.
pub(super) fn maybe_lint_bare_trait(&self, self_ty: &Ty<'_>, in_path: bool)
source§impl<'o, 'tcx> dyn AstConv<'tcx> + 'o
impl<'o, 'tcx> dyn AstConv<'tcx> + 'o
pub(super) fn conv_object_ty_poly_trait_ref( &self, span: Span, hir_id: HirId, hir_trait_bounds: &[PolyTraitRef<'_>], lifetime: &Lifetime, borrowed: bool, representation: DynKind ) -> Ty<'tcx>
source§impl<'o, 'tcx> dyn AstConv<'tcx> + 'o
impl<'o, 'tcx> dyn AstConv<'tcx> + 'o
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<'_>
) -> GenericArgsRef<'tcx>
pub fn ast_path_args_for_ty( &self, span: Span, def_id: DefId, item_segment: &PathSegment<'_> ) -> 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<'a>(
&self,
span: Span,
def_id: DefId,
parent_args: &[GenericArg<'tcx>],
seg: &PathSegment<'_>,
generic_args: &'a GenericArgs<'_>,
infer_args: bool,
self_ty: Option<Ty<'tcx>>,
constness: BoundConstness
) -> (GenericArgsRef<'tcx>, GenericArgCountResult)
fn create_args_for_ast_path<'a>( &self, span: Span, def_id: DefId, parent_args: &[GenericArg<'tcx>], seg: &PathSegment<'_>, generic_args: &'a GenericArgs<'_>, infer_args: bool, 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 created from create_assoc_bindings_for_generic_args
.
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
, the associated type bindings likeOutput = u32
are returned fromcreate_assoc_bindings_for_generic_args
.
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]
.
fn create_assoc_bindings_for_generic_args<'a>( &self, generic_args: &'a GenericArgs<'_> ) -> Vec<ConvertedBinding<'a, 'tcx>>
pub fn create_args_for_associated_item( &self, span: Span, item_def_id: DefId, item_segment: &PathSegment<'_>, parent_args: GenericArgsRef<'tcx> ) -> GenericArgsRef<'tcx>
sourcepub fn instantiate_mono_trait_ref(
&self,
trait_ref: &TraitRef<'_>,
self_ty: Ty<'tcx>
) -> TraitRef<'tcx>
pub fn instantiate_mono_trait_ref( &self, trait_ref: &TraitRef<'_>, 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.
fn instantiate_poly_trait_ref_inner( &self, hir_id: HirId, span: Span, binding_span: Option<Span>, constness: BoundConstness, polarity: ImplPolarity, bounds: &mut Bounds<'tcx>, speculative: bool, trait_ref_span: Span, trait_def_id: DefId, trait_segment: &PathSegment<'_>, args: &GenericArgs<'_>, infer_args: bool, self_ty: Ty<'tcx>, only_self_bounds: OnlySelfBounds ) -> GenericArgCountResult
sourcepub(crate) fn instantiate_poly_trait_ref(
&self,
trait_ref: &TraitRef<'_>,
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<'_>, 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 bounder 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.
pub(crate) fn instantiate_lang_item_trait_ref( &self, lang_item: LangItem, span: Span, hir_id: HirId, args: &GenericArgs<'_>, self_ty: Ty<'tcx>, bounds: &mut Bounds<'tcx>, only_self_bounds: OnlySelfBounds )
fn ast_path_to_mono_trait_ref( &self, span: Span, trait_def_id: DefId, self_ty: Ty<'tcx>, trait_segment: &PathSegment<'_>, is_impl: bool, constness: BoundConstness ) -> TraitRef<'tcx>
fn create_args_for_ast_trait_ref<'a>( &self, span: Span, trait_def_id: DefId, self_ty: Ty<'tcx>, trait_segment: &'a PathSegment<'a>, is_impl: bool, constness: BoundConstness ) -> (GenericArgsRef<'tcx>, GenericArgCountResult)
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<'_> ) -> Ty<'tcx>
fn report_ambiguous_associated_type( &self, span: Span, types: &[String], traits: &[String], name: Symbol ) -> ErrorGuaranteed
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_type<I>( &self, all_candidates: impl Fn() -> I, ty_param_name: impl Display, assoc_name: Ident, span: Span, is_equality: Option<Term<'tcx>> ) -> Result<PolyTraitRef<'tcx>, ErrorGuaranteed>where I: Iterator<Item = PolyTraitRef<'tcx>>,
fn one_bound_for_assoc_method( &self, all_candidates: impl Iterator<Item = PolyTraitRef<'tcx>>, ty_name: impl Display, assoc_name: Ident, span: Span ) -> Result<PolyTraitRef<'tcx>, ErrorGuaranteed>
pub fn associated_path_to_ty( &self, hir_ref_id: HirId, span: Span, qself_ty: Ty<'tcx>, qself: &Ty<'_>, assoc_segment: &PathSegment<'_>, permit_variants: bool ) -> Result<(Ty<'tcx>, DefKind, DefId), ErrorGuaranteed>
fn lookup_inherent_assoc_ty( &self, name: Ident, segment: &PathSegment<'_>, adt_did: DefId, self_ty: Ty<'tcx>, block: HirId, span: Span ) -> Result<Option<(Ty<'tcx>, 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<'_>, item_segment: &PathSegment<'_>, constness: BoundConstness ) -> Ty<'tcx>
pub fn prohibit_generics<'a>( &self, segments: impl Iterator<Item = &'a PathSegment<'a>> + Clone, extend: impl Fn(&mut Diagnostic) ) -> 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<'_>,
hir_id: HirId,
permit_variants: bool
) -> Ty<'tcx>
pub fn res_to_ty( &self, opt_self_ty: Option<Ty<'tcx>>, path: &Path<'_>, 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<'_>) -> Ty<'tcx>
pub fn ast_ty_to_ty(&self, ast_ty: &Ty<'_>) -> 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<'_>) -> Ty<'tcx>
pub fn ast_ty_to_ty_in_path(&self, ast_ty: &Ty<'_>) -> 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.
sourcefn ast_ty_to_ty_inner(
&self,
ast_ty: &Ty<'_>,
borrowed: bool,
in_path: bool
) -> Ty<'tcx>
fn ast_ty_to_ty_inner( &self, ast_ty: &Ty<'_>, 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<'_>], origin: OpaqueTyOrigin, in_trait: bool ) -> Ty<'tcx>
pub fn ty_of_arg(&self, ty: &Ty<'_>, expected_ty: Option<Ty<'tcx>>) -> Ty<'tcx>
pub fn ty_of_fn( &self, hir_id: HirId, unsafety: Unsafety, abi: Abi, decl: &FnDecl<'_>, 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) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> )
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
.