Skip to content

MIR always initializes variables with them in (debuginfo) scope. #32949

Closed
@eddyb

Description

@eddyb

That is, given let x = expr;, MIR will produce the same code as let x; x = expr; (modulo borrows).
When breaking inside expr in a debugger, x will be in scope, uninitialized.
It can be really annoying when dealing with shadowing or arguments.
For example, if you break on the call in let x = ...; let x = f(x); and try to print x, you will get the second x, which is uninitialized at that point.

cc @michaelwoerister

Metadata

Metadata

Labels

A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlA-debuginfoArea: Debugging information in compiled programs (DWARF, PDB, etc.)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions