Skip to content

Commit d30a4f4

Browse files
committed
auto merge of #5207 : erickt/rust/libsyntax-deprecated-self, r=brson
This adds an explicit `&self` to each method in libsyntax, and sets the `#[deny(deprecated_self)]` in `syntax.rc`.
2 parents 3c23589 + 690caf8 commit d30a4f4

File tree

10 files changed

+347
-291
lines changed

10 files changed

+347
-291
lines changed

src/libsyntax/codemap.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -295,12 +295,16 @@ pub impl CodeMap {
295295
}
296296

297297
/// Add a new FileMap to the CodeMap and return it
298-
fn new_filemap(+filename: FileName, src: @~str) -> @FileMap {
298+
fn new_filemap(&self, +filename: FileName, src: @~str) -> @FileMap {
299299
return self.new_filemap_w_substr(filename, FssNone, src);
300300
}
301301

302-
fn new_filemap_w_substr(+filename: FileName, +substr: FileSubstr,
303-
src: @~str) -> @FileMap {
302+
fn new_filemap_w_substr(
303+
&self,
304+
+filename: FileName,
305+
+substr: FileSubstr,
306+
src: @~str
307+
) -> @FileMap {
304308
let start_pos = if self.files.len() == 0 {
305309
0
306310
} else {

src/libsyntax/ext/auto_encode.rs

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ pub fn expand_auto_decode(
223223

224224
priv impl ext_ctxt {
225225
fn bind_path(
226+
&self,
226227
span: span,
227228
ident: ast::ident,
228229
path: @ast::path,
@@ -241,7 +242,7 @@ priv impl ext_ctxt {
241242
}
242243
}
243244

244-
fn expr(span: span, +node: ast::expr_) -> @ast::expr {
245+
fn expr(&self, span: span, +node: ast::expr_) -> @ast::expr {
245246
@ast::expr {
246247
id: self.next_id(),
247248
callee_id: self.next_id(),
@@ -250,7 +251,7 @@ priv impl ext_ctxt {
250251
}
251252
}
252253

253-
fn path(span: span, +strs: ~[ast::ident]) -> @ast::path {
254+
fn path(&self, span: span, +strs: ~[ast::ident]) -> @ast::path {
254255
@ast::path {
255256
span: span,
256257
global: false,
@@ -260,7 +261,7 @@ priv impl ext_ctxt {
260261
}
261262
}
262263

263-
fn path_global(span: span, +strs: ~[ast::ident]) -> @ast::path {
264+
fn path_global(&self, span: span, +strs: ~[ast::ident]) -> @ast::path {
264265
@ast::path {
265266
span: span,
266267
global: true,
@@ -271,6 +272,7 @@ priv impl ext_ctxt {
271272
}
272273

273274
fn path_tps(
275+
&self,
274276
span: span,
275277
+strs: ~[ast::ident],
276278
+tps: ~[@ast::Ty]
@@ -285,6 +287,7 @@ priv impl ext_ctxt {
285287
}
286288

287289
fn path_tps_global(
290+
&self,
288291
span: span,
289292
+strs: ~[ast::ident],
290293
+tps: ~[@ast::Ty]
@@ -299,6 +302,7 @@ priv impl ext_ctxt {
299302
}
300303

301304
fn ty_path(
305+
&self,
302306
span: span,
303307
+strs: ~[ast::ident],
304308
+tps: ~[@ast::Ty]
@@ -312,7 +316,7 @@ priv impl ext_ctxt {
312316
}
313317
}
314318

315-
fn binder_pat(span: span, nm: ast::ident) -> @ast::pat {
319+
fn binder_pat(&self, span: span, nm: ast::ident) -> @ast::pat {
316320
@ast::pat {
317321
id: self.next_id(),
318322
node: ast::pat_ident(
@@ -323,12 +327,12 @@ priv impl ext_ctxt {
323327
}
324328
}
325329

326-
fn stmt(expr: @ast::expr) -> @ast::stmt {
330+
fn stmt(&self, expr: @ast::expr) -> @ast::stmt {
327331
@codemap::spanned { node: ast::stmt_semi(expr, self.next_id()),
328332
span: expr.span }
329333
}
330334

331-
fn lit_str(span: span, s: @~str) -> @ast::expr {
335+
fn lit_str(&self, span: span, s: @~str) -> @ast::expr {
332336
self.expr(
333337
span,
334338
ast::expr_vstore(
@@ -340,21 +344,21 @@ priv impl ext_ctxt {
340344
ast::expr_vstore_uniq))
341345
}
342346

343-
fn lit_uint(span: span, i: uint) -> @ast::expr {
347+
fn lit_uint(&self, span: span, i: uint) -> @ast::expr {
344348
self.expr(
345349
span,
346350
ast::expr_lit(
347351
@codemap::spanned { node: ast::lit_uint(i as u64, ast::ty_u),
348352
span: span}))
349353
}
350354

351-
fn lambda(+blk: ast::blk) -> @ast::expr {
352-
let ext_cx = self;
355+
fn lambda(&self, +blk: ast::blk) -> @ast::expr {
356+
let ext_cx = *self;
353357
let blk_e = self.expr(copy blk.span, ast::expr_block(copy blk));
354358
quote_expr!( || $blk_e )
355359
}
356360

357-
fn blk(span: span, +stmts: ~[@ast::stmt]) -> ast::blk {
361+
fn blk(&self, span: span, +stmts: ~[@ast::stmt]) -> ast::blk {
358362
codemap::spanned {
359363
node: ast::blk_ {
360364
view_items: ~[],
@@ -367,7 +371,7 @@ priv impl ext_ctxt {
367371
}
368372
}
369373

370-
fn expr_blk(expr: @ast::expr) -> ast::blk {
374+
fn expr_blk(&self, expr: @ast::expr) -> ast::blk {
371375
codemap::spanned {
372376
node: ast::blk_ {
373377
view_items: ~[],
@@ -380,19 +384,24 @@ priv impl ext_ctxt {
380384
}
381385
}
382386

383-
fn expr_path(span: span, +strs: ~[ast::ident]) -> @ast::expr {
387+
fn expr_path(&self, span: span, +strs: ~[ast::ident]) -> @ast::expr {
384388
self.expr(span, ast::expr_path(self.path(span, strs)))
385389
}
386390

387-
fn expr_path_global(span: span, +strs: ~[ast::ident]) -> @ast::expr {
391+
fn expr_path_global(
392+
&self,
393+
span: span,
394+
+strs: ~[ast::ident]
395+
) -> @ast::expr {
388396
self.expr(span, ast::expr_path(self.path_global(span, strs)))
389397
}
390398

391-
fn expr_var(span: span, +var: ~str) -> @ast::expr {
399+
fn expr_var(&self, span: span, +var: ~str) -> @ast::expr {
392400
self.expr_path(span, ~[self.ident_of(var)])
393401
}
394402

395403
fn expr_field(
404+
&self,
396405
span: span,
397406
expr: @ast::expr,
398407
ident: ast::ident
@@ -401,18 +410,19 @@ priv impl ext_ctxt {
401410
}
402411

403412
fn expr_call(
413+
&self,
404414
span: span,
405415
expr: @ast::expr,
406416
+args: ~[@ast::expr]
407417
) -> @ast::expr {
408418
self.expr(span, ast::expr_call(expr, args, ast::NoSugar))
409419
}
410420

411-
fn lambda_expr(expr: @ast::expr) -> @ast::expr {
421+
fn lambda_expr(&self, expr: @ast::expr) -> @ast::expr {
412422
self.lambda(self.expr_blk(expr))
413423
}
414424

415-
fn lambda_stmts(span: span, +stmts: ~[@ast::stmt]) -> @ast::expr {
425+
fn lambda_stmts(&self, span: span, +stmts: ~[@ast::stmt]) -> @ast::expr {
416426
self.lambda(self.blk(span, stmts))
417427
}
418428
}

src/libsyntax/ext/quote.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -167,15 +167,15 @@ pub mod rt {
167167
}
168168
169169
pub trait ExtParseUtils {
170-
fn parse_item(s: ~str) -> @ast::item;
171-
fn parse_expr(s: ~str) -> @ast::expr;
172-
fn parse_stmt(s: ~str) -> @ast::stmt;
173-
fn parse_tts(s: ~str) -> ~[ast::token_tree];
170+
fn parse_item(&self, s: ~str) -> @ast::item;
171+
fn parse_expr(&self, s: ~str) -> @ast::expr;
172+
fn parse_stmt(&self, s: ~str) -> @ast::stmt;
173+
fn parse_tts(&self, s: ~str) -> ~[ast::token_tree];
174174
}
175175
176176
impl ExtParseUtils for ext_ctxt {
177177
178-
fn parse_item(s: ~str) -> @ast::item {
178+
fn parse_item(&self, s: ~str) -> @ast::item {
179179
let res = parse::parse_item_from_source_str(
180180
~"<quote expansion>",
181181
@(copy s),
@@ -191,7 +191,7 @@ pub mod rt {
191191
}
192192
}
193193

194-
fn parse_stmt(s: ~str) -> @ast::stmt {
194+
fn parse_stmt(&self, s: ~str) -> @ast::stmt {
195195
parse::parse_stmt_from_source_str(
196196
~"<quote expansion>",
197197
@(copy s),
@@ -200,15 +200,15 @@ pub mod rt {
200200
self.parse_sess())
201201
}
202202
203-
fn parse_expr(s: ~str) -> @ast::expr {
203+
fn parse_expr(&self, s: ~str) -> @ast::expr {
204204
parse::parse_expr_from_source_str(
205205
~"<quote expansion>",
206206
@(copy s),
207207
self.cfg(),
208208
self.parse_sess())
209209
}
210210
211-
fn parse_tts(s: ~str) -> ~[ast::token_tree] {
211+
fn parse_tts(&self, s: ~str) -> ~[ast::token_tree] {
212212
parse::parse_tts_from_source_str(
213213
~"<quote expansion>",
214214
@(copy s),

src/libsyntax/fold.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -900,8 +900,8 @@ impl ast_fold for AstFoldFns {
900900
}
901901

902902
pub impl ast_fold {
903-
fn fold_attributes(attrs: ~[attribute]) -> ~[attribute] {
904-
attrs.map(|x| fold_attribute_(*x, self))
903+
fn fold_attributes(&self, attrs: ~[attribute]) -> ~[attribute] {
904+
attrs.map(|x| fold_attribute_(*x, *self))
905905
}
906906
}
907907

src/libsyntax/parse/attr.rs

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,24 @@ use core::either::{Either, Left, Right};
2121

2222
// a parser that can parse attributes.
2323
pub trait parser_attr {
24-
fn parse_outer_attributes() -> ~[ast::attribute];
25-
fn parse_attribute(style: ast::attr_style) -> ast::attribute;
26-
fn parse_attribute_naked(style: ast::attr_style, lo: BytePos) ->
27-
ast::attribute;
28-
fn parse_inner_attrs_and_next() ->
24+
fn parse_outer_attributes(&self) -> ~[ast::attribute];
25+
fn parse_attribute(&self, style: ast::attr_style) -> ast::attribute;
26+
fn parse_attribute_naked(
27+
&self,
28+
style: ast::attr_style,
29+
lo: BytePos
30+
) -> ast::attribute;
31+
fn parse_inner_attrs_and_next(&self) ->
2932
(~[ast::attribute], ~[ast::attribute]);
30-
fn parse_meta_item() -> @ast::meta_item;
31-
fn parse_meta_seq() -> ~[@ast::meta_item];
32-
fn parse_optional_meta() -> ~[@ast::meta_item];
33+
fn parse_meta_item(&self) -> @ast::meta_item;
34+
fn parse_meta_seq(&self) -> ~[@ast::meta_item];
35+
fn parse_optional_meta(&self) -> ~[@ast::meta_item];
3336
}
3437

3538
impl parser_attr for Parser {
3639

3740
// Parse attributes that appear before an item
38-
fn parse_outer_attributes() -> ~[ast::attribute] {
41+
fn parse_outer_attributes(&self) -> ~[ast::attribute] {
3942
let mut attrs: ~[ast::attribute] = ~[];
4043
loop {
4144
match *self.token {
@@ -63,13 +66,13 @@ impl parser_attr for Parser {
6366
return attrs;
6467
}
6568

66-
fn parse_attribute(style: ast::attr_style) -> ast::attribute {
69+
fn parse_attribute(&self, style: ast::attr_style) -> ast::attribute {
6770
let lo = self.span.lo;
6871
self.expect(&token::POUND);
6972
return self.parse_attribute_naked(style, lo);
7073
}
7174

72-
fn parse_attribute_naked(style: ast::attr_style, lo: BytePos) ->
75+
fn parse_attribute_naked(&self, style: ast::attr_style, lo: BytePos) ->
7376
ast::attribute {
7477
self.expect(&token::LBRACKET);
7578
let meta_item = self.parse_meta_item();
@@ -89,7 +92,7 @@ impl parser_attr for Parser {
8992

9093
// you can make the 'next' field an Option, but the result is going to be
9194
// more useful as a vector.
92-
fn parse_inner_attrs_and_next() ->
95+
fn parse_inner_attrs_and_next(&self) ->
9396
(~[ast::attribute], ~[ast::attribute]) {
9497
let mut inner_attrs: ~[ast::attribute] = ~[];
9598
let mut next_outer_attrs: ~[ast::attribute] = ~[];
@@ -135,7 +138,7 @@ impl parser_attr for Parser {
135138
(inner_attrs, next_outer_attrs)
136139
}
137140

138-
fn parse_meta_item() -> @ast::meta_item {
141+
fn parse_meta_item(&self) -> @ast::meta_item {
139142
let lo = self.span.lo;
140143
let name = self.id_to_str(self.parse_ident());
141144
match *self.token {
@@ -157,7 +160,7 @@ impl parser_attr for Parser {
157160
}
158161
}
159162

160-
fn parse_meta_seq() -> ~[@ast::meta_item] {
163+
fn parse_meta_seq(&self) -> ~[@ast::meta_item] {
161164
copy self.parse_seq(
162165
&token::LPAREN,
163166
&token::RPAREN,
@@ -166,7 +169,7 @@ impl parser_attr for Parser {
166169
).node
167170
}
168171

169-
fn parse_optional_meta() -> ~[@ast::meta_item] {
172+
fn parse_optional_meta(&self) -> ~[@ast::meta_item] {
170173
match *self.token {
171174
token::LPAREN => self.parse_meta_seq(),
172175
_ => ~[]

0 commit comments

Comments
 (0)