diff options
| author | Paul Daniel Faria <Nashenas88@users.noreply.github.com> | 2019-11-20 11:53:34 -0500 |
|---|---|---|
| committer | Paul Daniel Faria <Nashenas88@users.noreply.github.com> | 2019-12-02 08:41:30 -0500 |
| commit | 598797c6e76c041b449a838d09f1c829b0adc437 (patch) | |
| tree | 2288aabf1f439e6c4a1c4add4df4abec485f2b3d | |
| parent | c6354e9839cefbaf80d3a26304bc3e4adacfabb0 (diff) | |
Remove unchecked inline attribute, remove unused functions, make chache mod private again
| -rw-r--r-- | src/librustc/mir/cache.rs | 72 | ||||
| -rw-r--r-- | src/librustc/mir/mod.rs | 2 |
2 files changed, 26 insertions, 48 deletions
diff --git a/src/librustc/mir/cache.rs b/src/librustc/mir/cache.rs index fcab65cdfdd..30f383ff331 100644 --- a/src/librustc/mir/cache.rs +++ b/src/librustc/mir/cache.rs @@ -32,45 +32,6 @@ impl<'a> HashStable<StableHashingContext<'a>> for Cache { } } -macro_rules! get_predecessors { - (mut $self:ident, $block:expr, $body:expr) => { - $self.predecessors_for($block, $body) - }; - ($self:ident, $block:expr, $body:expr) => { - $self.unwrap_predecessors_for($block) - }; -} - -macro_rules! impl_predecessor_locations { - ( ( $($pub:ident)? ) $name:ident $($mutability:ident)?) => { - $($pub)? fn $name<'a>( - &'a $($mutability)? self, - loc: Location, - body: &'a Body<'a> - ) -> impl Iterator<Item = Location> + 'a { - let if_zero_locations = if loc.statement_index == 0 { - let predecessor_blocks = get_predecessors!($($mutability)? self, loc.block, body); - let num_predecessor_blocks = predecessor_blocks.len(); - Some( - (0..num_predecessor_blocks) - .map(move |i| predecessor_blocks[i]) - .map(move |bb| body.terminator_loc(bb)), - ) - } else { - None - }; - - let if_not_zero_locations = if loc.statement_index == 0 { - None - } else { - Some(Location { block: loc.block, statement_index: loc.statement_index - 1 }) - }; - - if_zero_locations.into_iter().flatten().chain(if_not_zero_locations) - } - }; -} - impl Cache { pub fn new() -> Self { Self { @@ -104,17 +65,35 @@ impl Cache { self.predecessors.as_ref().unwrap() } - fn predecessors_for(&mut self, bb: BasicBlock, body: &Body<'_>) -> &[BasicBlock] { - &self.predecessors(body)[bb] - } - fn unwrap_predecessors_for(&self, bb: BasicBlock) -> &[BasicBlock] { &self.predecessors.as_ref().unwrap()[bb] } - impl_predecessor_locations!((pub) predecessor_locations mut); - - impl_predecessor_locations!(() unwrap_predecessor_locations); + fn unwrap_predecessor_locations<'a>( + &'a self, + loc: Location, + body: &'a Body<'a> + ) -> impl Iterator<Item = Location> + 'a { + let if_zero_locations = if loc.statement_index == 0 { + let predecessor_blocks = self.unwrap_predecessors_for(loc.block); + let num_predecessor_blocks = predecessor_blocks.len(); + Some( + (0..num_predecessor_blocks) + .map(move |i| predecessor_blocks[i]) + .map(move |bb| body.terminator_loc(bb)), + ) + } else { + None + }; + + let if_not_zero_locations = if loc.statement_index == 0 { + None + } else { + Some(Location { block: loc.block, statement_index: loc.statement_index - 1 }) + }; + + if_zero_locations.into_iter().flatten().chain(if_not_zero_locations) + } pub fn basic_blocks_mut<'a, 'tcx>( &mut self, @@ -125,7 +104,6 @@ impl Cache { &mut body.basic_blocks } - #[inline] pub fn basic_blocks_and_local_decls_mut<'a, 'tcx>( &mut self, body: &'a mut Body<'tcx> diff --git a/src/librustc/mir/mod.rs b/src/librustc/mir/mod.rs index cc25ad0e225..df5d4997e08 100644 --- a/src/librustc/mir/mod.rs +++ b/src/librustc/mir/mod.rs @@ -41,7 +41,7 @@ pub use crate::mir::interpret::AssertMessage; pub use crate::mir::cache::{BodyCache, ReadOnlyBodyCache}; pub use crate::read_only; -pub mod cache; +mod cache; pub mod interpret; pub mod mono; pub mod tcx; |
