Skip to content

Commit 64a8ffe

Browse files
committed
Auto merge of #30757 - michaelwoerister:mir-visitor-cleanup, r=jroesch
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
2 parents 5c92010 + 8f51188 commit 64a8ffe

File tree

2 files changed

+281
-456
lines changed

2 files changed

+281
-456
lines changed

Diff for: src/librustc/mir/repr.rs

+17
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ use std::ascii;
2121
use std::borrow::{Cow, IntoCow};
2222
use std::fmt::{self, Debug, Formatter, Write};
2323
use std::{iter, u32};
24+
use std::ops::{Index, IndexMut};
2425

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

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

0 commit comments

Comments
 (0)