rustc_trait_selection::error_reporting::infer::nice_region_error

Struct NiceRegionError

Source
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>

Source

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>

Source§

impl<'a, 'tcx> NiceRegionError<'a, 'tcx>

Source

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>

Source

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.

Source

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>>

Source

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>

Source

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>

Source

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>

Source

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>

Source

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>)>

Source

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.

Source

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>

Source

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.

Source

fn emit_err( &self, sp: Span, expected: Ty<'tcx>, found: Ty<'tcx>, trait_def_id: DefId, ) -> ErrorGuaranteed

Source§

impl<'a, 'tcx> NiceRegionError<'a, 'tcx>

Source

pub(super) fn find_param_with_region( &self, anon_region: Region<'tcx>, replace_region: Region<'tcx>, ) -> Option<AnonymousParamInfo<'tcx>>

Source

pub(super) fn is_return_type_anon( &self, scope_def_id: LocalDefId, br: BoundRegionKind, hir_sig: &FnSig<'_>, ) -> Option<Span>

Source

fn includes_region( &self, ty: Binder<'tcx, impl TypeFoldable<TyCtxt<'tcx>>>, region: BoundRegionKind, ) -> bool

Source

pub(super) fn is_self_anon( &self, is_first: bool, scope_def_id: LocalDefId, ) -> bool

Source§

impl<'cx, 'tcx> NiceRegionError<'cx, 'tcx>

Source

pub fn new( cx: &'cx TypeErrCtxt<'cx, 'tcx>, generic_param_scope: LocalDefId, error: RegionResolutionError<'tcx>, ) -> Self

Source

pub fn new_from_span( cx: &'cx TypeErrCtxt<'cx, 'tcx>, generic_param_scope: LocalDefId, span: Span, sub: Region<'tcx>, sup: Region<'tcx>, ) -> Self

Source

fn tcx(&self) -> TyCtxt<'tcx>

Source

pub fn try_report_from_nll(&self) -> Option<Diag<'tcx>>

Source

pub fn try_report(&self) -> Option<ErrorGuaranteed>

Source

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> Aligned for T

Source§

const ALIGN: Alignment = _

Alignment of Self.
Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T, R> CollectAndApply<T, R> for T

Source§

fn collect_and_apply<I, F>(iter: I, f: F) -> R
where I: Iterator<Item = T>, F: FnOnce(&[T]) -> R,

Equivalent to f(&iter.collect::<Vec<_>>()).

Source§

type Output = R

Source§

impl<T> Filterable for T

Source§

fn filterable( self, filter_name: &'static str, ) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>

Creates a filterable data provider with the given name for debugging. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<P> IntoQueryParam<P> for P

Source§

impl<T> MaybeResult<T> for T

Source§

type Error = !

Source§

fn from(_: Result<T, <T as MaybeResult<T>>::Error>) -> T

Source§

fn to_result(self) -> Result<T, <T as MaybeResult<T>>::Error>

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize = _

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<I, T, U> Upcast<I, U> for T
where U: UpcastFrom<I, T>,

Source§

fn upcast(self, interner: I) -> U

Source§

impl<I, T> UpcastFrom<I, T> for T

Source§

fn upcast_from(from: T, _tcx: I) -> T

Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<Tcx, T> Value<Tcx> for T
where Tcx: DepContext,

Source§

default fn from_cycle_error( tcx: Tcx, cycle_error: &CycleError, _guar: ErrorGuaranteed, ) -> T

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<'a, T> Captures<'a> for T
where T: ?Sized,

Source§

impl<T> ErasedDestructor for T
where 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