@@ -66,6 +66,7 @@ impl BorrowExplanation {
6666 err : & mut DiagnosticBuilder < ' _ > ,
6767 borrow_desc : & str ,
6868 borrow_span : Option < Span > ,
69+ multiple_borrow_span : Option < ( Span , Span ) > ,
6970 ) {
7071 match * self {
7172 BorrowExplanation :: UsedLater ( later_use_kind, var_or_use_span, path_span) => {
@@ -192,14 +193,23 @@ impl BorrowExplanation {
192193
193194 if let Some ( info) = & local_decl. is_block_tail {
194195 if info. tail_result_is_ignored {
195- err. span_suggestion_verbose (
196- info. span . shrink_to_hi ( ) ,
197- "consider adding semicolon after the expression so its \
198- temporaries are dropped sooner, before the local variables \
199- declared by the block are dropped",
200- ";" . to_string ( ) ,
201- Applicability :: MaybeIncorrect ,
202- ) ;
196+ // #85581: If the first mutable borrow's scope contains
197+ // the second borrow, this suggestion isn't helpful.
198+ if !multiple_borrow_span
199+ . map ( |( old, new) | {
200+ old. to ( info. span . shrink_to_hi ( ) ) . contains ( new)
201+ } )
202+ . unwrap_or ( false )
203+ {
204+ err. span_suggestion_verbose (
205+ info. span . shrink_to_hi ( ) ,
206+ "consider adding semicolon after the expression so its \
207+ temporaries are dropped sooner, before the local variables \
208+ declared by the block are dropped",
209+ ";" . to_string ( ) ,
210+ Applicability :: MaybeIncorrect ,
211+ ) ;
212+ }
203213 } else {
204214 err. note (
205215 "the temporary is part of an expression at the end of a \
0 commit comments