diff options
| author | bors <bors@rust-lang.org> | 2025-06-16 00:39:47 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2025-06-16 00:39:47 +0000 |
| commit | e314b97ee54091b6bcf33db4770c93d82fded8bc (patch) | |
| tree | 217c635e957d5248d5c59abcd9bb481454ae3e53 /compiler/rustc_borrowck | |
| parent | f768dc01da9a681716724418ccf64ce55bd396c5 (diff) | |
| parent | 07048643ddcb2245ba6251fc65403f308e6c38c4 (diff) | |
| download | rust-e314b97ee54091b6bcf33db4770c93d82fded8bc.tar.gz rust-e314b97ee54091b6bcf33db4770c93d82fded8bc.zip | |
Auto merge of #142550 - fmease:rollup-fteyzcv, r=fmease
Rollup of 10 pull requests Successful merges: - rust-lang/rust#133952 (Remove wasm legacy abi) - rust-lang/rust#134661 (Reduce precedence of expressions that have an outer attr) - rust-lang/rust#141769 (Move metadata object generation for dylibs to the linker code ) - rust-lang/rust#141937 (Report never type lints in dependencies) - rust-lang/rust#142347 (Async drop - fix for StorageLive/StorageDead codegen for pinned future) - rust-lang/rust#142389 (Apply ABI attributes on return types in `rustc_codegen_cranelift`) - rust-lang/rust#142470 (Add some missing mailmap entries) - rust-lang/rust#142481 (Add `f16` inline asm support for LoongArch) - rust-lang/rust#142499 (Remove check run bootstrap) - rust-lang/rust#142543 (Suggest adding semicolon in user code rather than macro impl details) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_borrowck')
| -rw-r--r-- | compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs b/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs index a845431faca..c4b0f503664 100644 --- a/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs +++ b/compiler/rustc_borrowck/src/diagnostics/explain_borrow.rs @@ -342,6 +342,10 @@ impl<'tcx> BorrowExplanation<'tcx> { } } } else if let LocalInfo::BlockTailTemp(info) = local_decl.local_info() { + let sp = info + .span + .find_ancestor_in_same_ctxt(local_decl.source_info.span) + .unwrap_or(info.span); if info.tail_result_is_ignored { // #85581: If the first mutable borrow's scope contains // the second borrow, this suggestion isn't helpful. @@ -349,7 +353,7 @@ impl<'tcx> BorrowExplanation<'tcx> { old.to(info.span.shrink_to_hi()).contains(new) }) { err.span_suggestion_verbose( - info.span.shrink_to_hi(), + sp.shrink_to_hi(), "consider adding semicolon after the expression so its \ temporaries are dropped sooner, before the local variables \ declared by the block are dropped", @@ -368,8 +372,8 @@ impl<'tcx> BorrowExplanation<'tcx> { local variable `x` and then make `x` be the expression at the \ end of the block", vec![ - (info.span.shrink_to_lo(), "let x = ".to_string()), - (info.span.shrink_to_hi(), "; x".to_string()), + (sp.shrink_to_lo(), "let x = ".to_string()), + (sp.shrink_to_hi(), "; x".to_string()), ], Applicability::MaybeIncorrect, ); |
