Tweak output to account for alternative bindings in the same pattern
This commit is contained in:
parent
24f80ea7d7
commit
5993f5d0f8
@ -192,26 +192,23 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
|||||||
is_loop_move = true;
|
is_loop_move = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.suggest_ref_or_clone(
|
if !seen_spans.contains(&move_span) {
|
||||||
mpi,
|
self.suggest_ref_or_clone(mpi, move_span, &mut err, &mut in_pattern);
|
||||||
move_span,
|
|
||||||
&mut err,
|
|
||||||
&mut seen_spans,
|
|
||||||
&mut in_pattern,
|
|
||||||
);
|
|
||||||
|
|
||||||
self.explain_captures(
|
self.explain_captures(
|
||||||
&mut err,
|
&mut err,
|
||||||
span,
|
span,
|
||||||
move_span,
|
move_span,
|
||||||
move_spans,
|
move_spans,
|
||||||
*moved_place,
|
*moved_place,
|
||||||
partially_str,
|
partially_str,
|
||||||
loop_message,
|
loop_message,
|
||||||
move_msg,
|
move_msg,
|
||||||
is_loop_move,
|
is_loop_move,
|
||||||
maybe_reinitialized_locations.is_empty(),
|
maybe_reinitialized_locations.is_empty(),
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
seen_spans.insert(move_span);
|
||||||
}
|
}
|
||||||
|
|
||||||
use_spans.var_path_only_subdiag(&mut err, desired_action);
|
use_spans.var_path_only_subdiag(&mut err, desired_action);
|
||||||
@ -312,7 +309,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
|||||||
mpi: MovePathIndex,
|
mpi: MovePathIndex,
|
||||||
move_span: Span,
|
move_span: Span,
|
||||||
err: &mut DiagnosticBuilder<'_, ErrorGuaranteed>,
|
err: &mut DiagnosticBuilder<'_, ErrorGuaranteed>,
|
||||||
seen_spans: &mut FxHashSet<Span>,
|
|
||||||
in_pattern: &mut bool,
|
in_pattern: &mut bool,
|
||||||
) {
|
) {
|
||||||
struct ExpressionFinder<'hir> {
|
struct ExpressionFinder<'hir> {
|
||||||
@ -436,7 +432,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let Some(pat) = finder.pat && !seen_spans.contains(&pat.span) {
|
if let Some(pat) = finder.pat {
|
||||||
*in_pattern = true;
|
*in_pattern = true;
|
||||||
err.span_suggestion_verbose(
|
err.span_suggestion_verbose(
|
||||||
pat.span.shrink_to_lo(),
|
pat.span.shrink_to_lo(),
|
||||||
@ -444,7 +440,6 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
|||||||
"ref ".to_string(),
|
"ref ".to_string(),
|
||||||
Applicability::MachineApplicable,
|
Applicability::MachineApplicable,
|
||||||
);
|
);
|
||||||
seen_spans.insert(pat.span);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -76,10 +76,7 @@ LL | fn bindings_after_at_or_patterns_move(x: Option<Test>) {
|
|||||||
| - move occurs because `x` has type `Option<Test>`, which does not implement the `Copy` trait
|
| - move occurs because `x` has type `Option<Test>`, which does not implement the `Copy` trait
|
||||||
LL | match x {
|
LL | match x {
|
||||||
LL | foo @ Some(Test::Foo | Test::Bar) => (),
|
LL | foo @ Some(Test::Foo | Test::Bar) => (),
|
||||||
| ---
|
| --- value moved here
|
||||||
| |
|
|
||||||
| value moved here
|
|
||||||
| value moved here
|
|
||||||
...
|
...
|
||||||
LL | &x;
|
LL | &x;
|
||||||
| ^^ value borrowed here after move
|
| ^^ value borrowed here after move
|
||||||
@ -132,10 +129,7 @@ LL | fn bindings_after_at_slice_patterns_or_patterns_moves(x: [Option<Test>; 4])
|
|||||||
| - move occurs because `x` has type `[Option<Test>; 4]`, which does not implement the `Copy` trait
|
| - move occurs because `x` has type `[Option<Test>; 4]`, which does not implement the `Copy` trait
|
||||||
LL | match x {
|
LL | match x {
|
||||||
LL | a @ [.., Some(Test::Foo | Test::Bar)] => (),
|
LL | a @ [.., Some(Test::Foo | Test::Bar)] => (),
|
||||||
| -
|
| - value moved here
|
||||||
| |
|
|
||||||
| value moved here
|
|
||||||
| value moved here
|
|
||||||
...
|
...
|
||||||
LL | &x;
|
LL | &x;
|
||||||
| ^^ value borrowed here after move
|
| ^^ value borrowed here after move
|
||||||
|
Loading…
x
Reference in New Issue
Block a user