Enum rustc_borrowck::diagnostics::UseSpans
source · 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.
The access is caused by capturing a variable for a closure.
FnSelfUse
Fields
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<'_>
impl UseSpans<'_>
pub(crate) fn args_or_use(self) -> Span
sourcepub(crate) fn var_or_use_path_span(self) -> Span
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
sourcepub(crate) fn var_or_use(self) -> Span
pub(crate) fn var_or_use(self) -> Span
Returns the span of self
, in the case of a ClosureUse
returns the capture_kind_span
pub(crate) fn generator_kind(self) -> Option<GeneratorKind>
sourcepub(crate) fn args_span_label(
self,
err: &mut Diagnostic,
message: impl Into<String>
)
pub(crate) fn args_span_label(
self,
err: &mut Diagnostic,
message: impl Into<String>
)
Add a span label to the arguments of the closure, if it exists.
sourcepub(crate) fn var_path_only_subdiag(
self,
err: &mut Diagnostic,
action: InitializationRequiringAction
)
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
sourcepub(crate) fn var_span_label(
self,
err: &mut Diagnostic,
message: impl Into<String>,
kind_desc: impl Into<String>
)
pub(crate) fn var_span_label(
self,
err: &mut Diagnostic,
message: impl Into<String>,
kind_desc: impl Into<String>
)
Add a span label to the use of the captured variable, if it exists.
sourcepub(crate) fn var_subdiag(
self,
err: &mut Diagnostic,
kind: Option<BorrowKind>,
f: impl Fn(Option<GeneratorKind>, Span) -> CaptureVarCause
)
pub(crate) fn var_subdiag(
self,
err: &mut Diagnostic,
kind: Option<BorrowKind>,
f: impl Fn(Option<GeneratorKind>, Span) -> CaptureVarCause
)
Add a subdiagnostic to the use of the captured variable, if it exists.
sourcepub(crate) fn for_closure(&self) -> bool
pub(crate) fn for_closure(&self) -> bool
Returns false
if this place is not used in a closure.
sourcepub(crate) fn for_generator(&self) -> bool
pub(crate) fn for_generator(&self) -> bool
Returns false
if this place is not used in a generator.
pub(crate) fn or_else<F>(self, if_other: F) -> Selfwhere
F: FnOnce() -> Self,
Trait Implementations§
source§impl<'tcx> PartialEq<UseSpans<'tcx>> for UseSpans<'tcx>
impl<'tcx> PartialEq<UseSpans<'tcx>> for UseSpans<'tcx>
impl<'tcx> Copy for UseSpans<'tcx>
impl<'tcx> Eq for UseSpans<'tcx>
impl<'tcx> StructuralEq for UseSpans<'tcx>
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§
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: 64 bytes
Size for each variant:
ClosureUse
: 56 bytesFnSelfUse
: 64 bytesPatUse
: 8 bytesOtherUse
: 8 bytes