Support pretty printing of invalid constants
Make it possible to pretty print invalid constants by introducing a fallible variant of `destructure_const` and falling back to debug formatting when it fails.
This commit is contained in:
parent
bfb2856f27
commit
92d20c4aad
7 changed files with 117 additions and 29 deletions
|
@ -924,10 +924,12 @@ rustc_queries! {
|
|||
}
|
||||
|
||||
/// Destructure a constant ADT or array into its variant index and its
|
||||
/// field values.
|
||||
query destructure_const(
|
||||
/// field values or return `None` if constant is invalid.
|
||||
///
|
||||
/// Use infallible `TyCtxt::destructure_const` when you know that constant is valid.
|
||||
query try_destructure_const(
|
||||
key: ty::ParamEnvAnd<'tcx, ty::Const<'tcx>>
|
||||
) -> mir::DestructuredConst<'tcx> {
|
||||
) -> Option<mir::DestructuredConst<'tcx>> {
|
||||
desc { "destructure constant" }
|
||||
remap_env_constness
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue