[−][src]Trait rustc_trait_selection::traits::error_reporting::suggestions::InferCtxtExt
Required methods
pub fn suggest_restricting_param_bound(
&self,
err: &mut DiagnosticBuilder<'_>,
trait_ref: PolyTraitRef<'tcx>,
body_id: HirId
)[src]
&self,
err: &mut DiagnosticBuilder<'_>,
trait_ref: PolyTraitRef<'tcx>,
body_id: HirId
)
pub fn suggest_dereferences(
&self,
obligation: &PredicateObligation<'tcx>,
err: &mut DiagnosticBuilder<'tcx>,
trait_ref: PolyTraitRef<'tcx>,
points_at_arg: bool
)[src]
&self,
obligation: &PredicateObligation<'tcx>,
err: &mut DiagnosticBuilder<'tcx>,
trait_ref: PolyTraitRef<'tcx>,
points_at_arg: bool
)
pub fn get_closure_name(
&self,
def_id: DefId,
err: &mut DiagnosticBuilder<'_>,
msg: &str
) -> Option<String>[src]
&self,
def_id: DefId,
err: &mut DiagnosticBuilder<'_>,
msg: &str
) -> Option<String>
pub fn suggest_fn_call(
&self,
obligation: &PredicateObligation<'tcx>,
err: &mut DiagnosticBuilder<'_>,
trait_ref: Binder<TraitRef<'tcx>>,
points_at_arg: bool
)[src]
&self,
obligation: &PredicateObligation<'tcx>,
err: &mut DiagnosticBuilder<'_>,
trait_ref: Binder<TraitRef<'tcx>>,
points_at_arg: bool
)
pub fn suggest_add_reference_to_arg(
&self,
obligation: &PredicateObligation<'tcx>,
err: &mut DiagnosticBuilder<'_>,
trait_ref: &Binder<TraitRef<'tcx>>,
points_at_arg: bool,
has_custom_message: bool
) -> bool[src]
&self,
obligation: &PredicateObligation<'tcx>,
err: &mut DiagnosticBuilder<'_>,
trait_ref: &Binder<TraitRef<'tcx>>,
points_at_arg: bool,
has_custom_message: bool
) -> bool
pub fn suggest_remove_reference(
&self,
obligation: &PredicateObligation<'tcx>,
err: &mut DiagnosticBuilder<'_>,
trait_ref: Binder<TraitRef<'tcx>>
)[src]
&self,
obligation: &PredicateObligation<'tcx>,
err: &mut DiagnosticBuilder<'_>,
trait_ref: Binder<TraitRef<'tcx>>
)
pub fn suggest_change_mut(
&self,
obligation: &PredicateObligation<'tcx>,
err: &mut DiagnosticBuilder<'_>,
trait_ref: Binder<TraitRef<'tcx>>,
points_at_arg: bool
)[src]
&self,
obligation: &PredicateObligation<'tcx>,
err: &mut DiagnosticBuilder<'_>,
trait_ref: Binder<TraitRef<'tcx>>,
points_at_arg: bool
)
pub fn suggest_semicolon_removal(
&self,
obligation: &PredicateObligation<'tcx>,
err: &mut DiagnosticBuilder<'_>,
span: Span,
trait_ref: Binder<TraitRef<'tcx>>
)[src]
&self,
obligation: &PredicateObligation<'tcx>,
err: &mut DiagnosticBuilder<'_>,
span: Span,
trait_ref: Binder<TraitRef<'tcx>>
)
pub fn return_type_span(
&self,
obligation: &PredicateObligation<'tcx>
) -> Option<Span>[src]
&self,
obligation: &PredicateObligation<'tcx>
) -> Option<Span>
pub fn suggest_impl_trait(
&self,
err: &mut DiagnosticBuilder<'_>,
span: Span,
obligation: &PredicateObligation<'tcx>,
trait_ref: Binder<TraitRef<'tcx>>
) -> bool[src]
&self,
err: &mut DiagnosticBuilder<'_>,
span: Span,
obligation: &PredicateObligation<'tcx>,
trait_ref: Binder<TraitRef<'tcx>>
) -> bool
pub fn point_at_returns_when_relevant(
&self,
err: &mut DiagnosticBuilder<'_>,
obligation: &PredicateObligation<'tcx>
)[src]
&self,
err: &mut DiagnosticBuilder<'_>,
obligation: &PredicateObligation<'tcx>
)
pub fn report_closure_arg_mismatch(
&self,
span: Span,
found_span: Option<Span>,
expected_ref: PolyTraitRef<'tcx>,
found: PolyTraitRef<'tcx>
) -> DiagnosticBuilder<'tcx>[src]
&self,
span: Span,
found_span: Option<Span>,
expected_ref: PolyTraitRef<'tcx>,
found: PolyTraitRef<'tcx>
) -> DiagnosticBuilder<'tcx>
pub fn suggest_fully_qualified_path(
&self,
err: &mut DiagnosticBuilder<'_>,
def_id: DefId,
span: Span,
trait_ref: DefId
)[src]
&self,
err: &mut DiagnosticBuilder<'_>,
def_id: DefId,
span: Span,
trait_ref: DefId
)
pub fn maybe_note_obligation_cause_for_async_await(
&self,
err: &mut DiagnosticBuilder<'_>,
obligation: &PredicateObligation<'tcx>
) -> bool[src]
&self,
err: &mut DiagnosticBuilder<'_>,
obligation: &PredicateObligation<'tcx>
) -> bool
pub fn note_obligation_cause_for_async_await(
&self,
err: &mut DiagnosticBuilder<'_>,
interior_or_upvar_span: GeneratorInteriorOrUpvar,
interior_extra_info: Option<(Option<Span>, Span, Option<HirId>, Option<Span>)>,
inner_generator_body: Option<&Body<'tcx>>,
outer_generator: Option<DefId>,
trait_ref: TraitRef<'tcx>,
target_ty: Ty<'tcx>,
typeck_results: &TypeckResults<'tcx>,
obligation: &PredicateObligation<'tcx>,
next_code: Option<&ObligationCauseCode<'tcx>>
)[src]
&self,
err: &mut DiagnosticBuilder<'_>,
interior_or_upvar_span: GeneratorInteriorOrUpvar,
interior_extra_info: Option<(Option<Span>, Span, Option<HirId>, Option<Span>)>,
inner_generator_body: Option<&Body<'tcx>>,
outer_generator: Option<DefId>,
trait_ref: TraitRef<'tcx>,
target_ty: Ty<'tcx>,
typeck_results: &TypeckResults<'tcx>,
obligation: &PredicateObligation<'tcx>,
next_code: Option<&ObligationCauseCode<'tcx>>
)
pub fn note_obligation_cause_code<T>(
&self,
err: &mut DiagnosticBuilder<'_>,
predicate: &T,
cause_code: &ObligationCauseCode<'tcx>,
obligated_types: &mut Vec<&TyS<'tcx>>,
seen_requirements: &mut FxHashSet<DefId>
) where
T: Display, [src]
&self,
err: &mut DiagnosticBuilder<'_>,
predicate: &T,
cause_code: &ObligationCauseCode<'tcx>,
obligated_types: &mut Vec<&TyS<'tcx>>,
seen_requirements: &mut FxHashSet<DefId>
) where
T: Display,
pub fn suggest_new_overflow_limit(&self, err: &mut DiagnosticBuilder<'_>)[src]
pub fn suggest_await_before_try(
&self,
err: &mut DiagnosticBuilder<'_>,
obligation: &PredicateObligation<'tcx>,
trait_ref: Binder<TraitRef<'tcx>>,
span: Span
)[src]
&self,
err: &mut DiagnosticBuilder<'_>,
obligation: &PredicateObligation<'tcx>,
trait_ref: Binder<TraitRef<'tcx>>,
span: Span
)
Suggest to await before try: future? => future.await?
Implementors
impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx>[src]
pub fn suggest_restricting_param_bound(
&self,
err: &mut DiagnosticBuilder<'_>,
trait_ref: PolyTraitRef<'tcx>,
body_id: HirId
)[src]
&self,
err: &mut DiagnosticBuilder<'_>,
trait_ref: PolyTraitRef<'tcx>,
body_id: HirId
)
pub fn suggest_dereferences(
&self,
obligation: &PredicateObligation<'tcx>,
err: &mut DiagnosticBuilder<'tcx>,
trait_ref: PolyTraitRef<'tcx>,
points_at_arg: bool
)[src]
&self,
obligation: &PredicateObligation<'tcx>,
err: &mut DiagnosticBuilder<'tcx>,
trait_ref: PolyTraitRef<'tcx>,
points_at_arg: bool
)
When after several dereferencing, the reference satisfies the trait binding. This function provides dereference suggestion for this specific situation.
pub fn get_closure_name(
&self,
def_id: DefId,
err: &mut DiagnosticBuilder<'_>,
msg: &str
) -> Option<String>[src]
&self,
def_id: DefId,
err: &mut DiagnosticBuilder<'_>,
msg: &str
) -> Option<String>
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.
pub fn suggest_fn_call(
&self,
obligation: &PredicateObligation<'tcx>,
err: &mut DiagnosticBuilder<'_>,
trait_ref: Binder<TraitRef<'tcx>>,
points_at_arg: bool
)[src]
&self,
obligation: &PredicateObligation<'tcx>,
err: &mut DiagnosticBuilder<'_>,
trait_ref: Binder<TraitRef<'tcx>>,
points_at_arg: 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.
pub fn suggest_add_reference_to_arg(
&self,
obligation: &PredicateObligation<'tcx>,
err: &mut DiagnosticBuilder<'_>,
trait_ref: &Binder<TraitRef<'tcx>>,
points_at_arg: bool,
has_custom_message: bool
) -> bool[src]
&self,
obligation: &PredicateObligation<'tcx>,
err: &mut DiagnosticBuilder<'_>,
trait_ref: &Binder<TraitRef<'tcx>>,
points_at_arg: bool,
has_custom_message: bool
) -> bool
pub fn suggest_remove_reference(
&self,
obligation: &PredicateObligation<'tcx>,
err: &mut DiagnosticBuilder<'_>,
trait_ref: Binder<TraitRef<'tcx>>
)[src]
&self,
obligation: &PredicateObligation<'tcx>,
err: &mut DiagnosticBuilder<'_>,
trait_ref: Binder<TraitRef<'tcx>>
)
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.
pub fn suggest_change_mut(
&self,
obligation: &PredicateObligation<'tcx>,
err: &mut DiagnosticBuilder<'_>,
trait_ref: Binder<TraitRef<'tcx>>,
points_at_arg: bool
)[src]
&self,
obligation: &PredicateObligation<'tcx>,
err: &mut DiagnosticBuilder<'_>,
trait_ref: Binder<TraitRef<'tcx>>,
points_at_arg: bool
)
Check if the trait bound is implemented for a different mutability and note it in the final error.
pub fn suggest_semicolon_removal(
&self,
obligation: &PredicateObligation<'tcx>,
err: &mut DiagnosticBuilder<'_>,
span: Span,
trait_ref: Binder<TraitRef<'tcx>>
)[src]
&self,
obligation: &PredicateObligation<'tcx>,
err: &mut DiagnosticBuilder<'_>,
span: Span,
trait_ref: Binder<TraitRef<'tcx>>
)
pub fn return_type_span(
&self,
obligation: &PredicateObligation<'tcx>
) -> Option<Span>[src]
&self,
obligation: &PredicateObligation<'tcx>
) -> Option<Span>
pub fn suggest_impl_trait(
&self,
err: &mut DiagnosticBuilder<'_>,
span: Span,
obligation: &PredicateObligation<'tcx>,
trait_ref: Binder<TraitRef<'tcx>>
) -> bool[src]
&self,
err: &mut DiagnosticBuilder<'_>,
span: Span,
obligation: &PredicateObligation<'tcx>,
trait_ref: Binder<TraitRef<'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.
pub fn point_at_returns_when_relevant(
&self,
err: &mut DiagnosticBuilder<'_>,
obligation: &PredicateObligation<'tcx>
)[src]
&self,
err: &mut DiagnosticBuilder<'_>,
obligation: &PredicateObligation<'tcx>
)
pub fn report_closure_arg_mismatch(
&self,
span: Span,
found_span: Option<Span>,
expected_ref: PolyTraitRef<'tcx>,
found: PolyTraitRef<'tcx>
) -> DiagnosticBuilder<'tcx>[src]
&self,
span: Span,
found_span: Option<Span>,
expected_ref: PolyTraitRef<'tcx>,
found: PolyTraitRef<'tcx>
) -> DiagnosticBuilder<'tcx>
pub fn suggest_fully_qualified_path(
&self,
err: &mut DiagnosticBuilder<'_>,
def_id: DefId,
span: Span,
trait_ref: DefId
)[src]
&self,
err: &mut DiagnosticBuilder<'_>,
def_id: DefId,
span: Span,
trait_ref: DefId
)
pub fn maybe_note_obligation_cause_for_async_await(
&self,
err: &mut DiagnosticBuilder<'_>,
obligation: &PredicateObligation<'tcx>
) -> bool[src]
&self,
err: &mut DiagnosticBuilder<'_>,
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.
pub fn note_obligation_cause_for_async_await(
&self,
err: &mut DiagnosticBuilder<'_>,
interior_or_upvar_span: GeneratorInteriorOrUpvar,
interior_extra_info: Option<(Option<Span>, Span, Option<HirId>, Option<Span>)>,
inner_generator_body: Option<&Body<'tcx>>,
outer_generator: Option<DefId>,
trait_ref: TraitRef<'tcx>,
target_ty: Ty<'tcx>,
typeck_results: &TypeckResults<'tcx>,
obligation: &PredicateObligation<'tcx>,
next_code: Option<&ObligationCauseCode<'tcx>>
)[src]
&self,
err: &mut DiagnosticBuilder<'_>,
interior_or_upvar_span: GeneratorInteriorOrUpvar,
interior_extra_info: Option<(Option<Span>, Span, Option<HirId>, Option<Span>)>,
inner_generator_body: Option<&Body<'tcx>>,
outer_generator: Option<DefId>,
trait_ref: TraitRef<'tcx>,
target_ty: Ty<'tcx>,
typeck_results: &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.
pub fn note_obligation_cause_code<T>(
&self,
err: &mut DiagnosticBuilder<'_>,
predicate: &T,
cause_code: &ObligationCauseCode<'tcx>,
obligated_types: &mut Vec<&TyS<'tcx>>,
seen_requirements: &mut FxHashSet<DefId>
) where
T: Display, [src]
&self,
err: &mut DiagnosticBuilder<'_>,
predicate: &T,
cause_code: &ObligationCauseCode<'tcx>,
obligated_types: &mut Vec<&TyS<'tcx>>,
seen_requirements: &mut FxHashSet<DefId>
) where
T: Display,
pub fn suggest_new_overflow_limit(&self, err: &mut DiagnosticBuilder<'_>)[src]
pub fn suggest_await_before_try(
&self,
err: &mut DiagnosticBuilder<'_>,
obligation: &PredicateObligation<'tcx>,
trait_ref: Binder<TraitRef<'tcx>>,
span: Span
)[src]
&self,
err: &mut DiagnosticBuilder<'_>,
obligation: &PredicateObligation<'tcx>,
trait_ref: Binder<TraitRef<'tcx>>,
span: Span
)