Rename MIR local iterators to match convention

This commit is contained in:
Jonas Schievink 2016-09-26 22:50:03 +02:00
parent 3b0c318a5f
commit bcfbdb871f
7 changed files with 15 additions and 15 deletions

View File

@ -188,7 +188,7 @@ impl<'tcx> Mir<'tcx> {
/// Returns an iterator over all temporaries.
#[inline]
pub fn temp_iter<'a>(&'a self) -> impl Iterator<Item=Local> + 'a {
pub fn temps_iter<'a>(&'a self) -> impl Iterator<Item=Local> + 'a {
(self.arg_count+1..self.local_decls.len()).filter_map(move |index| {
let local = Local::new(index);
if self.local_decls[local].source_info.is_none() {
@ -201,7 +201,7 @@ impl<'tcx> Mir<'tcx> {
/// Returns an iterator over all user-declared locals.
#[inline]
pub fn var_iter<'a>(&'a self) -> impl Iterator<Item=Local> + 'a {
pub fn vars_iter<'a>(&'a self) -> impl Iterator<Item=Local> + 'a {
(self.arg_count+1..self.local_decls.len()).filter_map(move |index| {
let local = Local::new(index);
if self.local_decls[local].source_info.is_none() {
@ -214,14 +214,14 @@ impl<'tcx> Mir<'tcx> {
/// Returns an iterator over all function arguments.
#[inline]
pub fn arg_iter<'a>(&'a self) -> impl Iterator<Item=Local> + 'a {
pub fn args_iter<'a>(&'a self) -> impl Iterator<Item=Local> + 'a {
(1..self.arg_count+1).map(Local::new)
}
/// Returns an iterator over all user-defined variables and compiler-generated temporaries (all
/// locals that are neither arguments nor the return pointer).
#[inline]
pub fn var_and_temp_iter<'a>(&'a self) -> impl Iterator<Item=Local> + 'a {
pub fn vars_and_temps_iter<'a>(&'a self) -> impl Iterator<Item=Local> + 'a {
(self.arg_count+1..self.local_decls.len()).map(Local::new)
}

View File

@ -338,7 +338,7 @@ fn drop_flag_effects_for_function_entry<'a, 'tcx, F>(
where F: FnMut(MovePathIndex, DropFlagState)
{
let move_data = &ctxt.move_data;
for arg in mir.arg_iter() {
for arg in mir.args_iter() {
let lvalue = repr::Lvalue::Local(arg);
let lookup_result = move_data.rev_lookup.find(&lvalue);
on_lookup_result_bits(tcx, mir, move_data,

View File

@ -136,7 +136,7 @@ fn write_graph_label<'a, 'tcx, W: Write>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
write!(w, " label=<fn {}(", dot::escape_html(&tcx.node_path_str(nid)))?;
// fn argument types.
for (i, arg) in mir.arg_iter().enumerate() {
for (i, arg) in mir.args_iter().enumerate() {
if i > 0 {
write!(w, ", ")?;
}
@ -146,7 +146,7 @@ fn write_graph_label<'a, 'tcx, W: Write>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
write!(w, ") -&gt; {}", escape(mir.return_ty))?;
write!(w, r#"<br align="left"/>"#)?;
for local in mir.var_and_temp_iter() {
for local in mir.vars_and_temps_iter() {
let decl = &mir.local_decls[local];
write!(w, "let ")?;

View File

@ -237,7 +237,7 @@ fn write_scope_tree(tcx: TyCtxt,
writeln!(w, "{0:1$}scope {2} {{", "", indent, child.index())?;
// User variable types (including the user's name in a comment).
for local in mir.var_iter() {
for local in mir.vars_iter() {
let var = &mir.local_decls[local];
let (name, source_info) = if var.source_info.unwrap().scope == child {
(var.name.unwrap(), var.source_info.unwrap())
@ -333,7 +333,7 @@ fn write_mir_sig(tcx: TyCtxt, src: MirSource, mir: &Mir, w: &mut Write)
write!(w, "(")?;
// fn argument types.
for (i, arg) in mir.arg_iter().enumerate() {
for (i, arg) in mir.args_iter().enumerate() {
if i != 0 {
write!(w, ", ")?;
}
@ -349,7 +349,7 @@ fn write_mir_sig(tcx: TyCtxt, src: MirSource, mir: &Mir, w: &mut Write)
fn write_temp_decls(mir: &Mir, w: &mut Write) -> io::Result<()> {
// Compiler-introduced temporary types.
for temp in mir.temp_iter() {
for temp in mir.temps_iter() {
writeln!(w, "{}let mut {:?}: {};", INDENT, temp, mir.local_decls[temp].ty)?;
}

View File

@ -410,7 +410,7 @@ impl<'a, 'tcx> Qualifier<'a, 'tcx, 'tcx> {
TerminatorKind::Return => {
// Check for unused values. This usually means
// there are extra statements in the AST.
for temp in mir.temp_iter() {
for temp in mir.temps_iter() {
if self.temp_qualif[temp].is_none() {
continue;
}
@ -435,7 +435,7 @@ impl<'a, 'tcx> Qualifier<'a, 'tcx, 'tcx> {
// Make sure there are no extra unassigned variables.
self.qualif = Qualif::NOT_CONST;
for index in mir.var_iter() {
for index in mir.vars_iter() {
if !self.const_fn_arg_vars.contains(index.index()) {
debug!("unassigned variable {:?}", index);
self.assign(&Lvalue::Local(index), Location {

View File

@ -63,7 +63,7 @@ pub fn create_mir_scopes(fcx: &FunctionContext) -> IndexVec<VisibilityScope, Mir
// Find all the scopes with variables defined in them.
let mut has_variables = BitVector::new(mir.visibility_scopes.len());
for var in mir.var_iter() {
for var in mir.vars_iter() {
let decl = &mir.local_decls[var];
has_variables.insert(decl.source_info.unwrap().scope.index());
}

View File

@ -290,7 +290,7 @@ pub fn trans_mir<'blk, 'tcx: 'blk>(fcx: &'blk FunctionContext<'blk, 'tcx>) {
let retptr = allocate_local(mir::RETURN_POINTER);
iter::once(retptr)
.chain(args.into_iter())
.chain(mir.var_and_temp_iter().map(&mut allocate_local))
.chain(mir.vars_and_temps_iter().map(&mut allocate_local))
.collect()
};
@ -356,7 +356,7 @@ fn arg_local_refs<'bcx, 'tcx>(bcx: &BlockAndBuilder<'bcx, 'tcx>,
None
};
mir.arg_iter().enumerate().map(|(arg_index, local)| {
mir.args_iter().enumerate().map(|(arg_index, local)| {
let arg_decl = &mir.local_decls[local];
let arg_ty = bcx.monomorphize(&arg_decl.ty);