Skip to content

Commit

Permalink
Rename MIR local iterators to match convention
Browse files Browse the repository at this point in the history
  • Loading branch information
jonas-schievink committed Sep 26, 2016
1 parent 3b0c318 commit bcfbdb8
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 15 deletions.
8 changes: 4 additions & 4 deletions src/librustc/mir/repr.rs
Expand Up @@ -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() {
Expand All @@ -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() {
Expand All @@ -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)
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_borrowck/borrowck/mir/mod.rs
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_mir/graphviz.rs
Expand Up @@ -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, ", ")?;
}
Expand All @@ -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 ")?;
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_mir/pretty.rs
Expand Up @@ -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())
Expand Down Expand Up @@ -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, ", ")?;
}
Expand All @@ -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)?;
}

Expand Down
4 changes: 2 additions & 2 deletions src/librustc_mir/transform/qualify_consts.rs
Expand Up @@ -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;
}
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_trans/debuginfo/create_scope_map.rs
Expand Up @@ -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());
}
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_trans/mir/mod.rs
Expand Up @@ -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()
};

Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit bcfbdb8

Please sign in to comment.