diff --git a/compiler/rustc_mir/src/borrow_check/diagnostics/explain_borrow.rs b/compiler/rustc_mir/src/borrow_check/diagnostics/explain_borrow.rs index 0e12655114235cbdafce4bfb12a35af85e7521f3..49e59f6612fd223f32c365455f226e82a76491c7 100644 --- a/compiler/rustc_mir/src/borrow_check/diagnostics/explain_borrow.rs +++ b/compiler/rustc_mir/src/borrow_check/diagnostics/explain_borrow.rs @@ -112,7 +112,7 @@ pub(in crate::borrow_check) fn add_explanation_to_diagnostic<'tcx>( LaterUseKind::Other => "borrow used here, in later iteration of loop", }; // We can use `var_or_use_span` if either `path_span` is not present, or both spans are the same - if path_span.map_or(true, |path_span| path_span == var_or_use_span) { + if path_span.map(|path_span| path_span == var_or_use_span).unwrap_or(true) { err.span_label(var_or_use_span, format!("{}{}", borrow_desc, message)); } else { // path_span must be `Some` as otherwise the if condition is true