Skip to content

Commit b9d9157

Browse files
committed
libsyntax: add &self to extensions
1 parent 4a73426 commit b9d9157

File tree

2 files changed

+34
-24
lines changed

2 files changed

+34
-24
lines changed

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),

0 commit comments

Comments
 (0)