Fix rustc panic on second compile_input
auto merge of #19392 : murarth/rust/rustc-compile-twice, r=nick29581

Closes #19371