mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
remove old var_span_path_only
doc comment
This commit is contained in:
parent
e636af7dfd
commit
a0cee0ab90
@ -224,10 +224,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
use_spans.var_span_label_path_only(
|
||||
&mut err,
|
||||
format!("{} occurs due to use{}", desired_action.as_noun(), use_spans.describe()),
|
||||
);
|
||||
use_spans.var_path_only_subdiag(&mut err, desired_action);
|
||||
|
||||
if !is_loop_move {
|
||||
err.span_label(
|
||||
@ -404,10 +401,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
let used = desired_action.as_general_verb_in_past_tense();
|
||||
let mut err =
|
||||
struct_span_err!(self, span, E0381, "{used} binding {desc}{isnt_initialized}");
|
||||
use_spans.var_span_label_path_only(
|
||||
&mut err,
|
||||
format!("{} occurs due to use{}", desired_action.as_noun(), use_spans.describe()),
|
||||
);
|
||||
use_spans.var_path_only_subdiag(&mut err, desired_action);
|
||||
|
||||
if let InitializationRequiringAction::PartialAssignment
|
||||
| InitializationRequiringAction::Assignment = desired_action
|
||||
@ -678,10 +672,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
err.span_label(borrow_span, format!("borrow of {} occurs here", borrow_msg));
|
||||
err.span_label(span, format!("move out of {} occurs here", value_msg));
|
||||
|
||||
borrow_spans.var_span_label_path_only(
|
||||
&mut err,
|
||||
format!("borrow occurs due to use{}", borrow_spans.describe()),
|
||||
);
|
||||
borrow_spans.var_path_only_subdiag(&mut err, crate::InitializationRequiringAction::Borrow);
|
||||
|
||||
move_spans.var_span_label(
|
||||
&mut err,
|
||||
|
@ -595,11 +595,34 @@ impl UseSpans<'_> {
|
||||
}
|
||||
}
|
||||
|
||||
// Add a span label to the use of the captured variable, if it exists.
|
||||
// only adds label to the `path_span`
|
||||
pub(super) fn var_span_label_path_only(self, err: &mut Diagnostic, message: impl Into<String>) {
|
||||
if let UseSpans::ClosureUse { path_span, .. } = self {
|
||||
err.span_label(path_span, message);
|
||||
/// Add a span label to the use of the captured variable, if it exists.
|
||||
/// only adds label to the `path_span`
|
||||
pub(super) fn var_path_only_subdiag(
|
||||
self,
|
||||
err: &mut Diagnostic,
|
||||
action: crate::InitializationRequiringAction,
|
||||
) {
|
||||
use crate::session_diagnostics::CaptureVarPathUseCause::*;
|
||||
use crate::InitializationRequiringAction::*;
|
||||
if let UseSpans::ClosureUse { generator_kind, path_span, .. } = self {
|
||||
match generator_kind {
|
||||
Some(_) => {
|
||||
err.subdiagnostic(match action {
|
||||
Borrow => BorrowInGenerator { path_span },
|
||||
MatchOn | Use => UseInGenerator { path_span },
|
||||
Assignment => AssignInGenerator { path_span },
|
||||
PartialAssignment => AssignPartInGenerator { path_span },
|
||||
});
|
||||
}
|
||||
None => {
|
||||
err.subdiagnostic(match action {
|
||||
Borrow => BorrowInClosure { path_span },
|
||||
MatchOn | Use => UseInClosure { path_span },
|
||||
Assignment => AssignInClosure { path_span },
|
||||
PartialAssignment => AssignPartInClosure { path_span },
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -178,3 +178,47 @@ pub(crate) enum CaptureVarCause {
|
||||
var_span: Span,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Subdiagnostic)]
|
||||
pub(crate) enum CaptureVarPathUseCause {
|
||||
#[label(borrowck_borrow_due_to_use_generator)]
|
||||
BorrowInGenerator {
|
||||
#[primary_span]
|
||||
path_span: Span,
|
||||
},
|
||||
#[label(borrowck_use_due_to_use_generator)]
|
||||
UseInGenerator {
|
||||
#[primary_span]
|
||||
path_span: Span,
|
||||
},
|
||||
#[label(borrowck_assign_due_to_use_generator)]
|
||||
AssignInGenerator {
|
||||
#[primary_span]
|
||||
path_span: Span,
|
||||
},
|
||||
#[label(borrowck_assign_part_due_to_use_generator)]
|
||||
AssignPartInGenerator {
|
||||
#[primary_span]
|
||||
path_span: Span,
|
||||
},
|
||||
#[label(borrowck_borrow_due_to_use_closure)]
|
||||
BorrowInClosure {
|
||||
#[primary_span]
|
||||
path_span: Span,
|
||||
},
|
||||
#[label(borrowck_use_due_to_use_closure)]
|
||||
UseInClosure {
|
||||
#[primary_span]
|
||||
path_span: Span,
|
||||
},
|
||||
#[label(borrowck_assign_due_to_use_closure)]
|
||||
AssignInClosure {
|
||||
#[primary_span]
|
||||
path_span: Span,
|
||||
},
|
||||
#[label(borrowck_assign_part_due_to_use_closure)]
|
||||
AssignPartInClosure {
|
||||
#[primary_span]
|
||||
path_span: Span,
|
||||
},
|
||||
}
|
||||
|
@ -70,3 +70,27 @@ borrowck_var_borrow_by_use_place_in_closure =
|
||||
|
||||
borrowck_var_borrow_by_use_place =
|
||||
borrow occurs due to use of {$place}
|
||||
|
||||
borrowck_borrow_due_to_use_generator =
|
||||
borrow occurs due to use in generator
|
||||
|
||||
borrowck_use_due_to_use_generator =
|
||||
use occurs due to use in generator
|
||||
|
||||
borrowck_assign_due_to_use_generator =
|
||||
assign occurs due to use in generator
|
||||
|
||||
borrowck_assign_part_due_to_use_generator =
|
||||
assign to part occurs due to use in generator
|
||||
|
||||
borrowck_borrow_due_to_use_closure =
|
||||
borrow occurs due to use in closure
|
||||
|
||||
borrowck_use_due_to_use_closure =
|
||||
use occurs due to use in closure
|
||||
|
||||
borrowck_assign_due_to_use_closure =
|
||||
assign occurs due to use in closure
|
||||
|
||||
borrowck_assign_part_due_to_use_closure =
|
||||
assign to part occurs due to use in closure
|
||||
|
Loading…
Reference in New Issue
Block a user