rust/src/librustc_mir
Dylan DPC 71bf986f4b
Rollup merge of #71655 - RalfJung:const-pattern-soundness, r=oli-obk
Miri: better document and fix dynamic const pattern soundness checks

https://github.com/rust-lang/const-eval/issues/42 got me thinking about soundness for consts being used in patterns, and I found a hole in our existing dynamic checks: a const referring to a mutable static *in a different crate* was not caught. This PR fixes that. It also adds some comments that explain which invariants are crucial for soundness of const-patterns.

Curiously, trying to weaponize this soundness hole failed: pattern matching compilation ICEd when encountering the cross-crate static, saying "expected allocation ID alloc0 to point to memory". I don't know why that would happen, statics *should* be entirely normal memory for pattern matching to access.

r? @oli-obk
Cc @rust-lang/wg-const-eval
2020-04-30 14:07:55 +02:00
..
2020-04-28 23:54:47 +02:00