const-eval: perform validation before interning #122398
Labels
A-const-eval
Area: Constant evaluation, covers all const contexts (static, const fn, ...)
WG-const-eval
Working group: Const evaluation
Currently, after const-eval is done, we first intern the result into
tcx
and then validate that it matches the type. This is unfortunate because interning can go wrong (when there is a mutable pointer somewhere we did not expect), and in most cases that issue would also be detected by validation -- and validation shows a much nicer error, indicating where in the value the issue arises.However, interning currently also does the job of adjusting the allocation's mutability to its final value. This has to be done before validation. So fixing this would end up with a final order of operations like:
All that said, I'm not entirely sure whether this is worth it since triggering the interning error should be pretty rare. Our static const checks should largely prevent them.
Cc @rust-lang/wg-const-eval
The text was updated successfully, but these errors were encountered: