Struct rustc_trait_selection::infer::InferCtxt
source · [−]pub struct InferCtxt<'a, 'tcx> {Show 16 fields
pub tcx: TyCtxt<'tcx>,
pub defining_use_anchor: DefiningAnchor,
pub considering_regions: bool,
pub in_progress_typeck_results: Option<&'a RefCell<TypeckResults<'tcx>>>,
pub inner: RefCell<InferCtxtInner<'tcx>>,
skip_leak_check: Cell<bool>,
lexical_region_resolutions: RefCell<Option<LexicalRegionResolutions<'tcx>>>,
pub selection_cache: Cache<(ParamEnv<'tcx>, TraitPredicate<'tcx>), Result<Option<SelectionCandidate<'tcx>>, SelectionError<'tcx>>>,
pub evaluation_cache: Cache<(ParamEnv<'tcx>, Binder<'tcx, TraitPredicate<'tcx>>), EvaluationResult>,
pub reported_trait_errors: RefCell<HashMap<Span, Vec<Predicate<'tcx>, Global>, BuildHasherDefault<FxHasher>>>,
pub reported_closure_mismatch: RefCell<HashSet<(Span, Option<Span>), BuildHasherDefault<FxHasher>>>,
tainted_by_errors: Cell<Option<ErrorGuaranteed>>,
err_count_on_creation: usize,
in_snapshot: Cell<bool>,
universe: Cell<UniverseIndex>,
normalize_fn_sig_for_diagnostic: Option<Rc<dyn Fn(&InferCtxt<'_, 'tcx>, Binder<'tcx, FnSig<'tcx>>) + 'static>>,
}
Fields
tcx: TyCtxt<'tcx>
defining_use_anchor: DefiningAnchor
The DefId
of the item in whose context we are performing inference or typeck.
It is used to check whether an opaque type use is a defining use.
If it is DefiningAnchor::Bubble
, we can’t resolve opaque types here and need to bubble up
the obligation. This frequently happens for
short lived InferCtxt within queries. The opaque type obligations are forwarded
to the outside until the end up in an InferCtxt
for typeck or borrowck.
It is default value is DefiningAnchor::Error
, this way it is easier to catch errors that
might come up during inference or typeck.
considering_regions: bool
Whether this inference context should care about region obligations in the root universe. Most notably, this is used during hir typeck as region solving is left to borrowck instead.
in_progress_typeck_results: Option<&'a RefCell<TypeckResults<'tcx>>>
During type-checking/inference of a body, in_progress_typeck_results
contains a reference to the typeck results being built up, which are
used for reading closure kinds/signatures as they are inferred,
and for error reporting logic to read arbitrary node types.
inner: RefCell<InferCtxtInner<'tcx>>
skip_leak_check: Cell<bool>
If set, this flag causes us to skip the ‘leak check’ during higher-ranked subtyping operations. This flag is a temporary one used to manage the removal of the leak-check: for the time being, we still run the leak-check, but we issue warnings. This flag can only be set to true when entering a snapshot.
lexical_region_resolutions: RefCell<Option<LexicalRegionResolutions<'tcx>>>
Once region inference is done, the values for each variable.
selection_cache: Cache<(ParamEnv<'tcx>, TraitPredicate<'tcx>), Result<Option<SelectionCandidate<'tcx>>, SelectionError<'tcx>>>
Caches the results of trait selection. This cache is used for things that have to do with the parameters in scope.
evaluation_cache: Cache<(ParamEnv<'tcx>, Binder<'tcx, TraitPredicate<'tcx>>), EvaluationResult>
Caches the results of trait evaluation.
reported_trait_errors: RefCell<HashMap<Span, Vec<Predicate<'tcx>, Global>, BuildHasherDefault<FxHasher>>>
the set of predicates on which errors have been reported, to avoid reporting the same error twice.
reported_closure_mismatch: RefCell<HashSet<(Span, Option<Span>), BuildHasherDefault<FxHasher>>>
tainted_by_errors: Cell<Option<ErrorGuaranteed>>
When an error occurs, we want to avoid reporting “derived”
errors that are due to this original failure. Normally, we
handle this with the err_count_on_creation
count, which
basically just tracks how many errors were reported when we
started type-checking a fn and checks to see if any new errors
have been reported since then. Not great, but it works.
However, when errors originated in other passes – notably resolve – this heuristic breaks down. Therefore, we have this auxiliary flag that one can set whenever one creates a type-error that is due to an error in a prior pass.
Don’t read this flag directly, call is_tainted_by_errors()
and set_tainted_by_errors()
.
err_count_on_creation: usize
Track how many errors were reported when this infcx is created.
If the number of errors increases, that’s also a sign (line
tainted_by_errors
) to avoid reporting certain kinds of errors.
in_snapshot: Cell<bool>
This flag is true while there is an active snapshot.
universe: Cell<UniverseIndex>
What is the innermost universe we have created? Starts out as
UniverseIndex::root()
but grows from there as we enter
universal quantifiers.
N.B., at present, we exclude the universal quantifiers on the
item we are type-checking, and just consider those names as
part of the root universe. So this would only get incremented
when we enter into a higher-ranked (for<..>
) type or trait
bound.
normalize_fn_sig_for_diagnostic: Option<Rc<dyn Fn(&InferCtxt<'_, 'tcx>, Binder<'tcx, FnSig<'tcx>>) + 'static>>
Trait Implementations
sourceimpl<'a, 'cx, 'tcx: 'a> InferCtxtExt<'a, 'tcx> for InferCtxt<'cx, 'tcx>
impl<'a, 'cx, 'tcx: 'a> InferCtxtExt<'a, 'tcx> for InferCtxt<'cx, 'tcx>
sourcefn implied_outlives_bounds(
&self,
param_env: ParamEnv<'tcx>,
body_id: HirId,
ty: Ty<'tcx>
) -> Vec<OutlivesBound<'tcx>>
fn implied_outlives_bounds(
&self,
param_env: ParamEnv<'tcx>,
body_id: HirId,
ty: Ty<'tcx>
) -> Vec<OutlivesBound<'tcx>>
Implied bounds are region relationships that we deduce automatically. The idea is that (e.g.) a caller must check that a function’s argument types are well-formed immediately before calling that fn, and hence the callee can assume that its argument types are well-formed. This may imply certain relationships between generic parameters. For example:
fn foo<'a,T>(x: &'a T) {}
can only be called with a 'a
and T
such that &'a T
is WF.
For &'a T
to be WF, T: 'a
must hold. So we can assume T: 'a
.
Parameters
param_env
, the where-clauses in scopebody_id
, the body-id to use when normalizing assoc types. Note that this may cause outlives obligations to be injected into the inference context with this body-id.ty
, the type that we are supposed to assume is WF.
fn implied_bounds_tys(
&'a self,
param_env: ParamEnv<'tcx>,
body_id: HirId,
tys: FxHashSet<Ty<'tcx>>
) -> impl Iterator<Item = OutlivesBound<'tcx>> + 'a
sourceimpl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx>
impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx>
sourcefn describe_enclosure(&self, hir_id: HirId) -> Option<&'static str>
fn describe_enclosure(&self, hir_id: HirId) -> Option<&'static str>
Used to set on_unimplemented’s ItemContext
to be the enclosing (async) block/function/closure
fn impl_similar_to(
&self,
trait_ref: PolyTraitRef<'tcx>,
obligation: &PredicateObligation<'tcx>
) -> Option<(DefId, SubstsRef<'tcx>)>
fn on_unimplemented_note(
&self,
trait_ref: PolyTraitRef<'tcx>,
obligation: &PredicateObligation<'tcx>
) -> OnUnimplementedNote
sourceimpl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx>
impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx>
sourcefn suggest_dereferences(
&self,
obligation: &PredicateObligation<'tcx>,
err: &mut Diagnostic,
trait_pred: PolyTraitPredicate<'tcx>
) -> bool
fn suggest_dereferences(
&self,
obligation: &PredicateObligation<'tcx>,
err: &mut Diagnostic,
trait_pred: PolyTraitPredicate<'tcx>
) -> bool
When after several dereferencing, the reference satisfies the trait binding. This function provides dereference suggestion for this specific situation.
sourcefn get_closure_name(
&self,
def_id: DefId,
err: &mut Diagnostic,
msg: &str
) -> Option<Symbol>
fn get_closure_name(
&self,
def_id: DefId,
err: &mut Diagnostic,
msg: &str
) -> Option<Symbol>
Given a closure’s DefId
, return the given name of the closure.
This doesn’t account for reassignments, but it’s only used for suggestions.
sourcefn suggest_fn_call(
&self,
obligation: &PredicateObligation<'tcx>,
err: &mut Diagnostic,
trait_pred: PolyTraitPredicate<'tcx>
) -> bool
fn suggest_fn_call(
&self,
obligation: &PredicateObligation<'tcx>,
err: &mut Diagnostic,
trait_pred: PolyTraitPredicate<'tcx>
) -> bool
We tried to apply the bound to an fn
or closure. Check whether calling it would
evaluate to a type that would satisfy the trait binding. If it would, suggest calling
it: bar(foo)
→ bar(foo())
. This case is very likely to be hit if foo
is async
.
sourcefn suggest_remove_reference(
&self,
obligation: &PredicateObligation<'tcx>,
err: &mut Diagnostic,
trait_pred: PolyTraitPredicate<'tcx>
) -> bool
fn suggest_remove_reference(
&self,
obligation: &PredicateObligation<'tcx>,
err: &mut Diagnostic,
trait_pred: PolyTraitPredicate<'tcx>
) -> bool
Whenever references are used by mistake, like for (i, e) in &vec.iter().enumerate()
,
suggest removing these references until we reach a type that implements the trait.
sourcefn suggest_change_mut(
&self,
obligation: &PredicateObligation<'tcx>,
err: &mut Diagnostic,
trait_pred: PolyTraitPredicate<'tcx>
)
fn suggest_change_mut(
&self,
obligation: &PredicateObligation<'tcx>,
err: &mut Diagnostic,
trait_pred: PolyTraitPredicate<'tcx>
)
Check if the trait bound is implemented for a different mutability and note it in the final error.
sourcefn suggest_impl_trait(
&self,
err: &mut Diagnostic,
span: Span,
obligation: &PredicateObligation<'tcx>,
trait_pred: PolyTraitPredicate<'tcx>
) -> bool
fn suggest_impl_trait(
&self,
err: &mut Diagnostic,
span: Span,
obligation: &PredicateObligation<'tcx>,
trait_pred: PolyTraitPredicate<'tcx>
) -> bool
If all conditions are met to identify a returned dyn Trait
, suggest using impl Trait
if
applicable and signal that the error has been expanded appropriately and needs to be
emitted.
sourcefn maybe_note_obligation_cause_for_async_await(
&self,
err: &mut Diagnostic,
obligation: &PredicateObligation<'tcx>
) -> bool
fn maybe_note_obligation_cause_for_async_await(
&self,
err: &mut Diagnostic,
obligation: &PredicateObligation<'tcx>
) -> bool
Adds an async-await specific note to the diagnostic when the future does not implement an auto trait because of a captured type.
note: future does not implement `Qux` as this value is used across an await
--> $DIR/issue-64130-3-other.rs:17:5
|
LL | let x = Foo;
| - has type `Foo`
LL | baz().await;
| ^^^^^^^^^^^ await occurs here, with `x` maybe used later
LL | }
| - `x` is later dropped here
When the diagnostic does not implement Send
or Sync
specifically, then the diagnostic
is “replaced” with a different message and a more specific error.
error: future cannot be sent between threads safely
--> $DIR/issue-64130-2-send.rs:21:5
|
LL | fn is_send<T: Send>(t: T) { }
| ---- required by this bound in `is_send`
...
LL | is_send(bar());
| ^^^^^^^ future returned by `bar` is not send
|
= help: within `impl std::future::Future`, the trait `std::marker::Send` is not
implemented for `Foo`
note: future is not send as this value is used across an await
--> $DIR/issue-64130-2-send.rs:15:5
|
LL | let x = Foo;
| - has type `Foo`
LL | baz().await;
| ^^^^^^^^^^^ await occurs here, with `x` maybe used later
LL | }
| - `x` is later dropped here
Returns true
if an async-await specific note was added to the diagnostic.
sourcefn note_obligation_cause_for_async_await(
&self,
err: &mut Diagnostic,
interior_or_upvar_span: GeneratorInteriorOrUpvar,
interior_extra_info: Option<(Option<Span>, Span, Option<HirId>, Option<Span>)>,
is_async: bool,
outer_generator: Option<DefId>,
trait_pred: TraitPredicate<'tcx>,
target_ty: Ty<'tcx>,
typeck_results: Option<&TypeckResults<'tcx>>,
obligation: &PredicateObligation<'tcx>,
next_code: Option<&ObligationCauseCode<'tcx>>
)
fn note_obligation_cause_for_async_await(
&self,
err: &mut Diagnostic,
interior_or_upvar_span: GeneratorInteriorOrUpvar,
interior_extra_info: Option<(Option<Span>, Span, Option<HirId>, Option<Span>)>,
is_async: bool,
outer_generator: Option<DefId>,
trait_pred: TraitPredicate<'tcx>,
target_ty: Ty<'tcx>,
typeck_results: Option<&TypeckResults<'tcx>>,
obligation: &PredicateObligation<'tcx>,
next_code: Option<&ObligationCauseCode<'tcx>>
)
Unconditionally adds the diagnostic note described in
maybe_note_obligation_cause_for_async_await
’s documentation comment.
fn suggest_restricting_param_bound(
&self,
err: &mut Diagnostic,
trait_pred: PolyTraitPredicate<'tcx>,
associated_ty: Option<(&'static str, Ty<'tcx>)>,
body_id: HirId
)
fn suggest_add_reference_to_arg(
&self,
obligation: &PredicateObligation<'tcx>,
err: &mut Diagnostic,
poly_trait_pred: PolyTraitPredicate<'tcx>,
has_custom_message: bool
) -> bool
fn suggest_borrowing_for_object_cast(
&self,
err: &mut Diagnostic,
obligation: &PredicateObligation<'tcx>,
self_ty: Ty<'tcx>,
object_ty: Ty<'tcx>
)
fn suggest_remove_await(
&self,
obligation: &PredicateObligation<'tcx>,
err: &mut Diagnostic
)
fn suggest_semicolon_removal(
&self,
obligation: &PredicateObligation<'tcx>,
err: &mut Diagnostic,
span: Span,
trait_pred: PolyTraitPredicate<'tcx>
) -> bool
fn return_type_span(
&self,
obligation: &PredicateObligation<'tcx>
) -> Option<Span>
fn point_at_returns_when_relevant(
&self,
err: &mut Diagnostic,
obligation: &PredicateObligation<'tcx>
)
fn report_closure_arg_mismatch(
&self,
span: Span,
found_span: Option<Span>,
found: PolyTraitRef<'tcx>,
expected: PolyTraitRef<'tcx>
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed>
fn suggest_fully_qualified_path(
&self,
err: &mut Diagnostic,
item_def_id: DefId,
span: Span,
trait_ref: DefId
)
fn note_obligation_cause_code<T>(
&self,
err: &mut Diagnostic,
predicate: &T,
param_env: ParamEnv<'tcx>,
cause_code: &ObligationCauseCode<'tcx>,
obligated_types: &mut Vec<Ty<'tcx>>,
seen_requirements: &mut FxHashSet<DefId>
)where
T: Display,
fn suggest_new_overflow_limit(&self, err: &mut Diagnostic)
sourcefn suggest_await_before_try(
&self,
err: &mut Diagnostic,
obligation: &PredicateObligation<'tcx>,
trait_pred: PolyTraitPredicate<'tcx>,
span: Span
)
fn suggest_await_before_try(
&self,
err: &mut Diagnostic,
obligation: &PredicateObligation<'tcx>,
trait_pred: PolyTraitPredicate<'tcx>,
span: Span
)
fn suggest_floating_point_literal(
&self,
obligation: &PredicateObligation<'tcx>,
err: &mut Diagnostic,
trait_ref: &PolyTraitRef<'tcx>
)
fn suggest_derive(
&self,
obligation: &PredicateObligation<'tcx>,
err: &mut Diagnostic,
trait_pred: PolyTraitPredicate<'tcx>
)
fn suggest_dereferencing_index(
&self,
obligation: &PredicateObligation<'tcx>,
err: &mut Diagnostic,
trait_pred: PolyTraitPredicate<'tcx>
)
sourceimpl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx>
impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx>
sourcefn report_overflow_error<T>(
&self,
obligation: &Obligation<'tcx, T>,
suggest_increasing_limit: bool
) -> !where
T: Display + TypeFoldable<'tcx>,
fn report_overflow_error<T>(
&self,
obligation: &Obligation<'tcx, T>,
suggest_increasing_limit: bool
) -> !where
T: Display + TypeFoldable<'tcx>,
Reports that an overflow has occurred and halts compilation. We halt compilation unconditionally because it is important that overflows never be masked – they basically represent computations whose result could not be truly determined and thus we can’t say if the program type checks or not – and they are unusual occurrences in any case.
sourcefn report_overflow_error_cycle(&self, cycle: &[PredicateObligation<'tcx>]) -> !
fn report_overflow_error_cycle(&self, cycle: &[PredicateObligation<'tcx>]) -> !
Reports that a cycle was detected which led to overflow and halts
compilation. This is equivalent to report_overflow_error
except
that we can give a more helpful error message (and, in particular,
we do not suggest increasing the overflow limit, which is not
going to help).
sourcefn get_fn_like_arguments(&self, node: Node<'_>) -> Option<(Span, Vec<ArgKind>)>
fn get_fn_like_arguments(&self, node: Node<'_>) -> Option<(Span, Vec<ArgKind>)>
Given some node representing a fn-like thing in the HIR map,
returns a span and ArgKind
information that describes the
arguments it expects. This can be supplied to
report_arg_count_mismatch
.
sourcefn report_arg_count_mismatch(
&self,
span: Span,
found_span: Option<Span>,
expected_args: Vec<ArgKind>,
found_args: Vec<ArgKind>,
is_closure: bool
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed>
fn report_arg_count_mismatch(
&self,
span: Span,
found_span: Option<Span>,
expected_args: Vec<ArgKind>,
found_args: Vec<ArgKind>,
is_closure: bool
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed>
Reports an error when the number of arguments needed by a trait match doesn’t match the number that the expression provides.
fn report_fulfillment_errors(
&self,
errors: &[FulfillmentError<'tcx>],
body_id: Option<BodyId>,
fallback_has_occurred: bool
) -> ErrorGuaranteed
sourcefn report_selection_error(
&self,
obligation: PredicateObligation<'tcx>,
root_obligation: &PredicateObligation<'tcx>,
error: &SelectionError<'tcx>,
fallback_has_occurred: bool
)
fn report_selection_error(
&self,
obligation: PredicateObligation<'tcx>,
root_obligation: &PredicateObligation<'tcx>,
error: &SelectionError<'tcx>,
fallback_has_occurred: bool
)
root_obligation
parameter should be the root_obligation
field
from a FulfillmentError
. If no FulfillmentError
is available,
then it should be the same as obligation
. Read moresourcefn type_implements_fn_trait(
&self,
param_env: ParamEnv<'tcx>,
ty: Binder<'tcx, Ty<'tcx>>,
constness: BoundConstness,
polarity: ImplPolarity
) -> Result<(ClosureKind, Binder<'tcx, Ty<'tcx>>), ()>
fn type_implements_fn_trait(
&self,
param_env: ParamEnv<'tcx>,
ty: Binder<'tcx, Ty<'tcx>>,
constness: BoundConstness,
polarity: ImplPolarity
) -> Result<(ClosureKind, Binder<'tcx, Ty<'tcx>>), ()>
Fn
, FnMut
, or FnOnce
in that order, and returns the generic type corresponding to the
argument of that trait (corresponding to the closure arguments). Read moresourceimpl<'cx, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'cx, 'tcx>
impl<'cx, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'cx, 'tcx>
sourcefn partially_normalize_associated_types_in<T>(
&self,
cause: ObligationCause<'tcx>,
param_env: ParamEnv<'tcx>,
value: T
) -> InferOk<'tcx, T>where
T: TypeFoldable<'tcx>,
fn partially_normalize_associated_types_in<T>(
&self,
cause: ObligationCause<'tcx>,
param_env: ParamEnv<'tcx>,
value: T
) -> InferOk<'tcx, T>where
T: TypeFoldable<'tcx>,
Normalizes associated types in value
, potentially returning
new obligations that must further be processed.
fn type_is_copy_modulo_regions(
&self,
param_env: ParamEnv<'tcx>,
ty: Ty<'tcx>,
span: Span
) -> bool
fn type_is_sized_modulo_regions(
&self,
param_env: ParamEnv<'tcx>,
ty: Ty<'tcx>,
span: Span
) -> bool
sourcefn type_implements_trait(
&self,
trait_def_id: DefId,
ty: Ty<'tcx>,
params: SubstsRef<'tcx>,
param_env: ParamEnv<'tcx>
) -> EvaluationResult
fn type_implements_trait(
&self,
trait_def_id: DefId,
ty: Ty<'tcx>,
params: SubstsRef<'tcx>,
param_env: ParamEnv<'tcx>
) -> EvaluationResult
ty
implements given trait(trait_def_id).
The inputs are: Read moresourceimpl<'cx, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'cx, 'tcx>
impl<'cx, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'cx, 'tcx>
sourcefn predicate_may_hold(&self, obligation: &PredicateObligation<'tcx>) -> bool
fn predicate_may_hold(&self, obligation: &PredicateObligation<'tcx>) -> bool
Evaluates whether the predicate can be satisfied (by any means)
in the given ParamEnv
.
sourcefn predicate_must_hold_considering_regions(
&self,
obligation: &PredicateObligation<'tcx>
) -> bool
fn predicate_must_hold_considering_regions(
&self,
obligation: &PredicateObligation<'tcx>
) -> bool
Evaluates whether the predicate can be satisfied in the given
ParamEnv
, and returns false
if not certain. However, this is
not entirely accurate if inference variables are involved.
This version may conservatively fail when outlives obligations are required.
sourcefn predicate_must_hold_modulo_regions(
&self,
obligation: &PredicateObligation<'tcx>
) -> bool
fn predicate_must_hold_modulo_regions(
&self,
obligation: &PredicateObligation<'tcx>
) -> bool
Evaluates whether the predicate can be satisfied in the given
ParamEnv
, and returns false
if not certain. However, this is
not entirely accurate if inference variables are involved.
This version ignores all outlives constraints.
sourcefn evaluate_obligation(
&self,
obligation: &PredicateObligation<'tcx>
) -> Result<EvaluationResult, OverflowError>
fn evaluate_obligation(
&self,
obligation: &PredicateObligation<'tcx>
) -> Result<EvaluationResult, OverflowError>
Evaluate a given predicate, capturing overflow and propagating it back.
fn evaluate_obligation_no_overflow(
&self,
obligation: &PredicateObligation<'tcx>
) -> EvaluationResult
sourceimpl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx>
impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx>
sourcefn get_parent_trait_ref(
&self,
code: &ObligationCauseCode<'tcx>
) -> Option<(String, Option<Span>)>
fn get_parent_trait_ref(
&self,
code: &ObligationCauseCode<'tcx>
) -> Option<(String, Option<Span>)>
Gets the parent trait chain start
sourcefn note_version_mismatch(
&self,
err: &mut Diagnostic,
trait_ref: &PolyTraitRef<'tcx>
) -> bool
fn note_version_mismatch(
&self,
err: &mut Diagnostic,
trait_ref: &PolyTraitRef<'tcx>
) -> bool
If the Self
type of the unsatisfied trait trait_ref
implements a trait
with the same path as trait_ref
, a help message about
a probable version mismatch is added to err
sourcefn predicate_can_apply(
&self,
param_env: ParamEnv<'tcx>,
pred: PolyTraitRef<'tcx>
) -> bool
fn predicate_can_apply(
&self,
param_env: ParamEnv<'tcx>,
pred: PolyTraitRef<'tcx>
) -> bool
Returns true
if the trait predicate may apply for some assignment
to the type parameters.
fn error_implies(&self, cond: Predicate<'tcx>, error: Predicate<'tcx>) -> bool
fn report_fulfillment_error(
&self,
error: &FulfillmentError<'tcx>,
body_id: Option<BodyId>,
fallback_has_occurred: bool
)
fn report_projection_error(
&self,
obligation: &PredicateObligation<'tcx>,
error: &MismatchedProjectionTypes<'tcx>
)
fn maybe_detailed_projection_msg(
&self,
pred: ProjectionPredicate<'tcx>,
normalized_ty: Term<'tcx>,
expected_ty: Term<'tcx>
) -> Option<String>
fn fuzzy_match_tys(
&self,
a: Ty<'tcx>,
b: Ty<'tcx>,
ignoring_lifetimes: bool
) -> Option<CandidateSimilarity>
fn describe_generator(&self, body_id: BodyId) -> Option<&'static str>
fn find_similar_impl_candidates(
&self,
trait_pred: PolyTraitPredicate<'tcx>
) -> Vec<ImplCandidate<'tcx>>
fn report_similar_impl_candidates(
&self,
impl_candidates: Vec<ImplCandidate<'tcx>>,
trait_ref: PolyTraitRef<'tcx>,
body_id: HirId,
err: &mut Diagnostic
) -> bool
sourcefn mk_trait_obligation_with_new_self_ty(
&self,
param_env: ParamEnv<'tcx>,
trait_ref_and_ty: Binder<'tcx, (TraitPredicate<'tcx>, Ty<'tcx>)>
) -> PredicateObligation<'tcx>
fn mk_trait_obligation_with_new_self_ty(
&self,
param_env: ParamEnv<'tcx>,
trait_ref_and_ty: Binder<'tcx, (TraitPredicate<'tcx>, Ty<'tcx>)>
) -> PredicateObligation<'tcx>
PredicateObligation
with new_self_ty
replacing the existing type in the
trait_ref
. Read morefn maybe_report_ambiguity(
&self,
obligation: &PredicateObligation<'tcx>,
body_id: Option<BodyId>
)
fn annotate_source_of_ambiguity(
&self,
err: &mut Diagnostic,
impls: &[DefId],
predicate: Predicate<'tcx>
)
fn note_obligation_cause(
&self,
err: &mut Diagnostic,
obligation: &PredicateObligation<'tcx>
)
fn suggest_unsized_bound_if_applicable(
&self,
err: &mut Diagnostic,
obligation: &PredicateObligation<'tcx>
)
fn maybe_suggest_unsized_generics<'hir>(
&self,
err: &mut Diagnostic,
span: Span,
node: Node<'hir>
)
fn maybe_indirection_for_unsized<'hir>(
&self,
err: &mut Diagnostic,
item: &'hir Item<'hir>,
param: &'hir GenericParam<'hir>
) -> bool
fn is_recursive_obligation(
&self,
obligated_types: &mut Vec<Ty<'tcx>>,
cause_code: &ObligationCauseCode<'tcx>
) -> bool
Auto Trait Implementations
impl<'a, 'tcx> !RefUnwindSafe for InferCtxt<'a, 'tcx>
impl<'a, 'tcx> !Send for InferCtxt<'a, 'tcx>
impl<'a, 'tcx> !Sync for InferCtxt<'a, 'tcx>
impl<'a, 'tcx> Unpin for InferCtxt<'a, 'tcx>where
'tcx: 'a,
impl<'a, 'tcx> !UnwindSafe for InferCtxt<'a, 'tcx>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Layout
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference’s “Type Layout” chapter for details on type layout guarantees.
Size: 736 bytes