[−][src]Struct rustc_infer::infer::error_reporting::nice_region_error::NiceRegionError

pub struct NiceRegionError<'cx, 'tcx> {
    infcx: &'cx InferCtxt<'cx, 'tcx>,
    error: Option<RegionResolutionError<'tcx>>,
    regions: Option<(Span, Region<'tcx>, Region<'tcx>)>,
}

Fields

infcx: &'cx InferCtxt<'cx, 'tcx>error: Option<RegionResolutionError<'tcx>>regions: Option<(Span, Region<'tcx>, Region<'tcx>)>

Implementations

impl<'a, 'tcx> NiceRegionError<'a, 'tcx>[src]

pub(in infer::error_reporting::nice_region_error) fn try_report_anon_anon_conflict(
    &self
) -> Option<ErrorReported>
[src]

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.

impl<'a, 'tcx> NiceRegionError<'a, 'tcx>[src]

pub(in infer::error_reporting::nice_region_error) fn find_anon_type(
    &self,
    region: Region<'tcx>,
    br: &BoundRegion
) -> Option<(&Ty<'tcx>, &FnDecl<'tcx>)>
[src]

This function calls the visit_ty method for the parameters corresponding to the anonymous regions. The nested_visitor.found_type contains the anonymous type.

Arguments

region - the anonymous region corresponding to the anon_anon conflict br - the bound region corresponding to the above region which is of type BrAnon(_)

Example

fn foo(x: &mut Vec<&u8>, y: &u8)
   { x.push(y); }

The function returns the nested type corresponding to the anonymous region for e.g., &u8 and Vec<&u8.

pub(in infer::error_reporting::nice_region_error::find_anon_type) fn find_component_for_bound_region(
    &self,
    arg: &'tcx Ty<'tcx>,
    br: &BoundRegion
) -> Option<&'tcx Ty<'tcx>>
[src]

impl<'a, 'tcx> NiceRegionError<'a, 'tcx>[src]

pub(in infer::error_reporting::nice_region_error) fn try_report_named_anon_conflict(
    &self
) -> Option<DiagnosticBuilder<'a>>
[src]

When given a ConcreteFailure for a function with parameters containing a named region and an anonymous region, emit an descriptive diagnostic error.

impl<'me, 'tcx> NiceRegionError<'me, 'tcx>[src]

pub(in infer::error_reporting::nice_region_error) fn try_report_placeholder_conflict(
    &self
) -> Option<DiagnosticBuilder<'me>>
[src]

When given a ConcreteFailure for a function with arguments containing a named region and an anonymous region, emit a descriptive diagnostic error.

pub(in infer::error_reporting::nice_region_error::placeholder_error) fn try_report_placeholders_trait(
    &self,
    vid: Option<Region<'tcx>>,
    cause: &ObligationCause<'tcx>,
    sub_placeholder: Option<Region<'tcx>>,
    sup_placeholder: Option<Region<'tcx>>,
    trait_def_id: DefId,
    expected_substs: SubstsRef<'tcx>,
    actual_substs: SubstsRef<'tcx>
) -> DiagnosticBuilder<'me>
[src]

pub(in infer::error_reporting::nice_region_error::placeholder_error) fn explain_actual_impl_that_was_found(
    &self,
    err: &mut DiagnosticBuilder<'_>,
    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
)
[src]

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.

impl<'a, 'tcx> NiceRegionError<'a, 'tcx>[src]

pub(in infer::error_reporting::nice_region_error) fn try_report_static_impl_trait(
    &self
) -> Option<ErrorReported>
[src]

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.

pub(in infer::error_reporting::nice_region_error::static_impl_trait) fn get_impl_ident_and_self_ty_from_trait(
    &self,
    def_id: DefId,
    trait_objects: &[DefId]
) -> Option<(Ident, &'tcx Ty<'tcx>)>
[src]

pub(in infer::error_reporting::nice_region_error::static_impl_trait) fn find_impl_on_dyn_trait(
    &self,
    err: &mut DiagnosticBuilder<'_>,
    ty: Ty<'_>,
    ctxt: &UnifyReceiverContext<'tcx>
) -> bool
[src]

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.

pub(in infer::error_reporting::nice_region_error::static_impl_trait) fn suggest_constrain_dyn_trait_in_impl(
    &self,
    err: &mut DiagnosticBuilder<'_>,
    found_dids: &[DefId],
    ident: Ident,
    self_ty: &Ty<'_>
) -> bool
[src]

impl<'a, 'tcx> NiceRegionError<'a, 'tcx>[src]

pub(in infer::error_reporting::nice_region_error) fn try_report_impl_not_conforming_to_trait(
    &self
) -> Option<ErrorReported>
[src]

Print the error message for lifetime errors when the impl doesn't conform to the trait.

pub(in infer::error_reporting::nice_region_error::trait_impl_difference) fn emit_err(
    &self,
    sp: Span,
    expected: Ty<'tcx>,
    found: Ty<'tcx>,
    trait_def_id: DefId
)
[src]

impl<'a, 'tcx> NiceRegionError<'a, 'tcx>[src]

pub(in infer::error_reporting::nice_region_error) fn find_param_with_region(
    &self,
    anon_region: Region<'tcx>,
    replace_region: Region<'tcx>
) -> Option<AnonymousParamInfo<'_>>
[src]

pub(in infer::error_reporting::nice_region_error) fn future_return_type(
    &self,
    local_def_id: LocalDefId
) -> Option<&Ty<'_>>
[src]

pub(in infer::error_reporting::nice_region_error) fn asyncness(
    &self,
    local_def_id: LocalDefId
) -> Option<IsAsync>
[src]

pub(in infer::error_reporting::nice_region_error) fn is_return_type_anon(
    &self,
    scope_def_id: LocalDefId,
    br: BoundRegion,
    decl: &FnDecl<'_>
) -> Option<Span>
[src]

pub(in infer::error_reporting::nice_region_error) fn is_self_anon(
    &self,
    is_first: bool,
    scope_def_id: LocalDefId
) -> bool
[src]

impl<'cx, 'tcx> NiceRegionError<'cx, 'tcx>[src]

pub fn new(
    infcx: &'cx InferCtxt<'cx, 'tcx>,
    error: RegionResolutionError<'tcx>
) -> Self
[src]

pub fn new_from_span(
    infcx: &'cx InferCtxt<'cx, 'tcx>,
    span: Span,
    sub: Region<'tcx>,
    sup: Region<'tcx>
) -> Self
[src]

pub(in infer::error_reporting::nice_region_error) fn tcx(
    &self
) -> TyCtxt<'tcx>
[src]

pub fn try_report_from_nll(&self) -> Option<DiagnosticBuilder<'cx>>[src]

pub fn try_report(&self) -> Option<ErrorReported>[src]

pub fn regions(&self) -> Option<(Span, Region<'tcx>, Region<'tcx>)>[src]

Auto Trait Implementations

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> where
    'tcx: 'cx, 

impl<'cx, 'tcx> !UnwindSafe for NiceRegionError<'cx, 'tcx>

Blanket Implementations

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

impl<T> Borrow<T> for T where
    T: ?Sized, 
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized, 
[src]

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

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> WithConstness for T[src]