mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-31 00:53:48 +00:00
Explain and simplify valtree -> mir-const fallback
This commit is contained in:
parent
9cf7810078
commit
c4d5dded57
@ -519,16 +519,18 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
|
||||
};
|
||||
|
||||
let cid = GlobalId { instance, promoted: None };
|
||||
// Prefer
|
||||
// Prefer valtrees over opaque constants.
|
||||
let const_value = self
|
||||
.tcx
|
||||
.const_eval_global_id_for_typeck(param_env_reveal_all, cid, Some(span))
|
||||
.and_then(|val| match val {
|
||||
Some(valtree) => Ok(mir::ConstantKind::Ty(self.tcx.mk_const(valtree, ty))),
|
||||
None => self
|
||||
.tcx
|
||||
.const_eval_global_id(param_env_reveal_all, cid, Some(span))
|
||||
.map(|lit| mir::ConstantKind::Val(lit, ty)),
|
||||
.map(|val| match val {
|
||||
Some(valtree) => mir::ConstantKind::Ty(self.tcx.mk_const(valtree, ty)),
|
||||
None => mir::ConstantKind::Val(
|
||||
self.tcx
|
||||
.const_eval_global_id(param_env_reveal_all, cid, Some(span))
|
||||
.expect("const_eval_global_id_for_typeck should have already failed"),
|
||||
ty,
|
||||
),
|
||||
});
|
||||
|
||||
match const_value {
|
||||
|
Loading…
Reference in New Issue
Block a user