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
|
@ -562,6 +562,12 @@ impl<'a, 'tcx> Decodable<DecodeContext<'a, 'tcx>> for Span {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Decodable<DecodeContext<'a, 'tcx>> for &'tcx [mir::abstract_const::Node<'tcx>] {
|
||||
fn decode(d: &mut DecodeContext<'a, 'tcx>) -> Result<Self, String> {
|
||||
ty::codec::RefDecodable::decode(d)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Decodable<DecodeContext<'a, 'tcx>> for &'tcx [(ty::Predicate<'tcx>, Span)] {
|
||||
fn decode(d: &mut DecodeContext<'a, 'tcx>) -> Result<Self, String> {
|
||||
ty::codec::RefDecodable::decode(d)
|
||||
|
@ -1191,6 +1197,19 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
|
|||
.decode((self, tcx))
|
||||
}
|
||||
|
||||
fn get_mir_abstract_const(
|
||||
&self,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
id: DefIndex,
|
||||
) -> Option<&'tcx [mir::abstract_const::Node<'tcx>]> {
|
||||
self.root
|
||||
.tables
|
||||
.mir_abstract_consts
|
||||
.get(self, id)
|
||||
.filter(|_| !self.is_proc_macro(id))
|
||||
.map_or(None, |v| Some(v.decode((self, tcx))))
|
||||
}
|
||||
|
||||
fn get_unused_generic_params(&self, id: DefIndex) -> FiniteBitSet<u32> {
|
||||
self.root
|
||||
.tables
|
||||
|
|
|
@ -112,6 +112,7 @@ provide! { <'tcx> tcx, def_id, other, cdata,
|
|||
}
|
||||
optimized_mir => { tcx.arena.alloc(cdata.get_optimized_mir(tcx, def_id.index)) }
|
||||
promoted_mir => { tcx.arena.alloc(cdata.get_promoted_mir(tcx, def_id.index)) }
|
||||
mir_abstract_const => { cdata.get_mir_abstract_const(tcx, def_id.index) }
|
||||
unused_generic_params => { cdata.get_unused_generic_params(def_id.index) }
|
||||
mir_const_qualif => { cdata.mir_const_qualif(def_id.index) }
|
||||
fn_sig => { cdata.fn_sig(def_id.index, tcx) }
|
||||
|
|
|
@ -321,6 +321,12 @@ impl<'a, 'tcx> TyEncoder<'tcx> for EncodeContext<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Encodable<EncodeContext<'a, 'tcx>> for &'tcx [mir::abstract_const::Node<'tcx>] {
|
||||
fn encode(&self, s: &mut EncodeContext<'a, 'tcx>) -> opaque::EncodeResult {
|
||||
(**self).encode(s)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Encodable<EncodeContext<'a, 'tcx>> for &'tcx [(ty::Predicate<'tcx>, Span)] {
|
||||
fn encode(&self, s: &mut EncodeContext<'a, 'tcx>) -> opaque::EncodeResult {
|
||||
(**self).encode(s)
|
||||
|
@ -1109,6 +1115,11 @@ impl EncodeContext<'a, 'tcx> {
|
|||
if !unused.is_empty() {
|
||||
record!(self.tables.unused_generic_params[def_id.to_def_id()] <- unused);
|
||||
}
|
||||
|
||||
let abstract_const = self.tcx.mir_abstract_const(def_id);
|
||||
if let Some(abstract_const) = abstract_const {
|
||||
record!(self.tables.mir_abstract_consts[def_id.to_def_id()] <- abstract_const);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -284,6 +284,7 @@ define_tables! {
|
|||
super_predicates: Table<DefIndex, Lazy!(ty::GenericPredicates<'tcx>)>,
|
||||
mir: Table<DefIndex, Lazy!(mir::Body<'tcx>)>,
|
||||
promoted_mir: Table<DefIndex, Lazy!(IndexVec<mir::Promoted, mir::Body<'tcx>>)>,
|
||||
mir_abstract_consts: Table<DefIndex, Lazy!(&'tcx [mir::abstract_const::Node<'tcx>])>,
|
||||
unused_generic_params: Table<DefIndex, Lazy<FiniteBitSet<u32>>>,
|
||||
// `def_keys` and `def_path_hashes` represent a lazy version of a
|
||||
// `DefPathTable`. This allows us to avoid deserializing an entire
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue