pub (in borrow_check) fn report_why_borrow_contains_point(
        &self,
        err: &mut DiagnosticBuilder,
        reason: BorrowContainsPointReason<'tcx>,
        kind_place: Option<(WriteKind, &Place<'tcx>)>,
    ) {
        use self::BorrowContainsPointReason::*;

        debug!(
            "find_why_borrow_contains_point(reason={:?}, kind_place={:?})",
            reason, kind_place,
        );

        let mir = self.mir;

        match reason {
            Liveness { local, location, in_loop } => {
                let span = mir.source_info(location).span;
                let spans = self.move_spans(&Place::Local(local), location)
                    .or_else(|| self.borrow_spans(span, location));
                let message = if in_loop {
                    if spans.for_closure() {
                        "borrow captured here by closure in later iteration of loop"
                    } else {
                        "borrow used here in later iteration of loop"
                    }
                } else {
                    if spans.for_closure() {
                        "borrow later captured here by closure"
                    } else {
                        "borrow later used here"
                    }
                };
                err.span_label(spans.var_or_use(), message);
            }
            DropLiveness { local, location } => match &mir.local_decls[local].name {
                Some(local_name) => {
                    err.span_label(
                        mir.source_info(location).span,
                        format!("borrow later used here, when `{}` is dropped", local_name),
                    );

                    if let Some((WriteKind::StorageDeadOrDrop, place)) = kind_place {
                        if let Place::Local(borrowed_local) = place {
                            let dropped_local_scope = mir.local_decls[local].visibility_scope;
                            let borrowed_local_scope =
                            mir.local_decls[*borrowed_local].visibility_scope;

                            if mir.is_sub_scope(borrowed_local_scope, dropped_local_scope) {
                                err.note(
                                "values in a scope are dropped \
                                                     in the opposite order they are defined",
                                );
                            }
                        }
                    }
                }

                None => {}
            }
            OutlivesFreeRegion { outlived_region: Some(region) } => {
                self.tcx.note_and_explain_free_region(
                    err,
                    "borrowed value must be valid for ",
                    region,
                    "...",
                );
            }
            OutlivesFreeRegion { outlived_region: None } => (),
        }
    }
/// Adds annotations to `err` for the explanation `reason`. This is a
/// separate method so that the caller can change their error message based
/// on the reason that is going to be reported.
Adds annotations to `err` for the explanation `reason`. This is a
separate method so that the caller can change their error message based
on the reason that is going to be reported.
Adds annotations to ` err ` for the explanation ` reason ` . This is a separate method so that the caller can change their error message based on the reason that is going to be reported .
pub (in borrow_check) fn report_why_borrow_contains_point(
        &self,
        err: &mut DiagnosticBuilder,
        reason: BorrowContainsPointReason<'tcx>,
        kind_place: Option<(WriteKind, &Place<'tcx>)>,
    ) {
        use self::BorrowContainsPointReason::*;
        debug!(
            "find_why_borrow_contains_point(reason={:?}, kind_place={:?})",
            reason, kind_place,
        );
        let mir = self.mir;
        match reason {
            Liveness { local, location, in_loop } => {
                let span = mir.source_info(location).span;
                let spans = self.move_spans(&Place::Local(local), location)
                    .or_else(|| self.borrow_spans(span, location));
                let message = if in_loop {
                    if spans.for_closure() {
                        "borrow captured here by closure in later iteration of loop"
                    } else {
                        "borrow used here in later iteration of loop"
                    }
                } else {
                    if spans.for_closure() {
                        "borrow later captured here by closure"
                    } else {
                        "borrow later used here"
                    }
                };
                err.span_label(spans.var_or_use(), message);
            }
            DropLiveness { local, location } => match &mir.local_decls[local].name {
                Some(local_name) => {
                    err.span_label(
                        mir.source_info(location).span,
                        format!("borrow later used here, when `{}` is dropped", local_name),
                    );
                    if let Some((WriteKind::StorageDeadOrDrop, place)) = kind_place {
                        if let Place::Local(borrowed_local) = place {
                            let dropped_local_scope = mir.local_decls[local].visibility_scope;
                            let borrowed_local_scope =
                            mir.local_decls[*borrowed_local].visibility_scope;
                            if mir.is_sub_scope(borrowed_local_scope, dropped_local_scope) {
                                err.note(
                                "values in a scope are dropped \
                                                     in the opposite order they are defined",
                                );
                            }
                        }
                    }
                }
                None => {}
            }
            OutlivesFreeRegion { outlived_region: Some(region) } => {
                self.tcx.note_and_explain_free_region(
                    err,
                    "borrowed value must be valid for ",
                    region,
                    "...",
                );
            }
            OutlivesFreeRegion { outlived_region: None } => (),
        }
    }
pub ( in borrow_check ) fn report_why_borrow_contains_point ( & self , err : & mut DiagnosticBuilder , reason : BorrowContainsPointReason < ' tcx > , kind_place : Option < ( WriteKind , & Place < ' tcx > ) > , ) { use self :: BorrowContainsPointReason :: * ; debug ! ( " " reason kind_place ) ; let mir = self . mir ; match reason { Liveness { local , location , in_loop } => { let span = mir . source_info ( location ) . span ; let spans = self . move_spans ( & Place :: Local ( local ) , location ) . or_else ( | | self . borrow_spans ( span , location ) ) ; let message = if in_loop { if spans . for_closure ( ) { " " } else { " " } } else { if spans . for_closure ( ) { " " } else { " " } } ; err . span_label ( spans . var_or_use ( ) , message ) ; } DropLiveness { local , location } => match & mir . local_decls [ local ] . name { Some ( local_name ) => { err . span_label ( mir . source_info ( location ) . span , format ! ( " " local_name ) , ) ; if let Some ( ( WriteKind :: StorageDeadOrDrop , place ) ) = kind_place { if let Place :: Local ( borrowed_local ) = place { let dropped_local_scope = mir . local_decls [ local ] . visibility_scope ; let borrowed_local_scope = mir . local_decls [ * borrowed_local ] . visibility_scope ; if mir . is_sub_scope ( borrowed_local_scope , dropped_local_scope ) { err . note ( " \
 " , ) ; } } } } None => { } } OutlivesFreeRegion { outlived_region : Some ( region ) } => { self . tcx . note_and_explain_free_region ( err , " " , region , " " , ) ; } OutlivesFreeRegion { outlived_region : None } => ( ) , } }
Adds annotations to `err` for the explanation `reason`.
Adds annotations to ` err ` for the explanation ` reason ` .
&self
err
&mut DiagnosticBuilder
reason
BorrowContainsPointReason<'tcx>
kind_place
Option<(WriteKind, &Place<'tcx>)>
&self
err
&mut DiagnosticBuilder
reason
BorrowContainsPointReason<'tcx>
kind_place
Option<(WriteKind, &Place<'tcx>)>