Trait rustc_typeck::astconv::AstConv
source · [−]pub trait AstConv<'tcx> {
fn tcx<'a>(&'a self) -> TyCtxt<'tcx>;
fn item_def_id(&self) -> Option<DefId>;
fn get_type_parameter_bounds(
&self,
span: Span,
def_id: DefId,
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 normalize_ty(&self, span: Span, ty: Ty<'tcx>) -> Ty<'tcx>;
fn set_tainted_by_errors(&self);
fn record_ty(&self, hir_id: HirId, ty: Ty<'tcx>, span: Span);
}
Required Methods
fn item_def_id(&self) -> Option<DefId>
sourcefn get_type_parameter_bounds(
&self,
span: Span,
def_id: DefId,
assoc_name: Ident
) -> GenericPredicates<'tcx>
fn get_type_parameter_bounds(
&self,
span: Span,
def_id: DefId,
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”.
Returns the lifetime to use when a lifetime is omitted (and not elided).
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.
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 normalize_ty(&self, span: Span, ty: Ty<'tcx>) -> Ty<'tcx>
fn normalize_ty(&self, span: Span, ty: Ty<'tcx>) -> Ty<'tcx>
Normalize an associated type coming from the user.
sourcefn set_tainted_by_errors(&self)
fn set_tainted_by_errors(&self)
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.
Implementations
sourceimpl<'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>>,
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.
sourceimpl<'o, 'tcx> dyn AstConv<'tcx> + 'o
impl<'o, 'tcx> dyn AstConv<'tcx> + 'o
sourcefn generic_arg_mismatch_err(
tcx: TyCtxt<'_>,
arg: &GenericArg<'_>,
param: &GenericParamDef,
possible_ordering_error: bool,
help: Option<&str>
)
fn generic_arg_mismatch_err(
tcx: TyCtxt<'_>,
arg: &GenericArg<'_>,
param: &GenericParamDef,
possible_ordering_error: bool,
help: Option<&str>
)
Report an error that a generic argument did not match the generic parameter that was expected.
sourcepub fn create_substs_for_generic_args<'a>(
tcx: TyCtxt<'tcx>,
def_id: DefId,
parent_substs: &[GenericArg<'tcx>],
has_self: bool,
self_ty: Option<Ty<'tcx>>,
arg_count: &GenericArgCountResult,
ctx: &mut impl CreateSubstsForGenericArgsCtxt<'a, 'tcx>
) -> SubstsRef<'tcx>
pub fn create_substs_for_generic_args<'a>(
tcx: TyCtxt<'tcx>,
def_id: DefId,
parent_substs: &[GenericArg<'tcx>],
has_self: bool,
self_ty: Option<Ty<'tcx>>,
arg_count: &GenericArgCountResult,
ctx: &mut impl CreateSubstsForGenericArgsCtxt<'a, 'tcx>
) -> SubstsRef<'tcx>
Creates the relevant generic argument substitutions corresponding to a set of generic parameters. This is a rather complex function. Let us try to explain the role of each of its parameters:
To start, we are given the def_id
of the thing we are
creating the substitutions for, and a partial set of
substitutions parent_substs
. In general, the substitutions
for an item begin with substitutions for all the “parents” of
that item – e.g., for a method it might include the
parameters from the impl.
Therefore, the method begins by walking down these parents,
starting with the outermost parent and proceed inwards until
it reaches def_id
. For each parent P
, it will check parent_substs
first to see if the parent’s substitutions are listed in there. If so,
we can append those and move on. Otherwise, it invokes the
three callback functions:
args_for_def_id
: given theDefId
P
, supplies back the generic arguments that were given to that parent from within the path; so e.g., if you have<T as Foo>::Bar
, theDefId
might refer to the traitFoo
, and the arguments might be[T]
. The boolean value indicates whether to infer values for arguments whose values were not explicitly provided.provided_kind
: given the generic parameter and the value fromargs_for_def_id
, instantiate aGenericArg
.inferred_kind
: if no parameter was provided, and inference is enabled, then creates a suitable inference variable.
sourcepub fn check_generic_arg_count_for_call(
tcx: TyCtxt<'_>,
span: Span,
def_id: DefId,
generics: &Generics,
seg: &PathSegment<'_>,
is_method_call: IsMethodCall
) -> GenericArgCountResult
pub fn check_generic_arg_count_for_call(
tcx: TyCtxt<'_>,
span: Span,
def_id: DefId,
generics: &Generics,
seg: &PathSegment<'_>,
is_method_call: IsMethodCall
) -> GenericArgCountResult
Checks that the correct number of generic arguments have been provided. Used specifically for function calls.
sourcepub(crate) fn check_generic_arg_count(
tcx: TyCtxt<'_>,
span: Span,
def_id: DefId,
seg: &PathSegment<'_>,
gen_params: &Generics,
gen_args: &GenericArgs<'_>,
gen_pos: GenericArgPosition,
has_self: bool,
infer_args: bool
) -> GenericArgCountResult
pub(crate) fn check_generic_arg_count(
tcx: TyCtxt<'_>,
span: Span,
def_id: DefId,
seg: &PathSegment<'_>,
gen_params: &Generics,
gen_args: &GenericArgs<'_>,
gen_pos: GenericArgPosition,
has_self: bool,
infer_args: bool
) -> GenericArgCountResult
Checks that the correct number of generic arguments have been provided. This is used both for datatypes and function calls.
sourcepub fn prohibit_assoc_ty_binding(tcx: TyCtxt<'_>, span: Span)
pub fn prohibit_assoc_ty_binding(tcx: TyCtxt<'_>, span: Span)
Emits an error regarding forbidden type binding associations
sourcepub(crate) fn prohibit_explicit_late_bound_lifetimes(
tcx: TyCtxt<'_>,
def: &Generics,
args: &GenericArgs<'_>,
position: GenericArgPosition
) -> ExplicitLateBound
pub(crate) fn prohibit_explicit_late_bound_lifetimes(
tcx: TyCtxt<'_>,
def: &Generics,
args: &GenericArgs<'_>,
position: GenericArgPosition
) -> ExplicitLateBound
Prohibits explicit lifetime arguments if late-bound lifetime parameters are present. This is used both for datatypes and function calls.
sourceimpl<'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_substs_for_ty(
&self,
span: Span,
def_id: DefId,
item_segment: &PathSegment<'_>
) -> SubstsRef<'tcx>
pub fn ast_path_substs_for_ty(
&self,
span: Span,
def_id: DefId,
item_segment: &PathSegment<'_>
) -> SubstsRef<'tcx>
Given a path path
that refers to an item I
with the declared generics decl_generics
,
returns an appropriate set of substitutions for this particular reference to I
.
sourcefn create_substs_for_ast_path<'a>(
&self,
span: Span,
def_id: DefId,
parent_substs: &[GenericArg<'tcx>],
seg: &PathSegment<'_>,
generic_args: &'a GenericArgs<'_>,
infer_args: bool,
self_ty: Option<Ty<'tcx>>
) -> (SubstsRef<'tcx>, GenericArgCountResult)
fn create_substs_for_ast_path<'a>(
&self,
span: Span,
def_id: DefId,
parent_substs: &[GenericArg<'tcx>],
seg: &PathSegment<'_>,
generic_args: &'a GenericArgs<'_>,
infer_args: bool,
self_ty: Option<Ty<'tcx>>
) -> (SubstsRef<'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 substitutions. 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 theSubstsRef
, 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 substs are the substs for the parent trait:
[Vec<u8>, u8]
and generic_args
are the arguments for the associated
type itself: ['a]
. The returned SubstsRef
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(crate) fn create_substs_for_associated_item(
&self,
tcx: TyCtxt<'tcx>,
span: Span,
item_def_id: DefId,
item_segment: &PathSegment<'_>,
parent_substs: SubstsRef<'tcx>
) -> SubstsRef<'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,
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>
) -> GenericArgCountResult
sourcepub(crate) fn instantiate_poly_trait_ref(
&self,
trait_ref: &TraitRef<'_>,
span: Span,
constness: BoundConstness,
self_ty: Ty<'tcx>,
bounds: &mut Bounds<'tcx>,
speculative: bool
) -> GenericArgCountResult
pub(crate) fn instantiate_poly_trait_ref(
&self,
trait_ref: &TraitRef<'_>,
span: Span,
constness: BoundConstness,
self_ty: Ty<'tcx>,
bounds: &mut Bounds<'tcx>,
speculative: bool
) -> 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>
)
fn ast_path_to_mono_trait_ref(
&self,
span: Span,
trait_def_id: DefId,
self_ty: Ty<'tcx>,
trait_segment: &PathSegment<'_>,
is_impl: bool
) -> TraitRef<'tcx>
fn create_substs_for_ast_trait_ref<'a>(
&self,
span: Span,
trait_def_id: DefId,
self_ty: Ty<'tcx>,
trait_segment: &'a PathSegment<'a>,
is_impl: bool
) -> (SubstsRef<'tcx>, GenericArgCountResult)
fn trait_defines_associated_type_named(
&self,
trait_def_id: DefId,
assoc_name: Ident
) -> bool
fn trait_defines_associated_const_named(
&self,
trait_def_id: DefId,
assoc_name: Ident
) -> bool
pub(crate) fn add_implicitly_sized<'hir>(
&self,
bounds: &mut Bounds<'hir>,
ast_bounds: &'hir [GenericBound<'hir>],
self_ty_where_predicates: Option<(HirId, &'hir [WherePredicate<'hir>])>,
span: Span
)
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>
)
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>
)
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<'_>]
) -> Bounds<'tcx>
pub(crate) fn compute_bounds(
&self,
param_ty: Ty<'tcx>,
ast_bounds: &[GenericBound<'_>]
) -> 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(crate) fn compute_bounds_that_match_assoc_type(
&self,
param_ty: Ty<'tcx>,
ast_bounds: &[GenericBound<'_>],
assoc_name: Ident
) -> Bounds<'tcx>
pub(crate) fn compute_bounds_that_match_assoc_type(
&self,
param_ty: Ty<'tcx>,
ast_bounds: &[GenericBound<'_>],
assoc_name: Ident
) -> Bounds<'tcx>
Convert the bounds in ast_bounds
that refer to traits which define an associated type
named assoc_name
into ty::Bounds. Ignore the rest.
fn compute_bounds_inner(
&self,
param_ty: Ty<'tcx>,
ast_bounds: &[GenericBound<'_>]
) -> Bounds<'tcx>
sourcefn 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
) -> Result<(), ErrorGuaranteed>
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
) -> 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.
fn ast_path_to_ty(
&self,
span: Span,
did: DefId,
item_segment: &PathSegment<'_>
) -> Ty<'tcx>
fn conv_object_ty_poly_trait_ref(
&self,
span: Span,
trait_bounds: &[PolyTraitRef<'_>],
lifetime: &Lifetime,
borrowed: bool,
representation: DynKind
) -> Ty<'tcx>
fn report_ambiguous_associated_type(
&self,
span: Span,
type_str: &str,
trait_str: &str,
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 Fn() -> String,
assoc_name: Ident,
span: Span,
is_equality: impl Fn() -> Option<String>
) -> 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<'_>,
permit_variants: bool
) -> Result<(Ty<'tcx>, DefKind, DefId), ErrorGuaranteed>
fn qpath_to_ty(
&self,
span: Span,
opt_self_ty: Option<Ty<'tcx>>,
item_def_id: DefId,
trait_segment: &PathSegment<'_>,
item_segment: &PathSegment<'_>
) -> 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
) -> Vec<PathSeg>
pub fn res_to_ty(
&self,
opt_self_ty: Option<Ty<'tcx>>,
path: &Path<'_>,
permit_variants: bool
) -> Ty<'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<Binder<'tcx, ExistentialPredicate<'tcx>>>
) -> Option<Region<'tcx>>
fn compute_object_lifetime_bound(
&self,
span: Span,
existential_predicates: &'tcx List<Binder<'tcx, ExistentialPredicate<'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
.
sourcefn maybe_lint_blanket_trait_impl(&self, self_ty: &Ty<'_>, diag: &mut Diagnostic)
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.