pub(crate) enum UseSpans<'tcx> {
    ClosureUse {
        generator_kind: Option<GeneratorKind>,
        args_span: Span,
        capture_kind_span: Span,
        path_span: Span,
    },
    FnSelfUse {
        var_span: Span,
        fn_call_span: Span,
        fn_span: Span,
        kind: CallKind<'tcx>,
    },
    PatUse(Span),
    OtherUse(Span),
}
Expand description

The span(s) associated to a use of a place.

Variants§

§

ClosureUse

Fields

§generator_kind: Option<GeneratorKind>

This is true if the captured variable was from a generator.

§args_span: Span

The span of the args of the closure, including the move keyword if it’s present.

§capture_kind_span: Span

The span of the use resulting in capture kind Check ty::CaptureInfo for more details

§path_span: Span

The span of the use resulting in the captured path Check ty::CaptureInfo for more details

The access is caused by capturing a variable for a closure.

§

FnSelfUse

Fields

§var_span: Span

The span of the variable being moved

§fn_call_span: Span

The span of the method call on the variable

§fn_span: Span

The definition span of the method being called

§kind: CallKind<'tcx>

The access is caused by using a variable as the receiver of a method that takes ‘self’

§

PatUse(Span)

This access is caused by a match or if let pattern.

§

OtherUse(Span)

This access has a single span associated to it: common case.

Implementations§

source§

impl UseSpans<'_>

source

pub(crate) fn args_or_use(self) -> Span

source

pub(crate) fn var_or_use_path_span(self) -> Span

Returns the span of self, in the case of a ClosureUse returns the path_span

source

pub(crate) fn var_or_use(self) -> Span

Returns the span of self, in the case of a ClosureUse returns the capture_kind_span

source

pub(crate) fn generator_kind(self) -> Option<GeneratorKind>

source

pub(crate) fn args_subdiag( self, err: &mut Diagnostic, f: impl FnOnce(Span) -> CaptureArgLabel )

Add a span label to the arguments of the closure, if it exists.

source

pub(crate) fn var_path_only_subdiag( self, err: &mut Diagnostic, action: InitializationRequiringAction )

Add a span label to the use of the captured variable, if it exists. only adds label to the path_span

source

pub(crate) fn var_subdiag( self, handler: Option<&Handler>, err: &mut Diagnostic, kind: Option<BorrowKind>, f: impl FnOnce(Option<GeneratorKind>, Span) -> CaptureVarCause )

Add a subdiagnostic to the use of the captured variable, if it exists.

source

pub(crate) fn for_closure(&self) -> bool

Returns false if this place is not used in a closure.

source

pub(crate) fn for_generator(&self) -> bool

Returns false if this place is not used in a generator.

source

pub(crate) fn or_else<F>(self, if_other: F) -> Selfwhere F: FnOnce() -> Self,

Trait Implementations§

source§

impl<'tcx> Clone for UseSpans<'tcx>

source§

fn clone(&self) -> UseSpans<'tcx>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'tcx> Debug for UseSpans<'tcx>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'tcx> PartialEq<UseSpans<'tcx>> for UseSpans<'tcx>

source§

fn eq(&self, other: &UseSpans<'tcx>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'tcx> Copy for UseSpans<'tcx>

source§

impl<'tcx> Eq for UseSpans<'tcx>

source§

impl<'tcx> StructuralEq for UseSpans<'tcx>

source§

impl<'tcx> StructuralPartialEq for UseSpans<'tcx>

Auto Trait Implementations§

§

impl<'tcx> !RefUnwindSafe for UseSpans<'tcx>

§

impl<'tcx> !Send for UseSpans<'tcx>

§

impl<'tcx> !Sync for UseSpans<'tcx>

§

impl<'tcx> Unpin for UseSpans<'tcx>

§

impl<'tcx> !UnwindSafe for UseSpans<'tcx>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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 Twhere U: TryFrom<T>,

§

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.

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: 72 bytes

Size for each variant:

  • ClosureUse: 32 bytes
  • FnSelfUse: 72 bytes
  • PatUse: 12 bytes
  • OtherUse: 12 bytes