Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

disable deprecated_self in libsyntax #5207

Merged
merged 3 commits into from
Mar 4, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/libsyntax/codemap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,12 +295,16 @@ pub impl CodeMap {
}

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

fn new_filemap_w_substr(+filename: FileName, +substr: FileSubstr,
src: @~str) -> @FileMap {
fn new_filemap_w_substr(
&self,
+filename: FileName,
+substr: FileSubstr,
src: @~str
) -> @FileMap {
let start_pos = if self.files.len() == 0 {
0
} else {
Expand Down
42 changes: 26 additions & 16 deletions src/libsyntax/ext/auto_encode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ pub fn expand_auto_decode(

priv impl ext_ctxt {
fn bind_path(
&self,
span: span,
ident: ast::ident,
path: @ast::path,
Expand All @@ -241,7 +242,7 @@ priv impl ext_ctxt {
}
}

fn expr(span: span, +node: ast::expr_) -> @ast::expr {
fn expr(&self, span: span, +node: ast::expr_) -> @ast::expr {
@ast::expr {
id: self.next_id(),
callee_id: self.next_id(),
Expand All @@ -250,7 +251,7 @@ priv impl ext_ctxt {
}
}

fn path(span: span, +strs: ~[ast::ident]) -> @ast::path {
fn path(&self, span: span, +strs: ~[ast::ident]) -> @ast::path {
@ast::path {
span: span,
global: false,
Expand All @@ -260,7 +261,7 @@ priv impl ext_ctxt {
}
}

fn path_global(span: span, +strs: ~[ast::ident]) -> @ast::path {
fn path_global(&self, span: span, +strs: ~[ast::ident]) -> @ast::path {
@ast::path {
span: span,
global: true,
Expand All @@ -271,6 +272,7 @@ priv impl ext_ctxt {
}

fn path_tps(
&self,
span: span,
+strs: ~[ast::ident],
+tps: ~[@ast::Ty]
Expand All @@ -285,6 +287,7 @@ priv impl ext_ctxt {
}

fn path_tps_global(
&self,
span: span,
+strs: ~[ast::ident],
+tps: ~[@ast::Ty]
Expand All @@ -299,6 +302,7 @@ priv impl ext_ctxt {
}

fn ty_path(
&self,
span: span,
+strs: ~[ast::ident],
+tps: ~[@ast::Ty]
Expand All @@ -312,7 +316,7 @@ priv impl ext_ctxt {
}
}

fn binder_pat(span: span, nm: ast::ident) -> @ast::pat {
fn binder_pat(&self, span: span, nm: ast::ident) -> @ast::pat {
@ast::pat {
id: self.next_id(),
node: ast::pat_ident(
Expand All @@ -323,12 +327,12 @@ priv impl ext_ctxt {
}
}

fn stmt(expr: @ast::expr) -> @ast::stmt {
fn stmt(&self, expr: @ast::expr) -> @ast::stmt {
@codemap::spanned { node: ast::stmt_semi(expr, self.next_id()),
span: expr.span }
}

fn lit_str(span: span, s: @~str) -> @ast::expr {
fn lit_str(&self, span: span, s: @~str) -> @ast::expr {
self.expr(
span,
ast::expr_vstore(
Expand All @@ -340,21 +344,21 @@ priv impl ext_ctxt {
ast::expr_vstore_uniq))
}

fn lit_uint(span: span, i: uint) -> @ast::expr {
fn lit_uint(&self, span: span, i: uint) -> @ast::expr {
self.expr(
span,
ast::expr_lit(
@codemap::spanned { node: ast::lit_uint(i as u64, ast::ty_u),
span: span}))
}

fn lambda(+blk: ast::blk) -> @ast::expr {
let ext_cx = self;
fn lambda(&self, +blk: ast::blk) -> @ast::expr {
let ext_cx = *self;
let blk_e = self.expr(copy blk.span, ast::expr_block(copy blk));
quote_expr!( || $blk_e )
}

fn blk(span: span, +stmts: ~[@ast::stmt]) -> ast::blk {
fn blk(&self, span: span, +stmts: ~[@ast::stmt]) -> ast::blk {
codemap::spanned {
node: ast::blk_ {
view_items: ~[],
Expand All @@ -367,7 +371,7 @@ priv impl ext_ctxt {
}
}

fn expr_blk(expr: @ast::expr) -> ast::blk {
fn expr_blk(&self, expr: @ast::expr) -> ast::blk {
codemap::spanned {
node: ast::blk_ {
view_items: ~[],
Expand All @@ -380,19 +384,24 @@ priv impl ext_ctxt {
}
}

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

fn expr_path_global(span: span, +strs: ~[ast::ident]) -> @ast::expr {
fn expr_path_global(
&self,
span: span,
+strs: ~[ast::ident]
) -> @ast::expr {
self.expr(span, ast::expr_path(self.path_global(span, strs)))
}

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

fn expr_field(
&self,
span: span,
expr: @ast::expr,
ident: ast::ident
Expand All @@ -401,18 +410,19 @@ priv impl ext_ctxt {
}

fn expr_call(
&self,
span: span,
expr: @ast::expr,
+args: ~[@ast::expr]
) -> @ast::expr {
self.expr(span, ast::expr_call(expr, args, ast::NoSugar))
}

fn lambda_expr(expr: @ast::expr) -> @ast::expr {
fn lambda_expr(&self, expr: @ast::expr) -> @ast::expr {
self.lambda(self.expr_blk(expr))
}

fn lambda_stmts(span: span, +stmts: ~[@ast::stmt]) -> @ast::expr {
fn lambda_stmts(&self, span: span, +stmts: ~[@ast::stmt]) -> @ast::expr {
self.lambda(self.blk(span, stmts))
}
}
Expand Down
16 changes: 8 additions & 8 deletions src/libsyntax/ext/quote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,15 @@ pub mod rt {
}

pub trait ExtParseUtils {
fn parse_item(s: ~str) -> @ast::item;
fn parse_expr(s: ~str) -> @ast::expr;
fn parse_stmt(s: ~str) -> @ast::stmt;
fn parse_tts(s: ~str) -> ~[ast::token_tree];
fn parse_item(&self, s: ~str) -> @ast::item;
fn parse_expr(&self, s: ~str) -> @ast::expr;
fn parse_stmt(&self, s: ~str) -> @ast::stmt;
fn parse_tts(&self, s: ~str) -> ~[ast::token_tree];
}

impl ExtParseUtils for ext_ctxt {

fn parse_item(s: ~str) -> @ast::item {
fn parse_item(&self, s: ~str) -> @ast::item {
let res = parse::parse_item_from_source_str(
~"<quote expansion>",
@(copy s),
Expand All @@ -191,7 +191,7 @@ pub mod rt {
}
}

fn parse_stmt(s: ~str) -> @ast::stmt {
fn parse_stmt(&self, s: ~str) -> @ast::stmt {
parse::parse_stmt_from_source_str(
~"<quote expansion>",
@(copy s),
Expand All @@ -200,15 +200,15 @@ pub mod rt {
self.parse_sess())
}

fn parse_expr(s: ~str) -> @ast::expr {
fn parse_expr(&self, s: ~str) -> @ast::expr {
parse::parse_expr_from_source_str(
~"<quote expansion>",
@(copy s),
self.cfg(),
self.parse_sess())
}

fn parse_tts(s: ~str) -> ~[ast::token_tree] {
fn parse_tts(&self, s: ~str) -> ~[ast::token_tree] {
parse::parse_tts_from_source_str(
~"<quote expansion>",
@(copy s),
Expand Down
4 changes: 2 additions & 2 deletions src/libsyntax/fold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -900,8 +900,8 @@ impl ast_fold for AstFoldFns {
}

pub impl ast_fold {
fn fold_attributes(attrs: ~[attribute]) -> ~[attribute] {
attrs.map(|x| fold_attribute_(*x, self))
fn fold_attributes(&self, attrs: ~[attribute]) -> ~[attribute] {
attrs.map(|x| fold_attribute_(*x, *self))
}
}

Expand Down
33 changes: 18 additions & 15 deletions src/libsyntax/parse/attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,24 @@ use core::either::{Either, Left, Right};

// a parser that can parse attributes.
pub trait parser_attr {
fn parse_outer_attributes() -> ~[ast::attribute];
fn parse_attribute(style: ast::attr_style) -> ast::attribute;
fn parse_attribute_naked(style: ast::attr_style, lo: BytePos) ->
ast::attribute;
fn parse_inner_attrs_and_next() ->
fn parse_outer_attributes(&self) -> ~[ast::attribute];
fn parse_attribute(&self, style: ast::attr_style) -> ast::attribute;
fn parse_attribute_naked(
&self,
style: ast::attr_style,
lo: BytePos
) -> ast::attribute;
fn parse_inner_attrs_and_next(&self) ->
(~[ast::attribute], ~[ast::attribute]);
fn parse_meta_item() -> @ast::meta_item;
fn parse_meta_seq() -> ~[@ast::meta_item];
fn parse_optional_meta() -> ~[@ast::meta_item];
fn parse_meta_item(&self) -> @ast::meta_item;
fn parse_meta_seq(&self) -> ~[@ast::meta_item];
fn parse_optional_meta(&self) -> ~[@ast::meta_item];
}

impl parser_attr for Parser {

// Parse attributes that appear before an item
fn parse_outer_attributes() -> ~[ast::attribute] {
fn parse_outer_attributes(&self) -> ~[ast::attribute] {
let mut attrs: ~[ast::attribute] = ~[];
loop {
match *self.token {
Expand Down Expand Up @@ -63,13 +66,13 @@ impl parser_attr for Parser {
return attrs;
}

fn parse_attribute(style: ast::attr_style) -> ast::attribute {
fn parse_attribute(&self, style: ast::attr_style) -> ast::attribute {
let lo = self.span.lo;
self.expect(&token::POUND);
return self.parse_attribute_naked(style, lo);
}

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

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

fn parse_meta_item() -> @ast::meta_item {
fn parse_meta_item(&self) -> @ast::meta_item {
let lo = self.span.lo;
let name = self.id_to_str(self.parse_ident());
match *self.token {
Expand All @@ -157,7 +160,7 @@ impl parser_attr for Parser {
}
}

fn parse_meta_seq() -> ~[@ast::meta_item] {
fn parse_meta_seq(&self) -> ~[@ast::meta_item] {
copy self.parse_seq(
&token::LPAREN,
&token::RPAREN,
Expand All @@ -166,7 +169,7 @@ impl parser_attr for Parser {
).node
}

fn parse_optional_meta() -> ~[@ast::meta_item] {
fn parse_optional_meta(&self) -> ~[@ast::meta_item] {
match *self.token {
token::LPAREN => self.parse_meta_seq(),
_ => ~[]
Expand Down
Loading