#![allow(non_camel_case_types)]
-use rustc_front::hir;
+use rustc::hir;
-use middle::def_id::{DefId, DefIndex};
+use rustc::hir::def_id::{DefId, DefIndex};
use middle::region;
-use middle::subst;
-use middle::subst::VecPerParamSpace;
-use middle::ty::{self, ToPredicate, Ty, TypeFoldable};
+use rustc::ty::subst;
+use rustc::ty::subst::VecPerParamSpace;
+use rustc::ty::{self, ToPredicate, Ty, TyCtxt, TypeFoldable};
use rbml;
use rbml::leb128;
data: &'a [u8],
krate: ast::CrateNum,
pos: usize,
- tcx: &'a ty::ctxt<'tcx>,
+ tcx: &'a TyCtxt<'tcx>,
conv_def_id: DefIdConvert<'a>,
}
impl<'a,'tcx> TyDecoder<'a,'tcx> {
- pub fn with_doc(tcx: &'a ty::ctxt<'tcx>,
+ pub fn with_doc(tcx: &'a TyCtxt<'tcx>,
crate_num: ast::CrateNum,
doc: rbml::Doc<'a>,
conv: DefIdConvert<'a>)
pub fn new(data: &'a [u8],
crate_num: ast::CrateNum,
pos: usize,
- tcx: &'a ty::ctxt<'tcx>,
+ tcx: &'a TyCtxt<'tcx>,
conv: DefIdConvert<'a>)
-> TyDecoder<'a, 'tcx> {
TyDecoder {
}
pub fn parse_substs(&mut self) -> subst::Substs<'tcx> {
- let regions = self.parse_region_substs();
+ let regions = self.parse_vec_per_param_space(|this| this.parse_region());
let types = self.parse_vec_per_param_space(|this| this.parse_ty());
subst::Substs { types: types, regions: regions }
}
- fn parse_region_substs(&mut self) -> subst::RegionSubsts {
- match self.next() {
- 'e' => subst::ErasedRegions,
- 'n' => {
- subst::NonerasedRegions(
- self.parse_vec_per_param_space(|this| this.parse_region()))
- }
- _ => panic!("parse_bound_region: bad input")
- }
- }
-
fn parse_bound_region(&mut self) -> ty::BoundRegion {
match self.next() {
'a' => {
ty::BrFresh(id)
}
'e' => ty::BrEnv,
- _ => panic!("parse_bound_region: bad input")
+ _ => bug!("parse_bound_region: bad input")
}
}
'e' => {
ty::ReStatic
}
- _ => panic!("parse_region: bad input")
+ _ => bug!("parse_region: bad input")
}
}
};
region::CodeExtentData::Remainder(block_remainder)
}
- _ => panic!("parse_scope: bad input")
+ _ => bug!("parse_scope: bad input")
})
}
match self.next() {
'n' => None,
's' => Some(f(self)),
- _ => panic!("parse_opt: bad input")
+ _ => bug!("parse_opt: bad input")
}
}
'D' => return tcx.types.i64,
'f' => return tcx.types.f32,
'F' => return tcx.types.f64,
- _ => panic!("parse_ty: bad numeric type")
+ _ => bug!("parse_ty: bad numeric type")
}
}
'c' => return tcx.types.char,
}
'F' => {
let def_id = self.parse_def();
- return tcx.mk_fn(Some(def_id), tcx.mk_bare_fn(self.parse_bare_fn_ty()));
+ let substs = self.tcx.mk_substs(self.parse_substs());
+ return tcx.mk_fn_def(def_id, substs, self.parse_bare_fn_ty());
}
'G' => {
- return tcx.mk_fn(None, tcx.mk_bare_fn(self.parse_bare_fn_ty()));
+ return tcx.mk_fn_ptr(self.parse_bare_fn_ty());
}
'#' => {
// This is a hacky little caching scheme. The idea is that if we encode
'e' => {
return tcx.types.err;
}
- c => { panic!("unexpected char in type string: {}", c);}
+ c => { bug!("unexpected char in type string: {}", c);}
}
}
let variadic = match self.next() {
'V' => true,
'N' => false,
- r => panic!(format!("bad variadic: {}", r)),
+ r => bug!("bad variadic: {}", r),
};
let output = match self.peek() {
'z' => {
assert_eq!(self.next(), '|');
ty::Predicate::ObjectSafe(def_id)
}
- c => panic!("Encountered invalid character in metadata: {}", c)
+ c => bug!("Encountered invalid character in metadata: {}", c)
}
}
'R' => bounds.push(self.parse_region()),
'.' => { break; }
c => {
- panic!("parse_region_param_def: bad bounds ('{}')", c)
+ bug!("parse_region_param_def: bad bounds ('{}')", c)
}
}
}
let region = self.parse_region();
ty::ObjectLifetimeDefault::Specific(region)
}
- _ => panic!("parse_object_lifetime_default: bad input")
+ _ => bug!("parse_object_lifetime_default: bad input")
}
}
}
'.' => { break; }
c => {
- panic!("parse_bounds: bad bounds ('{}')", c)
+ bug!("parse_bounds: bad bounds ('{}')", c)
}
}
}
return builtin_bounds;
}
c => {
- panic!("parse_bounds: bad builtin bounds ('{}')", c)
+ bug!("parse_bounds: bad builtin bounds ('{}')", c)
}
}
}
while colon_idx < len && buf[colon_idx] != ':' as u8 { colon_idx += 1; }
if colon_idx == len {
error!("didn't find ':' when parsing def id");
- panic!();
+ bug!();
}
let crate_part = &buf[0..colon_idx];
s.parse::<usize>().ok()
}) {
Some(cn) => cn as ast::CrateNum,
- None => panic!("internal error: parse_defid: crate number expected, found {:?}",
+ None => bug!("internal error: parse_defid: crate number expected, found {:?}",
crate_part)
};
let def_num = match str::from_utf8(def_part).ok().and_then(|s| {
s.parse::<usize>().ok()
}) {
Some(dn) => dn,
- None => panic!("internal error: parse_defid: id expected, found {:?}",
+ None => bug!("internal error: parse_defid: id expected, found {:?}",
def_part)
};
let index = DefIndex::new(def_num);
match c {
'u' => hir::Unsafety::Unsafe,
'n' => hir::Unsafety::Normal,
- _ => panic!("parse_unsafety: bad unsafety {}", c)
+ _ => bug!("parse_unsafety: bad unsafety {}", c)
}
}