pub struct NiceRegionError<'cx, 'tcx> {
cx: &'cx TypeErrCtxt<'cx, 'tcx>,
generic_param_scope: LocalDefId,
error: Option<RegionResolutionError<'tcx>>,
regions: Option<(Span, Region<'tcx>, Region<'tcx>)>,
}
Fields§
§cx: &'cx TypeErrCtxt<'cx, 'tcx>
§generic_param_scope: LocalDefId
The innermost definition that introduces generic parameters that may be involved in the region errors we are dealing with.
error: Option<RegionResolutionError<'tcx>>
§regions: Option<(Span, Region<'tcx>, Region<'tcx>)>
Implementations§
Source§impl<'a, 'tcx> NiceRegionError<'a, 'tcx>
impl<'a, 'tcx> NiceRegionError<'a, 'tcx>
Sourcepub(super) fn try_report_anon_anon_conflict(&self) -> Option<ErrorGuaranteed>
pub(super) fn try_report_anon_anon_conflict(&self) -> Option<ErrorGuaranteed>
Print the error message for lifetime errors when both the concerned regions are anonymous.
Consider a case where we have
fn foo(x: &mut Vec<&u8>, y: &u8) {
x.push(y);
}
The example gives
fn foo(x: &mut Vec<&u8>, y: &u8) {
--- --- these references are declared with different lifetimes...
x.push(y);
^ ...but data from `y` flows into `x` here
It has been extended for the case of structs too.
Consider the example
struct Ref<'a> { x: &'a u32 }
fn foo(mut x: Vec<Ref>, y: Ref) {
--- --- these structs are declared with different lifetimes...
x.push(y);
^ ...but data from `y` flows into `x` here
}
It will later be extended to trait objects.
Source§impl<'a, 'tcx> NiceRegionError<'a, 'tcx>
impl<'a, 'tcx> NiceRegionError<'a, 'tcx>
pub(super) fn try_report_mismatched_static_lifetime( &self, ) -> Option<ErrorGuaranteed>
Source§impl<'a, 'tcx> NiceRegionError<'a, 'tcx>
impl<'a, 'tcx> NiceRegionError<'a, 'tcx>
Sourcepub(super) fn try_report_named_anon_conflict(&self) -> Option<Diag<'tcx>>
pub(super) fn try_report_named_anon_conflict(&self) -> Option<Diag<'tcx>>
When given a ConcreteFailure
for a function with parameters containing a named region and
an anonymous region, emit an descriptive diagnostic error.
Source§impl<'tcx> NiceRegionError<'_, 'tcx>
impl<'tcx> NiceRegionError<'_, 'tcx>
Sourcepub(super) fn try_report_placeholder_conflict(&self) -> Option<Diag<'tcx>>
pub(super) fn try_report_placeholder_conflict(&self) -> Option<Diag<'tcx>>
When given a ConcreteFailure
for a function with arguments containing a named region and
an anonymous region, emit a descriptive diagnostic error.
fn try_report_trait_placeholder_mismatch( &self, vid: Option<Region<'tcx>>, cause: &ObligationCause<'tcx>, sub_placeholder: Option<Region<'tcx>>, sup_placeholder: Option<Region<'tcx>>, value_pairs: &ValuePairs<'tcx>, ) -> Option<Diag<'tcx>>
fn report_trait_placeholder_mismatch( &self, vid: Option<Region<'tcx>>, cause: &ObligationCause<'tcx>, sub_placeholder: Option<Region<'tcx>>, sup_placeholder: Option<Region<'tcx>>, trait_def_id: DefId, expected_args: GenericArgsRef<'tcx>, actual_args: GenericArgsRef<'tcx>, ) -> Diag<'tcx>
Sourcefn explain_actual_impl_that_was_found(
&self,
sub_placeholder: Option<Region<'tcx>>,
sup_placeholder: Option<Region<'tcx>>,
has_sub: Option<usize>,
has_sup: Option<usize>,
expected_trait_ref: TraitRef<'tcx>,
actual_trait_ref: TraitRef<'tcx>,
vid: Option<Region<'tcx>>,
expected_has_vid: Option<usize>,
actual_has_vid: Option<usize>,
any_self_ty_has_vid: bool,
leading_ellipsis: bool,
) -> Vec<ActualImplExplNotes<'tcx>>
fn explain_actual_impl_that_was_found( &self, sub_placeholder: Option<Region<'tcx>>, sup_placeholder: Option<Region<'tcx>>, has_sub: Option<usize>, has_sup: Option<usize>, expected_trait_ref: TraitRef<'tcx>, actual_trait_ref: TraitRef<'tcx>, vid: Option<Region<'tcx>>, expected_has_vid: Option<usize>, actual_has_vid: Option<usize>, any_self_ty_has_vid: bool, leading_ellipsis: bool, ) -> Vec<ActualImplExplNotes<'tcx>>
Add notes with details about the expected and actual trait refs, with attention to cases when placeholder regions are involved: either the trait or the self type containing them needs to be mentioned the closest to the placeholders. This makes the error messages read better, however at the cost of some complexity due to the number of combinations we have to deal with.
Source§impl<'tcx> NiceRegionError<'_, 'tcx>
impl<'tcx> NiceRegionError<'_, 'tcx>
Sourcepub(super) fn try_report_placeholder_relation(&self) -> Option<Diag<'tcx>>
pub(super) fn try_report_placeholder_relation(&self) -> Option<Diag<'tcx>>
Emitted wwhen given a ConcreteFailure
when relating two placeholders.
Source§impl<'a, 'tcx> NiceRegionError<'a, 'tcx>
impl<'a, 'tcx> NiceRegionError<'a, 'tcx>
Sourcepub(super) fn try_report_static_impl_trait(&self) -> Option<ErrorGuaranteed>
pub(super) fn try_report_static_impl_trait(&self) -> Option<ErrorGuaranteed>
Print the error message for lifetime errors when the return type is a static impl Trait
,
dyn Trait
or if a method call on a trait object introduces a static requirement.
Source§impl<'a, 'tcx> NiceRegionError<'a, 'tcx>
impl<'a, 'tcx> NiceRegionError<'a, 'tcx>
pub fn get_impl_ident_and_self_ty_from_trait( tcx: TyCtxt<'tcx>, def_id: DefId, trait_objects: &FxIndexSet<DefId>, ) -> Option<(Ident, &'tcx Ty<'tcx>)>
Sourcefn find_impl_on_dyn_trait(
&self,
err: &mut Diag<'_>,
ty: Ty<'_>,
ctxt: &UnifyReceiverContext<'tcx>,
) -> bool
fn find_impl_on_dyn_trait( &self, err: &mut Diag<'_>, ty: Ty<'_>, ctxt: &UnifyReceiverContext<'tcx>, ) -> bool
When we call a method coming from an impl Foo for dyn Bar
, dyn Bar
introduces a default
'static
obligation. Suggest relaxing that implicit bound.
fn suggest_constrain_dyn_trait_in_impl( &self, err: &mut Diag<'_>, found_dids: &FxIndexSet<DefId>, ident: Ident, self_ty: &Ty<'_>, ) -> bool
Source§impl<'a, 'tcx> NiceRegionError<'a, 'tcx>
impl<'a, 'tcx> NiceRegionError<'a, 'tcx>
Sourcepub(super) fn try_report_impl_not_conforming_to_trait(
&self,
) -> Option<ErrorGuaranteed>
pub(super) fn try_report_impl_not_conforming_to_trait( &self, ) -> Option<ErrorGuaranteed>
Print the error message for lifetime errors when the impl
doesn’t conform to the trait
.
fn emit_err( &self, sp: Span, expected: Ty<'tcx>, found: Ty<'tcx>, trait_def_id: DefId, ) -> ErrorGuaranteed
Source§impl<'a, 'tcx> NiceRegionError<'a, 'tcx>
impl<'a, 'tcx> NiceRegionError<'a, 'tcx>
pub(super) fn find_param_with_region( &self, anon_region: Region<'tcx>, replace_region: Region<'tcx>, ) -> Option<AnonymousParamInfo<'tcx>>
pub(super) fn is_return_type_anon( &self, scope_def_id: LocalDefId, br: BoundRegionKind, hir_sig: &FnSig<'_>, ) -> Option<Span>
fn includes_region( &self, ty: Binder<'tcx, impl TypeFoldable<TyCtxt<'tcx>>>, region: BoundRegionKind, ) -> bool
pub(super) fn is_self_anon( &self, is_first: bool, scope_def_id: LocalDefId, ) -> bool
Source§impl<'cx, 'tcx> NiceRegionError<'cx, 'tcx>
impl<'cx, 'tcx> NiceRegionError<'cx, 'tcx>
pub fn new( cx: &'cx TypeErrCtxt<'cx, 'tcx>, generic_param_scope: LocalDefId, error: RegionResolutionError<'tcx>, ) -> Self
pub fn new_from_span( cx: &'cx TypeErrCtxt<'cx, 'tcx>, generic_param_scope: LocalDefId, span: Span, sub: Region<'tcx>, sup: Region<'tcx>, ) -> Self
fn tcx(&self) -> TyCtxt<'tcx>
pub fn try_report_from_nll(&self) -> Option<Diag<'tcx>>
pub fn try_report(&self) -> Option<ErrorGuaranteed>
pub(super) fn regions(&self) -> Option<(Span, Region<'tcx>, Region<'tcx>)>
Auto Trait Implementations§
impl<'cx, 'tcx> !DynSend for NiceRegionError<'cx, 'tcx>
impl<'cx, 'tcx> !DynSync for NiceRegionError<'cx, 'tcx>
impl<'cx, 'tcx> Freeze for NiceRegionError<'cx, 'tcx>
impl<'cx, 'tcx> !RefUnwindSafe for NiceRegionError<'cx, 'tcx>
impl<'cx, 'tcx> !Send for NiceRegionError<'cx, 'tcx>
impl<'cx, 'tcx> !Sync for NiceRegionError<'cx, 'tcx>
impl<'cx, 'tcx> Unpin for NiceRegionError<'cx, 'tcx>
impl<'cx, 'tcx> !UnwindSafe for NiceRegionError<'cx, 'tcx>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T, R> CollectAndApply<T, R> for T
impl<T, R> CollectAndApply<T, R> for T
Source§impl<T> Filterable for T
impl<T> Filterable for T
Source§fn filterable(
self,
filter_name: &'static str,
) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>
fn filterable( self, filter_name: &'static str, ) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<P> IntoQueryParam<P> for P
impl<P> IntoQueryParam<P> for P
fn into_query_param(self) -> P
Source§impl<T> MaybeResult<T> for T
impl<T> MaybeResult<T> for T
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<I, T, U> Upcast<I, U> for Twhere
U: UpcastFrom<I, T>,
impl<I, T, U> Upcast<I, U> for Twhere
U: UpcastFrom<I, T>,
Source§impl<I, T> UpcastFrom<I, T> for T
impl<I, T> UpcastFrom<I, T> for T
fn upcast_from(from: T, _tcx: I) -> T
Source§impl<Tcx, T> Value<Tcx> for Twhere
Tcx: DepContext,
impl<Tcx, T> Value<Tcx> for Twhere
Tcx: DepContext,
default fn from_cycle_error( tcx: Tcx, cycle_error: &CycleError, _guar: ErrorGuaranteed, ) -> T
Source§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
Source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
Source§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
impl<'a, T> Captures<'a> for Twhere
T: ?Sized,
impl<T> ErasedDestructor for Twhere
T: 'static,
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: 176 bytes