提交 18f6a51d 编写于 作者: E Erick Tryzelaar

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

上级 70e02cf4
......@@ -100,7 +100,7 @@ impl items contain tag_item_impl_method elements, and classes
different tags.
*/
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;
......
......@@ -135,11 +135,12 @@ pub fn get_method(tcx: ty::ctxt,
decoder::get_method(tcx.cstore.intr, cdata, def.node, tcx)
}
pub fn get_method_name_and_self_ty(cstore: @mut cstore::CStore,
def: ast::def_id) -> (ast::ident, ast::self_ty_)
pub fn get_method_name_and_explicit_self(cstore: @mut cstore::CStore,
def: ast::def_id)
-> (ast::ident, ast::explicit_self_)
{
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,
......
......@@ -670,7 +670,7 @@ pub fn get_enum_variants(intr: @ident_interner, cdata: cmd, id: ast::node_id,
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 {
match ch as char {
'i' => { ast::m_imm }
......@@ -682,11 +682,11 @@ fn get_mutability(ch: u8) -> ast::mutability {
}
}
let self_type_doc = reader::get_doc(item, tag_item_trait_method_self_ty);
let string = reader::doc_as_str(self_type_doc);
let explicit_self_doc = reader::get_doc(item, tag_item_trait_method_explicit_self);
let string = reader::doc_as_str(explicit_self_doc);
let self_ty_kind = string[0];
match self_ty_kind as char {
let explicit_self_kind = string[0];
match explicit_self_kind as char {
's' => { return ast::sty_static; }
'v' => { return ast::sty_value; }
'@' => { return ast::sty_box(get_mutability(string[1])); }
......@@ -696,7 +696,7 @@ fn get_mutability(ch: u8) -> ast::mutability {
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| {
let m_did = reader::with_doc_data(doc, |d| parse_def_id(d));
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 {
did: translate_def_id(cdata, m_did),
n_tps: item_ty_param_count(mth_item) - base_tps,
ident: item_name(intr, mth_item),
self_type: self_ty});
explicit_self: explicit_self});
}
rslt
}
......@@ -748,15 +748,15 @@ pub fn get_impls_for_mod(intr: @ident_interner,
@result
}
pub fn get_method_name_and_self_ty(
pub fn get_method_name_and_explicit_self(
intr: @ident_interner,
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 name = item_name(intr, method_doc);
let self_ty = get_self_ty(method_doc);
(name, self_ty)
let explicit_self = get_explicit_self(method_doc);
(name, explicit_self)
}
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 fty = doc_method_fty(method_doc, tcx, cdata);
let vis = item_visibility(method_doc);
let self_ty = get_self_ty(method_doc);
let explicit_self = get_explicit_self(method_doc);
ty::method {
ident: name,
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,
fty: fty,
self_ty: self_ty,
explicit_self: explicit_self,
vis: vis,
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 self_ty = get_self_ty(mth);
let explicit_self = get_explicit_self(mth);
let ty_method = ty::method {
ident: name,
generics: ty::Generics {
......@@ -832,7 +832,7 @@ pub fn get_provided_trait_methods(intr: @ident_interner, cdata: cmd,
},
transformed_self_ty: transformed_self_ty,
fty: fty,
self_ty: self_ty,
explicit_self: explicit_self,
vis: ast::public,
def_id: did
};
......
......@@ -389,7 +389,7 @@ fn encode_reexported_static_methods(ecx: @EncodeContext,
Some(&ast_map::node_item(_, path)) => {
if mod_path != *path {
for methods.each |&m| {
if m.self_ty == ast::sty_static {
if m.explicit_self == ast::sty_static {
encode_reexported_static_method(ecx,
ebml_w,
exp, m);
......@@ -486,11 +486,11 @@ fn encode_visibility(ebml_w: &mut writer::Encoder, visibility: visibility) {
ebml_w.end_tag();
}
fn encode_self_type(ebml_w: &mut writer::Encoder, self_type: ast::self_ty_) {
ebml_w.start_tag(tag_item_trait_method_self_ty);
fn encode_explicit_self(ebml_w: &mut writer::Encoder, explicit_self: ast::explicit_self_) {
ebml_w.start_tag(tag_item_trait_method_explicit_self);
// Encode the base self type.
match self_type {
match explicit_self {
sty_static => {
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_method_fty(ecx, ebml_w, &method_ty.fty);
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,
......@@ -655,7 +655,7 @@ fn encode_info_for_method(ecx: @EncodeContext,
let method_ty: @ty::method = ty::method(ecx.tcx, method_def_id);
encode_method_ty_fields(ecx, ebml_w, method_ty);
match m.self_ty.node {
match m.explicit_self.node {
ast::sty_static => {
encode_family(ebml_w, purity_static_method_family(m.purity));
}
......@@ -962,7 +962,7 @@ fn add_to_index_(item: @item, ebml_w: &writer::Encoder,
trait_path.push(ast_map::path_name(item.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 => {
encode_family(ebml_w,
purity_static_method_family(
......@@ -991,7 +991,7 @@ fn add_to_index_(item: @item, ebml_w: &writer::Encoder,
// This is obviously a bogus assert but I don't think this
// ever worked before anyhow...near as I can tell, before
// we would emit two items.
if method_ty.self_ty == sty_static {
if method_ty.explicit_self == sty_static {
tcx.sess.span_unimpl(
item.span,
fmt!("Method %s is both provided and static",
......
......@@ -552,8 +552,8 @@ fn read_method_map_entry(&mut self, xcx: @ExtendedDecodeContext)
explicit_self: this.read_struct_field("explicit_self",
2,
|this| {
let self_type: ast::self_ty_ = Decodable::decode(this);
self_type
let explicit_self: ast::explicit_self_ = Decodable::decode(this);
explicit_self
}),
origin: this.read_struct_field("origin", 1, |this| {
let method_origin: method_origin =
......
......@@ -381,7 +381,7 @@ fn visit_fn(fk: &visit::fn_kind,
// Add `this`, whether explicit or implicit.
match *fk {
fk_method(_, _, method) => {
match method.self_ty.node {
match method.explicit_self.node {
sty_value | sty_region(*) | sty_box(_) | sty_uniq(_) => {
fn_maps.add_variable(Arg(method.self_id,
special_idents::self_));
......
......@@ -10,7 +10,7 @@
use driver::session::Session;
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_type_name_if_impl;
use metadata::cstore::find_extern_mod_stmt_cnum;
......@@ -28,7 +28,7 @@
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_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_fn_block, expr_index, expr_method_call, expr_path};
use syntax::ast::{def_prim_ty, def_region, def_self, def_ty, def_ty_param};
......@@ -45,7 +45,7 @@
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::{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::{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};
......@@ -96,7 +96,7 @@ pub struct MethodInfo {
did: def_id,
n_tps: uint,
ident: ident,
self_type: self_ty_
explicit_self: explicit_self_
}
pub struct Impl {
......@@ -1203,7 +1203,7 @@ fn build_reduced_graph_for_item(@mut self,
// Bail out early if there are no static methods.
let mut has_static_methods = false;
for methods.each |method| {
match method.self_ty.node {
match method.explicit_self.node {
sty_static => has_static_methods = true,
_ => {}
}
......@@ -1236,7 +1236,7 @@ fn build_reduced_graph_for_item(@mut self,
// For each static method...
for methods.each |method| {
match method.self_ty.node {
match method.explicit_self.node {
sty_static => {
// Add the static method to the
// module.
......@@ -1274,7 +1274,7 @@ fn build_reduced_graph_for_item(@mut self,
let mut has_static_methods = false;
for (*methods).each |method| {
let ty_m = trait_method_to_ty_method(method);
match ty_m.self_ty.node {
match ty_m.explicit_self.node {
sty_static => {
has_static_methods = true;
break;
......@@ -1306,7 +1306,7 @@ fn build_reduced_graph_for_item(@mut self,
let ident = ty_m.ident;
// Add it to the trait info if not static,
// add it as a name in the trait module otherwise.
match ty_m.self_ty.node {
match ty_m.explicit_self.node {
sty_static => {
let def = def_static_method(
local_def(ty_m.id),
......@@ -1612,9 +1612,9 @@ fn handle_external_def(@mut self,
def_id);
let mut interned_method_names = HashSet::new();
for method_def_ids.each |&method_def_id| {
let (method_name, self_ty) =
get_method_name_and_self_ty(self.session.cstore,
method_def_id);
let (method_name, explicit_self) =
get_method_name_and_explicit_self(self.session.cstore,
method_def_id);
debug!("(building reduced graph for \
external crate) ... adding \
......@@ -1622,7 +1622,7 @@ trait method '%s'",
*self.session.str_of(method_name));
// 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);
}
}
......@@ -3774,7 +3774,7 @@ fn resolve_method(@mut self,
outer_type_parameter_count,
rib_kind);
// 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 }
_ => { HasSelfBinding(method.self_id, false) }
};
......
......@@ -11,7 +11,7 @@
use driver::session;
use driver::session::Session;
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_type_name_if_impl;
use metadata::cstore::find_extern_mod_stmt_cnum;
......@@ -46,7 +46,7 @@
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::{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::{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};
......@@ -97,7 +97,7 @@ pub struct MethodInfo {
did: def_id,
n_tps: uint,
ident: ident,
self_type: self_ty_
explicit_self: explicit_self_
}
pub struct Impl {
......@@ -1219,7 +1219,7 @@ fn build_reduced_graph_for_item(@mut self,
// Bail out early if there are no static methods.
let mut has_static_methods = false;
for methods.each |method| {
match method.self_ty.node {
match method.explicit_self.node {
sty_static => has_static_methods = true,
_ => {}
}
......@@ -1252,7 +1252,7 @@ fn build_reduced_graph_for_item(@mut self,
// For each static method...
for methods.each |method| {
match method.self_ty.node {
match method.explicit_self.node {
sty_static => {
// Add the static method to the
// module.
......@@ -1290,7 +1290,7 @@ fn build_reduced_graph_for_item(@mut self,
let mut has_static_methods = false;
for (*methods).each |method| {
let ty_m = trait_method_to_ty_method(method);
match ty_m.self_ty.node {
match ty_m.explicit_self.node {
sty_static => {
has_static_methods = true;
break;
......@@ -1322,7 +1322,7 @@ fn build_reduced_graph_for_item(@mut self,
let ident = ty_m.ident;
// Add it to the trait info if not static,
// add it as a name in the trait module otherwise.
match ty_m.self_ty.node {
match ty_m.explicit_self.node {
sty_static => {
let def = def_static_method(
local_def(ty_m.id),
......@@ -1628,9 +1628,9 @@ fn handle_external_def(@mut self,
def_id);
let mut interned_method_names = HashSet::new();
for method_def_ids.each |&method_def_id| {
let (method_name, self_ty) =
get_method_name_and_self_ty(self.session.cstore,
method_def_id);
let (method_name, explicit_self) =
get_method_name_and_explicit_self(self.session.cstore,
method_def_id);
debug!("(building reduced graph for \
external crate) ... adding \
......@@ -1638,7 +1638,7 @@ trait method '%s'",
*self.session.str_of(method_name));
// 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);
}
}
......@@ -3800,7 +3800,7 @@ fn resolve_method(@mut self,
outer_type_parameter_count,
rib_kind);
// 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 }
_ => { HasSelfBinding(method.self_id, false) }
};
......
......@@ -99,14 +99,14 @@ pub fn maybe_instantiate_inline(ccx: @CrateContext, fn_id: ast::def_id,
let path = vec::append(
ty::item_path(ccx.tcx, impl_did),
~[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,
_ => {
let self_ty = ty::node_id_to_type(ccx.tcx,
mth.self_id);
debug!("calling inline trans_fn with self_ty %s",
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),
_ => impl_self(self_ty),
}
......
......@@ -103,7 +103,7 @@ pub fn trans_method(ccx: @CrateContext,
llfn: ValueRef,
impl_id: ast::def_id) {
// 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 => {
no_self
}
......@@ -123,7 +123,7 @@ pub fn trans_method(ccx: @CrateContext,
debug!("calling trans_fn with base_self_ty %s, self_ty %s",
base_self_ty.repr(ccx.tcx),
self_ty.repr(ccx.tcx));
match method.self_ty.node {
match method.explicit_self.node {
ast::sty_value => {
impl_owned_self(self_ty)
}
......@@ -590,7 +590,7 @@ pub fn trans_trait_callee(bcx: block,
n_method: uint,
self_expr: @ast::expr,
store: ty::TraitStore,
explicit_self: ast::self_ty_)
explicit_self: ast::explicit_self_)
-> Callee {
//!
//
......@@ -627,7 +627,7 @@ pub fn trans_trait_callee_from_llval(bcx: block,
n_method: uint,
llpair: ValueRef,
store: ty::TraitStore,
explicit_self: ast::self_ty_)
explicit_self: ast::explicit_self_)
-> Callee {
//!
//
......
......@@ -58,7 +58,7 @@ pub struct method {
generics: ty::Generics,
transformed_self_ty: Option<ty::t>,
fty: BareFnTy,
self_ty: ast::self_ty_,
explicit_self: ast::explicit_self_,
vis: ast::visibility,
def_id: ast::def_id
}
......
......@@ -542,7 +542,7 @@ pub fn bound_lifetimes<AC:AstConv>(
struct SelfInfo {
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>(
......@@ -551,12 +551,12 @@ pub fn ty_of_method<AC:AstConv,RS:region_scope + Copy + 'static>(
purity: ast::purity,
lifetimes: &OptVec<ast::Lifetime>,
untransformed_self_ty: ty::t,
self_transform: ast::self_ty,
explicit_self: ast::explicit_self,
decl: &ast::fn_decl) -> (Option<ty::t>, ty::BareFnTy)
{
let self_info = SelfInfo {
untransformed_self_ty: untransformed_self_ty,
self_transform: self_transform
explicit_self: explicit_self
};
let (a, b) = ty_of_method_or_bare_fn(
this, rscope, purity, AbiSet::Rust(), lifetimes, Some(&self_info), decl);
......@@ -617,7 +617,7 @@ fn transform_self_ty<AC:AstConv,RS:region_scope + Copy + 'static>(
rscope: &RS,
self_info: &SelfInfo) -> Option<ty::t>
{
match self_info.self_transform.node {
match self_info.explicit_self.node {
ast::sty_static => None,
ast::sty_value => {
Some(self_info.untransformed_self_ty)
......@@ -625,7 +625,7 @@ fn transform_self_ty<AC:AstConv,RS:region_scope + Copy + 'static>(
ast::sty_region(lifetime, mutability) => {
let region =
ast_region_to_region(this, rscope,
self_info.self_transform.span,
self_info.explicit_self.span,
lifetime);
Some(ty::mk_rptr(this.tcx(), region,
ty::mt {ty: self_info.untransformed_self_ty,
......
......@@ -381,7 +381,7 @@ fn push_inherent_candidates_from_param(&self,
let trait_methods = ty::trait_methods(tcx, bound_trait_ref.def_id);
let pos = {
match trait_methods.position(|m| {
m.self_ty != ast::sty_static &&
m.explicit_self != ast::sty_static &&
m.ident == self.m_name })
{
Some(pos) => pos,
......@@ -948,11 +948,11 @@ fn confirm_candidate(&self,
self.enforce_drop_trait_limitations(candidate);
// 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 {
method_trait(*) => {
match candidate.method_ty.self_ty {
match candidate.method_ty.explicit_self {
sty_region(*) => {
// FIXME(#5762) again, preserving existing
// behavior here which (for &self) desires
......@@ -1033,7 +1033,7 @@ fn confirm_candidate(&self,
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));
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
// of rcvr_ty; now we actually make it so (this may cause
......@@ -1055,7 +1055,7 @@ fn confirm_candidate(&self,
method_map_entry {
self_ty: candidate.rcvr_ty,
self_mode: self_mode,
explicit_self: candidate.method_ty.self_ty,
explicit_self: candidate.method_ty.explicit_self,
origin: candidate.origin,
}
}
......@@ -1126,7 +1126,7 @@ fn is_relevant(&self, rcvr_ty: ty::t, candidate: &Candidate) -> bool {
// on an @Trait object here and so forth
match candidate.origin {
method_trait(*) => {
match candidate.method_ty.self_ty {
match candidate.method_ty.explicit_self {
sty_static | sty_value => {
return false;
}
......@@ -1144,7 +1144,7 @@ fn is_relevant(&self, rcvr_ty: ty::t, candidate: &Candidate) -> bool {
_ => {}
}
return match candidate.method_ty.self_ty {
return match candidate.method_ty.explicit_self {
sty_static => {
false
}
......@@ -1301,8 +1301,8 @@ fn bug(&self, s: ~str) -> ! {
}
}
pub fn get_mode_from_self_type(self_type: ast::self_ty_) -> SelfMode {
match self_type {
pub fn get_mode_from_explicit_self(explicit_self: ast::explicit_self_) -> SelfMode {
match explicit_self {
sty_value => ty::ByCopy,
_ => ty::ByRef,
}
......
......@@ -527,7 +527,7 @@ pub fn check_method(ccx: @mut CrateCtxt,
let opt_self_info = method_ty.transformed_self_ty.map(|&ty| {
SelfInfo {self_ty: ty,
self_id: method.self_id,
span: method.self_ty.span}
span: method.explicit_self.span}
});
check_bare_fn(
......
......@@ -156,7 +156,7 @@ pub fn method_to_MethodInfo(ast_method: @method) -> @MethodInfo {
did: local_def(ast_method.id),
n_tps: ast_method.generics.ty_params.len(),
ident: ast_method.ident,
self_type: ast_method.self_ty.node
explicit_self: ast_method.explicit_self.node
}
}
......@@ -383,7 +383,7 @@ fn instantiate_default_methods(&self,
did: new_did,
n_tps: trait_method.generics.type_param_defs.len(),
ident: trait_method.ident,
self_type: trait_method.self_ty
explicit_self: trait_method.explicit_self
},
trait_method_def_id: trait_method.def_id
};
......@@ -975,7 +975,7 @@ fn add_default_methods_for_external_trait(&self,
did: new_did,
n_tps: trait_method_info.ty.generics.type_param_defs.len(),
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
};
......@@ -1126,7 +1126,7 @@ fn subst_receiver_types_in_method_ty(
// method types *can* appear in the generic bounds or the fty
generics: method.generics.subst(tcx, &combined_substs),
fty: method.fty.subst(tcx, &combined_substs),
self_ty: method.self_ty,
explicit_self: method.explicit_self,
vis: method.vis,
def_id: new_def_id
}
......
......@@ -52,7 +52,7 @@
use syntax::ast_util::{local_def, split_trait_methods};
use syntax::codemap::span;
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::opt_vec::OptVec;
use syntax::opt_vec;
......@@ -234,19 +234,19 @@ pub fn ensure_trait_methods(ccx: &CrateCtxt,
&ast::required(ref m) => {
ty_method_of_trait_method(
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)
}
&ast::provided(ref m) => {
ty_method_of_trait_method(
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)
}
};
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,
&trait_ty_generics);
}
......@@ -376,23 +376,23 @@ fn ty_method_of_trait_method(this: &CrateCtxt,
trait_generics: &ast::Generics,
m_id: &ast::node_id,
m_ident: &ast::ident,
m_self_ty: &ast::self_ty,
m_explicit_self: &ast::explicit_self,
m_generics: &ast::Generics,
m_purity: &ast::purity,
m_decl: &ast::fn_decl) -> ty::method
{
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) =
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();
ty::method {
ident: *m_ident,
generics: ty_generics(this, None, m_generics, num_trait_type_params),
transformed_self_ty: transformed_self_ty,
fty: fty,
self_ty: m_self_ty.node,
explicit_self: m_explicit_self.node,
// assume public, because this is only invoked on trait methods
vis: ast::public,
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
// inscrutable, particularly for cases where one method has no
// 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, _) => {
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, \
but not in the trait",
*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;
}
(_, &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, \
but not in the impl",
*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;
}
_ => {
......@@ -778,14 +778,14 @@ fn ty_of_method(ccx: &CrateCtxt,
rcvr_visibility: ast::visibility,
method_generics: &ast::Generics) -> ty::method
{
let rscope = MethodRscope::new(m.self_ty.node,
let rscope = MethodRscope::new(m.explicit_self.node,
rp,
rcvr_generics);
let (transformed_self_ty, fty) =
astconv::ty_of_method(ccx, &rscope, m.purity,
&method_generics.lifetimes,
untransformed_rcvr_ty,
m.self_ty, &m.decl);
m.explicit_self, &m.decl);
// if the method specifies a visibility, use that, otherwise
// inherit the visibility from the impl (so `foo` in `pub impl
......@@ -799,7 +799,7 @@ fn ty_of_method(ccx: &CrateCtxt,
generics: ty_generics(ccx, None, &m.generics, num_rcvr_type_params),
transformed_self_ty: transformed_self_ty,
fty: fty,
self_ty: m.self_ty.node,
explicit_self: m.explicit_self.node,
vis: method_vis,
def_id: local_def(m.id)
}
......
......@@ -124,7 +124,7 @@ pub struct method_map_entry {
self_mode: ty::SelfMode,
// the type of explicit self on the method
explicit_self: ast::self_ty_,
explicit_self: ast::explicit_self_,
// method details being invoked
origin: method_origin,
......
......@@ -142,7 +142,7 @@ pub fn from_variance_and_generics(variance: Option<ty::region_variance>,
}
pub struct MethodRscope {
self_ty: ast::self_ty_,
explicit_self: ast::explicit_self_,
variance: Option<ty::region_variance>,
region_param_names: RegionParamNames,
}
......@@ -150,14 +150,14 @@ pub struct MethodRscope {
impl MethodRscope {
// `generics` here refers to the generics of the outer item (impl or
// trait).
pub fn new(self_ty: ast::self_ty_,
pub fn new(explicit_self: ast::explicit_self_,
variance: Option<ty::region_variance>,
rcvr_generics: &ast::Generics)
-> MethodRscope {
let region_param_names =
RegionParamNames::from_generics(rcvr_generics);
MethodRscope {
self_ty: self_ty,
explicit_self: explicit_self,
variance: variance,
region_param_names: region_param_names
}
......
......@@ -636,12 +636,12 @@ fn repr(&self, tcx: ctxt) -> ~str {
impl Repr for ty::method {
fn repr(&self, tcx: ctxt) -> ~str {
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.generics.repr(tcx),
self.transformed_self_ty.repr(tcx),
self.fty.repr(tcx),
self.self_ty.repr(tcx),
self.explicit_self.repr(tcx),
self.vis.repr(tcx),
self.def_id.repr(tcx))
}
......@@ -653,7 +653,7 @@ fn repr(&self, tcx: ctxt) -> ~str {
}
}
impl Repr for ast::self_ty_ {
impl Repr for ast::explicit_self_ {
fn repr(&self, _tcx: ctxt) -> ~str {
fmt!("%?", *self)
}
......
......@@ -187,7 +187,7 @@ fn get_method_sig(
&ty_m.decl,
ty_m.purity,
ty_m.ident,
Some(ty_m.self_ty.node),
Some(ty_m.explicit_self.node),
&ty_m.generics,
extract::interner()
))
......@@ -197,7 +197,7 @@ fn get_method_sig(
&m.decl,
m.purity,
m.ident,
Some(m.self_ty.node),
Some(m.explicit_self.node),
&m.generics,
extract::interner()
))
......@@ -218,7 +218,7 @@ fn get_method_sig(
&method.decl,
method.purity,
method.ident,
Some(method.self_ty.node),
Some(method.explicit_self.node),
&method.generics,
extract::interner()
))
......
......@@ -767,7 +767,7 @@ pub struct ty_method {
purity: purity,
decl: fn_decl,
generics: Generics,
self_ty: self_ty,
explicit_self: explicit_self,
id: node_id,
span: span,
}
......@@ -1064,7 +1064,7 @@ fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
#[auto_encode]
#[auto_decode]
#[deriving(Eq)]
pub enum self_ty_ {
pub enum explicit_self_ {
sty_static, // no self
sty_value, // `self`
sty_region(Option<@Lifetime>, mutability), // `&'lt self`
......@@ -1073,7 +1073,7 @@ pub enum self_ty_ {
}
#[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) {
match *self {
sty_static => 0u8.iter_bytes(lsb0, f),
......@@ -1086,7 +1086,7 @@ fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
}
#[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 {
match *self {
sty_static => 0u8.iter_bytes(lsb0, f),
......@@ -1098,7 +1098,7 @@ fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
}
}
pub type self_ty = spanned<self_ty_>;
pub type explicit_self = spanned<explicit_self_>;
#[auto_encode]
#[auto_decode]
......@@ -1107,7 +1107,7 @@ pub struct method {
ident: ident,
attrs: ~[attribute],
generics: Generics,
self_ty: self_ty,
explicit_self: explicit_self,
purity: purity,
decl: fn_decl,
body: blk,
......
......@@ -272,7 +272,7 @@ pub fn trait_method_to_ty_method(method: &trait_method) -> ty_method {
purity: m.purity,
decl: copy m.decl,
generics: copy m.generics,
self_ty: m.self_ty,
explicit_self: m.explicit_self,
id: m.id,
span: m.span,
}
......
......@@ -713,7 +713,7 @@ fn mk_ser_method(
ident: cx.ident_of("encode"),
attrs: ~[],
generics: ast_util::empty_generics(),
self_ty: codemap::spanned {
explicit_self: codemap::spanned {
node: ast::sty_region(None, ast::m_imm),
span: span
},
......@@ -772,7 +772,7 @@ fn mk_deser_method(
ident: cx.ident_of("decode"),
attrs: ~[],
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,
decl: deser_decl,
body: deser_body,
......
......@@ -28,7 +28,7 @@ pub fn expand_deriving_clone(cx: @ext_ctxt,
MethodDef {
name: ~"clone",
generics: LifetimeBounds::empty(),
self_ty: borrowed_explicit_self(),
explicit_self: borrowed_explicit_self(),
args: ~[],
ret_ty: Self,
const_nonmatching: false,
......
......@@ -34,7 +34,7 @@ fn cs_ne(cx: @ext_ctxt, span: span, substr: &Substructure) -> @expr {
MethodDef {
name: $name,
generics: LifetimeBounds::empty(),
self_ty: borrowed_explicit_self(),
explicit_self: borrowed_explicit_self(),
args: ~[borrowed_self()],
ret_ty: Literal(Path::new(~[~"bool"])),
const_nonmatching: true,
......
......@@ -24,7 +24,7 @@ pub fn expand_deriving_ord(cx: @ext_ctxt,
MethodDef {
name: $name,
generics: LifetimeBounds::empty(),
self_ty: borrowed_explicit_self(),
explicit_self: borrowed_explicit_self(),
args: ~[borrowed_self()],
ret_ty: Literal(Path::new(~[~"bool"])),
const_nonmatching: false,
......
......@@ -33,7 +33,7 @@ fn cs_equals(cx: @ext_ctxt, span: span, substr: &Substructure) -> @expr {
MethodDef {
name: ~"equals",
generics: LifetimeBounds::empty(),
self_ty: borrowed_explicit_self(),
explicit_self: borrowed_explicit_self(),
args: ~[borrowed_self()],
ret_ty: Literal(Path::new(~[~"bool"])),
const_nonmatching: true,
......
......@@ -27,7 +27,7 @@ pub fn expand_deriving_totalord(cx: @ext_ctxt,
MethodDef {
name: ~"cmp",
generics: LifetimeBounds::empty(),
self_ty: borrowed_explicit_self(),
explicit_self: borrowed_explicit_self(),
args: ~[borrowed_self()],
ret_ty: Literal(Path::new(~[~"core", ~"cmp", ~"Ordering"])),
const_nonmatching: false,
......
......@@ -119,13 +119,13 @@ fn create_decode_method(
let body_block = build::mk_simple_block(cx, span, expr);
// 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");
@ast::method {
ident: method_ident,
attrs: ~[],
generics: ast_util::empty_generics(),
self_ty: self_ty,
explicit_self: explicit_self,
purity: impure_fn,
decl: fn_decl,
body: body_block,
......
......@@ -111,13 +111,13 @@ fn create_encode_method(
let body_block = build::mk_block_(cx, span, statements);
// 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");
@ast::method {
ident: method_ident,
attrs: ~[],
generics: ast_util::empty_generics(),
self_ty: self_ty,
explicit_self: explicit_self,
purity: impure_fn,
decl: fn_decl,
body: body_block,
......
......@@ -216,7 +216,7 @@ pub struct MethodDef<'self> {
/// Whether there is a self argument (outer Option) i.e. whether
/// this is a static function, and whether it is a pointer (inner
/// Option)
self_ty: Option<Option<PtrTy>>,
explicit_self: Option<Option<PtrTy>>,
/// Arguments other than the self argument
args: ~[Ty],
......@@ -321,7 +321,7 @@ fn expand_struct_def(&self, cx: @ext_ctxt,
type_ident: ident,
generics: &Generics) -> @ast::item {
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);
let body = if method_def.is_static() {
......@@ -339,7 +339,7 @@ fn expand_struct_def(&self, cx: @ext_ctxt,
method_def.create_method(cx, span,
type_ident, generics,
self_ty, tys,
explicit_self, tys,
body)
};
......@@ -352,7 +352,7 @@ fn expand_enum_def(&self,
type_ident: ident,
generics: &Generics) -> @ast::item {
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);
let body = if method_def.is_static() {
......@@ -370,7 +370,7 @@ fn expand_enum_def(&self,
method_def.create_method(cx, span,
type_ident, generics,
self_ty, tys,
explicit_self, tys,
body)
};
......@@ -404,28 +404,27 @@ fn get_ret_ty(&self, cx: @ext_ctxt, span: span,
}
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,
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 ast_self_ty = respan(span, ast::sty_static);
let mut nonstatic = false;
match self.self_ty {
let ast_explicit_self = match self.explicit_self {
Some(ref self_ptr) => {
let (self_expr, self_ty) = ty::get_explicit_self(cx, span,
self_ptr);
let (self_expr, explicit_self) = ty::get_explicit_self(cx, span, self_ptr);
ast_self_ty = self_ty;
self_args.push(self_expr);
nonstatic = true;
explicit_self
}
_ => {}
}
None => respan(span, ast::sty_static),
};
for self.args.eachi |i, ty| {
let ast_ty = ty.to_ty(cx, span, type_ident, generics);
......@@ -449,13 +448,13 @@ fn split_self_nonself_args(&self, cx: @ext_ctxt, span: span,
}
}
(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,
type_ident: ident,
generics: &Generics,
self_ty: ast::self_ty,
explicit_self: ast::explicit_self,
arg_types: ~[(ident, @ast::Ty)],
body: @expr) -> @ast::method {
// create the generics that aren't for Self
......@@ -477,7 +476,7 @@ fn create_method(&self, cx: @ext_ctxt, span: span,
ident: method_ident,
attrs: ~[],
generics: fn_generics,
self_ty: self_ty,
explicit_self: explicit_self,
purity: ast::impure_fn,
decl: fn_decl,
body: body_block,
......
......@@ -26,7 +26,7 @@ pub fn expand_deriving_iter_bytes(cx: @ext_ctxt,
MethodDef {
name: ~"iter_bytes",
generics: LifetimeBounds::empty(),
self_ty: borrowed_explicit_self(),
explicit_self: borrowed_explicit_self(),
args: ~[
Literal(Path::new(~[~"bool"])),
Literal(Path::new(~[~"core", ~"to_bytes", ~"Cb"]))
......
......@@ -32,7 +32,7 @@ pub fn expand_deriving_rand(cx: @ext_ctxt,
bounds: ~[(~"R",
~[ Path::new(~[~"core", ~"rand", ~"Rng"]) ])]
},
self_ty: None,
explicit_self: None,
args: ~[
Ptr(~Literal(Path::new_local(~"R")),
Borrowed(None, ast::m_mutbl))
......
......@@ -27,7 +27,7 @@ pub fn expand_deriving_to_str(cx: @ext_ctxt,
MethodDef {
name: ~"to_str",
generics: LifetimeBounds::empty(),
self_ty: borrowed_explicit_self(),
explicit_self: borrowed_explicit_self(),
args: ~[],
ret_ty: Ptr(~Literal(Path::new_local(~"str")), Owned),
const_nonmatching: false,
......
......@@ -217,7 +217,7 @@ fn to_generics(&self, cx: @ext_ctxt, span: span,
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);
match *self_ptr {
None => {
......
......@@ -323,7 +323,7 @@ fn noop_fold_method(m: @method, fld: @ast_fold) -> @method {
ident: fld.fold_ident(m.ident),
attrs: /* FIXME (#2543) */ copy m.attrs,
generics: fold_generics(&m.generics, fld),
self_ty: m.self_ty,
explicit_self: m.explicit_self,
purity: m.purity,
decl: fold_fn_decl(&m.decl, fld),
body: fld.fold_block(&m.body),
......
......@@ -19,7 +19,7 @@
use ast::{bind_by_copy, bitand, bitor, bitxor, blk};
use ast::{blk_check_mode, box};
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_assign, expr_assign_op, expr_binary, expr_block};
use ast::{expr_break, expr_call, expr_cast, expr_copy, expr_do_body};
......@@ -43,7 +43,7 @@
use ast::{pat_ident, pat_lit, pat_range, pat_region, pat_struct};
use ast::{pat_tup, pat_uniq, pat_wild, private};
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::{struct_variant_kind, subtract};
use ast::{sty_box, sty_region, sty_static, sty_uniq, sty_value};
......@@ -504,7 +504,7 @@ fn parse_trait_methods(&self) -> ~[trait_method] {
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
// names to be left off if there is a definition...
either::Left(p.parse_arg_general(false))
......@@ -526,7 +526,7 @@ fn parse_trait_methods(&self) -> ~[trait_method] {
purity: pur,
decl: d,
generics: generics,
self_ty: self_ty,
explicit_self: explicit_self,
id: p.get_id(),
span: mk_sp(lo, hi)
})
......@@ -540,7 +540,7 @@ fn parse_trait_methods(&self) -> ~[trait_method] {
ident: ident,
attrs: attrs,
generics: generics,
self_ty: self_ty,
explicit_self: explicit_self,
purity: pur,
decl: d,
body: body,
......@@ -3002,11 +3002,11 @@ fn parse_fn_decl_with_self(
&self,
parse_arg_fn:
&fn(&Parser) -> arg_or_capture_item
) -> (self_ty, fn_decl) {
fn maybe_parse_self_ty(
cnstr: &fn(v: mutability) -> ast::self_ty_,
) -> (explicit_self, fn_decl) {
fn maybe_parse_explicit_self(
cnstr: &fn(v: mutability) -> ast::explicit_self_,
p: &Parser
) -> ast::self_ty_ {
) -> ast::explicit_self_ {
// We need to make sure it isn't a mode or a type
if p.token_is_keyword(&~"self", &p.look_ahead(1)) ||
((p.token_is_keyword(&~"const", &p.look_ahead(1)) ||
......@@ -3022,7 +3022,7 @@ fn maybe_parse_self_ty(
}
}
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:
//
// fn(&self)
......@@ -3066,15 +3066,15 @@ fn maybe_parse_borrowed_self_ty(this: &Parser) -> ast::self_ty_ {
// A bit of complexity and lookahead is needed here in order to to be
// backwards compatible.
let lo = self.span.lo;
let self_ty = match *self.token {
let explicit_self = match *self.token {
token::BINOP(token::AND) => {
maybe_parse_borrowed_self_ty(self)
maybe_parse_borrowed_explicit_self(self)
}
token::AT => {
maybe_parse_self_ty(sty_box, self)
maybe_parse_explicit_self(sty_box, self)
}
token::TILDE => {
maybe_parse_self_ty(sty_uniq, self)
maybe_parse_explicit_self(sty_uniq, self)
}
token::IDENT(*) if self.is_self_ident() => {
self.bump();
......@@ -3087,7 +3087,7 @@ fn maybe_parse_borrowed_self_ty(this: &Parser) -> ast::self_ty_ {
// If we parsed a self type, expect a comma before the argument list.
let args_or_capture_items;
if self_ty != sty_static {
if explicit_self != sty_static {
match *self.token {
token::COMMA => {
self.bump();
......@@ -3132,7 +3132,7 @@ fn maybe_parse_borrowed_self_ty(this: &Parser) -> ast::self_ty_ {
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
......@@ -3199,7 +3199,7 @@ fn parse_method(&self) -> @method {
let pur = self.parse_fn_purity();
let ident = self.parse_ident();
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()
};
......@@ -3210,7 +3210,7 @@ fn parse_method(&self) -> @method {
ident: ident,
attrs: attrs,
generics: generics,
self_ty: self_ty,
explicit_self: explicit_self,
purity: pur,
decl: decl,
body: body,
......
......@@ -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,
opt_self_ty: Option<ast::self_ty_>,
opt_explicit_self: Option<ast::explicit_self_>,
generics: &ast::Generics, intr: @ident_interner) -> ~str {
do io::with_str_writer |wr| {
let s = rust_printer(wr, intr);
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 outer box
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_ty_fn(s, None, None, None, m.purity, ast::Many,
&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, ~";");
}
......@@ -813,7 +813,7 @@ pub fn print_method(s: @ps, meth: @ast::method) {
maybe_print_comment(s, meth.span.lo);
print_outer_attributes(s, meth.attrs);
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);
word(s.s, ~" ");
print_block_with_attrs(s, &meth.body, meth.attrs);
......@@ -1626,13 +1626,13 @@ fn print_field(s: @ps, f: ast::field_pat, refutable: bool) {
(s.ann.post)(ann_node);
}
pub fn self_ty_to_str(self_ty: ast::self_ty_, intr: @ident_interner) -> ~str {
to_str(self_ty, |a, b| { print_self_ty(a, b); () }, intr)
pub fn explicit_self_to_str(explicit_self: ast::explicit_self_, intr: @ident_interner) -> ~str {
to_str(explicit_self, |a, b| { print_explicit_self(a, b); () }, intr)
}
// Returns whether it printed anything
pub fn print_self_ty(s: @ps, self_ty: ast::self_ty_) -> bool {
match self_ty {
pub fn print_explicit_self(s: @ps, explicit_self: ast::explicit_self_) -> bool {
match explicit_self {
ast::sty_static => { return false; }
ast::sty_value => { word(s.s, ~"self"); }
ast::sty_region(lt, m) => {
......@@ -1657,24 +1657,24 @@ pub fn print_fn(s: @ps,
abis: AbiSet,
name: ast::ident,
generics: &ast::Generics,
opt_self_ty: Option<ast::self_ty_>,
opt_explicit_self: Option<ast::explicit_self_>,
vis: ast::visibility) {
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);
print_ident(s, name);
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,
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
// self type and the args all in the same box.
box(s, 0u, inconsistent);
let mut first = true;
for opt_self_ty.each |self_ty| {
first = !print_self_ty(s, *self_ty);
for opt_explicit_self.each |explicit_self| {
first = !print_explicit_self(s, *explicit_self);
}
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,
opt_self_ty: Option<ast::self_ty_>) {
opt_explicit_self: Option<ast::explicit_self_>) {
popen(s);
print_fn_args(s, decl, opt_self_ty);
print_fn_args(s, decl, opt_explicit_self);
pclose(s);
maybe_print_comment(s, decl.output.span.lo);
......@@ -1900,7 +1900,7 @@ pub fn print_ty_fn(s: @ps,
decl: &ast::fn_decl,
id: Option<ast::ident>,
generics: Option<&ast::Generics>,
opt_self_ty: Option<ast::self_ty_>) {
opt_explicit_self: Option<ast::explicit_self_>) {
ibox(s, indent_unit);
// 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.
box(s, 0u, inconsistent);
let mut first = true;
for opt_self_ty.each |self_ty| {
first = !print_self_ty(s, *self_ty);
for opt_explicit_self.each |explicit_self| {
first = !print_explicit_self(s, *explicit_self);
}
for decl.inputs.each |arg| {
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,
_opt_sty: Option<ast::self_ty_>,
_opt_explicit_self: Option<ast::explicit_self_>,
opt_purity: Option<ast::purity>,
abis: AbiSet,
onceness: ast::Onceness,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册