auto merge of #9686 : alexcrichton/rust/lint, r=thestinger

This purges about 500 lines of visitor cruft from lint passes. All lints are
handled in a much more sane way at this point. The other huge bonus of this
commit is that there are no more @-boxes in the lint passes, fixing the 500MB
memory regression seen when the lint passes were refactored.

Closes #8589
This commit is contained in:
bors 2013-10-03 10:31:33 -07:00
commit 9344e2a866
3 changed files with 454 additions and 957 deletions

View File

@ -880,13 +880,13 @@ fn encode_side_tables_for_ii(ecx: &e::EncodeContext,
// Because the ast visitor uses @IdVisitingOperation, I can't pass in
// ecx directly, but /I/ know that it'll be fine since the lifetime is
// tied to the CrateContext that lives throughout this entire section.
ast_util::visit_ids_for_inlined_item(ii, @SideTableEncodingIdVisitor {
ast_util::visit_ids_for_inlined_item(ii, &SideTableEncodingIdVisitor {
ecx_ptr: unsafe {
cast::transmute(ecx)
},
new_ebml_w: new_ebml_w,
maps: maps,
} as @ast_util::IdVisitingOperation);
});
ebml_w.end_tag();
}

File diff suppressed because it is too large Load Diff

View File

@ -397,27 +397,17 @@ impl id_range {
}
}
pub fn id_visitor(operation: @IdVisitingOperation, pass_through_items: bool)
-> @mut Visitor<()> {
let visitor = @mut IdVisitor {
operation: operation,
pass_through_items: pass_through_items,
visited_outermost: false,
};
visitor as @mut Visitor<()>
}
pub trait IdVisitingOperation {
fn visit_id(&self, node_id: NodeId);
}
pub struct IdVisitor {
operation: @IdVisitingOperation,
pub struct IdVisitor<'self, O> {
operation: &'self O,
pass_through_items: bool,
visited_outermost: bool,
}
impl IdVisitor {
impl<'self, O: IdVisitingOperation> IdVisitor<'self, O> {
fn visit_generics_helper(&self, generics: &Generics) {
for type_parameter in generics.ty_params.iter() {
self.operation.visit_id(type_parameter.id)
@ -428,7 +418,7 @@ impl IdVisitor {
}
}
impl Visitor<()> for IdVisitor {
impl<'self, O: IdVisitingOperation> Visitor<()> for IdVisitor<'self, O> {
fn visit_mod(&mut self,
module: &_mod,
_: Span,
@ -601,10 +591,18 @@ impl Visitor<()> for IdVisitor {
struct_def.ctor_id.map(|&ctor_id| self.operation.visit_id(ctor_id));
visit::walk_struct_def(self, struct_def, ident, generics, id, ());
}
fn visit_trait_method(&mut self, tm: &ast::trait_method, _: ()) {
match *tm {
ast::required(ref m) => self.operation.visit_id(m.id),
ast::provided(ref m) => self.operation.visit_id(m.id),
}
visit::walk_trait_method(self, tm, ());
}
}
pub fn visit_ids_for_inlined_item(item: &inlined_item,
operation: @IdVisitingOperation) {
pub fn visit_ids_for_inlined_item<O: IdVisitingOperation>(item: &inlined_item,
operation: &O) {
let mut id_visitor = IdVisitor {
operation: operation,
pass_through_items: true,
@ -623,16 +621,12 @@ impl IdVisitingOperation for IdRangeComputingVisitor {
}
}
pub fn compute_id_range(visit_ids_fn: &fn(@IdVisitingOperation)) -> id_range {
let result = @mut id_range::max();
visit_ids_fn(@IdRangeComputingVisitor {
result: result,
} as @IdVisitingOperation);
*result
}
pub fn compute_id_range_for_inlined_item(item: &inlined_item) -> id_range {
compute_id_range(|f| visit_ids_for_inlined_item(item, f))
let result = @mut id_range::max();
visit_ids_for_inlined_item(item, &IdRangeComputingVisitor {
result: result,
});
*result
}
pub fn is_item_impl(item: @ast::item) -> bool {