miri
miri copied to clipboard
Stacked Borrows "is this argument" diagnostics go wrong for protected in-place function arguments
For example, in this test case, or in this one, it doesn't even point at something that is an argument.
Cc @saethlin
🤨 Is the problem here just that custom MIR doesn't have coherent spans? Is it supposed to? My instinct is that anyone using custom MIR has already opted out of usable diagnostics.
No, the spans are fine. The problem is that we're using protectors for things that are not function arguments. When a function argument is passed by-move, then we put a protector on the memory it comes from. We also put a protector on the return place. The diagnostics assume that only function arguments are protected and then things go downhill from there.
Reliably triggering these errors requires custom MIR, but with MIR optimizations it might be possible to also trigger those errors without nightly features. The initially created MIR has enough temporaries to make it impossible to trigger the error (as far as I know).
Ah I see! My brain grouped the diagnostic with the wrong span in the error. At first glance this seems pretty thorny to do a good diagnostic for. Hm.
Yeah it's definitely tricky, and also fairly low-priority since it cannot usually be encountered by users.