Move has_metadata back to context.rs

This commit is contained in:
Maik Klein 2017-11-23 15:05:55 +01:00 committed by Ariel Ben-Yehuda
parent 6e94a7a91e
commit 282b231af2
2 changed files with 11 additions and 15 deletions

View File

@ -2040,20 +2040,6 @@ impl<'tcx> TyS<'tcx> {
} }
} }
} }
pub fn has_metadata<'a>(&'tcx self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> bool {
use syntax_pos::DUMMY_SP;
if self.is_sized(tcx, ty::ParamEnv::empty(traits::Reveal::All), DUMMY_SP) {
return false;
}
let tail = tcx.struct_tail(self);
match tail.sty {
ty::TyForeign(..) => false,
ty::TyStr | ty::TySlice(..) | ty::TyDynamic(..) => true,
_ => bug!("unexpected unsized tail: {:?}", tail.sty),
}
}
} }
#[derive(Copy, Clone, Debug, PartialEq, Eq)] #[derive(Copy, Clone, Debug, PartialEq, Eq)]

View File

@ -324,7 +324,17 @@ impl<'b, 'tcx> SharedCrateContext<'b, 'tcx> {
} }
pub fn type_has_metadata(&self, ty: Ty<'tcx>) -> bool { pub fn type_has_metadata(&self, ty: Ty<'tcx>) -> bool {
ty.has_metadata(self.tcx) use syntax_pos::DUMMY_SP;
if ty.is_sized(self.tcx, ty::ParamEnv::empty(traits::Reveal::All), DUMMY_SP) {
return false;
}
let tail = self.tcx.struct_tail(ty);
match tail.sty {
ty::TyForeign(..) => false,
ty::TyStr | ty::TySlice(..) | ty::TyDynamic(..) => true,
_ => bug!("unexpected unsized tail: {:?}", tail.sty),
}
} }
pub fn tcx(&self) -> TyCtxt<'b, 'tcx, 'tcx> { pub fn tcx(&self) -> TyCtxt<'b, 'tcx, 'tcx> {