diff options
| author | Santiago Pastorino <spastorino@gmail.com> | 2019-12-11 10:39:24 -0300 |
|---|---|---|
| committer | Oliver Scherer <github35764891676564198441@oli-obk.de> | 2020-01-10 09:08:24 +0100 |
| commit | fd5aa32c352d9aa7e652a64320f89b7f3859858b (patch) | |
| tree | d8f3068aa129d83428f3268019dd5b9d7fe226cf /src/librustc | |
| parent | 9e70c4778371130ecc9ac5f1aff24000411eabd8 (diff) | |
| download | rust-fd5aa32c352d9aa7e652a64320f89b7f3859858b.tar.gz rust-fd5aa32c352d9aa7e652a64320f89b7f3859858b.zip | |
Remove Static from PlaceBase
Diffstat (limited to 'src/librustc')
| -rw-r--r-- | src/librustc/mir/mod.rs | 54 | ||||
| -rw-r--r-- | src/librustc/mir/tcx.rs | 5 | ||||
| -rw-r--r-- | src/librustc/mir/visit.rs | 15 | ||||
| -rw-r--r-- | src/librustc/ty/codec.rs | 2 |
4 files changed, 15 insertions, 61 deletions
diff --git a/src/librustc/mir/mod.rs b/src/librustc/mir/mod.rs index 42d24d9f332..05bb1d96980 100644 --- a/src/librustc/mir/mod.rs +++ b/src/librustc/mir/mod.rs @@ -1655,7 +1655,7 @@ impl Debug for Statement<'_> { /// changing or disturbing program state. #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, HashStable)] pub struct Place<'tcx> { - pub base: PlaceBase<'tcx>, + pub base: PlaceBase, /// projection out of a place (access a field, deref a pointer, etc) pub projection: &'tcx List<PlaceElem<'tcx>>, @@ -1664,34 +1664,9 @@ pub struct Place<'tcx> { impl<'tcx> rustc_serialize::UseSpecializedDecodable for Place<'tcx> {} #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable, HashStable)] -pub enum PlaceBase<'tcx> { +pub enum PlaceBase { /// local variable Local(Local), - - /// static or static mut variable - Static(Box<Static<'tcx>>), -} - -/// We store the normalized type to avoid requiring normalization when reading MIR -#[derive( - Clone, - Debug, - PartialEq, - Eq, - PartialOrd, - Ord, - Hash, - RustcEncodable, - RustcDecodable, - HashStable -)] -pub struct Static<'tcx> { - pub ty: Ty<'tcx>, - /// The `DefId` of the item this static was declared in. For promoted values, usually, this is - /// the same as the `DefId` of the `mir::Body` containing the `Place` this promoted appears in. - /// However, after inlining, that might no longer be the case as inlined `Place`s are copied - /// into the calling frame. - pub def_id: DefId, } #[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] @@ -1781,7 +1756,7 @@ rustc_index::newtype_index! { #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct PlaceRef<'a, 'tcx> { - pub base: &'a PlaceBase<'tcx>, + pub base: &'a PlaceBase, pub projection: &'a [PlaceElem<'tcx>], } @@ -1830,7 +1805,7 @@ impl From<Local> for Place<'_> { } } -impl From<Local> for PlaceBase<'_> { +impl From<Local> for PlaceBase { fn from(local: Local) -> Self { PlaceBase::Local(local) } @@ -1921,13 +1896,10 @@ impl Debug for Place<'_> { } } -impl Debug for PlaceBase<'_> { +impl Debug for PlaceBase { fn fmt(&self, fmt: &mut Formatter<'_>) -> fmt::Result { match *self { PlaceBase::Local(id) => write!(fmt, "{:?}", id), - PlaceBase::Static(box self::Static { ty, def_id }) => { - write!(fmt, "({}: {:?})", ty::tls::with(|tcx| tcx.def_path_str(def_id)), ty) - } } } } @@ -3000,18 +2972,16 @@ impl<'tcx> TypeFoldable<'tcx> for Place<'tcx> { } } -impl<'tcx> TypeFoldable<'tcx> for PlaceBase<'tcx> { +impl<'tcx> TypeFoldable<'tcx> for PlaceBase { fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self { match self { PlaceBase::Local(local) => PlaceBase::Local(local.fold_with(folder)), - PlaceBase::Static(static_) => PlaceBase::Static(static_.fold_with(folder)), } } fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool { match self { PlaceBase::Local(local) => local.visit_with(visitor), - PlaceBase::Static(static_) => (**static_).visit_with(visitor), } } } @@ -3027,18 +2997,6 @@ impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::List<PlaceElem<'tcx>> { } } -impl<'tcx> TypeFoldable<'tcx> for Static<'tcx> { - fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self { - Static { ty: self.ty.fold_with(folder), def_id: self.def_id } - } - - fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool { - let Static { ty, def_id: _ } = self; - - ty.visit_with(visitor) - } -} - impl<'tcx> TypeFoldable<'tcx> for Rvalue<'tcx> { fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self { use crate::mir::Rvalue::*; diff --git a/src/librustc/mir/tcx.rs b/src/librustc/mir/tcx.rs index 77f3ff47ff2..5adf6447d39 100644 --- a/src/librustc/mir/tcx.rs +++ b/src/librustc/mir/tcx.rs @@ -114,7 +114,7 @@ impl<'tcx> PlaceTy<'tcx> { impl<'tcx> Place<'tcx> { pub fn ty_from<D>( - base: &PlaceBase<'tcx>, + base: &PlaceBase, projection: &[PlaceElem<'tcx>], local_decls: &D, tcx: TyCtxt<'tcx>, @@ -135,14 +135,13 @@ impl<'tcx> Place<'tcx> { } } -impl<'tcx> PlaceBase<'tcx> { +impl<'tcx> PlaceBase { pub fn ty<D>(&self, local_decls: &D) -> PlaceTy<'tcx> where D: HasLocalDecls<'tcx>, { match self { PlaceBase::Local(index) => PlaceTy::from_ty(local_decls.local_decls()[*index].ty), - PlaceBase::Static(data) => PlaceTy::from_ty(data.ty), } } } diff --git a/src/librustc/mir/visit.rs b/src/librustc/mir/visit.rs index 3924a1aa47e..a31931c8a99 100644 --- a/src/librustc/mir/visit.rs +++ b/src/librustc/mir/visit.rs @@ -164,7 +164,7 @@ macro_rules! make_mir_visitor { } fn visit_place_base(&mut self, - base: & $($mutability)? PlaceBase<'tcx>, + base: & $($mutability)? PlaceBase, context: PlaceContext, location: Location) { self.super_place_base(base, context, location); @@ -705,16 +705,13 @@ macro_rules! make_mir_visitor { } fn super_place_base(&mut self, - place_base: & $($mutability)? PlaceBase<'tcx>, + place_base: & $($mutability)? PlaceBase, context: PlaceContext, location: Location) { match place_base { PlaceBase::Local(local) => { self.visit_local(local, context, location); } - PlaceBase::Static(box Static { ty, def_id: _ }) => { - self.visit_ty(& $($mutability)? *ty, TyContext::Location(location)); - } } } @@ -889,7 +886,7 @@ macro_rules! visit_place_fns { () => ( fn visit_projection( &mut self, - base: &PlaceBase<'tcx>, + base: &PlaceBase, projection: &[PlaceElem<'tcx>], context: PlaceContext, location: Location, @@ -899,7 +896,7 @@ macro_rules! visit_place_fns { fn visit_projection_elem( &mut self, - base: &PlaceBase<'tcx>, + base: &PlaceBase, proj_base: &[PlaceElem<'tcx>], elem: &PlaceElem<'tcx>, context: PlaceContext, @@ -934,7 +931,7 @@ macro_rules! visit_place_fns { fn super_projection( &mut self, - base: &PlaceBase<'tcx>, + base: &PlaceBase, projection: &[PlaceElem<'tcx>], context: PlaceContext, location: Location, @@ -948,7 +945,7 @@ macro_rules! visit_place_fns { fn super_projection_elem( &mut self, - _base: &PlaceBase<'tcx>, + _base: &PlaceBase, _proj_base: &[PlaceElem<'tcx>], elem: &PlaceElem<'tcx>, _context: PlaceContext, diff --git a/src/librustc/ty/codec.rs b/src/librustc/ty/codec.rs index 9b2714082f1..c691cb44f01 100644 --- a/src/librustc/ty/codec.rs +++ b/src/librustc/ty/codec.rs @@ -226,7 +226,7 @@ pub fn decode_place<D>(decoder: &mut D) -> Result<mir::Place<'tcx>, D::Error> where D: TyDecoder<'tcx>, { - let base: mir::PlaceBase<'tcx> = Decodable::decode(decoder)?; + let base: mir::PlaceBase = Decodable::decode(decoder)?; let len = decoder.read_usize()?; let projection: &'tcx List<mir::PlaceElem<'tcx>> = decoder.tcx().mk_place_elems((0..len).map(|_| Decodable::decode(decoder)))?; |
