Provide span for visit_struct_def + remove some dead code
This commit is contained in:
parent
877c35e8a2
commit
beda1f88a7
@ -665,7 +665,8 @@ impl<'a, 'tcx, 'v> hir_visit::Visitor<'v> for LateContext<'a, 'tcx> {
|
||||
s: &hir::StructDef,
|
||||
name: ast::Name,
|
||||
g: &hir::Generics,
|
||||
item_id: ast::NodeId) {
|
||||
item_id: ast::NodeId,
|
||||
_: Span) {
|
||||
run_lints!(self, check_struct_def, late_passes, s, name, g, item_id);
|
||||
hir_visit::walk_struct_def(self, s);
|
||||
run_lints!(self, check_struct_def_post, late_passes, s, name, g, item_id);
|
||||
@ -814,7 +815,8 @@ impl<'a, 'v> ast_visit::Visitor<'v> for EarlyContext<'a> {
|
||||
s: &ast::StructDef,
|
||||
ident: ast::Ident,
|
||||
g: &ast::Generics,
|
||||
item_id: ast::NodeId) {
|
||||
item_id: ast::NodeId,
|
||||
_: Span) {
|
||||
run_lints!(self, check_struct_def, early_passes, s, ident, g, item_id);
|
||||
ast_visit::walk_struct_def(self, s);
|
||||
run_lints!(self, check_struct_def_post, early_passes, s, ident, g, item_id);
|
||||
|
@ -216,7 +216,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
|
||||
impl<'a, 'tcx, 'v> Visitor<'v> for MarkSymbolVisitor<'a, 'tcx> {
|
||||
|
||||
fn visit_struct_def(&mut self, def: &hir::StructDef, _: ast::Name,
|
||||
_: &hir::Generics, _: ast::NodeId) {
|
||||
_: &hir::Generics, _: ast::NodeId, _: codemap::Span) {
|
||||
let has_extern_repr = self.struct_has_extern_repr;
|
||||
let inherited_pub_visibility = self.inherited_pub_visibility;
|
||||
let live_fields = def.fields.iter().filter(|f| {
|
||||
|
@ -301,7 +301,8 @@ mod svh_visitor {
|
||||
}
|
||||
|
||||
impl<'a, 'v> Visitor<'v> for StrictVersionHashVisitor<'a> {
|
||||
fn visit_struct_def(&mut self, s: &StructDef, name: Name, g: &Generics, _: NodeId) {
|
||||
fn visit_struct_def(&mut self, s: &StructDef, name: Name,
|
||||
g: &Generics, _: NodeId, _: Span) {
|
||||
SawStructDef(name.as_str()).hash(self.st);
|
||||
visit::walk_generics(self, g);
|
||||
visit::walk_struct_def(self, s)
|
||||
|
@ -247,10 +247,6 @@ pub trait Folder : Sized {
|
||||
noop_fold_opt_lifetime(o_lt, self)
|
||||
}
|
||||
|
||||
fn fold_variant_arg(&mut self, va: VariantArg) -> VariantArg {
|
||||
noop_fold_variant_arg(va, self)
|
||||
}
|
||||
|
||||
fn fold_opt_bounds(&mut self,
|
||||
b: Option<OwnedSlice<TyParamBound>>)
|
||||
-> Option<OwnedSlice<TyParamBound>> {
|
||||
@ -766,15 +762,6 @@ fn noop_fold_bounds<T: Folder>(bounds: TyParamBounds, folder: &mut T) -> TyParam
|
||||
bounds.move_map(|bound| folder.fold_ty_param_bound(bound))
|
||||
}
|
||||
|
||||
fn noop_fold_variant_arg<T: Folder>(VariantArg { id, ty }: VariantArg,
|
||||
folder: &mut T)
|
||||
-> VariantArg {
|
||||
VariantArg {
|
||||
id: folder.new_id(id),
|
||||
ty: folder.fold_ty(ty),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn noop_fold_block<T: Folder>(b: P<Block>, folder: &mut T) -> P<Block> {
|
||||
b.map(|Block { id, stmts, expr, rules, span }| {
|
||||
Block {
|
||||
|
@ -1014,12 +1014,6 @@ pub struct ForeignMod {
|
||||
pub items: Vec<P<ForeignItem>>,
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
||||
pub struct VariantArg {
|
||||
pub ty: P<Ty>,
|
||||
pub id: NodeId,
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
||||
pub struct EnumDef {
|
||||
pub variants: Vec<P<Variant>>,
|
||||
|
@ -285,7 +285,8 @@ impl<'a, 'v, O: ast_util::IdVisitingOperation> Visitor<'v> for IdVisitor<'a, O>
|
||||
struct_def: &StructDef,
|
||||
_: Name,
|
||||
_: &hir::Generics,
|
||||
_: NodeId) {
|
||||
_: NodeId,
|
||||
_: Span) {
|
||||
self.operation.visit_id(struct_def.id);
|
||||
visit::walk_struct_def(self, struct_def);
|
||||
}
|
||||
|
@ -112,7 +112,8 @@ pub trait Visitor<'v> : Sized {
|
||||
fn visit_poly_trait_ref(&mut self, t: &'v PolyTraitRef, m: &'v TraitBoundModifier) {
|
||||
walk_poly_trait_ref(self, t, m)
|
||||
}
|
||||
fn visit_struct_def(&mut self, s: &'v StructDef, _: Name, _: &'v Generics, _: NodeId) {
|
||||
fn visit_struct_def(&mut self, s: &'v StructDef, _: Name,
|
||||
_: &'v Generics, _: NodeId, _: Span) {
|
||||
walk_struct_def(self, s)
|
||||
}
|
||||
fn visit_struct_field(&mut self, s: &'v StructField) {
|
||||
@ -309,7 +310,8 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) {
|
||||
}
|
||||
ItemStruct(ref struct_definition, ref generics) => {
|
||||
visitor.visit_generics(generics);
|
||||
visitor.visit_struct_def(struct_definition, item.name, generics, item.id);
|
||||
visitor.visit_struct_def(struct_definition, item.name,
|
||||
generics, item.id, item.span);
|
||||
}
|
||||
ItemTrait(_, ref generics, ref bounds, ref methods) => {
|
||||
visitor.visit_generics(generics);
|
||||
@ -334,7 +336,8 @@ pub fn walk_variant<'v, V: Visitor<'v>>(visitor: &mut V,
|
||||
generics: &'v Generics,
|
||||
item_id: NodeId) {
|
||||
visitor.visit_name(variant.span, variant.node.name);
|
||||
visitor.visit_struct_def(&variant.node.def, variant.node.name, generics, item_id);
|
||||
visitor.visit_struct_def(&variant.node.def, variant.node.name,
|
||||
generics, item_id, variant.span);
|
||||
walk_list!(visitor, visit_expr, &variant.node.disr_expr);
|
||||
walk_list!(visitor, visit_attribute, &variant.node.attrs);
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ impl<'v> Visitor<'v> for ParentVisitor {
|
||||
}
|
||||
|
||||
fn visit_struct_def(&mut self, s: &hir::StructDef, _: ast::Name,
|
||||
_: &'v hir::Generics, item_id: ast::NodeId) {
|
||||
_: &'v hir::Generics, item_id: ast::NodeId, _: Span) {
|
||||
// Struct constructors are parented to their struct definitions because
|
||||
// they essentially are the struct definitions.
|
||||
if s.kind != hir::VariantKind::Dict {
|
||||
|
@ -501,7 +501,8 @@ impl<'a, 'v, 'tcx> Visitor<'v> for Resolver<'a, 'tcx> {
|
||||
}
|
||||
|
||||
// `visit::walk_variant` without the discriminant expression.
|
||||
self.visit_struct_def(&variant.node.def, variant.node.name, generics, item_id);
|
||||
self.visit_struct_def(&variant.node.def, variant.node.name,
|
||||
generics, item_id, variant.span);
|
||||
}
|
||||
fn visit_foreign_item(&mut self, foreign_item: &hir::ForeignItem) {
|
||||
execute_callback!(hir_map::Node::NodeForeignItem(foreign_item), self);
|
||||
|
@ -1570,12 +1570,6 @@ pub struct ForeignMod {
|
||||
pub items: Vec<P<ForeignItem>>,
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
||||
pub struct VariantArg {
|
||||
pub ty: P<Ty>,
|
||||
pub id: NodeId,
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
||||
pub struct EnumDef {
|
||||
pub variants: Vec<P<Variant>>,
|
||||
|
@ -456,7 +456,8 @@ impl<'a, 'v, O: IdVisitingOperation> Visitor<'v> for IdVisitor<'a, O> {
|
||||
struct_def: &StructDef,
|
||||
_: ast::Ident,
|
||||
_: &ast::Generics,
|
||||
_: NodeId) {
|
||||
_: NodeId,
|
||||
_: Span) {
|
||||
self.operation.visit_id(struct_def.id);
|
||||
visit::walk_struct_def(self, struct_def);
|
||||
}
|
||||
|
@ -271,10 +271,6 @@ pub trait Folder : Sized {
|
||||
noop_fold_opt_lifetime(o_lt, self)
|
||||
}
|
||||
|
||||
fn fold_variant_arg(&mut self, va: VariantArg) -> VariantArg {
|
||||
noop_fold_variant_arg(va, self)
|
||||
}
|
||||
|
||||
fn fold_opt_bounds(&mut self, b: Option<OwnedSlice<TyParamBound>>)
|
||||
-> Option<OwnedSlice<TyParamBound>> {
|
||||
noop_fold_opt_bounds(b, self)
|
||||
@ -884,14 +880,6 @@ fn noop_fold_bounds<T: Folder>(bounds: TyParamBounds, folder: &mut T)
|
||||
bounds.move_map(|bound| folder.fold_ty_param_bound(bound))
|
||||
}
|
||||
|
||||
fn noop_fold_variant_arg<T: Folder>(VariantArg {id, ty}: VariantArg, folder: &mut T)
|
||||
-> VariantArg {
|
||||
VariantArg {
|
||||
id: folder.new_id(id),
|
||||
ty: folder.fold_ty(ty)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn noop_fold_block<T: Folder>(b: P<Block>, folder: &mut T) -> P<Block> {
|
||||
b.map(|Block {id, stmts, expr, rules, span}| Block {
|
||||
id: folder.new_id(id),
|
||||
|
@ -80,7 +80,8 @@ pub trait Visitor<'v> : Sized {
|
||||
fn visit_poly_trait_ref(&mut self, t: &'v PolyTraitRef, m: &'v TraitBoundModifier) {
|
||||
walk_poly_trait_ref(self, t, m)
|
||||
}
|
||||
fn visit_struct_def(&mut self, s: &'v StructDef, _: Ident, _: &'v Generics, _: NodeId) {
|
||||
fn visit_struct_def(&mut self, s: &'v StructDef, _: Ident,
|
||||
_: &'v Generics, _: NodeId, _: Span) {
|
||||
walk_struct_def(self, s)
|
||||
}
|
||||
fn visit_struct_field(&mut self, s: &'v StructField) { walk_struct_field(self, s) }
|
||||
@ -288,7 +289,8 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item) {
|
||||
}
|
||||
ItemStruct(ref struct_definition, ref generics) => {
|
||||
visitor.visit_generics(generics);
|
||||
visitor.visit_struct_def(struct_definition, item.ident, generics, item.id);
|
||||
visitor.visit_struct_def(struct_definition, item.ident,
|
||||
generics, item.id, item.span);
|
||||
}
|
||||
ItemTrait(_, ref generics, ref bounds, ref methods) => {
|
||||
visitor.visit_generics(generics);
|
||||
@ -314,7 +316,8 @@ pub fn walk_variant<'v, V: Visitor<'v>>(visitor: &mut V,
|
||||
generics: &'v Generics,
|
||||
item_id: NodeId) {
|
||||
visitor.visit_ident(variant.span, variant.node.name);
|
||||
visitor.visit_struct_def(&variant.node.def, variant.node.name, generics, item_id);
|
||||
visitor.visit_struct_def(&variant.node.def, variant.node.name,
|
||||
generics, item_id, variant.span);
|
||||
walk_list!(visitor, visit_expr, &variant.node.disr_expr);
|
||||
walk_list!(visitor, visit_attribute, &variant.node.attrs);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user