Skip to content

Commit b19d5c0

Browse files
Name return place in debuginfo if it is a user variable
1 parent c38283d commit b19d5c0

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/librustc_codegen_ssa/mir/debuginfo.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
115115
let full_debug_info = bx.sess().opts.debuginfo == DebugInfo::Full;
116116

117117
// FIXME(eddyb) maybe name the return place as `_0` or `return`?
118-
if local == mir::RETURN_PLACE {
118+
if local == mir::RETURN_PLACE && !self.mir.local_decls[mir::RETURN_PLACE].is_user_variable()
119+
{
119120
return;
120121
}
121122

src/librustc_mir/transform/nrvo.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use rustc_hir::Mutability;
12
use rustc_index::bit_set::HybridBitSet;
23
use rustc_middle::mir::visit::{MutVisitor, PlaceContext, Visitor};
34
use rustc_middle::mir::{self, BasicBlock, Local, Location};
@@ -61,6 +62,9 @@ impl<'tcx> MirPass<'tcx> for RenameReturnPlace {
6162
body.local_decls.pick2_mut(returned_local, mir::RETURN_PLACE);
6263
debug_assert_eq!(ret_decl.ty, renamed_decl.ty);
6364
ret_decl.clone_from(renamed_decl);
65+
66+
// The return place is always mutable.
67+
ret_decl.mutability = Mutability::Mut;
6468
}
6569
}
6670

0 commit comments

Comments
 (0)