1
Fork 0

rustc: rename ast::self_ty and related fields to explicit_self

This commit is contained in:
Erick Tryzelaar 2013-04-30 08:49:48 -07:00
parent 70e02cf445
commit 18f6a51d0a
38 changed files with 184 additions and 184 deletions

View file

@ -100,7 +100,7 @@ pub static tag_mod_impl_trait: uint = 0x47u;
different tags. different tags.
*/ */
pub static tag_item_impl_method: uint = 0x48u; pub static tag_item_impl_method: uint = 0x48u;
pub static tag_item_trait_method_self_ty: uint = 0x4b; pub static tag_item_trait_method_explicit_self: uint = 0x4b;
pub static tag_item_trait_method_self_ty_region: uint = 0x4c; pub static tag_item_trait_method_self_ty_region: uint = 0x4c;

View file

@ -135,11 +135,12 @@ pub fn get_method(tcx: ty::ctxt,
decoder::get_method(tcx.cstore.intr, cdata, def.node, tcx) decoder::get_method(tcx.cstore.intr, cdata, def.node, tcx)
} }
pub fn get_method_name_and_self_ty(cstore: @mut cstore::CStore, pub fn get_method_name_and_explicit_self(cstore: @mut cstore::CStore,
def: ast::def_id) -> (ast::ident, ast::self_ty_) def: ast::def_id)
-> (ast::ident, ast::explicit_self_)
{ {
let cdata = cstore::get_crate_data(cstore, def.crate); let cdata = cstore::get_crate_data(cstore, def.crate);
decoder::get_method_name_and_self_ty(cstore.intr, cdata, def.node) decoder::get_method_name_and_explicit_self(cstore.intr, cdata, def.node)
} }
pub fn get_trait_method_def_ids(cstore: @mut cstore::CStore, pub fn get_trait_method_def_ids(cstore: @mut cstore::CStore,

View file

@ -670,7 +670,7 @@ pub fn get_enum_variants(intr: @ident_interner, cdata: cmd, id: ast::node_id,
return infos; return infos;
} }
fn get_self_ty(item: ebml::Doc) -> ast::self_ty_ { fn get_explicit_self(item: ebml::Doc) -> ast::explicit_self_ {
fn get_mutability(ch: u8) -> ast::mutability { fn get_mutability(ch: u8) -> ast::mutability {
match ch as char { match ch as char {
'i' => { ast::m_imm } 'i' => { ast::m_imm }
@ -682,11 +682,11 @@ fn get_self_ty(item: ebml::Doc) -> ast::self_ty_ {
} }
} }
let self_type_doc = reader::get_doc(item, tag_item_trait_method_self_ty); let explicit_self_doc = reader::get_doc(item, tag_item_trait_method_explicit_self);
let string = reader::doc_as_str(self_type_doc); let string = reader::doc_as_str(explicit_self_doc);
let self_ty_kind = string[0]; let explicit_self_kind = string[0];
match self_ty_kind as char { match explicit_self_kind as char {
's' => { return ast::sty_static; } 's' => { return ast::sty_static; }
'v' => { return ast::sty_value; } 'v' => { return ast::sty_value; }
'@' => { return ast::sty_box(get_mutability(string[1])); } '@' => { return ast::sty_box(get_mutability(string[1])); }
@ -696,7 +696,7 @@ fn get_self_ty(item: ebml::Doc) -> ast::self_ty_ {
return ast::sty_region(None, get_mutability(string[1])); return ast::sty_region(None, get_mutability(string[1]));
} }
_ => { _ => {
fail!("unknown self type code: `%c`", self_ty_kind as char); fail!("unknown self type code: `%c`", explicit_self_kind as char);
} }
} }
} }
@ -707,12 +707,12 @@ fn item_impl_methods(intr: @ident_interner, cdata: cmd, item: ebml::Doc,
for reader::tagged_docs(item, tag_item_impl_method) |doc| { for reader::tagged_docs(item, tag_item_impl_method) |doc| {
let m_did = reader::with_doc_data(doc, |d| parse_def_id(d)); let m_did = reader::with_doc_data(doc, |d| parse_def_id(d));
let mth_item = lookup_item(m_did.node, cdata.data); let mth_item = lookup_item(m_did.node, cdata.data);
let self_ty = get_self_ty(mth_item); let explicit_self = get_explicit_self(mth_item);
rslt.push(@resolve::MethodInfo { rslt.push(@resolve::MethodInfo {
did: translate_def_id(cdata, m_did), did: translate_def_id(cdata, m_did),
n_tps: item_ty_param_count(mth_item) - base_tps, n_tps: item_ty_param_count(mth_item) - base_tps,
ident: item_name(intr, mth_item), ident: item_name(intr, mth_item),
self_type: self_ty}); explicit_self: explicit_self});
} }
rslt rslt
} }
@ -748,15 +748,15 @@ pub fn get_impls_for_mod(intr: @ident_interner,
@result @result
} }
pub fn get_method_name_and_self_ty( pub fn get_method_name_and_explicit_self(
intr: @ident_interner, intr: @ident_interner,
cdata: cmd, cdata: cmd,
id: ast::node_id) -> (ast::ident, ast::self_ty_) id: ast::node_id) -> (ast::ident, ast::explicit_self_)
{ {
let method_doc = lookup_item(id, cdata.data); let method_doc = lookup_item(id, cdata.data);
let name = item_name(intr, method_doc); let name = item_name(intr, method_doc);
let self_ty = get_self_ty(method_doc); let explicit_self = get_explicit_self(method_doc);
(name, self_ty) (name, explicit_self)
} }
pub fn get_method(intr: @ident_interner, cdata: cmd, id: ast::node_id, pub fn get_method(intr: @ident_interner, cdata: cmd, id: ast::node_id,
@ -770,7 +770,7 @@ pub fn get_method(intr: @ident_interner, cdata: cmd, id: ast::node_id,
let transformed_self_ty = doc_transformed_self_ty(method_doc, tcx, cdata); let transformed_self_ty = doc_transformed_self_ty(method_doc, tcx, cdata);
let fty = doc_method_fty(method_doc, tcx, cdata); let fty = doc_method_fty(method_doc, tcx, cdata);
let vis = item_visibility(method_doc); let vis = item_visibility(method_doc);
let self_ty = get_self_ty(method_doc); let explicit_self = get_explicit_self(method_doc);
ty::method { ty::method {
ident: name, ident: name,
generics: ty::Generics { generics: ty::Generics {
@ -779,7 +779,7 @@ pub fn get_method(intr: @ident_interner, cdata: cmd, id: ast::node_id,
}, },
transformed_self_ty: transformed_self_ty, transformed_self_ty: transformed_self_ty,
fty: fty, fty: fty,
self_ty: self_ty, explicit_self: explicit_self,
vis: vis, vis: vis,
def_id: def_id def_id: def_id
} }
@ -823,7 +823,7 @@ pub fn get_provided_trait_methods(intr: @ident_interner, cdata: cmd,
}; };
let transformed_self_ty = doc_transformed_self_ty(mth, tcx, cdata); let transformed_self_ty = doc_transformed_self_ty(mth, tcx, cdata);
let self_ty = get_self_ty(mth); let explicit_self = get_explicit_self(mth);
let ty_method = ty::method { let ty_method = ty::method {
ident: name, ident: name,
generics: ty::Generics { generics: ty::Generics {
@ -832,7 +832,7 @@ pub fn get_provided_trait_methods(intr: @ident_interner, cdata: cmd,
}, },
transformed_self_ty: transformed_self_ty, transformed_self_ty: transformed_self_ty,
fty: fty, fty: fty,
self_ty: self_ty, explicit_self: explicit_self,
vis: ast::public, vis: ast::public,
def_id: did def_id: did
}; };

View file

@ -389,7 +389,7 @@ fn encode_reexported_static_methods(ecx: @EncodeContext,
Some(&ast_map::node_item(_, path)) => { Some(&ast_map::node_item(_, path)) => {
if mod_path != *path { if mod_path != *path {
for methods.each |&m| { for methods.each |&m| {
if m.self_ty == ast::sty_static { if m.explicit_self == ast::sty_static {
encode_reexported_static_method(ecx, encode_reexported_static_method(ecx,
ebml_w, ebml_w,
exp, m); exp, m);
@ -486,11 +486,11 @@ fn encode_visibility(ebml_w: &mut writer::Encoder, visibility: visibility) {
ebml_w.end_tag(); ebml_w.end_tag();
} }
fn encode_self_type(ebml_w: &mut writer::Encoder, self_type: ast::self_ty_) { fn encode_explicit_self(ebml_w: &mut writer::Encoder, explicit_self: ast::explicit_self_) {
ebml_w.start_tag(tag_item_trait_method_self_ty); ebml_w.start_tag(tag_item_trait_method_explicit_self);
// Encode the base self type. // Encode the base self type.
match self_type { match explicit_self {
sty_static => { sty_static => {
ebml_w.writer.write(&[ 's' as u8 ]); ebml_w.writer.write(&[ 's' as u8 ]);
} }
@ -634,7 +634,7 @@ fn encode_method_ty_fields(ecx: @EncodeContext,
encode_transformed_self_ty(ecx, ebml_w, method_ty.transformed_self_ty); encode_transformed_self_ty(ecx, ebml_w, method_ty.transformed_self_ty);
encode_method_fty(ecx, ebml_w, &method_ty.fty); encode_method_fty(ecx, ebml_w, &method_ty.fty);
encode_visibility(ebml_w, method_ty.vis); encode_visibility(ebml_w, method_ty.vis);
encode_self_type(ebml_w, method_ty.self_ty); encode_explicit_self(ebml_w, method_ty.explicit_self);
} }
fn encode_info_for_method(ecx: @EncodeContext, fn encode_info_for_method(ecx: @EncodeContext,
@ -655,7 +655,7 @@ fn encode_info_for_method(ecx: @EncodeContext,
let method_ty: @ty::method = ty::method(ecx.tcx, method_def_id); let method_ty: @ty::method = ty::method(ecx.tcx, method_def_id);
encode_method_ty_fields(ecx, ebml_w, method_ty); encode_method_ty_fields(ecx, ebml_w, method_ty);
match m.self_ty.node { match m.explicit_self.node {
ast::sty_static => { ast::sty_static => {
encode_family(ebml_w, purity_static_method_family(m.purity)); encode_family(ebml_w, purity_static_method_family(m.purity));
} }
@ -962,7 +962,7 @@ fn encode_info_for_item(ecx: @EncodeContext,
trait_path.push(ast_map::path_name(item.ident)); trait_path.push(ast_map::path_name(item.ident));
encode_path(ecx, ebml_w, trait_path, ast_map::path_name(method_ty.ident)); encode_path(ecx, ebml_w, trait_path, ast_map::path_name(method_ty.ident));
match method_ty.self_ty { match method_ty.explicit_self {
sty_static => { sty_static => {
encode_family(ebml_w, encode_family(ebml_w,
purity_static_method_family( purity_static_method_family(
@ -991,7 +991,7 @@ fn encode_info_for_item(ecx: @EncodeContext,
// This is obviously a bogus assert but I don't think this // This is obviously a bogus assert but I don't think this
// ever worked before anyhow...near as I can tell, before // ever worked before anyhow...near as I can tell, before
// we would emit two items. // we would emit two items.
if method_ty.self_ty == sty_static { if method_ty.explicit_self == sty_static {
tcx.sess.span_unimpl( tcx.sess.span_unimpl(
item.span, item.span,
fmt!("Method %s is both provided and static", fmt!("Method %s is both provided and static",

View file

@ -552,8 +552,8 @@ impl read_method_map_entry_helper for reader::Decoder {
explicit_self: this.read_struct_field("explicit_self", explicit_self: this.read_struct_field("explicit_self",
2, 2,
|this| { |this| {
let self_type: ast::self_ty_ = Decodable::decode(this); let explicit_self: ast::explicit_self_ = Decodable::decode(this);
self_type explicit_self
}), }),
origin: this.read_struct_field("origin", 1, |this| { origin: this.read_struct_field("origin", 1, |this| {
let method_origin: method_origin = let method_origin: method_origin =

View file

@ -381,7 +381,7 @@ fn visit_fn(fk: &visit::fn_kind,
// Add `this`, whether explicit or implicit. // Add `this`, whether explicit or implicit.
match *fk { match *fk {
fk_method(_, _, method) => { fk_method(_, _, method) => {
match method.self_ty.node { match method.explicit_self.node {
sty_value | sty_region(*) | sty_box(_) | sty_uniq(_) => { sty_value | sty_region(*) | sty_box(_) | sty_uniq(_) => {
fn_maps.add_variable(Arg(method.self_id, fn_maps.add_variable(Arg(method.self_id,
special_idents::self_)); special_idents::self_));

View file

@ -10,7 +10,7 @@
use driver::session::Session; use driver::session::Session;
use metadata::csearch::{each_path, get_trait_method_def_ids}; use metadata::csearch::{each_path, get_trait_method_def_ids};
use metadata::csearch::get_method_name_and_self_ty; use metadata::csearch::get_method_name_and_explicit_self;
use metadata::csearch::get_static_methods_if_impl; use metadata::csearch::get_static_methods_if_impl;
use metadata::csearch::get_type_name_if_impl; use metadata::csearch::get_type_name_if_impl;
use metadata::cstore::find_extern_mod_stmt_cnum; use metadata::cstore::find_extern_mod_stmt_cnum;
@ -28,7 +28,7 @@ use syntax::ast::{def_const, def_foreign_mod, def_fn, def_id, def_label};
use syntax::ast::{def_local, def_mod, def_prim_ty, def_region, def_self}; use syntax::ast::{def_local, def_mod, def_prim_ty, def_region, def_self};
use syntax::ast::{def_self_ty, def_static_method, def_struct, def_ty}; use syntax::ast::{def_self_ty, def_static_method, def_struct, def_ty};
use syntax::ast::{def_ty_param, def_typaram_binder, def_trait}; use syntax::ast::{def_ty_param, def_typaram_binder, def_trait};
use syntax::ast::{def_upvar, def_use, def_variant, expr, expr_assign_op}; use syntax::ast::{def_upvar, def_use, def_variant, explicit_self_, expr, expr_assign_op};
use syntax::ast::{expr_binary, expr_break, expr_field}; use syntax::ast::{expr_binary, expr_break, expr_field};
use syntax::ast::{expr_fn_block, expr_index, expr_method_call, expr_path}; use syntax::ast::{expr_fn_block, expr_index, expr_method_call, expr_path};
use syntax::ast::{def_prim_ty, def_region, def_self, def_ty, def_ty_param}; use syntax::ast::{def_prim_ty, def_region, def_self, def_ty, def_ty_param};
@ -45,7 +45,7 @@ use syntax::ast::{local, local_crate, lt, method, mul};
use syntax::ast::{named_field, ne, neg, node_id, pat, pat_enum, pat_ident}; use syntax::ast::{named_field, ne, neg, node_id, pat, pat_enum, pat_ident};
use syntax::ast::{Path, pat_lit, pat_range, pat_struct}; use syntax::ast::{Path, pat_lit, pat_range, pat_struct};
use syntax::ast::{prim_ty, private, provided}; use syntax::ast::{prim_ty, private, provided};
use syntax::ast::{public, required, rem, self_ty_, shl, shr, stmt_decl}; use syntax::ast::{public, required, rem, shl, shr, stmt_decl};
use syntax::ast::{struct_field, struct_variant_kind}; use syntax::ast::{struct_field, struct_variant_kind};
use syntax::ast::{sty_static, subtract, trait_ref, tuple_variant_kind, Ty}; use syntax::ast::{sty_static, subtract, trait_ref, tuple_variant_kind, Ty};
use syntax::ast::{ty_bool, ty_char, ty_f, ty_f32, ty_f64, ty_float, ty_i}; use syntax::ast::{ty_bool, ty_char, ty_f, ty_f32, ty_f64, ty_float, ty_i};
@ -96,7 +96,7 @@ pub struct MethodInfo {
did: def_id, did: def_id,
n_tps: uint, n_tps: uint,
ident: ident, ident: ident,
self_type: self_ty_ explicit_self: explicit_self_
} }
pub struct Impl { pub struct Impl {
@ -1203,7 +1203,7 @@ pub impl Resolver {
// Bail out early if there are no static methods. // Bail out early if there are no static methods.
let mut has_static_methods = false; let mut has_static_methods = false;
for methods.each |method| { for methods.each |method| {
match method.self_ty.node { match method.explicit_self.node {
sty_static => has_static_methods = true, sty_static => has_static_methods = true,
_ => {} _ => {}
} }
@ -1236,7 +1236,7 @@ pub impl Resolver {
// For each static method... // For each static method...
for methods.each |method| { for methods.each |method| {
match method.self_ty.node { match method.explicit_self.node {
sty_static => { sty_static => {
// Add the static method to the // Add the static method to the
// module. // module.
@ -1274,7 +1274,7 @@ pub impl Resolver {
let mut has_static_methods = false; let mut has_static_methods = false;
for (*methods).each |method| { for (*methods).each |method| {
let ty_m = trait_method_to_ty_method(method); let ty_m = trait_method_to_ty_method(method);
match ty_m.self_ty.node { match ty_m.explicit_self.node {
sty_static => { sty_static => {
has_static_methods = true; has_static_methods = true;
break; break;
@ -1306,7 +1306,7 @@ pub impl Resolver {
let ident = ty_m.ident; let ident = ty_m.ident;
// Add it to the trait info if not static, // Add it to the trait info if not static,
// add it as a name in the trait module otherwise. // add it as a name in the trait module otherwise.
match ty_m.self_ty.node { match ty_m.explicit_self.node {
sty_static => { sty_static => {
let def = def_static_method( let def = def_static_method(
local_def(ty_m.id), local_def(ty_m.id),
@ -1612,9 +1612,9 @@ pub impl Resolver {
def_id); def_id);
let mut interned_method_names = HashSet::new(); let mut interned_method_names = HashSet::new();
for method_def_ids.each |&method_def_id| { for method_def_ids.each |&method_def_id| {
let (method_name, self_ty) = let (method_name, explicit_self) =
get_method_name_and_self_ty(self.session.cstore, get_method_name_and_explicit_self(self.session.cstore,
method_def_id); method_def_id);
debug!("(building reduced graph for \ debug!("(building reduced graph for \
external crate) ... adding \ external crate) ... adding \
@ -1622,7 +1622,7 @@ pub impl Resolver {
*self.session.str_of(method_name)); *self.session.str_of(method_name));
// Add it to the trait info if not static. // Add it to the trait info if not static.
if self_ty != sty_static { if explicit_self != sty_static {
interned_method_names.insert(method_name); interned_method_names.insert(method_name);
} }
} }
@ -3774,7 +3774,7 @@ pub impl Resolver {
outer_type_parameter_count, outer_type_parameter_count,
rib_kind); rib_kind);
// we only have self ty if it is a non static method // we only have self ty if it is a non static method
let self_binding = match method.self_ty.node { let self_binding = match method.explicit_self.node {
sty_static => { NoSelfBinding } sty_static => { NoSelfBinding }
_ => { HasSelfBinding(method.self_id, false) } _ => { HasSelfBinding(method.self_id, false) }
}; };

View file

@ -11,7 +11,7 @@
use driver::session; use driver::session;
use driver::session::Session; use driver::session::Session;
use metadata::csearch::{each_path, get_trait_method_def_ids}; use metadata::csearch::{each_path, get_trait_method_def_ids};
use metadata::csearch::get_method_name_and_self_ty; use metadata::csearch::get_method_name_and_explicit_self;
use metadata::csearch::get_static_methods_if_impl; use metadata::csearch::get_static_methods_if_impl;
use metadata::csearch::get_type_name_if_impl; use metadata::csearch::get_type_name_if_impl;
use metadata::cstore::find_extern_mod_stmt_cnum; use metadata::cstore::find_extern_mod_stmt_cnum;
@ -46,7 +46,7 @@ use syntax::ast::{local, local_crate, lt, method, mul};
use syntax::ast::{named_field, ne, neg, node_id, pat, pat_enum, pat_ident}; use syntax::ast::{named_field, ne, neg, node_id, pat, pat_enum, pat_ident};
use syntax::ast::{Path, pat_lit, pat_range, pat_struct}; use syntax::ast::{Path, pat_lit, pat_range, pat_struct};
use syntax::ast::{prim_ty, private, provided}; use syntax::ast::{prim_ty, private, provided};
use syntax::ast::{public, required, rem, self_ty_, shl, shr, stmt_decl}; use syntax::ast::{public, required, rem, explicit_self_, shl, shr, stmt_decl};
use syntax::ast::{struct_field, struct_variant_kind}; use syntax::ast::{struct_field, struct_variant_kind};
use syntax::ast::{sty_static, subtract, trait_ref, tuple_variant_kind, Ty}; use syntax::ast::{sty_static, subtract, trait_ref, tuple_variant_kind, Ty};
use syntax::ast::{ty_bool, ty_char, ty_f, ty_f32, ty_f64, ty_float, ty_i}; use syntax::ast::{ty_bool, ty_char, ty_f, ty_f32, ty_f64, ty_float, ty_i};
@ -97,7 +97,7 @@ pub struct MethodInfo {
did: def_id, did: def_id,
n_tps: uint, n_tps: uint,
ident: ident, ident: ident,
self_type: self_ty_ explicit_self: explicit_self_
} }
pub struct Impl { pub struct Impl {
@ -1219,7 +1219,7 @@ pub impl Resolver {
// Bail out early if there are no static methods. // Bail out early if there are no static methods.
let mut has_static_methods = false; let mut has_static_methods = false;
for methods.each |method| { for methods.each |method| {
match method.self_ty.node { match method.explicit_self.node {
sty_static => has_static_methods = true, sty_static => has_static_methods = true,
_ => {} _ => {}
} }
@ -1252,7 +1252,7 @@ pub impl Resolver {
// For each static method... // For each static method...
for methods.each |method| { for methods.each |method| {
match method.self_ty.node { match method.explicit_self.node {
sty_static => { sty_static => {
// Add the static method to the // Add the static method to the
// module. // module.
@ -1290,7 +1290,7 @@ pub impl Resolver {
let mut has_static_methods = false; let mut has_static_methods = false;
for (*methods).each |method| { for (*methods).each |method| {
let ty_m = trait_method_to_ty_method(method); let ty_m = trait_method_to_ty_method(method);
match ty_m.self_ty.node { match ty_m.explicit_self.node {
sty_static => { sty_static => {
has_static_methods = true; has_static_methods = true;
break; break;
@ -1322,7 +1322,7 @@ pub impl Resolver {
let ident = ty_m.ident; let ident = ty_m.ident;
// Add it to the trait info if not static, // Add it to the trait info if not static,
// add it as a name in the trait module otherwise. // add it as a name in the trait module otherwise.
match ty_m.self_ty.node { match ty_m.explicit_self.node {
sty_static => { sty_static => {
let def = def_static_method( let def = def_static_method(
local_def(ty_m.id), local_def(ty_m.id),
@ -1628,9 +1628,9 @@ pub impl Resolver {
def_id); def_id);
let mut interned_method_names = HashSet::new(); let mut interned_method_names = HashSet::new();
for method_def_ids.each |&method_def_id| { for method_def_ids.each |&method_def_id| {
let (method_name, self_ty) = let (method_name, explicit_self) =
get_method_name_and_self_ty(self.session.cstore, get_method_name_and_explicit_self(self.session.cstore,
method_def_id); method_def_id);
debug!("(building reduced graph for \ debug!("(building reduced graph for \
external crate) ... adding \ external crate) ... adding \
@ -1638,7 +1638,7 @@ pub impl Resolver {
*self.session.str_of(method_name)); *self.session.str_of(method_name));
// Add it to the trait info if not static. // Add it to the trait info if not static.
if self_ty != sty_static { if explicit_self != sty_static {
interned_method_names.insert(method_name); interned_method_names.insert(method_name);
} }
} }
@ -3800,7 +3800,7 @@ pub impl Resolver {
outer_type_parameter_count, outer_type_parameter_count,
rib_kind); rib_kind);
// we only have self ty if it is a non static method // we only have self ty if it is a non static method
let self_binding = match method.self_ty.node { let self_binding = match method.explicit_self.node {
sty_static => { NoSelfBinding } sty_static => { NoSelfBinding }
_ => { HasSelfBinding(method.self_id, false) } _ => { HasSelfBinding(method.self_id, false) }
}; };

View file

@ -99,14 +99,14 @@ pub fn maybe_instantiate_inline(ccx: @CrateContext, fn_id: ast::def_id,
let path = vec::append( let path = vec::append(
ty::item_path(ccx.tcx, impl_did), ty::item_path(ccx.tcx, impl_did),
~[path_name(mth.ident)]); ~[path_name(mth.ident)]);
let self_kind = match mth.self_ty.node { let self_kind = match mth.explicit_self.node {
ast::sty_static => no_self, ast::sty_static => no_self,
_ => { _ => {
let self_ty = ty::node_id_to_type(ccx.tcx, let self_ty = ty::node_id_to_type(ccx.tcx,
mth.self_id); mth.self_id);
debug!("calling inline trans_fn with self_ty %s", debug!("calling inline trans_fn with self_ty %s",
ty_to_str(ccx.tcx, self_ty)); ty_to_str(ccx.tcx, self_ty));
match mth.self_ty.node { match mth.explicit_self.node {
ast::sty_value => impl_owned_self(self_ty), ast::sty_value => impl_owned_self(self_ty),
_ => impl_self(self_ty), _ => impl_self(self_ty),
} }

View file

@ -103,7 +103,7 @@ pub fn trans_method(ccx: @CrateContext,
llfn: ValueRef, llfn: ValueRef,
impl_id: ast::def_id) { impl_id: ast::def_id) {
// figure out how self is being passed // figure out how self is being passed
let self_arg = match method.self_ty.node { let self_arg = match method.explicit_self.node {
ast::sty_static => { ast::sty_static => {
no_self no_self
} }
@ -123,7 +123,7 @@ pub fn trans_method(ccx: @CrateContext,
debug!("calling trans_fn with base_self_ty %s, self_ty %s", debug!("calling trans_fn with base_self_ty %s, self_ty %s",
base_self_ty.repr(ccx.tcx), base_self_ty.repr(ccx.tcx),
self_ty.repr(ccx.tcx)); self_ty.repr(ccx.tcx));
match method.self_ty.node { match method.explicit_self.node {
ast::sty_value => { ast::sty_value => {
impl_owned_self(self_ty) impl_owned_self(self_ty)
} }
@ -590,7 +590,7 @@ pub fn trans_trait_callee(bcx: block,
n_method: uint, n_method: uint,
self_expr: @ast::expr, self_expr: @ast::expr,
store: ty::TraitStore, store: ty::TraitStore,
explicit_self: ast::self_ty_) explicit_self: ast::explicit_self_)
-> Callee { -> Callee {
//! //!
// //
@ -627,7 +627,7 @@ pub fn trans_trait_callee_from_llval(bcx: block,
n_method: uint, n_method: uint,
llpair: ValueRef, llpair: ValueRef,
store: ty::TraitStore, store: ty::TraitStore,
explicit_self: ast::self_ty_) explicit_self: ast::explicit_self_)
-> Callee { -> Callee {
//! //!
// //

View file

@ -58,7 +58,7 @@ pub struct method {
generics: ty::Generics, generics: ty::Generics,
transformed_self_ty: Option<ty::t>, transformed_self_ty: Option<ty::t>,
fty: BareFnTy, fty: BareFnTy,
self_ty: ast::self_ty_, explicit_self: ast::explicit_self_,
vis: ast::visibility, vis: ast::visibility,
def_id: ast::def_id def_id: ast::def_id
} }

View file

@ -542,7 +542,7 @@ pub fn bound_lifetimes<AC:AstConv>(
struct SelfInfo { struct SelfInfo {
untransformed_self_ty: ty::t, untransformed_self_ty: ty::t,
self_transform: ast::self_ty explicit_self: ast::explicit_self
} }
pub fn ty_of_method<AC:AstConv,RS:region_scope + Copy + 'static>( pub fn ty_of_method<AC:AstConv,RS:region_scope + Copy + 'static>(
@ -551,12 +551,12 @@ pub fn ty_of_method<AC:AstConv,RS:region_scope + Copy + 'static>(
purity: ast::purity, purity: ast::purity,
lifetimes: &OptVec<ast::Lifetime>, lifetimes: &OptVec<ast::Lifetime>,
untransformed_self_ty: ty::t, untransformed_self_ty: ty::t,
self_transform: ast::self_ty, explicit_self: ast::explicit_self,
decl: &ast::fn_decl) -> (Option<ty::t>, ty::BareFnTy) decl: &ast::fn_decl) -> (Option<ty::t>, ty::BareFnTy)
{ {
let self_info = SelfInfo { let self_info = SelfInfo {
untransformed_self_ty: untransformed_self_ty, untransformed_self_ty: untransformed_self_ty,
self_transform: self_transform explicit_self: explicit_self
}; };
let (a, b) = ty_of_method_or_bare_fn( let (a, b) = ty_of_method_or_bare_fn(
this, rscope, purity, AbiSet::Rust(), lifetimes, Some(&self_info), decl); this, rscope, purity, AbiSet::Rust(), lifetimes, Some(&self_info), decl);
@ -617,7 +617,7 @@ fn ty_of_method_or_bare_fn<AC:AstConv,RS:region_scope + Copy + 'static>(
rscope: &RS, rscope: &RS,
self_info: &SelfInfo) -> Option<ty::t> self_info: &SelfInfo) -> Option<ty::t>
{ {
match self_info.self_transform.node { match self_info.explicit_self.node {
ast::sty_static => None, ast::sty_static => None,
ast::sty_value => { ast::sty_value => {
Some(self_info.untransformed_self_ty) Some(self_info.untransformed_self_ty)
@ -625,7 +625,7 @@ fn ty_of_method_or_bare_fn<AC:AstConv,RS:region_scope + Copy + 'static>(
ast::sty_region(lifetime, mutability) => { ast::sty_region(lifetime, mutability) => {
let region = let region =
ast_region_to_region(this, rscope, ast_region_to_region(this, rscope,
self_info.self_transform.span, self_info.explicit_self.span,
lifetime); lifetime);
Some(ty::mk_rptr(this.tcx(), region, Some(ty::mk_rptr(this.tcx(), region,
ty::mt {ty: self_info.untransformed_self_ty, ty::mt {ty: self_info.untransformed_self_ty,

View file

@ -381,7 +381,7 @@ pub impl<'self> LookupContext<'self> {
let trait_methods = ty::trait_methods(tcx, bound_trait_ref.def_id); let trait_methods = ty::trait_methods(tcx, bound_trait_ref.def_id);
let pos = { let pos = {
match trait_methods.position(|m| { match trait_methods.position(|m| {
m.self_ty != ast::sty_static && m.explicit_self != ast::sty_static &&
m.ident == self.m_name }) m.ident == self.m_name })
{ {
Some(pos) => pos, Some(pos) => pos,
@ -948,11 +948,11 @@ pub impl<'self> LookupContext<'self> {
self.enforce_drop_trait_limitations(candidate); self.enforce_drop_trait_limitations(candidate);
// static methods should never have gotten this far: // static methods should never have gotten this far:
assert!(candidate.method_ty.self_ty != sty_static); assert!(candidate.method_ty.explicit_self != sty_static);
let transformed_self_ty = match candidate.origin { let transformed_self_ty = match candidate.origin {
method_trait(*) => { method_trait(*) => {
match candidate.method_ty.self_ty { match candidate.method_ty.explicit_self {
sty_region(*) => { sty_region(*) => {
// FIXME(#5762) again, preserving existing // FIXME(#5762) again, preserving existing
// behavior here which (for &self) desires // behavior here which (for &self) desires
@ -1033,7 +1033,7 @@ pub impl<'self> LookupContext<'self> {
let fty = ty::mk_bare_fn(tcx, ty::BareFnTy {sig: fn_sig, ..bare_fn_ty}); let fty = ty::mk_bare_fn(tcx, ty::BareFnTy {sig: fn_sig, ..bare_fn_ty});
debug!("after replacing bound regions, fty=%s", self.ty_to_str(fty)); debug!("after replacing bound regions, fty=%s", self.ty_to_str(fty));
let self_mode = get_mode_from_self_type(candidate.method_ty.self_ty); let self_mode = get_mode_from_explicit_self(candidate.method_ty.explicit_self);
// before we only checked whether self_ty could be a subtype // before we only checked whether self_ty could be a subtype
// of rcvr_ty; now we actually make it so (this may cause // of rcvr_ty; now we actually make it so (this may cause
@ -1055,7 +1055,7 @@ pub impl<'self> LookupContext<'self> {
method_map_entry { method_map_entry {
self_ty: candidate.rcvr_ty, self_ty: candidate.rcvr_ty,
self_mode: self_mode, self_mode: self_mode,
explicit_self: candidate.method_ty.self_ty, explicit_self: candidate.method_ty.explicit_self,
origin: candidate.origin, origin: candidate.origin,
} }
} }
@ -1126,7 +1126,7 @@ pub impl<'self> LookupContext<'self> {
// on an @Trait object here and so forth // on an @Trait object here and so forth
match candidate.origin { match candidate.origin {
method_trait(*) => { method_trait(*) => {
match candidate.method_ty.self_ty { match candidate.method_ty.explicit_self {
sty_static | sty_value => { sty_static | sty_value => {
return false; return false;
} }
@ -1144,7 +1144,7 @@ pub impl<'self> LookupContext<'self> {
_ => {} _ => {}
} }
return match candidate.method_ty.self_ty { return match candidate.method_ty.explicit_self {
sty_static => { sty_static => {
false false
} }
@ -1301,8 +1301,8 @@ pub impl<'self> LookupContext<'self> {
} }
} }
pub fn get_mode_from_self_type(self_type: ast::self_ty_) -> SelfMode { pub fn get_mode_from_explicit_self(explicit_self: ast::explicit_self_) -> SelfMode {
match self_type { match explicit_self {
sty_value => ty::ByCopy, sty_value => ty::ByCopy,
_ => ty::ByRef, _ => ty::ByRef,
} }

View file

@ -527,7 +527,7 @@ pub fn check_method(ccx: @mut CrateCtxt,
let opt_self_info = method_ty.transformed_self_ty.map(|&ty| { let opt_self_info = method_ty.transformed_self_ty.map(|&ty| {
SelfInfo {self_ty: ty, SelfInfo {self_ty: ty,
self_id: method.self_id, self_id: method.self_id,
span: method.self_ty.span} span: method.explicit_self.span}
}); });
check_bare_fn( check_bare_fn(

View file

@ -156,7 +156,7 @@ pub fn method_to_MethodInfo(ast_method: @method) -> @MethodInfo {
did: local_def(ast_method.id), did: local_def(ast_method.id),
n_tps: ast_method.generics.ty_params.len(), n_tps: ast_method.generics.ty_params.len(),
ident: ast_method.ident, ident: ast_method.ident,
self_type: ast_method.self_ty.node explicit_self: ast_method.explicit_self.node
} }
} }
@ -383,7 +383,7 @@ pub impl CoherenceChecker {
did: new_did, did: new_did,
n_tps: trait_method.generics.type_param_defs.len(), n_tps: trait_method.generics.type_param_defs.len(),
ident: trait_method.ident, ident: trait_method.ident,
self_type: trait_method.self_ty explicit_self: trait_method.explicit_self
}, },
trait_method_def_id: trait_method.def_id trait_method_def_id: trait_method.def_id
}; };
@ -975,7 +975,7 @@ pub impl CoherenceChecker {
did: new_did, did: new_did,
n_tps: trait_method_info.ty.generics.type_param_defs.len(), n_tps: trait_method_info.ty.generics.type_param_defs.len(),
ident: trait_method_info.ty.ident, ident: trait_method_info.ty.ident,
self_type: trait_method_info.ty.self_ty explicit_self: trait_method_info.ty.explicit_self
}, },
trait_method_def_id: trait_method_info.def_id trait_method_def_id: trait_method_info.def_id
}; };
@ -1126,7 +1126,7 @@ fn subst_receiver_types_in_method_ty(
// method types *can* appear in the generic bounds or the fty // method types *can* appear in the generic bounds or the fty
generics: method.generics.subst(tcx, &combined_substs), generics: method.generics.subst(tcx, &combined_substs),
fty: method.fty.subst(tcx, &combined_substs), fty: method.fty.subst(tcx, &combined_substs),
self_ty: method.self_ty, explicit_self: method.explicit_self,
vis: method.vis, vis: method.vis,
def_id: new_def_id def_id: new_def_id
} }

View file

@ -52,7 +52,7 @@ use syntax::ast_map;
use syntax::ast_util::{local_def, split_trait_methods}; use syntax::ast_util::{local_def, split_trait_methods};
use syntax::codemap::span; use syntax::codemap::span;
use syntax::codemap; use syntax::codemap;
use syntax::print::pprust::{path_to_str, self_ty_to_str}; use syntax::print::pprust::{path_to_str, explicit_self_to_str};
use syntax::visit; use syntax::visit;
use syntax::opt_vec::OptVec; use syntax::opt_vec::OptVec;
use syntax::opt_vec; use syntax::opt_vec;
@ -234,19 +234,19 @@ pub fn ensure_trait_methods(ccx: &CrateCtxt,
&ast::required(ref m) => { &ast::required(ref m) => {
ty_method_of_trait_method( ty_method_of_trait_method(
ccx, trait_id, region_paramd, generics, ccx, trait_id, region_paramd, generics,
&m.id, &m.ident, &m.self_ty, &m.id, &m.ident, &m.explicit_self,
&m.generics, &m.purity, &m.decl) &m.generics, &m.purity, &m.decl)
} }
&ast::provided(ref m) => { &ast::provided(ref m) => {
ty_method_of_trait_method( ty_method_of_trait_method(
ccx, trait_id, region_paramd, generics, ccx, trait_id, region_paramd, generics,
&m.id, &m.ident, &m.self_ty, &m.id, &m.ident, &m.explicit_self,
&m.generics, &m.purity, &m.decl) &m.generics, &m.purity, &m.decl)
} }
}; };
if ty_method.self_ty == ast::sty_static { if ty_method.explicit_self == ast::sty_static {
make_static_method_ty(ccx, trait_id, ty_method, make_static_method_ty(ccx, trait_id, ty_method,
&trait_ty_generics); &trait_ty_generics);
} }
@ -376,23 +376,23 @@ pub fn ensure_trait_methods(ccx: &CrateCtxt,
trait_generics: &ast::Generics, trait_generics: &ast::Generics,
m_id: &ast::node_id, m_id: &ast::node_id,
m_ident: &ast::ident, m_ident: &ast::ident,
m_self_ty: &ast::self_ty, m_explicit_self: &ast::explicit_self,
m_generics: &ast::Generics, m_generics: &ast::Generics,
m_purity: &ast::purity, m_purity: &ast::purity,
m_decl: &ast::fn_decl) -> ty::method m_decl: &ast::fn_decl) -> ty::method
{ {
let trait_self_ty = ty::mk_self(this.tcx, local_def(trait_id)); let trait_self_ty = ty::mk_self(this.tcx, local_def(trait_id));
let rscope = MethodRscope::new(m_self_ty.node, trait_rp, trait_generics); let rscope = MethodRscope::new(m_explicit_self.node, trait_rp, trait_generics);
let (transformed_self_ty, fty) = let (transformed_self_ty, fty) =
astconv::ty_of_method(this, &rscope, *m_purity, &m_generics.lifetimes, astconv::ty_of_method(this, &rscope, *m_purity, &m_generics.lifetimes,
trait_self_ty, *m_self_ty, m_decl); trait_self_ty, *m_explicit_self, m_decl);
let num_trait_type_params = trait_generics.ty_params.len(); let num_trait_type_params = trait_generics.ty_params.len();
ty::method { ty::method {
ident: *m_ident, ident: *m_ident,
generics: ty_generics(this, None, m_generics, num_trait_type_params), generics: ty_generics(this, None, m_generics, num_trait_type_params),
transformed_self_ty: transformed_self_ty, transformed_self_ty: transformed_self_ty,
fty: fty, fty: fty,
self_ty: m_self_ty.node, explicit_self: m_explicit_self.node,
// assume public, because this is only invoked on trait methods // assume public, because this is only invoked on trait methods
vis: ast::public, vis: ast::public,
def_id: local_def(*m_id) def_id: local_def(*m_id)
@ -459,7 +459,7 @@ pub fn compare_impl_method(tcx: ty::ctxt,
// that the error messages you get out of this code are a bit more // that the error messages you get out of this code are a bit more
// inscrutable, particularly for cases where one method has no // inscrutable, particularly for cases where one method has no
// self. // self.
match (&trait_m.self_ty, &impl_m.self_ty) { match (&trait_m.explicit_self, &impl_m.explicit_self) {
(&ast::sty_static, &ast::sty_static) => {} (&ast::sty_static, &ast::sty_static) => {}
(&ast::sty_static, _) => { (&ast::sty_static, _) => {
tcx.sess.span_err( tcx.sess.span_err(
@ -467,7 +467,7 @@ pub fn compare_impl_method(tcx: ty::ctxt,
fmt!("method `%s` has a `%s` declaration in the impl, \ fmt!("method `%s` has a `%s` declaration in the impl, \
but not in the trait", but not in the trait",
*tcx.sess.str_of(trait_m.ident), *tcx.sess.str_of(trait_m.ident),
self_ty_to_str(impl_m.self_ty, tcx.sess.intr()))); explicit_self_to_str(impl_m.explicit_self, tcx.sess.intr())));
return; return;
} }
(_, &ast::sty_static) => { (_, &ast::sty_static) => {
@ -476,7 +476,7 @@ pub fn compare_impl_method(tcx: ty::ctxt,
fmt!("method `%s` has a `%s` declaration in the trait, \ fmt!("method `%s` has a `%s` declaration in the trait, \
but not in the impl", but not in the impl",
*tcx.sess.str_of(trait_m.ident), *tcx.sess.str_of(trait_m.ident),
self_ty_to_str(trait_m.self_ty, tcx.sess.intr()))); explicit_self_to_str(trait_m.explicit_self, tcx.sess.intr())));
return; return;
} }
_ => { _ => {
@ -778,14 +778,14 @@ pub fn convert_methods(ccx: &CrateCtxt,
rcvr_visibility: ast::visibility, rcvr_visibility: ast::visibility,
method_generics: &ast::Generics) -> ty::method method_generics: &ast::Generics) -> ty::method
{ {
let rscope = MethodRscope::new(m.self_ty.node, let rscope = MethodRscope::new(m.explicit_self.node,
rp, rp,
rcvr_generics); rcvr_generics);
let (transformed_self_ty, fty) = let (transformed_self_ty, fty) =
astconv::ty_of_method(ccx, &rscope, m.purity, astconv::ty_of_method(ccx, &rscope, m.purity,
&method_generics.lifetimes, &method_generics.lifetimes,
untransformed_rcvr_ty, untransformed_rcvr_ty,
m.self_ty, &m.decl); m.explicit_self, &m.decl);
// if the method specifies a visibility, use that, otherwise // if the method specifies a visibility, use that, otherwise
// inherit the visibility from the impl (so `foo` in `pub impl // inherit the visibility from the impl (so `foo` in `pub impl
@ -799,7 +799,7 @@ pub fn convert_methods(ccx: &CrateCtxt,
generics: ty_generics(ccx, None, &m.generics, num_rcvr_type_params), generics: ty_generics(ccx, None, &m.generics, num_rcvr_type_params),
transformed_self_ty: transformed_self_ty, transformed_self_ty: transformed_self_ty,
fty: fty, fty: fty,
self_ty: m.self_ty.node, explicit_self: m.explicit_self.node,
vis: method_vis, vis: method_vis,
def_id: local_def(m.id) def_id: local_def(m.id)
} }

View file

@ -124,7 +124,7 @@ pub struct method_map_entry {
self_mode: ty::SelfMode, self_mode: ty::SelfMode,
// the type of explicit self on the method // the type of explicit self on the method
explicit_self: ast::self_ty_, explicit_self: ast::explicit_self_,
// method details being invoked // method details being invoked
origin: method_origin, origin: method_origin,

View file

@ -142,7 +142,7 @@ impl RegionParameterization {
} }
pub struct MethodRscope { pub struct MethodRscope {
self_ty: ast::self_ty_, explicit_self: ast::explicit_self_,
variance: Option<ty::region_variance>, variance: Option<ty::region_variance>,
region_param_names: RegionParamNames, region_param_names: RegionParamNames,
} }
@ -150,14 +150,14 @@ pub struct MethodRscope {
impl MethodRscope { impl MethodRscope {
// `generics` here refers to the generics of the outer item (impl or // `generics` here refers to the generics of the outer item (impl or
// trait). // trait).
pub fn new(self_ty: ast::self_ty_, pub fn new(explicit_self: ast::explicit_self_,
variance: Option<ty::region_variance>, variance: Option<ty::region_variance>,
rcvr_generics: &ast::Generics) rcvr_generics: &ast::Generics)
-> MethodRscope { -> MethodRscope {
let region_param_names = let region_param_names =
RegionParamNames::from_generics(rcvr_generics); RegionParamNames::from_generics(rcvr_generics);
MethodRscope { MethodRscope {
self_ty: self_ty, explicit_self: explicit_self,
variance: variance, variance: variance,
region_param_names: region_param_names region_param_names: region_param_names
} }

View file

@ -636,12 +636,12 @@ impl Repr for ty::Generics {
impl Repr for ty::method { impl Repr for ty::method {
fn repr(&self, tcx: ctxt) -> ~str { fn repr(&self, tcx: ctxt) -> ~str {
fmt!("method {ident: %s, generics: %s, transformed_self_ty: %s, \ fmt!("method {ident: %s, generics: %s, transformed_self_ty: %s, \
fty: %s, self_ty: %s, vis: %s, def_id: %s}", fty: %s, explicit_self: %s, vis: %s, def_id: %s}",
self.ident.repr(tcx), self.ident.repr(tcx),
self.generics.repr(tcx), self.generics.repr(tcx),
self.transformed_self_ty.repr(tcx), self.transformed_self_ty.repr(tcx),
self.fty.repr(tcx), self.fty.repr(tcx),
self.self_ty.repr(tcx), self.explicit_self.repr(tcx),
self.vis.repr(tcx), self.vis.repr(tcx),
self.def_id.repr(tcx)) self.def_id.repr(tcx))
} }
@ -653,7 +653,7 @@ impl Repr for ast::ident {
} }
} }
impl Repr for ast::self_ty_ { impl Repr for ast::explicit_self_ {
fn repr(&self, _tcx: ctxt) -> ~str { fn repr(&self, _tcx: ctxt) -> ~str {
fmt!("%?", *self) fmt!("%?", *self)
} }

View file

@ -187,7 +187,7 @@ fn get_method_sig(
&ty_m.decl, &ty_m.decl,
ty_m.purity, ty_m.purity,
ty_m.ident, ty_m.ident,
Some(ty_m.self_ty.node), Some(ty_m.explicit_self.node),
&ty_m.generics, &ty_m.generics,
extract::interner() extract::interner()
)) ))
@ -197,7 +197,7 @@ fn get_method_sig(
&m.decl, &m.decl,
m.purity, m.purity,
m.ident, m.ident,
Some(m.self_ty.node), Some(m.explicit_self.node),
&m.generics, &m.generics,
extract::interner() extract::interner()
)) ))
@ -218,7 +218,7 @@ fn get_method_sig(
&method.decl, &method.decl,
method.purity, method.purity,
method.ident, method.ident,
Some(method.self_ty.node), Some(method.explicit_self.node),
&method.generics, &method.generics,
extract::interner() extract::interner()
)) ))

View file

@ -767,7 +767,7 @@ pub struct ty_method {
purity: purity, purity: purity,
decl: fn_decl, decl: fn_decl,
generics: Generics, generics: Generics,
self_ty: self_ty, explicit_self: explicit_self,
id: node_id, id: node_id,
span: span, span: span,
} }
@ -1064,7 +1064,7 @@ impl to_bytes::IterBytes for ret_style {
#[auto_encode] #[auto_encode]
#[auto_decode] #[auto_decode]
#[deriving(Eq)] #[deriving(Eq)]
pub enum self_ty_ { pub enum explicit_self_ {
sty_static, // no self sty_static, // no self
sty_value, // `self` sty_value, // `self`
sty_region(Option<@Lifetime>, mutability), // `&'lt self` sty_region(Option<@Lifetime>, mutability), // `&'lt self`
@ -1073,7 +1073,7 @@ pub enum self_ty_ {
} }
#[cfg(stage0)] #[cfg(stage0)]
impl to_bytes::IterBytes for self_ty_ { impl to_bytes::IterBytes for explicit_self_ {
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) { fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
match *self { match *self {
sty_static => 0u8.iter_bytes(lsb0, f), sty_static => 0u8.iter_bytes(lsb0, f),
@ -1086,7 +1086,7 @@ impl to_bytes::IterBytes for self_ty_ {
} }
#[cfg(not(stage0))] #[cfg(not(stage0))]
impl to_bytes::IterBytes for self_ty_ { impl to_bytes::IterBytes for explicit_self_ {
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool { fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
match *self { match *self {
sty_static => 0u8.iter_bytes(lsb0, f), sty_static => 0u8.iter_bytes(lsb0, f),
@ -1098,7 +1098,7 @@ impl to_bytes::IterBytes for self_ty_ {
} }
} }
pub type self_ty = spanned<self_ty_>; pub type explicit_self = spanned<explicit_self_>;
#[auto_encode] #[auto_encode]
#[auto_decode] #[auto_decode]
@ -1107,7 +1107,7 @@ pub struct method {
ident: ident, ident: ident,
attrs: ~[attribute], attrs: ~[attribute],
generics: Generics, generics: Generics,
self_ty: self_ty, explicit_self: explicit_self,
purity: purity, purity: purity,
decl: fn_decl, decl: fn_decl,
body: blk, body: blk,

View file

@ -272,7 +272,7 @@ pub fn trait_method_to_ty_method(method: &trait_method) -> ty_method {
purity: m.purity, purity: m.purity,
decl: copy m.decl, decl: copy m.decl,
generics: copy m.generics, generics: copy m.generics,
self_ty: m.self_ty, explicit_self: m.explicit_self,
id: m.id, id: m.id,
span: m.span, span: m.span,
} }

View file

@ -713,7 +713,7 @@ fn mk_ser_method(
ident: cx.ident_of("encode"), ident: cx.ident_of("encode"),
attrs: ~[], attrs: ~[],
generics: ast_util::empty_generics(), generics: ast_util::empty_generics(),
self_ty: codemap::spanned { explicit_self: codemap::spanned {
node: ast::sty_region(None, ast::m_imm), node: ast::sty_region(None, ast::m_imm),
span: span span: span
}, },
@ -772,7 +772,7 @@ fn mk_deser_method(
ident: cx.ident_of("decode"), ident: cx.ident_of("decode"),
attrs: ~[], attrs: ~[],
generics: ast_util::empty_generics(), generics: ast_util::empty_generics(),
self_ty: codemap::spanned { node: ast::sty_static, span: span }, explicit_self: codemap::spanned { node: ast::sty_static, span: span },
purity: ast::impure_fn, purity: ast::impure_fn,
decl: deser_decl, decl: deser_decl,
body: deser_body, body: deser_body,

View file

@ -28,7 +28,7 @@ pub fn expand_deriving_clone(cx: @ext_ctxt,
MethodDef { MethodDef {
name: ~"clone", name: ~"clone",
generics: LifetimeBounds::empty(), generics: LifetimeBounds::empty(),
self_ty: borrowed_explicit_self(), explicit_self: borrowed_explicit_self(),
args: ~[], args: ~[],
ret_ty: Self, ret_ty: Self,
const_nonmatching: false, const_nonmatching: false,

View file

@ -34,7 +34,7 @@ pub fn expand_deriving_eq(cx: @ext_ctxt,
MethodDef { MethodDef {
name: $name, name: $name,
generics: LifetimeBounds::empty(), generics: LifetimeBounds::empty(),
self_ty: borrowed_explicit_self(), explicit_self: borrowed_explicit_self(),
args: ~[borrowed_self()], args: ~[borrowed_self()],
ret_ty: Literal(Path::new(~[~"bool"])), ret_ty: Literal(Path::new(~[~"bool"])),
const_nonmatching: true, const_nonmatching: true,

View file

@ -24,7 +24,7 @@ pub fn expand_deriving_ord(cx: @ext_ctxt,
MethodDef { MethodDef {
name: $name, name: $name,
generics: LifetimeBounds::empty(), generics: LifetimeBounds::empty(),
self_ty: borrowed_explicit_self(), explicit_self: borrowed_explicit_self(),
args: ~[borrowed_self()], args: ~[borrowed_self()],
ret_ty: Literal(Path::new(~[~"bool"])), ret_ty: Literal(Path::new(~[~"bool"])),
const_nonmatching: false, const_nonmatching: false,

View file

@ -33,7 +33,7 @@ pub fn expand_deriving_totaleq(cx: @ext_ctxt,
MethodDef { MethodDef {
name: ~"equals", name: ~"equals",
generics: LifetimeBounds::empty(), generics: LifetimeBounds::empty(),
self_ty: borrowed_explicit_self(), explicit_self: borrowed_explicit_self(),
args: ~[borrowed_self()], args: ~[borrowed_self()],
ret_ty: Literal(Path::new(~[~"bool"])), ret_ty: Literal(Path::new(~[~"bool"])),
const_nonmatching: true, const_nonmatching: true,

View file

@ -27,7 +27,7 @@ pub fn expand_deriving_totalord(cx: @ext_ctxt,
MethodDef { MethodDef {
name: ~"cmp", name: ~"cmp",
generics: LifetimeBounds::empty(), generics: LifetimeBounds::empty(),
self_ty: borrowed_explicit_self(), explicit_self: borrowed_explicit_self(),
args: ~[borrowed_self()], args: ~[borrowed_self()],
ret_ty: Literal(Path::new(~[~"core", ~"cmp", ~"Ordering"])), ret_ty: Literal(Path::new(~[~"core", ~"cmp", ~"Ordering"])),
const_nonmatching: false, const_nonmatching: false,

View file

@ -119,13 +119,13 @@ fn create_decode_method(
let body_block = build::mk_simple_block(cx, span, expr); let body_block = build::mk_simple_block(cx, span, expr);
// Create the method. // Create the method.
let self_ty = spanned { node: sty_static, span: span }; let explicit_self = spanned { node: sty_static, span: span };
let method_ident = cx.ident_of("decode"); let method_ident = cx.ident_of("decode");
@ast::method { @ast::method {
ident: method_ident, ident: method_ident,
attrs: ~[], attrs: ~[],
generics: ast_util::empty_generics(), generics: ast_util::empty_generics(),
self_ty: self_ty, explicit_self: explicit_self,
purity: impure_fn, purity: impure_fn,
decl: fn_decl, decl: fn_decl,
body: body_block, body: body_block,

View file

@ -111,13 +111,13 @@ fn create_encode_method(
let body_block = build::mk_block_(cx, span, statements); let body_block = build::mk_block_(cx, span, statements);
// Create the method. // Create the method.
let self_ty = spanned { node: sty_region(None, m_imm), span: span }; let explicit_self = spanned { node: sty_region(None, m_imm), span: span };
let method_ident = cx.ident_of("encode"); let method_ident = cx.ident_of("encode");
@ast::method { @ast::method {
ident: method_ident, ident: method_ident,
attrs: ~[], attrs: ~[],
generics: ast_util::empty_generics(), generics: ast_util::empty_generics(),
self_ty: self_ty, explicit_self: explicit_self,
purity: impure_fn, purity: impure_fn,
decl: fn_decl, decl: fn_decl,
body: body_block, body: body_block,

View file

@ -216,7 +216,7 @@ pub struct MethodDef<'self> {
/// Whether there is a self argument (outer Option) i.e. whether /// Whether there is a self argument (outer Option) i.e. whether
/// this is a static function, and whether it is a pointer (inner /// this is a static function, and whether it is a pointer (inner
/// Option) /// Option)
self_ty: Option<Option<PtrTy>>, explicit_self: Option<Option<PtrTy>>,
/// Arguments other than the self argument /// Arguments other than the self argument
args: ~[Ty], args: ~[Ty],
@ -321,7 +321,7 @@ impl<'self> TraitDef<'self> {
type_ident: ident, type_ident: ident,
generics: &Generics) -> @ast::item { generics: &Generics) -> @ast::item {
let methods = do self.methods.map |method_def| { let methods = do self.methods.map |method_def| {
let (self_ty, self_args, nonself_args, tys) = let (explicit_self, self_args, nonself_args, tys) =
method_def.split_self_nonself_args(cx, span, type_ident, generics); method_def.split_self_nonself_args(cx, span, type_ident, generics);
let body = if method_def.is_static() { let body = if method_def.is_static() {
@ -339,7 +339,7 @@ impl<'self> TraitDef<'self> {
method_def.create_method(cx, span, method_def.create_method(cx, span,
type_ident, generics, type_ident, generics,
self_ty, tys, explicit_self, tys,
body) body)
}; };
@ -352,7 +352,7 @@ impl<'self> TraitDef<'self> {
type_ident: ident, type_ident: ident,
generics: &Generics) -> @ast::item { generics: &Generics) -> @ast::item {
let methods = do self.methods.map |method_def| { let methods = do self.methods.map |method_def| {
let (self_ty, self_args, nonself_args, tys) = let (explicit_self, self_args, nonself_args, tys) =
method_def.split_self_nonself_args(cx, span, type_ident, generics); method_def.split_self_nonself_args(cx, span, type_ident, generics);
let body = if method_def.is_static() { let body = if method_def.is_static() {
@ -370,7 +370,7 @@ impl<'self> TraitDef<'self> {
method_def.create_method(cx, span, method_def.create_method(cx, span,
type_ident, generics, type_ident, generics,
self_ty, tys, explicit_self, tys,
body) body)
}; };
@ -404,28 +404,27 @@ impl<'self> MethodDef<'self> {
} }
fn is_static(&self) -> bool { fn is_static(&self) -> bool {
self.self_ty.is_none() self.explicit_self.is_none()
} }
fn split_self_nonself_args(&self, cx: @ext_ctxt, span: span, fn split_self_nonself_args(&self, cx: @ext_ctxt, span: span,
type_ident: ident, generics: &Generics) type_ident: ident, generics: &Generics)
-> (ast::self_ty, ~[@expr], ~[@expr], ~[(ident, @ast::Ty)]) { -> (ast::explicit_self, ~[@expr], ~[@expr], ~[(ident, @ast::Ty)]) {
let mut self_args = ~[], nonself_args = ~[], arg_tys = ~[]; let mut self_args = ~[], nonself_args = ~[], arg_tys = ~[];
let mut ast_self_ty = respan(span, ast::sty_static);
let mut nonstatic = false; let mut nonstatic = false;
match self.self_ty { let ast_explicit_self = match self.explicit_self {
Some(ref self_ptr) => { Some(ref self_ptr) => {
let (self_expr, self_ty) = ty::get_explicit_self(cx, span, let (self_expr, explicit_self) = ty::get_explicit_self(cx, span, self_ptr);
self_ptr);
ast_self_ty = self_ty;
self_args.push(self_expr); self_args.push(self_expr);
nonstatic = true; nonstatic = true;
explicit_self
} }
_ => {} None => respan(span, ast::sty_static),
} };
for self.args.eachi |i, ty| { for self.args.eachi |i, ty| {
let ast_ty = ty.to_ty(cx, span, type_ident, generics); let ast_ty = ty.to_ty(cx, span, type_ident, generics);
@ -449,13 +448,13 @@ impl<'self> MethodDef<'self> {
} }
} }
(ast_self_ty, self_args, nonself_args, arg_tys) (ast_explicit_self, self_args, nonself_args, arg_tys)
} }
fn create_method(&self, cx: @ext_ctxt, span: span, fn create_method(&self, cx: @ext_ctxt, span: span,
type_ident: ident, type_ident: ident,
generics: &Generics, generics: &Generics,
self_ty: ast::self_ty, explicit_self: ast::explicit_self,
arg_types: ~[(ident, @ast::Ty)], arg_types: ~[(ident, @ast::Ty)],
body: @expr) -> @ast::method { body: @expr) -> @ast::method {
// create the generics that aren't for Self // create the generics that aren't for Self
@ -477,7 +476,7 @@ impl<'self> MethodDef<'self> {
ident: method_ident, ident: method_ident,
attrs: ~[], attrs: ~[],
generics: fn_generics, generics: fn_generics,
self_ty: self_ty, explicit_self: explicit_self,
purity: ast::impure_fn, purity: ast::impure_fn,
decl: fn_decl, decl: fn_decl,
body: body_block, body: body_block,

View file

@ -26,7 +26,7 @@ pub fn expand_deriving_iter_bytes(cx: @ext_ctxt,
MethodDef { MethodDef {
name: ~"iter_bytes", name: ~"iter_bytes",
generics: LifetimeBounds::empty(), generics: LifetimeBounds::empty(),
self_ty: borrowed_explicit_self(), explicit_self: borrowed_explicit_self(),
args: ~[ args: ~[
Literal(Path::new(~[~"bool"])), Literal(Path::new(~[~"bool"])),
Literal(Path::new(~[~"core", ~"to_bytes", ~"Cb"])) Literal(Path::new(~[~"core", ~"to_bytes", ~"Cb"]))

View file

@ -32,7 +32,7 @@ pub fn expand_deriving_rand(cx: @ext_ctxt,
bounds: ~[(~"R", bounds: ~[(~"R",
~[ Path::new(~[~"core", ~"rand", ~"Rng"]) ])] ~[ Path::new(~[~"core", ~"rand", ~"Rng"]) ])]
}, },
self_ty: None, explicit_self: None,
args: ~[ args: ~[
Ptr(~Literal(Path::new_local(~"R")), Ptr(~Literal(Path::new_local(~"R")),
Borrowed(None, ast::m_mutbl)) Borrowed(None, ast::m_mutbl))

View file

@ -27,7 +27,7 @@ pub fn expand_deriving_to_str(cx: @ext_ctxt,
MethodDef { MethodDef {
name: ~"to_str", name: ~"to_str",
generics: LifetimeBounds::empty(), generics: LifetimeBounds::empty(),
self_ty: borrowed_explicit_self(), explicit_self: borrowed_explicit_self(),
args: ~[], args: ~[],
ret_ty: Ptr(~Literal(Path::new_local(~"str")), Owned), ret_ty: Ptr(~Literal(Path::new_local(~"str")), Owned),
const_nonmatching: false, const_nonmatching: false,

View file

@ -217,7 +217,7 @@ pub impl LifetimeBounds {
pub fn get_explicit_self(cx: @ext_ctxt, span: span, self_ptr: &Option<PtrTy>) pub fn get_explicit_self(cx: @ext_ctxt, span: span, self_ptr: &Option<PtrTy>)
-> (@expr, ast::self_ty) { -> (@expr, ast::explicit_self) {
let self_path = build::make_self(cx, span); let self_path = build::make_self(cx, span);
match *self_ptr { match *self_ptr {
None => { None => {

View file

@ -323,7 +323,7 @@ fn noop_fold_method(m: @method, fld: @ast_fold) -> @method {
ident: fld.fold_ident(m.ident), ident: fld.fold_ident(m.ident),
attrs: /* FIXME (#2543) */ copy m.attrs, attrs: /* FIXME (#2543) */ copy m.attrs,
generics: fold_generics(&m.generics, fld), generics: fold_generics(&m.generics, fld),
self_ty: m.self_ty, explicit_self: m.explicit_self,
purity: m.purity, purity: m.purity,
decl: fold_fn_decl(&m.decl, fld), decl: fold_fn_decl(&m.decl, fld),
body: fld.fold_block(&m.body), body: fld.fold_block(&m.body),

View file

@ -19,7 +19,7 @@ use ast::{_mod, add, arg, arm, attribute, bind_by_ref, bind_infer};
use ast::{bind_by_copy, bitand, bitor, bitxor, blk}; use ast::{bind_by_copy, bitand, bitor, bitxor, blk};
use ast::{blk_check_mode, box}; use ast::{blk_check_mode, box};
use ast::{crate, crate_cfg, decl, decl_item}; use ast::{crate, crate_cfg, decl, decl_item};
use ast::{decl_local, default_blk, deref, div, enum_def}; use ast::{decl_local, default_blk, deref, div, enum_def, explicit_self};
use ast::{expr, expr_, expr_addr_of, expr_match, expr_again}; use ast::{expr, expr_, expr_addr_of, expr_match, expr_again};
use ast::{expr_assign, expr_assign_op, expr_binary, expr_block}; use ast::{expr_assign, expr_assign_op, expr_binary, expr_block};
use ast::{expr_break, expr_call, expr_cast, expr_copy, expr_do_body}; use ast::{expr_break, expr_call, expr_cast, expr_copy, expr_do_body};
@ -43,7 +43,7 @@ use ast::{named_field, neg, node_id, noreturn, not, pat, pat_box, pat_enum};
use ast::{pat_ident, pat_lit, pat_range, pat_region, pat_struct}; use ast::{pat_ident, pat_lit, pat_range, pat_region, pat_struct};
use ast::{pat_tup, pat_uniq, pat_wild, private}; use ast::{pat_tup, pat_uniq, pat_wild, private};
use ast::{rem, required}; use ast::{rem, required};
use ast::{ret_style, return_val, self_ty, shl, shr, stmt, stmt_decl}; use ast::{ret_style, return_val, shl, shr, stmt, stmt_decl};
use ast::{stmt_expr, stmt_semi, stmt_mac, struct_def, struct_field}; use ast::{stmt_expr, stmt_semi, stmt_mac, struct_def, struct_field};
use ast::{struct_variant_kind, subtract}; use ast::{struct_variant_kind, subtract};
use ast::{sty_box, sty_region, sty_static, sty_uniq, sty_value}; use ast::{sty_box, sty_region, sty_static, sty_uniq, sty_value};
@ -504,7 +504,7 @@ pub impl Parser {
let generics = p.parse_generics(); let generics = p.parse_generics();
let (self_ty, d) = do self.parse_fn_decl_with_self() |p| { let (explicit_self, d) = do self.parse_fn_decl_with_self() |p| {
// This is somewhat dubious; We don't want to allow argument // This is somewhat dubious; We don't want to allow argument
// names to be left off if there is a definition... // names to be left off if there is a definition...
either::Left(p.parse_arg_general(false)) either::Left(p.parse_arg_general(false))
@ -526,7 +526,7 @@ pub impl Parser {
purity: pur, purity: pur,
decl: d, decl: d,
generics: generics, generics: generics,
self_ty: self_ty, explicit_self: explicit_self,
id: p.get_id(), id: p.get_id(),
span: mk_sp(lo, hi) span: mk_sp(lo, hi)
}) })
@ -540,7 +540,7 @@ pub impl Parser {
ident: ident, ident: ident,
attrs: attrs, attrs: attrs,
generics: generics, generics: generics,
self_ty: self_ty, explicit_self: explicit_self,
purity: pur, purity: pur,
decl: d, decl: d,
body: body, body: body,
@ -3002,11 +3002,11 @@ pub impl Parser {
&self, &self,
parse_arg_fn: parse_arg_fn:
&fn(&Parser) -> arg_or_capture_item &fn(&Parser) -> arg_or_capture_item
) -> (self_ty, fn_decl) { ) -> (explicit_self, fn_decl) {
fn maybe_parse_self_ty( fn maybe_parse_explicit_self(
cnstr: &fn(v: mutability) -> ast::self_ty_, cnstr: &fn(v: mutability) -> ast::explicit_self_,
p: &Parser p: &Parser
) -> ast::self_ty_ { ) -> ast::explicit_self_ {
// We need to make sure it isn't a mode or a type // We need to make sure it isn't a mode or a type
if p.token_is_keyword(&~"self", &p.look_ahead(1)) || if p.token_is_keyword(&~"self", &p.look_ahead(1)) ||
((p.token_is_keyword(&~"const", &p.look_ahead(1)) || ((p.token_is_keyword(&~"const", &p.look_ahead(1)) ||
@ -3022,7 +3022,7 @@ pub impl Parser {
} }
} }
fn maybe_parse_borrowed_self_ty(this: &Parser) -> ast::self_ty_ { fn maybe_parse_borrowed_explicit_self(this: &Parser) -> ast::explicit_self_ {
// The following things are possible to see here: // The following things are possible to see here:
// //
// fn(&self) // fn(&self)
@ -3066,15 +3066,15 @@ pub impl Parser {
// A bit of complexity and lookahead is needed here in order to to be // A bit of complexity and lookahead is needed here in order to to be
// backwards compatible. // backwards compatible.
let lo = self.span.lo; let lo = self.span.lo;
let self_ty = match *self.token { let explicit_self = match *self.token {
token::BINOP(token::AND) => { token::BINOP(token::AND) => {
maybe_parse_borrowed_self_ty(self) maybe_parse_borrowed_explicit_self(self)
} }
token::AT => { token::AT => {
maybe_parse_self_ty(sty_box, self) maybe_parse_explicit_self(sty_box, self)
} }
token::TILDE => { token::TILDE => {
maybe_parse_self_ty(sty_uniq, self) maybe_parse_explicit_self(sty_uniq, self)
} }
token::IDENT(*) if self.is_self_ident() => { token::IDENT(*) if self.is_self_ident() => {
self.bump(); self.bump();
@ -3087,7 +3087,7 @@ pub impl Parser {
// If we parsed a self type, expect a comma before the argument list. // If we parsed a self type, expect a comma before the argument list.
let args_or_capture_items; let args_or_capture_items;
if self_ty != sty_static { if explicit_self != sty_static {
match *self.token { match *self.token {
token::COMMA => { token::COMMA => {
self.bump(); self.bump();
@ -3132,7 +3132,7 @@ pub impl Parser {
cf: ret_style cf: ret_style
}; };
(spanned(lo, hi, self_ty), fn_decl) (spanned(lo, hi, explicit_self), fn_decl)
} }
// parse the |arg, arg| header on a lambda // parse the |arg, arg| header on a lambda
@ -3199,7 +3199,7 @@ pub impl Parser {
let pur = self.parse_fn_purity(); let pur = self.parse_fn_purity();
let ident = self.parse_ident(); let ident = self.parse_ident();
let generics = self.parse_generics(); let generics = self.parse_generics();
let (self_ty, decl) = do self.parse_fn_decl_with_self() |p| { let (explicit_self, decl) = do self.parse_fn_decl_with_self() |p| {
p.parse_arg() p.parse_arg()
}; };
@ -3210,7 +3210,7 @@ pub impl Parser {
ident: ident, ident: ident,
attrs: attrs, attrs: attrs,
generics: generics, generics: generics,
self_ty: self_ty, explicit_self: explicit_self,
purity: pur, purity: pur,
decl: decl, decl: decl,
body: body, body: body,

View file

@ -181,12 +181,12 @@ pub fn path_to_str(p: @ast::Path, intr: @ident_interner) -> ~str {
} }
pub fn fun_to_str(decl: &ast::fn_decl, purity: ast::purity, name: ast::ident, pub fn fun_to_str(decl: &ast::fn_decl, purity: ast::purity, name: ast::ident,
opt_self_ty: Option<ast::self_ty_>, opt_explicit_self: Option<ast::explicit_self_>,
generics: &ast::Generics, intr: @ident_interner) -> ~str { generics: &ast::Generics, intr: @ident_interner) -> ~str {
do io::with_str_writer |wr| { do io::with_str_writer |wr| {
let s = rust_printer(wr, intr); let s = rust_printer(wr, intr);
print_fn(s, decl, Some(purity), AbiSet::Rust(), print_fn(s, decl, Some(purity), AbiSet::Rust(),
name, generics, opt_self_ty, ast::inherited); name, generics, opt_explicit_self, ast::inherited);
end(s); // Close the head box end(s); // Close the head box
end(s); // Close the outer box end(s); // Close the outer box
eof(s.s); eof(s.s);
@ -797,7 +797,7 @@ pub fn print_ty_method(s: @ps, m: &ast::ty_method) {
print_outer_attributes(s, m.attrs); print_outer_attributes(s, m.attrs);
print_ty_fn(s, None, None, None, m.purity, ast::Many, print_ty_fn(s, None, None, None, m.purity, ast::Many,
&m.decl, Some(m.ident), Some(&m.generics), &m.decl, Some(m.ident), Some(&m.generics),
Some(/*bad*/ copy m.self_ty.node)); Some(/*bad*/ copy m.explicit_self.node));
word(s.s, ~";"); word(s.s, ~";");
} }
@ -813,7 +813,7 @@ pub fn print_method(s: @ps, meth: @ast::method) {
maybe_print_comment(s, meth.span.lo); maybe_print_comment(s, meth.span.lo);
print_outer_attributes(s, meth.attrs); print_outer_attributes(s, meth.attrs);
print_fn(s, &meth.decl, Some(meth.purity), AbiSet::Rust(), print_fn(s, &meth.decl, Some(meth.purity), AbiSet::Rust(),
meth.ident, &meth.generics, Some(meth.self_ty.node), meth.ident, &meth.generics, Some(meth.explicit_self.node),
meth.vis); meth.vis);
word(s.s, ~" "); word(s.s, ~" ");
print_block_with_attrs(s, &meth.body, meth.attrs); print_block_with_attrs(s, &meth.body, meth.attrs);
@ -1626,13 +1626,13 @@ pub fn print_pat(s: @ps, pat: @ast::pat, refutable: bool) {
(s.ann.post)(ann_node); (s.ann.post)(ann_node);
} }
pub fn self_ty_to_str(self_ty: ast::self_ty_, intr: @ident_interner) -> ~str { pub fn explicit_self_to_str(explicit_self: ast::explicit_self_, intr: @ident_interner) -> ~str {
to_str(self_ty, |a, b| { print_self_ty(a, b); () }, intr) to_str(explicit_self, |a, b| { print_explicit_self(a, b); () }, intr)
} }
// Returns whether it printed anything // Returns whether it printed anything
pub fn print_self_ty(s: @ps, self_ty: ast::self_ty_) -> bool { pub fn print_explicit_self(s: @ps, explicit_self: ast::explicit_self_) -> bool {
match self_ty { match explicit_self {
ast::sty_static => { return false; } ast::sty_static => { return false; }
ast::sty_value => { word(s.s, ~"self"); } ast::sty_value => { word(s.s, ~"self"); }
ast::sty_region(lt, m) => { ast::sty_region(lt, m) => {
@ -1657,24 +1657,24 @@ pub fn print_fn(s: @ps,
abis: AbiSet, abis: AbiSet,
name: ast::ident, name: ast::ident,
generics: &ast::Generics, generics: &ast::Generics,
opt_self_ty: Option<ast::self_ty_>, opt_explicit_self: Option<ast::explicit_self_>,
vis: ast::visibility) { vis: ast::visibility) {
head(s, ~""); head(s, ~"");
print_fn_header_info(s, opt_self_ty, purity, abis, ast::Many, None, vis); print_fn_header_info(s, opt_explicit_self, purity, abis, ast::Many, None, vis);
nbsp(s); nbsp(s);
print_ident(s, name); print_ident(s, name);
print_generics(s, generics); print_generics(s, generics);
print_fn_args_and_ret(s, decl, opt_self_ty); print_fn_args_and_ret(s, decl, opt_explicit_self);
} }
pub fn print_fn_args(s: @ps, decl: &ast::fn_decl, pub fn print_fn_args(s: @ps, decl: &ast::fn_decl,
opt_self_ty: Option<ast::self_ty_>) { opt_explicit_self: Option<ast::explicit_self_>) {
// It is unfortunate to duplicate the commasep logic, but we we want the // It is unfortunate to duplicate the commasep logic, but we we want the
// self type and the args all in the same box. // self type and the args all in the same box.
box(s, 0u, inconsistent); box(s, 0u, inconsistent);
let mut first = true; let mut first = true;
for opt_self_ty.each |self_ty| { for opt_explicit_self.each |explicit_self| {
first = !print_self_ty(s, *self_ty); first = !print_explicit_self(s, *explicit_self);
} }
for decl.inputs.each |arg| { for decl.inputs.each |arg| {
@ -1686,9 +1686,9 @@ pub fn print_fn_args(s: @ps, decl: &ast::fn_decl,
} }
pub fn print_fn_args_and_ret(s: @ps, decl: &ast::fn_decl, pub fn print_fn_args_and_ret(s: @ps, decl: &ast::fn_decl,
opt_self_ty: Option<ast::self_ty_>) { opt_explicit_self: Option<ast::explicit_self_>) {
popen(s); popen(s);
print_fn_args(s, decl, opt_self_ty); print_fn_args(s, decl, opt_explicit_self);
pclose(s); pclose(s);
maybe_print_comment(s, decl.output.span.lo); maybe_print_comment(s, decl.output.span.lo);
@ -1900,7 +1900,7 @@ pub fn print_ty_fn(s: @ps,
decl: &ast::fn_decl, decl: &ast::fn_decl,
id: Option<ast::ident>, id: Option<ast::ident>,
generics: Option<&ast::Generics>, generics: Option<&ast::Generics>,
opt_self_ty: Option<ast::self_ty_>) { opt_explicit_self: Option<ast::explicit_self_>) {
ibox(s, indent_unit); ibox(s, indent_unit);
// Duplicates the logic in `print_fn_header_info()`. This is because that // Duplicates the logic in `print_fn_header_info()`. This is because that
@ -1920,8 +1920,8 @@ pub fn print_ty_fn(s: @ps,
// self type and the args all in the same box. // self type and the args all in the same box.
box(s, 0u, inconsistent); box(s, 0u, inconsistent);
let mut first = true; let mut first = true;
for opt_self_ty.each |self_ty| { for opt_explicit_self.each |explicit_self| {
first = !print_self_ty(s, *self_ty); first = !print_explicit_self(s, *explicit_self);
} }
for decl.inputs.each |arg| { for decl.inputs.each |arg| {
if first { first = false; } else { word_space(s, ~","); } if first { first = false; } else { word_space(s, ~","); }
@ -2163,7 +2163,7 @@ pub fn print_opt_sigil(s: @ps, opt_sigil: Option<ast::Sigil>) {
} }
pub fn print_fn_header_info(s: @ps, pub fn print_fn_header_info(s: @ps,
_opt_sty: Option<ast::self_ty_>, _opt_explicit_self: Option<ast::explicit_self_>,
opt_purity: Option<ast::purity>, opt_purity: Option<ast::purity>,
abis: AbiSet, abis: AbiSet,
onceness: ast::Onceness, onceness: ast::Onceness,