Skip to content

Commit

Permalink
Rollup merge of rust-lang#57634 - oli-obk:remove_unused_argument, r=d…
Browse files Browse the repository at this point in the history
…avidtwco

Remove an unused function argument

The only use was a debug printing, which might help someone with debugging dataflow problems, but seems otherwise useless
  • Loading branch information
Centril committed Jan 19, 2019
2 parents fd779d3 + 096ca87 commit e00932a
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 74 deletions.
58 changes: 1 addition & 57 deletions src/librustc/hir/intravisit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,9 @@ use syntax::ast::{NodeId, CRATE_NODE_ID, Ident, Name, Attribute};
use syntax_pos::Span;
use hir::*;
use hir::def::Def;
use hir::map::{self, Map};
use hir::map::Map;
use super::itemlikevisit::DeepVisitor;

use std::cmp;

#[derive(Copy, Clone)]
pub enum FnKind<'a> {
/// `#[xxx] pub async/const/extern "Abi" fn foo()`
Expand Down Expand Up @@ -1133,57 +1131,3 @@ pub fn walk_defaultness<'v, V: Visitor<'v>>(_: &mut V, _: &'v Defaultness) {
// the right thing to do, should content be added in the future,
// would be to walk it.
}

#[derive(Copy, Clone, RustcEncodable, RustcDecodable, Debug)]
pub struct IdRange {
pub min: NodeId,
pub max: NodeId,
}

impl IdRange {
pub fn max() -> IdRange {
IdRange {
min: NodeId::MAX,
max: NodeId::from_u32(0),
}
}

pub fn empty(&self) -> bool {
self.min >= self.max
}

pub fn contains(&self, id: NodeId) -> bool {
id >= self.min && id < self.max
}

pub fn add(&mut self, id: NodeId) {
self.min = cmp::min(self.min, id);
self.max = cmp::max(self.max, NodeId::from_u32(id.as_u32() + 1));
}
}


pub struct IdRangeComputingVisitor<'a, 'hir: 'a> {
result: IdRange,
map: &'a map::Map<'hir>,
}

impl<'a, 'hir> IdRangeComputingVisitor<'a, 'hir> {
pub fn new(map: &'a map::Map<'hir>) -> IdRangeComputingVisitor<'a, 'hir> {
IdRangeComputingVisitor { result: IdRange::max(), map: map }
}

pub fn result(&self) -> IdRange {
self.result
}
}

impl<'a, 'hir> Visitor<'hir> for IdRangeComputingVisitor<'a, 'hir> {
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'hir> {
NestedVisitorMap::OnlyBodies(&self.map)
}

fn visit_id(&mut self, id: NodeId) {
self.result.add(id);
}
}
9 changes: 0 additions & 9 deletions src/librustc_borrowck/borrowck/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ use syntax_pos::{MultiSpan, Span};
use errors::{Applicability, DiagnosticBuilder, DiagnosticId};

use rustc::hir;
use rustc::hir::intravisit::{self, Visitor};

use dataflow::{DataFlowContext, BitwiseOperator, DataFlowOperator, KillFrom};

Expand Down Expand Up @@ -157,12 +156,6 @@ fn build_borrowck_dataflow_data<'a, 'c, 'tcx, F>(this: &mut BorrowckCtxt<'a, 'tc
where F: FnOnce(&mut BorrowckCtxt<'a, 'tcx>) -> &'c cfg::CFG
{
// Check the body of fn items.
let tcx = this.tcx;
let id_range = {
let mut visitor = intravisit::IdRangeComputingVisitor::new(&tcx.hir());
visitor.visit_body(this.body);
visitor.result()
};
let (all_loans, move_data) =
gather_loans::gather_loans_in_fn(this, body_id);

Expand All @@ -184,7 +177,6 @@ fn build_borrowck_dataflow_data<'a, 'c, 'tcx, F>(this: &mut BorrowckCtxt<'a, 'tc
Some(this.body),
cfg,
LoanDataFlowOperator,
id_range,
all_loans.len());
for (loan_idx, loan) in all_loans.iter().enumerate() {
loan_dfcx.add_gen(loan.gen_scope.item_local_id(), loan_idx);
Expand All @@ -198,7 +190,6 @@ fn build_borrowck_dataflow_data<'a, 'c, 'tcx, F>(this: &mut BorrowckCtxt<'a, 'tc
let flowed_moves = move_data::FlowedMoveData::new(move_data,
this,
cfg,
id_range,
this.body);

Some(AnalysisData { all_loans,
Expand Down
4 changes: 0 additions & 4 deletions src/librustc_borrowck/borrowck/move_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use std::rc::Rc;
use std::usize;
use syntax_pos::Span;
use rustc::hir;
use rustc::hir::intravisit::IdRange;

#[derive(Default)]
pub struct MoveData<'tcx> {
Expand Down Expand Up @@ -559,7 +558,6 @@ impl<'a, 'tcx> FlowedMoveData<'a, 'tcx> {
pub fn new(move_data: MoveData<'tcx>,
bccx: &BorrowckCtxt<'a, 'tcx>,
cfg: &cfg::CFG,
id_range: IdRange,
body: &hir::Body)
-> FlowedMoveData<'a, 'tcx> {
let tcx = bccx.tcx;
Expand All @@ -570,15 +568,13 @@ impl<'a, 'tcx> FlowedMoveData<'a, 'tcx> {
Some(body),
cfg,
MoveDataFlowOperator,
id_range,
move_data.moves.borrow().len());
let mut dfcx_assign =
DataFlowContext::new(tcx,
"flowed_move_data_assigns",
Some(body),
cfg,
AssignDataFlowOperator,
id_range,
move_data.var_assignments.borrow().len());

move_data.add_gen_kills(bccx,
Expand Down
7 changes: 3 additions & 4 deletions src/librustc_borrowck/dataflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use rustc_data_structures::graph::implementation::OUTGOING;

use rustc::util::nodemap::FxHashMap;
use rustc::hir;
use rustc::hir::intravisit::{self, IdRange};
use rustc::hir::intravisit;
use rustc::hir::print as pprust;


Expand Down Expand Up @@ -230,16 +230,15 @@ impl<'a, 'tcx, O:DataFlowOperator> DataFlowContext<'a, 'tcx, O> {
body: Option<&hir::Body>,
cfg: &cfg::CFG,
oper: O,
id_range: IdRange,
bits_per_id: usize) -> DataFlowContext<'a, 'tcx, O> {
let usize_bits = mem::size_of::<usize>() * 8;
let words_per_id = (bits_per_id + usize_bits - 1) / usize_bits;
let num_nodes = cfg.graph.all_nodes().len();

debug!("DataFlowContext::new(analysis_name: {}, id_range={:?}, \
debug!("DataFlowContext::new(analysis_name: {}, \
bits_per_id={}, words_per_id={}) \
num_nodes: {}",
analysis_name, id_range, bits_per_id, words_per_id,
analysis_name, bits_per_id, words_per_id,
num_nodes);

let entry = if oper.initial_value() { usize::MAX } else {0};
Expand Down

0 comments on commit e00932a

Please sign in to comment.