Skip to content

Commit e964ca7

Browse files
authored
Rollup merge of rust-lang#57634 - oli-obk:remove_unused_argument, r=davidtwco
Remove an unused function argument The only use was a debug printing, which might help someone with debugging dataflow problems, but seems otherwise useless
2 parents 53f7e66 + 096ca87 commit e964ca7

File tree

4 files changed

+4
-74
lines changed

4 files changed

+4
-74
lines changed

src/librustc/hir/intravisit.rs

+1-57
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,9 @@ use syntax::ast::{NodeId, CRATE_NODE_ID, Ident, Name, Attribute};
3535
use syntax_pos::Span;
3636
use hir::*;
3737
use hir::def::Def;
38-
use hir::map::{self, Map};
38+
use hir::map::Map;
3939
use super::itemlikevisit::DeepVisitor;
4040

41-
use std::cmp;
42-
4341
#[derive(Copy, Clone)]
4442
pub enum FnKind<'a> {
4543
/// `#[xxx] pub async/const/extern "Abi" fn foo()`
@@ -1133,57 +1131,3 @@ pub fn walk_defaultness<'v, V: Visitor<'v>>(_: &mut V, _: &'v Defaultness) {
11331131
// the right thing to do, should content be added in the future,
11341132
// would be to walk it.
11351133
}
1136-
1137-
#[derive(Copy, Clone, RustcEncodable, RustcDecodable, Debug)]
1138-
pub struct IdRange {
1139-
pub min: NodeId,
1140-
pub max: NodeId,
1141-
}
1142-
1143-
impl IdRange {
1144-
pub fn max() -> IdRange {
1145-
IdRange {
1146-
min: NodeId::MAX,
1147-
max: NodeId::from_u32(0),
1148-
}
1149-
}
1150-
1151-
pub fn empty(&self) -> bool {
1152-
self.min >= self.max
1153-
}
1154-
1155-
pub fn contains(&self, id: NodeId) -> bool {
1156-
id >= self.min && id < self.max
1157-
}
1158-
1159-
pub fn add(&mut self, id: NodeId) {
1160-
self.min = cmp::min(self.min, id);
1161-
self.max = cmp::max(self.max, NodeId::from_u32(id.as_u32() + 1));
1162-
}
1163-
}
1164-
1165-
1166-
pub struct IdRangeComputingVisitor<'a, 'hir: 'a> {
1167-
result: IdRange,
1168-
map: &'a map::Map<'hir>,
1169-
}
1170-
1171-
impl<'a, 'hir> IdRangeComputingVisitor<'a, 'hir> {
1172-
pub fn new(map: &'a map::Map<'hir>) -> IdRangeComputingVisitor<'a, 'hir> {
1173-
IdRangeComputingVisitor { result: IdRange::max(), map: map }
1174-
}
1175-
1176-
pub fn result(&self) -> IdRange {
1177-
self.result
1178-
}
1179-
}
1180-
1181-
impl<'a, 'hir> Visitor<'hir> for IdRangeComputingVisitor<'a, 'hir> {
1182-
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'hir> {
1183-
NestedVisitorMap::OnlyBodies(&self.map)
1184-
}
1185-
1186-
fn visit_id(&mut self, id: NodeId) {
1187-
self.result.add(id);
1188-
}
1189-
}

src/librustc_borrowck/borrowck/mod.rs

-9
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ use syntax_pos::{MultiSpan, Span};
3939
use errors::{Applicability, DiagnosticBuilder, DiagnosticId};
4040

4141
use rustc::hir;
42-
use rustc::hir::intravisit::{self, Visitor};
4342

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

@@ -157,12 +156,6 @@ fn build_borrowck_dataflow_data<'a, 'c, 'tcx, F>(this: &mut BorrowckCtxt<'a, 'tc
157156
where F: FnOnce(&mut BorrowckCtxt<'a, 'tcx>) -> &'c cfg::CFG
158157
{
159158
// Check the body of fn items.
160-
let tcx = this.tcx;
161-
let id_range = {
162-
let mut visitor = intravisit::IdRangeComputingVisitor::new(&tcx.hir());
163-
visitor.visit_body(this.body);
164-
visitor.result()
165-
};
166159
let (all_loans, move_data) =
167160
gather_loans::gather_loans_in_fn(this, body_id);
168161

@@ -184,7 +177,6 @@ fn build_borrowck_dataflow_data<'a, 'c, 'tcx, F>(this: &mut BorrowckCtxt<'a, 'tc
184177
Some(this.body),
185178
cfg,
186179
LoanDataFlowOperator,
187-
id_range,
188180
all_loans.len());
189181
for (loan_idx, loan) in all_loans.iter().enumerate() {
190182
loan_dfcx.add_gen(loan.gen_scope.item_local_id(), loan_idx);
@@ -198,7 +190,6 @@ fn build_borrowck_dataflow_data<'a, 'c, 'tcx, F>(this: &mut BorrowckCtxt<'a, 'tc
198190
let flowed_moves = move_data::FlowedMoveData::new(move_data,
199191
this,
200192
cfg,
201-
id_range,
202193
this.body);
203194

204195
Some(AnalysisData { all_loans,

src/librustc_borrowck/borrowck/move_data.rs

-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use std::rc::Rc;
1515
use std::usize;
1616
use syntax_pos::Span;
1717
use rustc::hir;
18-
use rustc::hir::intravisit::IdRange;
1918

2019
#[derive(Default)]
2120
pub struct MoveData<'tcx> {
@@ -559,7 +558,6 @@ impl<'a, 'tcx> FlowedMoveData<'a, 'tcx> {
559558
pub fn new(move_data: MoveData<'tcx>,
560559
bccx: &BorrowckCtxt<'a, 'tcx>,
561560
cfg: &cfg::CFG,
562-
id_range: IdRange,
563561
body: &hir::Body)
564562
-> FlowedMoveData<'a, 'tcx> {
565563
let tcx = bccx.tcx;
@@ -570,15 +568,13 @@ impl<'a, 'tcx> FlowedMoveData<'a, 'tcx> {
570568
Some(body),
571569
cfg,
572570
MoveDataFlowOperator,
573-
id_range,
574571
move_data.moves.borrow().len());
575572
let mut dfcx_assign =
576573
DataFlowContext::new(tcx,
577574
"flowed_move_data_assigns",
578575
Some(body),
579576
cfg,
580577
AssignDataFlowOperator,
581-
id_range,
582578
move_data.var_assignments.borrow().len());
583579

584580
move_data.add_gen_kills(bccx,

src/librustc_borrowck/dataflow.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use rustc_data_structures::graph::implementation::OUTGOING;
1515

1616
use rustc::util::nodemap::FxHashMap;
1717
use rustc::hir;
18-
use rustc::hir::intravisit::{self, IdRange};
18+
use rustc::hir::intravisit;
1919
use rustc::hir::print as pprust;
2020

2121

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

239-
debug!("DataFlowContext::new(analysis_name: {}, id_range={:?}, \
238+
debug!("DataFlowContext::new(analysis_name: {}, \
240239
bits_per_id={}, words_per_id={}) \
241240
num_nodes: {}",
242-
analysis_name, id_range, bits_per_id, words_per_id,
241+
analysis_name, bits_per_id, words_per_id,
243242
num_nodes);
244243

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

0 commit comments

Comments
 (0)