Skip to content

Commit 71d6ef8

Browse files
refactor with early exit
1 parent 6402fd0 commit 71d6ef8

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

compiler/rustc_borrowck/src/diagnostics/move_errors.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -825,21 +825,25 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
825825
}
826826
// If the `inner` is a raw pointer, do not suggest removing the "*", see #126863
827827
// FIXME: need to check whether the assigned object can be a raw pointer, see `tests/ui/borrowck/issue-20801.rs`.
828-
if !is_raw_ptr && (!is_destructuring_pattern_move || is_ref) {
828+
if is_raw_ptr {
829+
return;
830+
}
831+
832+
if !is_destructuring_pattern_move || is_ref {
829833
err.span_suggestion_verbose(
830834
span.with_hi(span.lo() + BytePos(1)),
831835
"consider removing the dereference here",
832836
String::new(),
833837
Applicability::MaybeIncorrect,
834838
);
835-
} else if !is_raw_ptr && !is_destructuring_assignment && !is_nested_deref {
839+
} else if !is_destructuring_assignment && !is_nested_deref {
836840
err.span_suggestion_verbose(
837841
span.shrink_to_lo(),
838842
"consider borrowing here",
839843
'&',
840844
Applicability::MaybeIncorrect,
841845
);
842-
} else if !is_raw_ptr {
846+
} else {
843847
err.span_help(
844848
span,
845849
"destructuring assignment cannot borrow from this expression; consider using a `let` binding instead",

0 commit comments

Comments
 (0)