Skip to content

Commit 8f51188

Browse files
Factor mir::[Mut]Visitor implementations into a common macro.
1 parent 91b27ec commit 8f51188

File tree

2 files changed

+281
-456
lines changed

2 files changed

+281
-456
lines changed

src/librustc/mir/repr.rs

+17
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ use syntax::codemap::Span;
2020
use std::borrow::{Cow, IntoCow};
2121
use std::fmt::{self, Debug, Formatter, Write};
2222
use std::{iter, u32};
23+
use std::ops::{Index, IndexMut};
2324

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

71+
impl<'tcx> Index<BasicBlock> for Mir<'tcx> {
72+
type Output = BasicBlockData<'tcx>;
73+
74+
#[inline]
75+
fn index(&self, index: BasicBlock) -> &BasicBlockData<'tcx> {
76+
self.basic_block_data(index)
77+
}
78+
}
79+
80+
impl<'tcx> IndexMut<BasicBlock> for Mir<'tcx> {
81+
#[inline]
82+
fn index_mut(&mut self, index: BasicBlock) -> &mut BasicBlockData<'tcx> {
83+
self.basic_block_data_mut(index)
84+
}
85+
}
86+
7087
///////////////////////////////////////////////////////////////////////////
7188
// Mutability and borrow kinds
7289

0 commit comments

Comments
 (0)