pub struct LocalDefId(DefIndex);
impl LocalDefId {
-
#[inline]
pub fn from_def_id(def_id: DefId) -> LocalDefId {
assert!(def_id.is_local());
use rustc::middle::exported_symbols::{ExportedSymbol, SymbolExportLevel};
use rustc::hir::def::{self, Def, CtorKind};
use rustc::hir::def_id::{CrateNum, DefId, DefIndex,
- CRATE_DEF_INDEX, LOCAL_CRATE};
+ CRATE_DEF_INDEX, LOCAL_CRATE, LocalDefId};
use rustc::ich::Fingerprint;
use rustc::middle::lang_items;
use rustc::mir::{self, interpret};
}
}
+impl<'a, 'tcx> SpecializedDecoder<LocalDefId> for DecodeContext<'a, 'tcx> {
+ #[inline]
+ fn specialized_decode(&mut self) -> Result<LocalDefId, Self::Error> {
+ self.specialized_decode().map(|i| LocalDefId::from_def_id(i))
+ }
+}
+
impl<'a, 'tcx> SpecializedDecoder<interpret::AllocId> for DecodeContext<'a, 'tcx> {
fn specialized_decode(&mut self) -> Result<interpret::AllocId, Self::Error> {
const MAX1: usize = usize::max_value() - 1;
use rustc::middle::cstore::{LinkMeta, LinkagePreference, NativeLibrary,
EncodedMetadata};
use rustc::hir::def::CtorKind;
-use rustc::hir::def_id::{CrateNum, CRATE_DEF_INDEX, DefIndex, DefId, LOCAL_CRATE};
+use rustc::hir::def_id::{CrateNum, CRATE_DEF_INDEX, DefIndex, DefId, LocalDefId, LOCAL_CRATE};
use rustc::hir::map::definitions::DefPathTable;
use rustc::ich::Fingerprint;
use rustc::middle::dependency_format::Linkage;
}
}
+impl<'a, 'tcx> SpecializedEncoder<LocalDefId> for EncodeContext<'a, 'tcx> {
+ #[inline]
+ fn specialized_encode(&mut self, def_id: &LocalDefId) -> Result<(), Self::Error> {
+ self.specialized_encode(&def_id.to_def_id())
+ }
+}
+
impl<'a, 'tcx> SpecializedEncoder<Ty<'tcx>> for EncodeContext<'a, 'tcx> {
fn specialized_encode(&mut self, ty: &Ty<'tcx>) -> Result<(), Self::Error> {
ty_codec::encode_with_shorthand(self, ty, |ecx| &mut ecx.type_shorthands)
use std::collections::VecDeque;
use std::fmt;
-use rustc_const_math::ConstInt;
use std::default::Default;
use std::{mem, slice, vec};
use std::iter::{FromIterator, once};
ty: cx.tcx.types.usize
})
});
- let n = if let ConstVal::Integral(ConstInt::Usize(n)) = n.val {
- n.to_string()
- } else if let ConstVal::Unevaluated(def_id, _) = n.val {
+ let n = if let ConstVal::Unevaluated(def_id, _) = n.val {
if let Some(node_id) = cx.tcx.hir.as_local_node_id(def_id) {
print_const_expr(cx, cx.tcx.hir.body_owned_by(node_id))
} else {
n = new_n;
}
};
- let n = if let ConstVal::Integral(ConstInt::Usize(n)) = n.val {
- n.to_string()
- } else if let ConstVal::Unevaluated(def_id, _) = n.val {
+ let n = if let ConstVal::Unevaluated(def_id, _) = n.val {
if let Some(node_id) = cx.tcx.hir.as_local_node_id(def_id) {
print_const_expr(cx, cx.tcx.hir.body_owned_by(node_id))
} else {