Description
In the porting to translatable diagnostics, the error messages from const validation where set up in a way that causes tons of code and text duplication:
rust/compiler/rustc_const_eval/src/errors.rs
Lines 613 to 624 in 9857952
rust/compiler/rustc_const_eval/messages.ftl
Lines 409 to 414 in 9857952
We shouldn't have one variant per pointer kind here, we should just tell the diagnostic about the pointer kind so that all the other text does only have to be written once. For those "dangling" messages we also should just have a single template, that only splits cases for the tail (explaining why this particular pointer is dangling). Currently we get a huge combinatorial explosion of all the things that appear in these messages, making maintenance of this code a pain.
I was about to introduce the information of whether the reference is shared or mutable, but the current system makes that way too complicated, so I'll hold off on that for now.