Skip to content

Commit 33ea1e3

Browse files
committed
Rollup merge of rust-lang#33943 - jseyfried:libsyntax_cleanup, r=nrc
Miscellaneous low priority cleanup in `libsyntax`.
2 parents 82a15a6 + 0644aba commit 33ea1e3

File tree

27 files changed

+269
-365
lines changed

27 files changed

+269
-365
lines changed

src/librustc/hir/check_attr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ impl<'a> CheckAttrVisitor<'a> {
9595
}
9696
}
9797

98-
impl<'a, 'v> Visitor<'v> for CheckAttrVisitor<'a> {
98+
impl<'a> Visitor for CheckAttrVisitor<'a> {
9999
fn visit_item(&mut self, item: &ast::Item) {
100100
let target = Target::from_item(item);
101101
for attr in &item.attrs {

src/librustc/hir/lowering.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ impl<'a> LoweringContext<'a> {
138138
lctx: &'lcx mut LoweringContext<'interner>,
139139
}
140140

141-
impl<'lcx, 'interner> Visitor<'lcx> for ItemLowerer<'lcx, 'interner> {
142-
fn visit_item(&mut self, item: &'lcx Item) {
141+
impl<'lcx, 'interner> Visitor for ItemLowerer<'lcx, 'interner> {
142+
fn visit_item(&mut self, item: &Item) {
143143
self.items.insert(item.id, self.lctx.lower_item(item));
144144
visit::walk_item(self, item);
145145
}

src/librustc/hir/map/def_collector.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ impl<'ast> DefCollector<'ast> {
9898
self.parent_def = parent;
9999
}
100100

101-
fn visit_ast_const_integer(&mut self, expr: &'ast Expr) {
101+
fn visit_ast_const_integer(&mut self, expr: &Expr) {
102102
// Find the node which will be used after lowering.
103103
if let ExprKind::Paren(ref inner) = expr.node {
104104
return self.visit_ast_const_integer(inner);
@@ -124,8 +124,8 @@ impl<'ast> DefCollector<'ast> {
124124
}
125125
}
126126

127-
impl<'ast> visit::Visitor<'ast> for DefCollector<'ast> {
128-
fn visit_item(&mut self, i: &'ast Item) {
127+
impl<'ast> visit::Visitor for DefCollector<'ast> {
128+
fn visit_item(&mut self, i: &Item) {
129129
debug!("visit_item: {:?}", i);
130130

131131
// Pick the def data. This need not be unique, but the more
@@ -183,23 +183,23 @@ impl<'ast> visit::Visitor<'ast> for DefCollector<'ast> {
183183
});
184184
}
185185

186-
fn visit_foreign_item(&mut self, foreign_item: &'ast ForeignItem) {
186+
fn visit_foreign_item(&mut self, foreign_item: &ForeignItem) {
187187
let def = self.create_def(foreign_item.id, DefPathData::ValueNs(foreign_item.ident.name));
188188

189189
self.with_parent(def, |this| {
190190
visit::walk_foreign_item(this, foreign_item);
191191
});
192192
}
193193

194-
fn visit_generics(&mut self, generics: &'ast Generics) {
194+
fn visit_generics(&mut self, generics: &Generics) {
195195
for ty_param in generics.ty_params.iter() {
196196
self.create_def(ty_param.id, DefPathData::TypeParam(ty_param.ident.name));
197197
}
198198

199199
visit::walk_generics(self, generics);
200200
}
201201

202-
fn visit_trait_item(&mut self, ti: &'ast TraitItem) {
202+
fn visit_trait_item(&mut self, ti: &TraitItem) {
203203
let def_data = match ti.node {
204204
TraitItemKind::Method(..) | TraitItemKind::Const(..) =>
205205
DefPathData::ValueNs(ti.ident.name),
@@ -217,7 +217,7 @@ impl<'ast> visit::Visitor<'ast> for DefCollector<'ast> {
217217
});
218218
}
219219

220-
fn visit_impl_item(&mut self, ii: &'ast ImplItem) {
220+
fn visit_impl_item(&mut self, ii: &ImplItem) {
221221
let def_data = match ii.node {
222222
ImplItemKind::Method(..) | ImplItemKind::Const(..) =>
223223
DefPathData::ValueNs(ii.ident.name),
@@ -235,7 +235,7 @@ impl<'ast> visit::Visitor<'ast> for DefCollector<'ast> {
235235
});
236236
}
237237

238-
fn visit_pat(&mut self, pat: &'ast Pat) {
238+
fn visit_pat(&mut self, pat: &Pat) {
239239
let parent_def = self.parent_def;
240240

241241
if let PatKind::Ident(_, id, _) = pat.node {
@@ -247,7 +247,7 @@ impl<'ast> visit::Visitor<'ast> for DefCollector<'ast> {
247247
self.parent_def = parent_def;
248248
}
249249

250-
fn visit_expr(&mut self, expr: &'ast Expr) {
250+
fn visit_expr(&mut self, expr: &Expr) {
251251
let parent_def = self.parent_def;
252252

253253
if let ExprKind::Repeat(_, ref count) = expr.node {
@@ -263,18 +263,18 @@ impl<'ast> visit::Visitor<'ast> for DefCollector<'ast> {
263263
self.parent_def = parent_def;
264264
}
265265

266-
fn visit_ty(&mut self, ty: &'ast Ty) {
266+
fn visit_ty(&mut self, ty: &Ty) {
267267
if let TyKind::FixedLengthVec(_, ref length) = ty.node {
268268
self.visit_ast_const_integer(length);
269269
}
270270
visit::walk_ty(self, ty);
271271
}
272272

273-
fn visit_lifetime_def(&mut self, def: &'ast LifetimeDef) {
273+
fn visit_lifetime_def(&mut self, def: &LifetimeDef) {
274274
self.create_def(def.lifetime.id, DefPathData::LifetimeDef(def.lifetime.name));
275275
}
276276

277-
fn visit_macro_def(&mut self, macro_def: &'ast MacroDef) {
277+
fn visit_macro_def(&mut self, macro_def: &MacroDef) {
278278
self.create_def(macro_def.id, DefPathData::MacroDef(macro_def.ident.name));
279279
}
280280
}

src/librustc/lint/context.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -905,7 +905,7 @@ impl<'a, 'tcx, 'v> hir_visit::Visitor<'v> for LateContext<'a, 'tcx> {
905905
}
906906
}
907907

908-
impl<'a, 'v> ast_visit::Visitor<'v> for EarlyContext<'a> {
908+
impl<'a> ast_visit::Visitor for EarlyContext<'a> {
909909
fn visit_item(&mut self, it: &ast::Item) {
910910
self.with_lint_attrs(&it.attrs, |cx| {
911911
run_lints!(cx, check_item, early_passes, it);
@@ -939,8 +939,8 @@ impl<'a, 'v> ast_visit::Visitor<'v> for EarlyContext<'a> {
939939
ast_visit::walk_stmt(self, s);
940940
}
941941

942-
fn visit_fn(&mut self, fk: ast_visit::FnKind<'v>, decl: &'v ast::FnDecl,
943-
body: &'v ast::Block, span: Span, id: ast::NodeId) {
942+
fn visit_fn(&mut self, fk: ast_visit::FnKind, decl: &ast::FnDecl,
943+
body: &ast::Block, span: Span, id: ast::NodeId) {
944944
run_lints!(self, check_fn, early_passes, fk, decl, body, span, id);
945945
ast_visit::walk_fn(self, fk, decl, body, span);
946946
run_lints!(self, check_fn_post, early_passes, fk, decl, body, span, id);

src/librustc_metadata/creader.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ pub struct CrateReader<'a> {
5959
local_crate_name: String,
6060
}
6161

62-
impl<'a, 'ast> visit::Visitor<'ast> for LocalCrateReader<'a> {
63-
fn visit_item(&mut self, a: &'ast ast::Item) {
62+
impl<'a> visit::Visitor for LocalCrateReader<'a> {
63+
fn visit_item(&mut self, a: &ast::Item) {
6464
self.process_item(a);
6565
visit::walk_item(self, a);
6666
}

src/librustc_passes/ast_validation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ impl<'a> AstValidator<'a> {
5757
}
5858
}
5959

60-
impl<'a, 'v> Visitor<'v> for AstValidator<'a> {
60+
impl<'a> Visitor for AstValidator<'a> {
6161
fn visit_lifetime(&mut self, lt: &Lifetime) {
6262
if lt.name.as_str() == "'_" {
6363
self.session.add_lint(

src/librustc_passes/no_asm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ struct CheckNoAsm<'a> {
2929
sess: &'a Session,
3030
}
3131

32-
impl<'a, 'v> Visitor<'v> for CheckNoAsm<'a> {
32+
impl<'a> Visitor for CheckNoAsm<'a> {
3333
fn visit_expr(&mut self, e: &ast::Expr) {
3434
match e.node {
3535
ast::ExprKind::InlineAsm(_) => span_err!(self.sess, e.span, E0472,

src/librustc_resolve/build_reduced_graph.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ struct BuildReducedGraphVisitor<'a, 'b: 'a> {
505505
parent: Module<'b>,
506506
}
507507

508-
impl<'a, 'b, 'v> Visitor<'v> for BuildReducedGraphVisitor<'a, 'b> {
508+
impl<'a, 'b> Visitor for BuildReducedGraphVisitor<'a, 'b> {
509509
fn visit_item(&mut self, item: &Item) {
510510
let old_parent = self.parent;
511511
self.resolver.build_reduced_graph_for_item(item, &mut self.parent);

src/librustc_resolve/check_unused.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ impl<'a, 'b> UnusedImportCheckVisitor<'a, 'b> {
7171
}
7272
}
7373

74-
impl<'a, 'b, 'v> Visitor<'v> for UnusedImportCheckVisitor<'a, 'b> {
74+
impl<'a, 'b> Visitor for UnusedImportCheckVisitor<'a, 'b> {
7575
fn visit_item(&mut self, item: &ast::Item) {
7676
visit::walk_item(self, item);
7777
// Ignore is_public import statements because there's no way to be sure

src/librustc_resolve/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ pub enum Namespace {
498498
ValueNS,
499499
}
500500

501-
impl<'a, 'v> Visitor<'v> for Resolver<'a> {
501+
impl<'a> Visitor for Resolver<'a> {
502502
fn visit_item(&mut self, item: &Item) {
503503
self.resolve_item(item);
504504
}
@@ -557,9 +557,9 @@ impl<'a, 'v> Visitor<'v> for Resolver<'a> {
557557
});
558558
}
559559
fn visit_fn(&mut self,
560-
function_kind: FnKind<'v>,
561-
declaration: &'v FnDecl,
562-
block: &'v Block,
560+
function_kind: FnKind,
561+
declaration: &FnDecl,
562+
block: &Block,
563563
_: Span,
564564
node_id: NodeId) {
565565
let rib_kind = match function_kind {

src/librustc_save_analysis/dump_visitor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1038,7 +1038,7 @@ impl<'l, 'tcx: 'l, 'll, D: Dump + 'll> DumpVisitor<'l, 'tcx, 'll, D> {
10381038
}
10391039
}
10401040

1041-
impl<'v, 'l, 'tcx: 'l, 'll, D: Dump +'ll> Visitor<'v> for DumpVisitor<'l, 'tcx, 'll, D> {
1041+
impl<'l, 'tcx: 'l, 'll, D: Dump +'ll> Visitor for DumpVisitor<'l, 'tcx, 'll, D> {
10421042
fn visit_item(&mut self, item: &ast::Item) {
10431043
use syntax::ast::ItemKind::*;
10441044
self.process_macro_use(item.span, item.id);

src/librustc_save_analysis/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,7 @@ impl PathCollector {
693693
}
694694
}
695695

696-
impl<'v> Visitor<'v> for PathCollector {
696+
impl Visitor for PathCollector {
697697
fn visit_pat(&mut self, p: &ast::Pat) {
698698
match p.node {
699699
PatKind::Struct(ref path, _, _) => {

src/libsyntax/ast.rs

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub use self::UnsafeSource::*;
1515
pub use self::ViewPath_::*;
1616
pub use self::PathParameters::*;
1717

18-
use attr::{ThinAttributes, HasAttrs};
18+
use attr::ThinAttributes;
1919
use syntax_pos::{mk_sp, Span, DUMMY_SP, ExpnId};
2020
use codemap::{respan, Spanned};
2121
use abi::Abi;
@@ -846,10 +846,6 @@ impl StmtKind {
846846
StmtKind::Mac(..) => None,
847847
}
848848
}
849-
850-
pub fn attrs(&self) -> &[Attribute] {
851-
HasAttrs::attrs(self)
852-
}
853849
}
854850

855851
#[derive(Clone, Copy, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
@@ -879,12 +875,6 @@ pub struct Local {
879875
pub attrs: ThinAttributes,
880876
}
881877

882-
impl Local {
883-
pub fn attrs(&self) -> &[Attribute] {
884-
HasAttrs::attrs(self)
885-
}
886-
}
887-
888878
pub type Decl = Spanned<DeclKind>;
889879

890880
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
@@ -895,12 +885,6 @@ pub enum DeclKind {
895885
Item(P<Item>),
896886
}
897887

898-
impl Decl {
899-
pub fn attrs(&self) -> &[Attribute] {
900-
HasAttrs::attrs(self)
901-
}
902-
}
903-
904888
/// An arm of a 'match'.
905889
///
906890
/// E.g. `0...10 => { println!("match!") }` as in
@@ -949,12 +933,6 @@ pub struct Expr {
949933
pub attrs: ThinAttributes
950934
}
951935

952-
impl Expr {
953-
pub fn attrs(&self) -> &[Attribute] {
954-
HasAttrs::attrs(self)
955-
}
956-
}
957-
958936
impl fmt::Debug for Expr {
959937
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
960938
write!(f, "expr({}: {})", self.id, pprust::expr_to_string(self))
@@ -1143,7 +1121,6 @@ pub type Mac = Spanned<Mac_>;
11431121
pub struct Mac_ {
11441122
pub path: Path,
11451123
pub tts: Vec<TokenTree>,
1146-
pub ctxt: SyntaxContext,
11471124
}
11481125

11491126
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
@@ -1916,12 +1893,6 @@ pub struct Item {
19161893
pub span: Span,
19171894
}
19181895

1919-
impl Item {
1920-
pub fn attrs(&self) -> &[Attribute] {
1921-
&self.attrs
1922-
}
1923-
}
1924-
19251896
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
19261897
pub enum ItemKind {
19271898
/// An`extern crate` item, with optional original crate name.

src/libsyntax/attr.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -882,21 +882,6 @@ pub trait HasAttrs: Sized {
882882
fn map_attrs<F: FnOnce(Vec<ast::Attribute>) -> Vec<ast::Attribute>>(self, f: F) -> Self;
883883
}
884884

885-
/// A cheap way to add Attributes to an AST node.
886-
pub trait WithAttrs {
887-
// FIXME: Could be extended to anything IntoIter<Item=Attribute>
888-
fn with_attrs(self, attrs: ThinAttributes) -> Self;
889-
}
890-
891-
impl<T: HasAttrs> WithAttrs for T {
892-
fn with_attrs(self, attrs: ThinAttributes) -> Self {
893-
self.map_attrs(|mut orig_attrs| {
894-
orig_attrs.extend(attrs.into_attr_vec());
895-
orig_attrs
896-
})
897-
}
898-
}
899-
900885
impl HasAttrs for Vec<Attribute> {
901886
fn attrs(&self) -> &[Attribute] {
902887
&self

0 commit comments

Comments
 (0)