Skip to content

Commit

Permalink
Factor mir::[Mut]Visitor implementations into a common macro.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelwoerister committed Jan 7, 2016
1 parent 91b27ec commit 8f51188
Show file tree
Hide file tree
Showing 2 changed files with 281 additions and 456 deletions.
17 changes: 17 additions & 0 deletions src/librustc/mir/repr.rs
Expand Up @@ -20,6 +20,7 @@ use syntax::codemap::Span;
use std::borrow::{Cow, IntoCow};
use std::fmt::{self, Debug, Formatter, Write};
use std::{iter, u32};
use std::ops::{Index, IndexMut};

/// Lowered representation of a single function.
#[derive(RustcEncodable, RustcDecodable)]
Expand Down Expand Up @@ -67,6 +68,22 @@ impl<'tcx> Mir<'tcx> {
}
}

impl<'tcx> Index<BasicBlock> for Mir<'tcx> {
type Output = BasicBlockData<'tcx>;

#[inline]
fn index(&self, index: BasicBlock) -> &BasicBlockData<'tcx> {
self.basic_block_data(index)
}
}

impl<'tcx> IndexMut<BasicBlock> for Mir<'tcx> {
#[inline]
fn index_mut(&mut self, index: BasicBlock) -> &mut BasicBlockData<'tcx> {
self.basic_block_data_mut(index)
}
}

///////////////////////////////////////////////////////////////////////////
// Mutability and borrow kinds

Expand Down

0 comments on commit 8f51188

Please sign in to comment.