support const_evaluatable_checked across crate boundaries
This commit is contained in:
parent
82ebbd7d6b
commit
30ff1ef3d0
14 changed files with 157 additions and 2 deletions
|
@ -11,7 +11,7 @@ rustc_index::newtype_index! {
|
|||
}
|
||||
|
||||
/// A node of an `AbstractConst`.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, HashStable)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, HashStable, TyEncodable, TyDecodable)]
|
||||
pub enum Node<'tcx> {
|
||||
Leaf(&'tcx ty::Const<'tcx>),
|
||||
Binop(mir::BinOp, NodeId, NodeId),
|
||||
|
|
|
@ -357,6 +357,26 @@ impl<'tcx, D: TyDecoder<'tcx>> RefDecodable<'tcx, D> for [(ty::Predicate<'tcx>,
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx, D: TyDecoder<'tcx>> RefDecodable<'tcx, D> for [mir::abstract_const::Node<'tcx>] {
|
||||
fn decode(decoder: &mut D) -> Result<&'tcx Self, D::Error> {
|
||||
Ok(decoder.tcx().arena.alloc_from_iter(
|
||||
(0..decoder.read_usize()?)
|
||||
.map(|_| Decodable::decode(decoder))
|
||||
.collect::<Result<Vec<_>, _>>()?,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx, D: TyDecoder<'tcx>> RefDecodable<'tcx, D> for [mir::abstract_const::NodeId] {
|
||||
fn decode(decoder: &mut D) -> Result<&'tcx Self, D::Error> {
|
||||
Ok(decoder.tcx().arena.alloc_from_iter(
|
||||
(0..decoder.read_usize()?)
|
||||
.map(|_| Decodable::decode(decoder))
|
||||
.collect::<Result<Vec<_>, _>>()?,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
impl_decodable_via_ref! {
|
||||
&'tcx ty::TypeckResults<'tcx>,
|
||||
&'tcx ty::List<Ty<'tcx>>,
|
||||
|
|
|
@ -760,6 +760,12 @@ impl<'a, 'tcx> Decodable<CacheDecoder<'a, 'tcx>>
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Decodable<CacheDecoder<'a, 'tcx>> for &'tcx [mir::abstract_const::Node<'tcx>] {
|
||||
fn decode(d: &mut CacheDecoder<'a, 'tcx>) -> Result<Self, String> {
|
||||
RefDecodable::decode(d)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Decodable<CacheDecoder<'a, 'tcx>> for &'tcx [(ty::Predicate<'tcx>, Span)] {
|
||||
fn decode(d: &mut CacheDecoder<'a, 'tcx>) -> Result<Self, String> {
|
||||
RefDecodable::decode(d)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue