Skip to content

Commit

Permalink
Auto merge of #30757 - michaelwoerister:mir-visitor-cleanup, r=jroesch
Browse files Browse the repository at this point in the history
After a call to `visit_def_id()` missing in `mir::visit::Visitor` but not `mir::visit::MutVisitor` has caused me a couple hours of error hunting, I decided I'd take the time to get rid of the code duplication between the two implementations.

cc @rust-lang/compiler
  • Loading branch information
bors committed Jan 7, 2016
2 parents 5c92010 + 8f51188 commit 64a8ffe
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
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use std::ascii;
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 @@ -68,6 +69,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
Loading

0 comments on commit 64a8ffe

Please sign in to comment.