]> git.lizzy.rs Git - rust.git/commit
Auto merge of #45380 - dotdash:arg_copies, r=arielb1
authorbors <bors@rust-lang.org>
Thu, 26 Oct 2017 14:14:15 +0000 (14:14 +0000)
committerbors <bors@rust-lang.org>
Thu, 26 Oct 2017 14:14:15 +0000 (14:14 +0000)
commitb0b80f8c2299cccd7a4f22ee3cc1a2ca823eaa31
tree011c1b2fa731579f0a7079e3415f1e08d35c06bf
parente0febe71449008fd35ccc762b0a42d106aa8e4f7
parent8ad7c284d793250edffe0e85f6cc898585496283
Auto merge of #45380 - dotdash:arg_copies, r=arielb1

Avoid unnecessary copies of arguments that are simple bindings

Initially MIR differentiated between arguments and locals, which
introduced a need to add extra copies assigning the argument to a
local, even for simple bindings. This differentiation no longer exists,
but we're still creating those copies, bloating the MIR and LLVM IR we
emit.

Additionally, the current approach means that we create debug info for
both the incoming argument (marking it as an argument), and then
immediately shadow it a local that goes by the same name. This can be
confusing when using e.g. "info args" in gdb, or when e.g. a debugger
with a GUI displays the function arguments separately from the local
variables, especially when the binding is mutable, because the argument
doesn't change, while the local variable does.