diff options
| author | Lindsey Kuper <lindsey@rockstargirl.org> | 2012-07-03 16:30:42 -0700 |
|---|---|---|
| committer | Lindsey Kuper <lindsey@rockstargirl.org> | 2012-07-05 11:01:43 -0700 |
| commit | 33334f3c435926422d88dcd5bfafd5e32b141111 (patch) | |
| tree | 7ab702e7bd5565be7419e853e312c8a277b69528 /src/rustc | |
| parent | d93f3c5d835f12614f07c2d840799dd02f4780bc (diff) | |
Change 'iface' to 'trait' internally; parse `trait` as `iface` synonym
Diffstat (limited to 'src/rustc')
30 files changed, 312 insertions, 312 deletions
diff --git a/src/rustc/front/intrinsic.rs b/src/rustc/front/intrinsic.rs index cfd367bb889..214d0aa0bee 100644 --- a/src/rustc/front/intrinsic.rs +++ b/src/rustc/front/intrinsic.rs @@ -106,7 +106,7 @@ mod intrinsic { fn visit_leave_fn(purity: uint, proto: uint, n_inputs: uint, retstyle: uint) -> bool; - fn visit_iface() -> bool; + fn visit_trait() -> bool; fn visit_enter_res() -> bool; fn visit_leave_res() -> bool; fn visit_var() -> bool; diff --git a/src/rustc/metadata/astencode.rs b/src/rustc/metadata/astencode.rs index 79807a3a0ba..8d2bfad04c9 100644 --- a/src/rustc/metadata/astencode.rs +++ b/src/rustc/metadata/astencode.rs @@ -380,8 +380,8 @@ impl of tr for method_origin { typeck::method_param(did, m, p, b) { typeck::method_param(did.tr(xcx), m, p, b) } - typeck::method_iface(did, m) { - typeck::method_iface(did.tr(xcx), m) + typeck::method_trait(did, m) { + typeck::method_trait(did.tr(xcx), m) } } } @@ -441,8 +441,8 @@ fn encode_vtable_origin(ecx: @e::encode_ctxt, } } } - typeck::vtable_iface(def_id, tys) { - ebml_w.emit_enum_variant("vtable_iface", 1u, 3u) {|| + typeck::vtable_trait(def_id, tys) { + ebml_w.emit_enum_variant("vtable_trait", 1u, 3u) {|| ebml_w.emit_enum_variant_arg(0u) {|| ebml_w.emit_def_id(def_id) } @@ -490,7 +490,7 @@ impl helpers for ebml::ebml_deserializer { ) } 2u { - typeck::vtable_iface( + typeck::vtable_trait( self.read_enum_variant_arg(0u) {|| self.read_def_id(xcx) }, diff --git a/src/rustc/metadata/common.rs b/src/rustc/metadata/common.rs index 99df3c79f74..f8280494138 100644 --- a/src/rustc/metadata/common.rs +++ b/src/rustc/metadata/common.rs @@ -70,8 +70,8 @@ const tag_crate_dep_vers: uint = 0x2cu; const tag_mod_impl: uint = 0x30u; -const tag_item_iface_method: uint = 0x31u; -const tag_impl_iface: uint = 0x32u; +const tag_item_trait_method: uint = 0x31u; +const tag_impl_trait: uint = 0x32u; // discriminator value for variants const tag_disr_val: uint = 0x34u; @@ -85,13 +85,13 @@ const tag_item_field: uint = 0x44u; const tag_class_mut: uint = 0x45u; const tag_region_param: uint = 0x46u; -const tag_mod_impl_iface: uint = 0x47u; +const tag_mod_impl_trait: uint = 0x47u; /* - iface items contain tag_item_iface_method elements, + trait items contain tag_item_trait_method elements, impl items contain tag_item_impl_method elements, and classes - have both. That's because some code treats classes like ifaces, + have both. That's because some code treats classes like traits, and other code treats them like impls. Because classes can contain - both, tag_item_iface_method and tag_item_impl_method have to be two + both, tag_item_trait_method and tag_item_impl_method have to be two different tags. */ const tag_item_impl_method: uint = 0x48u; diff --git a/src/rustc/metadata/csearch.rs b/src/rustc/metadata/csearch.rs index aec32aecc43..03b3fdcba86 100644 --- a/src/rustc/metadata/csearch.rs +++ b/src/rustc/metadata/csearch.rs @@ -21,10 +21,10 @@ export lookup_defs; export lookup_method_purity; export get_enum_variants; export get_impls_for_mod; -export get_iface_methods; +export get_trait_methods; export each_path; export get_type; -export get_impl_iface; +export get_impl_trait; export get_impl_method; export get_item_path; export maybe_get_item_ast, found_ast, found, found_parent, not_found; @@ -133,10 +133,10 @@ fn get_impls_for_mod(cstore: cstore::cstore, def: ast::def_id, } } -fn get_iface_methods(tcx: ty::ctxt, def: ast::def_id) -> @~[ty::method] { +fn get_trait_methods(tcx: ty::ctxt, def: ast::def_id) -> @~[ty::method] { let cstore = tcx.cstore; let cdata = cstore::get_crate_data(cstore, def.crate); - decoder::get_iface_methods(cdata, def.node, tcx) + decoder::get_trait_methods(cdata, def.node, tcx) } fn get_class_fields(tcx: ty::ctxt, def: ast::def_id) -> ~[ty::field_ty] { @@ -171,12 +171,12 @@ fn get_field_type(tcx: ty::ctxt, class_id: ast::def_id, ret {bounds: @~[], rp: ast::rp_none, ty: ty}; } -// Given a def_id for an impl or class, return the iface it implements, -// or none if it's not for an impl or for a class that implements ifaces -fn get_impl_iface(tcx: ty::ctxt, def: ast::def_id) -> option<ty::t> { +// Given a def_id for an impl or class, return the trait it implements, +// or none if it's not for an impl or for a class that implements traits +fn get_impl_trait(tcx: ty::ctxt, def: ast::def_id) -> option<ty::t> { let cstore = tcx.cstore; let cdata = cstore::get_crate_data(cstore, def.crate); - decoder::get_impl_iface(cdata, def.node, tcx) + decoder::get_impl_trait(cdata, def.node, tcx) } fn get_impl_method(cstore: cstore::cstore, @@ -186,8 +186,8 @@ fn get_impl_method(cstore: cstore::cstore, decoder::get_impl_method(cdata, def.node, mname) } -/* Because classes use the iface format rather than the impl format - for their methods (so that get_iface_methods can be reused to get +/* Because classes use the trait format rather than the impl format + for their methods (so that get_trait_methods can be reused to get class methods), classes require a slightly different version of get_impl_method. Sigh. */ fn get_class_method(cstore: cstore::cstore, diff --git a/src/rustc/metadata/decoder.rs b/src/rustc/metadata/decoder.rs index 21cfd77bd16..33805407860 100644 --- a/src/rustc/metadata/decoder.rs +++ b/src/rustc/metadata/decoder.rs @@ -22,7 +22,7 @@ export get_symbol; export get_enum_variants; export get_type; export get_type_param_count; -export get_impl_iface; +export get_impl_trait; export get_class_method; export get_impl_method; export lookup_def; @@ -35,7 +35,7 @@ export get_crate_deps; export get_crate_hash; export get_crate_vers; export get_impls_for_mod; -export get_iface_methods; +export get_trait_methods; export get_crate_module_paths; export def_like; export dl_def; @@ -164,10 +164,10 @@ fn item_type(item_id: ast::def_id, item: ebml::doc, } else { t } } -fn item_impl_iface(item: ebml::doc, tcx: ty::ctxt, cdata: cmd) +fn item_impl_trait(item: ebml::doc, tcx: ty::ctxt, cdata: cmd) -> option<ty::t> { let mut result = none; - do ebml::tagged_docs(item, tag_impl_iface) |ity| { + do ebml::tagged_docs(item, tag_impl_trait) |ity| { result = some(doc_type(ity, tcx, cdata)); }; result @@ -328,9 +328,9 @@ fn get_type_param_count(data: @~[u8], id: ast::node_id) -> uint { item_ty_param_count(lookup_item(id, data)) } -fn get_impl_iface(cdata: cmd, id: ast::node_id, tcx: ty::ctxt) +fn get_impl_trait(cdata: cmd, id: ast::node_id, tcx: ty::ctxt) -> option<ty::t> { - item_impl_iface(lookup_item(id, cdata.data), tcx, cdata) + item_impl_trait(lookup_item(id, cdata.data), tcx, cdata) } fn get_impl_method(cdata: cmd, id: ast::node_id, @@ -354,7 +354,7 @@ fn get_class_method(cdata: cmd, id: ast::node_id, some(it) { it } none { fail (#fmt("get_class_method: class id not found \ when looking up method %s", *name)) }}; - do ebml::tagged_docs(cls_items, tag_item_iface_method) |mid| { + do ebml::tagged_docs(cls_items, tag_item_trait_method) |mid| { let m_did = class_member_id(mid, cdata); if item_name(mid) == name { found = some(m_did); @@ -601,20 +601,20 @@ fn get_impls_for_mod(cdata: cmd, @result } -/* Works for both classes and ifaces */ -fn get_iface_methods(cdata: cmd, id: ast::node_id, tcx: ty::ctxt) +/* Works for both classes and traits */ +fn get_trait_methods(cdata: cmd, id: ast::node_id, tcx: ty::ctxt) -> @~[ty::method] { let data = cdata.data; let item = lookup_item(id, data); let mut result = ~[]; - do ebml::tagged_docs(item, tag_item_iface_method) |mth| { + do ebml::tagged_docs(item, tag_item_trait_method) |mth| { let bounds = item_ty_param_bounds(mth, tcx, cdata); let name = item_name(mth); let ty = doc_type(mth, tcx, cdata); let fty = alt ty::get(ty).struct { ty::ty_fn(f) { f } _ { tcx.diag.handler().bug( - "get_iface_methods: id has non-function type"); + "get_trait_methods: id has non-function type"); } }; vec::push(result, {ident: name, tps: bounds, fty: fty, purity: alt check item_family(mth) { @@ -703,7 +703,7 @@ fn item_family_to_str(fam: char) -> str { 'n' { ret "foreign mod"; } 'v' { ret "enum"; } 'i' { ret "impl"; } - 'I' { ret "iface"; } + 'I' { ret "trait"; } 'C' { ret "class"; } 'g' { ret "public field"; } 'j' { ret "private field"; } diff --git a/src/rustc/metadata/encoder.rs b/src/rustc/metadata/encoder.rs index 4907b835107..8da5ac9420f 100644 --- a/src/rustc/metadata/encoder.rs +++ b/src/rustc/metadata/encoder.rs @@ -211,7 +211,7 @@ fn encode_module_item_paths(ebml_w: ebml::writer, ecx: @encode_ctxt, } encode_enum_variant_paths(ebml_w, variants, path, index); } - item_iface(*) { + item_trait(*) { do ebml_w.wr_tag(tag_paths_data_item) { encode_name_and_def_id(ebml_w, it.ident, it.id); } @@ -221,8 +221,8 @@ fn encode_module_item_paths(ebml_w: ebml::writer, ecx: @encode_ctxt, } } -fn encode_iface_ref(ebml_w: ebml::writer, ecx: @encode_ctxt, t: @iface_ref) { - ebml_w.start_tag(tag_impl_iface); +fn encode_trait_ref(ebml_w: ebml::writer, ecx: @encode_ctxt, t: @trait_ref) { + ebml_w.start_tag(tag_impl_trait); encode_type(ecx, ebml_w, node_id_to_type(ecx.tcx, t.id)); ebml_w.end_tag(); } @@ -396,7 +396,7 @@ fn encode_info_for_mod(ecx: @encode_ctxt, ebml_w: ebml::writer, md: _mod, ebml_w.start_tag(tag_mod_impl); alt ecx.tcx.items.find(did.node) { some(ast_map::node_item(it@@{node: cl@item_class(*),_},_)) { - /* If did stands for an iface + /* If did stands for a trait ref, we need to map it to its parent class */ ebml_w.wr_str(def_to_str(local_def(it.id))); } @@ -622,7 +622,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item, encode_enum_variant_info(ecx, ebml_w, item.id, variants, path, index, tps); } - item_class(tps, ifaces, items, ctor, m_dtor, rp) { + item_class(tps, traits, items, ctor, m_dtor, rp) { /* First, encode the fields and methods These come first because we need to write them to make the index, and the index needs to be in the item for the @@ -650,8 +650,8 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item, encode_name(ebml_w, item.ident); encode_path(ebml_w, path, ast_map::path_name(item.ident)); encode_region_param(ebml_w, rp); - for ifaces.each |t| { - encode_iface_ref(ebml_w, ecx, t); + for traits.each |t| { + encode_trait_ref(ebml_w, ecx, t); } /* Encode the dtor */ /* Encode id for dtor */ @@ -662,7 +662,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item, }; /* Encode def_ids for each field and method - for methods, write all the stuff get_iface_method + for methods, write all the stuff get_trait_method needs to know*/ let (fs,ms) = ast_util::split_class_items(items); for fs.each |f| { @@ -677,8 +677,8 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item, private { /* do nothing */ } public { /* Write the info that's needed when viewing this class - as an iface */ - ebml_w.start_tag(tag_item_iface_method); + as a trait */ + ebml_w.start_tag(tag_item_trait_method); encode_family(ebml_w, purity_fn_family(m.decl.purity)); encode_name(ebml_w, m.ident); encode_type_param_bounds(ebml_w, ecx, m.tps); @@ -713,7 +713,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item, ebml_w.end_tag(); } do option::iter(ifce) |t| { - encode_iface_ref(ebml_w, ecx, t) + encode_trait_ref(ebml_w, ecx, t) }; encode_path(ebml_w, path, ast_map::path_name(item.ident)); ebml_w.end_tag(); @@ -727,7 +727,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item, vec::append(tps, m.tps)); } } - item_iface(tps, rp, ms) { + item_trait(tps, rp, ms) { add_to_index(); ebml_w.start_tag(tag_items_data_item); encode_def_id(ebml_w, local_def(item.id)); @@ -737,8 +737,8 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item, encode_type(ecx, ebml_w, node_id_to_type(tcx, item.id)); encode_name(ebml_w, item.ident); let mut i = 0u; - for vec::each(*ty::iface_methods(tcx, local_def(item.id))) |mty| { - ebml_w.start_tag(tag_item_iface_method); + for vec::each(*ty::trait_methods(tcx, local_def(item.id))) |mty| { + ebml_w.start_tag(tag_item_trait_method); encode_name(ebml_w, mty.ident); encode_type_param_bounds(ebml_w, ecx, ms[i].tps); encode_type(ecx, ebml_w, ty::mk_fn(tcx, mty.fty)); diff --git a/src/rustc/metadata/tydecode.rs b/src/rustc/metadata/tydecode.rs index 025b7fe9e92..31a92b72f97 100644 --- a/src/rustc/metadata/tydecode.rs +++ b/src/rustc/metadata/tydecode.rs @@ -290,7 +290,7 @@ fn parse_ty(st: @pstate, conv: conv_did) -> ty::t { let def = parse_def(st, conv); let substs = parse_substs(st, conv); assert next(st) == ']'; - ret ty::mk_iface(st.tcx, def, substs); + ret ty::mk_trait(st.tcx, def, substs); } 'p' { let did = parse_def(st, conv); @@ -505,7 +505,7 @@ fn parse_bounds(st: @pstate, conv: conv_did) -> @~[ty::param_bound] { 'S' { ty::bound_send } 'C' { ty::bound_copy } 'K' { ty::bound_const } - 'I' { ty::bound_iface(parse_ty(st, conv)) } + 'I' { ty::bound_trait(parse_ty(st, conv)) } '.' { break; } }); } diff --git a/src/rustc/metadata/tyencode.rs b/src/rustc/metadata/tyencode.rs index 4190b0440af..57a696094e8 100644 --- a/src/rustc/metadata/tyencode.rs +++ b/src/rustc/metadata/tyencode.rs @@ -222,7 +222,7 @@ fn enc_sty(w: io::writer, cx: @ctxt, st: ty::sty) { enc_substs(w, cx, substs); w.write_char(']'); } - ty::ty_iface(def, substs) { + ty::ty_trait(def, substs) { w.write_str("x["/&); w.write_str(cx.ds(def)); w.write_char('|'); @@ -401,7 +401,7 @@ fn enc_bounds(w: io::writer, cx: @ctxt, bs: @~[ty::param_bound]) { ty::bound_send { w.write_char('S'); } ty::bound_copy { w.write_char('C'); } ty::bound_const { w.write_char('K'); } - ty::bound_iface(tp) { + ty::bound_trait(tp) { w.write_char('I'); enc_ty(w, cx, tp); } diff --git a/src/rustc/middle/astencode.rs b/src/rustc/middle/astencode.rs index c0d34ec3325..ced44551a7f 100644 --- a/src/rustc/middle/astencode.rs +++ b/src/rustc/middle/astencode.rs @@ -395,10 +395,10 @@ impl of tr for method_origin { typeck::method_static(did.tr(xcx)) } typeck::method_param(mp) { - typeck::method_param({iface_id:mp.iface_id.tr(xcx) with mp}) + typeck::method_param({trait_id:mp.trait_id.tr(xcx) with mp}) } - typeck::method_iface(did, m) { - typeck::method_iface(did.tr(xcx), m) + typeck::method_trait(did, m) { + typeck::method_trait(did.tr(xcx), m) } } } @@ -458,8 +458,8 @@ fn encode_vtable_origin(ecx: @e::encode_ctxt, } } } - typeck::vtable_iface(def_id, tys) { - do ebml_w.emit_enum_variant("vtable_iface", 1u, 3u) { + typeck::vtable_trait(def_id, tys) { + do ebml_w.emit_enum_variant("vtable_trait", 1u, 3u) { do ebml_w.emit_enum_variant_arg(0u) { ebml_w.emit_def_id(def_id) } @@ -507,7 +507,7 @@ impl helpers for ebml::ebml_deserializer { ) } 2u { - typeck::vtable_iface( + typeck::vtable_trait( do self.read_enum_variant_arg(0u) { self.read_def_id(xcx) }, diff --git a/src/rustc/middle/kind.rs b/src/rustc/middle/kind.rs index 1f73a8fc999..f84dd4b0652 100644 --- a/src/rustc/middle/kind.rs +++ b/src/rustc/middle/kind.rs @@ -265,16 +265,16 @@ fn check_expr(e: @expr, cx: ctx, v: visit::vt<ctx>) { // and then the method bounds themselves... ty::lookup_item_type(cx.tcx, did).bounds } - typeck::method_param({iface_id:ifce_id, + typeck::method_param({trait_id:trt_id, method_num:n_mth, _}) | - typeck::method_iface(ifce_id, n_mth) { - // ...iface methods bounds, in contrast, include only the + typeck::method_trait(trt_id, n_mth) { + // ...trait methods bounds, in contrast, include only the // method bounds, so we must preprend the tps from the - // iface itself. This ought to be harmonized. - let ifce_bounds = - ty::lookup_item_type(cx.tcx, ifce_id).bounds; - let mth = ty::iface_methods(cx.tcx, ifce_id)[n_mth]; - @(vec::append(*ifce_bounds, *mth.tps)) + // trait itself. This ought to be harmonized. + let trt_bounds = + ty::lookup_item_type(cx.tcx, trt_id).bounds; + let mth = ty::trait_methods(cx.tcx, trt_id)[n_mth]; + @(vec::append(*trt_bounds, *mth.tps)) } } } diff --git a/src/rustc/middle/resolve.rs b/src/rustc/middle/resolve.rs index 330a5dac383..51c48f6a64c 100644 --- a/src/rustc/middle/resolve.rs +++ b/src/rustc/middle/resolve.rs @@ -406,7 +406,7 @@ fn maybe_insert(e: @env, id: node_id, def: option<def>) { } } -fn resolve_iface_ref(p: @iface_ref, sc: scopes, e: @env) { +fn resolve_trait_ref(p: @trait_ref, sc: scopes, e: @env) { maybe_insert(e, p.id, lookup_path_strict(*e, sc, p.path.span, p.path, ns_type)); } @@ -436,15 +436,15 @@ fn resolve_names(e: @env, c: @ast::crate) { fn walk_item(e: @env, i: @ast::item, &&sc: scopes, v: vt<scopes>) { visit_item_with_scope(e, i, sc, v); alt i.node { - /* At this point, the code knows what ifaces the iface refs + /* At this point, the code knows what traits the trait refs refer to, so it's possible to resolve them. */ ast::item_impl(_, _, ifce, _, _) { - ifce.iter(|p| resolve_iface_ref(p, sc, e)) + ifce.iter(|p| resolve_trait_ref(p, sc, e)) } - ast::item_class(_, ifaces, _, _, _, _) { - for ifaces.each |p| { - resolve_iface_ref(p, sc, e); + ast::item_class(_, traits, _, _, _, _) { + for traits.each |p| { + resolve_trait_ref(p, sc, e); } } _ {} @@ -485,7 +485,7 @@ fn resolve_names(e: @env, c: @ast::crate) { e.current_tp = some(current); for vec::each(*tp.bounds) |bound| { alt bound { - bound_iface(t) { v.visit_ty(t, sc, v); } + bound_trait(t) { v.visit_ty(t, sc, v); } _ {} } } @@ -564,7 +564,7 @@ fn visit_item_with_scope(e: @env, i: @ast::item, m.decl, m.body, m.span, m.id, msc, v); } } - ast::item_iface(tps, _, methods) { + ast::item_trait(tps, _, methods) { v.visit_ty_params(tps, sc, v); let isc = @cons(scope_method(i.id, tps), sc); for methods.each |m| { @@ -574,14 +574,14 @@ fn visit_item_with_scope(e: @env, i: @ast::item, v.visit_ty(m.decl.output, msc, v); } } - ast::item_class(tps, ifaces, members, ctor, m_dtor, _) { + ast::item_class(tps, traits, members, ctor, m_dtor, _) { v.visit_ty_params(tps, sc, v); let class_scope = @cons(scope_item(i), sc); /* visit the constructor... */ let ctor_scope = @cons(scope_method(ctor.node.self_id, tps), class_scope); - /* visit the iface refs in the class scope */ - for ifaces.each |p| { + /* visit the trait refs in the class scope */ + for traits.each |p| { visit::visit_path(p.path, class_scope, v); } visit_fn_with_scope(e, visit::fk_ctor(i.ident, tps, ctor.node.self_id, @@ -1048,7 +1048,7 @@ fn lookup_in_scope(e: env, &&sc: scopes, sp: span, name: ident, ns: namespace, ast::item_enum(_, tps, _) | ast::item_ty(_, tps, _) { if ns == ns_type { ret lookup_in_ty_params(e, name, tps); } } - ast::item_iface(tps, _, _) { + ast::item_trait(tps, _, _) { if ns == ns_type { if *name == "self" { ret some(def_self(it.id)); @@ -1336,7 +1336,7 @@ fn found_def_item(i: @ast::item, ns: namespace) -> option<def> { ret some(ast::def_foreign_mod(local_def(i.id))); } } - ast::item_ty(*) | item_iface(*) | item_enum(*) { + ast::item_ty(*) | item_trait(*) | item_enum(*) { if ns == ns_type { ret some(ast::def_ty(local_def(i.id))); } } ast::item_class(_, _, _members, ct, _, _) { @@ -1641,7 +1641,7 @@ fn index_mod(md: ast::_mod) -> mod_index { alt it.node { ast::item_const(_, _) | ast::item_fn(_, _, _) | ast::item_mod(_) | ast::item_foreign_mod(_) | ast::item_ty(_, _, _) | - ast::item_impl(*) | ast::item_iface(*) { + ast::item_impl(*) | ast::item_trait(*) { add_to_index(index, it.ident, mie_item(it)); } ast::item_enum(variants, _, _) { @@ -1780,7 +1780,7 @@ fn check_item(e: @env, i: @ast::item, &&x: (), v: vt<()>) { ensure_unique(*e, i.span, ty_params, |tp| tp.ident, "type parameter"); } - ast::item_iface(_, _, methods) { + ast::item_trait(_, _, methods) { ensure_unique(*e, i.span, methods, |m| m.ident, "method"); } @@ -1862,7 +1862,7 @@ fn check_block(e: @env, b: ast::blk, &&x: (), v: vt<()>) { ast::item_const(_, _) | ast::item_fn(*) { add_name(values, it.span, it.ident); } - ast::item_ty(*) | ast::item_iface(*) { + ast::item_ty(*) | ast::item_trait(*) { add_name(types, it.span, it.ident); } _ { } @@ -2146,7 +2146,7 @@ type method_info = {did: def_id, n_tps: uint, ident: ast::ident}; * did: the def id of the class or impl item * ident: the name of the impl, unless it has no name (as in "impl of X") in which case the ident - is the ident of the iface that's being implemented + is the ident of the trait that's being implemented * methods: the item's methods */ type _impl = {did: def_id, ident: ast::ident, methods: ~[@method_info]}; @@ -2258,7 +2258,7 @@ fn find_impls_in_item(e: env, i: @ast::item, &impls: ~[@_impl], let n_tps = tps.len(); do vec::iter(ifces) |p| { // The def_id, in this case, identifies the combination of - // class and iface + // class and trait vec::push(impls, @{did: local_def(p.id), ident: i.ident, methods: vec::map(mthds, |m| { diff --git a/src/rustc/middle/resolve3.rs b/src/rustc/middle/resolve3.rs index f149379130c..b7dc314c801 100644 --- a/src/rustc/middle/resolve3.rs +++ b/src/rustc/middle/resolve3.rs @@ -2,7 +2,7 @@ import driver::session::session; import metadata::csearch::{each_path, get_impls_for_mod, lookup_defs}; import metadata::cstore::find_use_stmt_cnum; import metadata::decoder::{def_like, dl_def, dl_field, dl_impl}; -import syntax::ast::{_mod, arm, blk, bound_const, bound_copy, bound_iface}; +import syntax::ast::{_mod, arm, blk, bound_const, bound_copy, bound_trait}; import syntax::ast::{bound_send, capture_clause, class_ctor, class_dtor}; import syntax::ast::{class_member, class_method, crate, crate_num, decl_item}; import syntax::ast::{def, def_arg, def_binding, def_class, def_const, def_fn}; @@ -12,9 +12,9 @@ import syntax::ast::{def_upvar, def_use, def_variant, expr, expr_assign_op}; import syntax::ast::{expr_binary, expr_cast, expr_field, expr_fn}; import syntax::ast::{expr_fn_block, expr_index, expr_new, expr_path}; import syntax::ast::{expr_unary, fn_decl, foreign_item, foreign_item_fn}; -import syntax::ast::{ident, iface_ref, impure_fn, instance_var, item}; +import syntax::ast::{ident, trait_ref, impure_fn, instance_var, item}; import syntax::ast::{item_class, item_const, item_enum, item_fn}; -import syntax::ast::{item_foreign_mod, item_iface, item_impl, item_mod}; +import syntax::ast::{item_foreign_mod, item_trait, item_impl, item_mod}; import syntax::ast::{item_ty, local, local_crate, method, node_id, pat}; import syntax::ast::{pat_enum, pat_ident, path, prim_ty, stmt_decl, ty}; import syntax::ast::{ty_bool, ty_char, ty_constr, ty_f, ty_f32, ty_f64}; @@ -867,7 +867,7 @@ class Resolver { visit_item(item, new_parent, visitor); } - item_iface(*) { + item_trait(*) { (*name_bindings).define_type(def_ty(local_def(item.id))); visit_item(item, new_parent, visitor); } @@ -1233,7 +1233,7 @@ class Resolver { fn build_reduced_graph_for_impls_in_external_module(module: @Module) { // XXX: This is really unfortunate. decoder::each_path can produce - // false positives, since, in the crate metadata, an iface named 'bar' + // false positives, since, in the crate metadata, a trait named 'bar' // in module 'foo' defining a method named 'baz' will result in the // creation of a (bogus) path entry named 'foo::bar::baz', and we will // create a module node for "bar". We can identify these fake modules @@ -2747,7 +2747,7 @@ class Resolver { visitor); } - item_iface(type_parameters, _, methods) { + item_trait(type_parameters, _, methods) { // Create a new rib for the self type. let self_type_rib = @Rib(NormalRibKind); (*self.type_ribs).push(self_type_rib); @@ -3013,7 +3013,7 @@ class Resolver { bound_copy | bound_send | bound_const { // Nothing to do. } - bound_iface(interface_type) { + bound_trait(interface_type) { self.resolve_type(interface_type, visitor); } } @@ -3023,14 +3023,14 @@ class Resolver { fn resolve_class(id: node_id, type_parameters: @~[ty_param], - interfaces: ~[@iface_ref], + interfaces: ~[@trait_ref], class_members: ~[@class_member], constructor: class_ctor, optional_destructor: option<class_dtor>, visitor: ResolveVisitor) { // Add a type into the def map. This is needed to prevent an ICE in - // ty::impl_iface. + // ty::impl_trait. // If applicable, create a rib for the type parameters. let outer_type_parameter_count = (*type_parameters).len(); @@ -3055,7 +3055,7 @@ class Resolver { // definition of the interface into the definition // map. - #debug("(resolving class) found iface def: %?", def); + #debug("(resolving class) found trait def: %?", def); self.record_def(interface.id, def); @@ -3122,7 +3122,7 @@ class Resolver { fn resolve_implementation(id: node_id, span: span, type_parameters: ~[ty_param], - interface_reference: option<@iface_ref>, + interface_reference: option<@trait_ref>, self_type: @ty, methods: ~[@method], visitor: ResolveVisitor) { diff --git a/src/rustc/middle/trans/base.rs b/src/rustc/middle/trans/base.rs index 1dab44d43c0..dcbb4aa0fd9 100644 --- a/src/rustc/middle/trans/base.rs +++ b/src/rustc/middle/trans/base.rs @@ -652,7 +652,7 @@ fn make_take_glue(bcx: block, v: ValueRef, t: ty::t) { ty::ty_fn(_) { closure::make_fn_glue(bcx, v, t, take_ty) } - ty::ty_iface(_, _) { + ty::ty_trait(_, _) { let llbox = Load(bcx, GEPi(bcx, v, ~[0u, 1u])); incr_refcnt_of_boxed(bcx, llbox); bcx @@ -682,10 +682,10 @@ fn incr_refcnt_of_boxed(cx: block, box_ptr: ValueRef) { fn make_visit_glue(bcx: block, v: ValueRef, t: ty::t) { let _icx = bcx.insn_ctxt("make_visit_glue"); let mut bcx = bcx; - assert bcx.ccx().tcx.intrinsic_ifaces.contains_key(@"ty_visitor"); - let (iid, ty) = bcx.ccx().tcx.intrinsic_ifaces.get(@"ty_visitor"); + assert bcx.ccx().tcx.intrinsic_traits.contains_key(@"ty_visitor"); + let (iid, ty) = bcx.ccx().tcx.intrinsic_traits.get(@"ty_visitor"); let v = PointerCast(bcx, v, T_ptr(type_of::type_of(bcx.ccx(), ty))); - bcx = reflect::emit_calls_to_iface_visit_ty(bcx, t, v, iid); + bcx = reflect::emit_calls_to_trait_visit_ty(bcx, t, v, iid); build_return(bcx); } @@ -808,7 +808,7 @@ fn make_drop_glue(bcx: block, v0: ValueRef, t: ty::t) { ty::ty_fn(_) { closure::make_fn_glue(bcx, v0, t, drop_ty) } - ty::ty_iface(_, _) { + ty::ty_trait(_, _) { let llbox = Load(bcx, GEPi(bcx, v0, ~[0u, 1u])); decr_refcnt_maybe_free(bcx, llbox, ty::mk_opaque_box(ccx.tcx)) } @@ -2063,7 +2063,7 @@ fn normalize_for_monomorphization(tcx: ty::ctxt, ty: ty::t) -> option<ty::t> { output: ty::mk_nil(tcx), ret_style: ast::return_val, constraints: ~[]})) } - ty::ty_iface(_, _) { some(ty::mk_fn(tcx, {purity: ast::impure_fn, + ty::ty_trait(_, _) { some(ty::mk_fn(tcx, {purity: ast::impure_fn, proto: ast::proto_box, inputs: ~[], output: ty::mk_nil(tcx), @@ -2085,7 +2085,7 @@ fn make_mono_id(ccx: @crate_ctxt, item: ast::def_id, substs: ~[ty::t], let mut v = ~[]; for vec::each(*bounds) |bound| { alt bound { - ty::bound_iface(_) { + ty::bound_trait(_) { vec::push(v, impl::vtable_id(ccx, vts[i])); i += 1u; } @@ -2822,7 +2822,7 @@ fn trans_cast(cx: block, e: @ast::expr, id: ast::node_id, let ccx = cx.ccx(); let t_out = node_id_type(cx, id); alt ty::get(t_out).struct { - ty::ty_iface(_, _) { ret impl::trans_cast(cx, e, id, dest); } + ty::ty_trait(_, _) { ret impl::trans_cast(cx, e, id, dest); } _ {} } let e_res = trans_temp_expr(cx, e); @@ -4964,7 +4964,7 @@ fn trans_item(ccx: @crate_ctxt, item: ast::item) { }; foreign::trans_foreign_mod(ccx, foreign_mod, abi); } - ast::item_class(tps, _ifaces, items, ctor, m_dtor, _) { + ast::item_class(tps, _traits, items, ctor, m_dtor, _) { if tps.len() == 0u { let psubsts = {tys: ty::ty_params_to_tys(ccx.tcx, tps), vtables: none, diff --git a/src/rustc/middle/trans/common.rs b/src/rustc/middle/trans/common.rs index 3125f3d84b8..cd1161e055c 100644 --- a/src/rustc/middle/trans/common.rs +++ b/src/rustc/middle/trans/common.rs @@ -783,7 +783,7 @@ fn T_captured_tydescs(cx: @crate_ctxt, n: uint) -> TypeRef { ret T_struct(vec::from_elem::<TypeRef>(n, T_ptr(cx.tydesc_type))); } -fn T_opaque_iface(cx: @crate_ctxt) -> TypeRef { +fn T_opaque_trait(cx: @crate_ctxt) -> TypeRef { T_struct(~[T_ptr(cx.tydesc_type), T_opaque_box_ptr(cx)]) } diff --git a/src/rustc/middle/trans/impl.rs b/src/rustc/middle/trans/impl.rs index d9ea8316054..b95864f5132 100644 --- a/src/rustc/middle/trans/impl.rs +++ b/src/rustc/middle/trans/impl.rs @@ -58,7 +58,7 @@ fn trans_method_callee(bcx: block, callee_id: ast::node_id, {env: self_env(val, node_id_type(bcx, self.id), none) with lval_static_fn(bcx, did, callee_id)} } - typeck::method_param({iface_id:iid, method_num:off, + typeck::method_param({trait_id:iid, method_num:off, param_num:p, bound_num:b}) { alt check bcx.fcx.param_substs { some(substs) { @@ -67,10 +67,10 @@ fn trans_method_callee(bcx: block, callee_id: ast::node_id, } } } - typeck::method_iface(_, off) { + typeck::method_trait(_, off) { let {bcx, val} = trans_temp_expr(bcx, self); let fty = node_id_type(bcx, callee_id); - trans_iface_callee(bcx, val, fty, off) + trans_trait_callee(bcx, val, fty, off) } } } @@ -112,14 +112,14 @@ fn method_ty_param_count(ccx: @crate_ctxt, m_id: ast::def_id, fn trans_monomorphized_callee(bcx: block, callee_id: ast::node_id, base: @ast::expr, derefs: uint, - iface_id: ast::def_id, n_method: uint, + trait_id: ast::def_id, n_method: uint, n_param: uint, n_bound: uint, substs: param_substs) -> lval_maybe_callee { let _icx = bcx.insn_ctxt("impl::trans_monomorphized_callee"); alt find_vtable_in_fn_ctxt(substs, n_param, n_bound) { typeck::vtable_static(impl_did, impl_substs, sub_origins) { let ccx = bcx.ccx(); - let mname = ty::iface_methods(ccx.tcx, iface_id)[n_method].ident; + let mname = ty::trait_methods(ccx.tcx, trait_id)[n_method].ident; let mth_id = method_with_name(bcx.ccx(), impl_did, mname); let n_m_tps = method_ty_param_count(ccx, mth_id, impl_did); let node_substs = node_id_type_params(bcx, callee_id); @@ -135,10 +135,10 @@ fn trans_monomorphized_callee(bcx: block, callee_id: ast::node_id, ccx, node_id_type(bcx, callee_id)))) with lval} } - typeck::vtable_iface(iid, tps) { + typeck::vtable_trait(iid, tps) { let {bcx, val} = trans_temp_expr(bcx, base); let fty = node_id_type(bcx, callee_id); - trans_iface_callee(bcx, val, fty, n_method) + trans_trait_callee(bcx, val, fty, n_method) } typeck::vtable_param(n_param, n_bound) { fail "vtable_param left in monomorphized function's vtable substs"; @@ -146,11 +146,11 @@ fn trans_monomorphized_callee(bcx: block, callee_id: ast::node_id, } } -// Method callee where the vtable comes from a boxed iface -fn trans_iface_callee(bcx: block, val: ValueRef, +// Method callee where the vtable comes from a boxed trait +fn trans_trait_callee(bcx: block, val: ValueRef, callee_ty: ty::t, n_method: uint) -> lval_maybe_callee { - let _icx = bcx.insn_ctxt("impl::trans_iface_callee"); + let _icx = bcx.insn_ctxt("impl::trans_trait_callee"); let ccx = bcx.ccx(); let vtable = Load(bcx, PointerCast(bcx, GEPi(bcx, val, ~[0u, 0u]), T_ptr(T_ptr(T_vtable())))); @@ -173,7 +173,7 @@ fn find_vtable_in_fn_ctxt(ps: param_substs, n_param: uint, n_bound: uint) for vec::each(*ps.bounds) |bounds| { if i >= n_param { break; } for vec::each(*bounds) |bound| { - alt bound { ty::bound_iface(_) { vtable_off += 1u; } _ {} } + alt bound { ty::bound_trait(_) { vtable_off += 1u; } _ {} } } i += 1u; } @@ -215,8 +215,8 @@ fn vtable_id(ccx: @crate_ctxt, origin: typeck::vtable_origin) -> mono_id { if (*sub_vtables).len() == 0u { none } else { some(sub_vtables) }, none) } - typeck::vtable_iface(iface_id, substs) { - @{def: iface_id, + typeck::vtable_trait(trait_id, substs) { + @{def: trait_id, params: vec::map(substs, |t| mono_precise(t, none))} } } @@ -254,11 +254,11 @@ fn make_impl_vtable(ccx: @crate_ctxt, impl_id: ast::def_id, substs: ~[ty::t], let _icx = ccx.insn_ctxt("impl::make_impl_vtable"); let tcx = ccx.tcx; let ifce_id = expect(ccx.sess, - ty::ty_to_def_id(option::get(ty::impl_iface(tcx, + ty::ty_to_def_id(option::get(ty::impl_trait(tcx, impl_id))), - || "make_impl_vtable: non-iface-type implemented"); + || "make_impl_vtable: non-trait-type implemented"); let has_tps = (*ty::lookup_item_type(ccx.tcx, impl_id).bounds).len() > 0u; - make_vtable(ccx, vec::map(*ty::iface_methods(tcx, ifce_id), |im| { + make_vtable(ccx, vec::map(*ty::trait_methods(tcx, ifce_id), |im| { let fty = ty::subst_tps(tcx, substs, ty::mk_fn(tcx, im.fty)); if (*im.tps).len() > 0u || ty::type_has_self(fty) { C_null(T_ptr(T_nil())) diff --git a/src/rustc/middle/trans/reachable.rs b/src/rustc/middle/trans/reachable.rs index 40db9c9c0db..edf76f42303 100644 --- a/src/rustc/middle/trans/reachable.rs +++ b/src/rustc/middle/trans/reachable.rs @@ -121,7 +121,7 @@ fn traverse_public_item(cx: ctx, item: @item) { } } } - item_class(tps, _ifaces, items, ctor, m_dtor, _) { + item_class(tps, _traits, items, ctor, m_dtor, _) { cx.rmap.insert(ctor.node.id, ()); do option::iter(m_dtor) |dtor| { cx.rmap.insert(dtor.node.id, ()); @@ -147,7 +147,7 @@ fn traverse_public_item(cx: ctx, item: @item) { traverse_ty(t, cx, mk_ty_visitor()); } item_const(*) | - item_enum(*) | item_iface(*) {} + item_enum(*) | item_trait(*) {} } } diff --git a/src/rustc/middle/trans/reflect.rs b/src/rustc/middle/trans/reflect.rs index 730686b9df7..3d5304f5f5c 100644 --- a/src/rustc/middle/trans/reflect.rs +++ b/src/rustc/middle/trans/reflect.rs @@ -47,7 +47,7 @@ impl methods for reflector { let v = self.visitor_val; let get_lval = |bcx| { let callee = - impl::trans_iface_callee(bcx, v, mth_ty, mth_idx); + impl::trans_trait_callee(bcx, v, mth_ty, mth_idx); #debug("calling mth ty %s, lltype %s", ty_to_str(bcx.ccx().tcx, mth_ty), val_str(bcx.ccx().tn, callee.val)); @@ -256,7 +256,7 @@ impl methods for reflector { } // Miscallaneous extra types - ty::ty_iface(_, _) { self.leaf("iface") } + ty::ty_trait(_, _) { self.leaf("trait") } ty::ty_var(_) { self.leaf("var") } ty::ty_var_integral(_) { self.leaf("var_integral") } ty::ty_param(n, _) { self.visit("param", ~[self.c_uint(n)]) } @@ -278,13 +278,13 @@ impl methods for reflector { } // Emit a sequence of calls to visit_ty::visit_foo -fn emit_calls_to_iface_visit_ty(bcx: block, t: ty::t, +fn emit_calls_to_trait_visit_ty(bcx: block, t: ty::t, visitor_val: ValueRef, visitor_iid: def_id) -> block { let r = reflector({ visitor_val: visitor_val, - visitor_methods: ty::iface_methods(bcx.tcx(), visitor_iid), + visitor_methods: ty::trait_methods(bcx.tcx(), visitor_iid), mut bcx: bcx }); diff --git a/src/rustc/middle/trans/shape.rs b/src/rustc/middle/trans/shape.rs index 2e2403090f5..da37a59dc09 100644 --- a/src/rustc/middle/trans/shape.rs +++ b/src/rustc/middle/trans/shape.rs @@ -329,7 +329,7 @@ fn shape_of(ccx: @crate_ctxt, t: ty::t) -> ~[u8] { add_substr(s, sub); s } - ty::ty_iface(_, _) { ~[shape_box_fn] } + ty::ty_trait(_, _) { ~[shape_box_fn] } ty::ty_class(did, substs) { // same as records, unless there's a dtor let tps = substs.tps; diff --git a/src/rustc/middle/trans/type_of.rs b/src/rustc/middle/trans/type_of.rs index 52dd2675040..cfc1f621efd 100644 --- a/src/rustc/middle/trans/type_of.rs +++ b/src/rustc/middle/trans/type_of.rs @@ -140,7 +140,7 @@ fn type_of(cx: @crate_ctxt, t: ty::t) -> TypeRef { T_struct(tys) } ty::ty_fn(_) { T_fn_pair(cx, type_of_fn_from_ty(cx, t)) } - ty::ty_iface(_, _) { T_opaque_iface(cx) } + ty::ty_trait(_, _) { T_opaque_trait(cx) } ty::ty_type { T_ptr(cx.tydesc_type) } ty::ty_tup(elts) { let mut tys = ~[]; diff --git a/src/rustc/middle/trans/type_use.rs b/src/rustc/middle/trans/type_use.rs index 15d69df36b1..c8ff5ef4c16 100644 --- a/src/rustc/middle/trans/type_use.rs +++ b/src/rustc/middle/trans/type_use.rs @@ -119,12 +119,12 @@ fn type_needs_inner(cx: ctx, use: uint, ty: ty::t, alt ty::get(ty).struct { /* This previously included ty_box -- that was wrong - because if we cast an @T to an iface (for example) and return + because if we cast an @T to an trait (for example) and return it, we depend on the drop glue for T (we have to write the right tydesc into the result) */ ty::ty_fn(_) | ty::ty_ptr(_) | ty::ty_rptr(_, _) - | ty::ty_iface(_, _) { false } + | ty::ty_trait(_, _) { false } ty::ty_enum(did, substs) { if option::is_none(list::find(enums_seen, |id| id == did)) { let seen = @cons(did, enums_seen); @@ -164,8 +164,8 @@ fn mark_for_expr(cx: ctx, e: @expr) { expr_cast(base, _) { let result_t = ty::node_id_to_type(cx.ccx.tcx, e.id); alt ty::get(result_t).struct { - ty::ty_iface(*) { - // When we're casting to an iface, we need the + ty::ty_trait(*) { + // When we're casting to an trait, we need the // tydesc for the expr that's being cast. node_type_needs(cx, use_tydesc, base.id); } @@ -221,7 +221,7 @@ fn mark_for_expr(cx: ctx, e: @expr) { typeck::method_param({param_num: param, _}) { cx.uses[param] |= use_tydesc; } - typeck::method_iface(_, _) {} + typeck::method_trait(_, _) {} } } } diff --git a/src/rustc/middle/tstate/pre_post_conditions.rs b/src/rustc/middle/tstate/pre_post_conditions.rs index 197ed4b3108..0561a04544a 100644 --- a/src/rustc/middle/tstate/pre_post_conditions.rs +++ b/src/rustc/middle/tstate/pre_post_conditions.rs @@ -48,7 +48,7 @@ fn find_pre_post_item(ccx: crate_ctxt, i: item) { } item_mod(m) { find_pre_post_mod(m); } item_foreign_mod(nm) { find_pre_post_foreign_mod(nm); } - item_ty(*) | item_enum(*) | item_iface(*) { ret; } + item_ty(*) | item_enum(*) | item_trait(*) { ret; } item_class(*) { fail "find_pre_post_item: shouldn't be called on item_class"; } diff --git a/src/rustc/middle/ty.rs b/src/rustc/middle/ty.rs index 455408b7e5a..bdb7cb4d472 100644 --- a/src/rustc/middle/ty.rs +++ b/src/rustc/middle/ty.rs @@ -69,7 +69,7 @@ export subst, subst_tps, substs_is_noop, substs_to_str, substs; export t; export new_ty_hash; export enum_variants, substd_enum_variants, enum_is_univariant; -export iface_methods, store_iface_methods, impl_iface; +export trait_methods, store_trait_methods, impl_trait; export enum_variant_with_id; export ty_dtor; export ty_param_bounds_and_ty; @@ -92,7 +92,7 @@ export ty_evec, mk_evec; export ty_unboxed_vec, mk_unboxed_vec, mk_mut_unboxed_vec; export vstore, vstore_fixed, vstore_uniq, vstore_box, vstore_slice; export ty_nil, mk_nil, type_is_nil; -export ty_iface, mk_iface; +export ty_trait, mk_trait; export ty_param, mk_param, ty_params_to_tys; export ty_ptr, mk_ptr, mk_mut_ptr, mk_imm_ptr, mk_nil_ptr, type_is_unsafe_ptr; export ty_rptr, mk_rptr; @@ -154,7 +154,7 @@ export closure_kind; export ck_block; export ck_box; export ck_uniq; -export param_bound, param_bounds, bound_copy, bound_send, bound_iface; +export param_bound, param_bounds, bound_copy, bound_send, bound_trait; export param_bounds_to_kind; export default_arg_mode_for_ty; export item_path; @@ -240,7 +240,7 @@ type ctxt = node_type_substs: hashmap<node_id, ~[t]>, items: ast_map::map, - intrinsic_ifaces: hashmap<ast::ident, (ast::def_id, t)>, + intrinsic_traits: hashmap<ast::ident, (ast::def_id, t)>, freevars: freevars::freevar_map, tcache: type_cache, rcache: creader_cache, @@ -250,7 +250,7 @@ type ctxt = kind_cache: hashmap<t, kind>, ast_ty_to_ty_cache: hashmap<@ast::ty, ast_ty_to_ty_cache_entry>, enum_var_cache: hashmap<def_id, @~[variant_info]>, - iface_method_cache: hashmap<def_id, @~[method]>, + trait_method_cache: hashmap<def_id, @~[method]>, ty_param_bounds: hashmap<ast::node_id, param_bounds>, inferred_modes: hashmap<ast::node_id, ast::mode>, // maps the id of borrowed expr to scope of borrowed ptr @@ -366,7 +366,7 @@ enum sty { ty_rptr(region, mt), ty_rec(~[field]), ty_fn(fn_ty), - ty_iface(def_id, substs), + ty_trait(def_id, substs), ty_class(def_id, substs), ty_tup(~[t]), @@ -426,7 +426,7 @@ enum param_bound { bound_copy, bound_send, bound_const, - bound_iface(t), + bound_trait(t), } enum tv_vid = uint; @@ -468,7 +468,7 @@ fn param_bounds_to_kind(bounds: param_bounds) -> kind { } bound_send { kind = raise_kind(kind, kind_send_only()); } bound_const { kind = raise_kind(kind, kind_const()); } - bound_iface(_) {} + bound_trait(_) {} } } kind @@ -519,7 +519,7 @@ fn mk_ctxt(s: session::session, dm: resolve::def_map, amap: ast_map::map, node_types: @smallintmap::mk(), node_type_substs: map::int_hash(), items: amap, - intrinsic_ifaces: map::box_str_hash(), + intrinsic_traits: map::box_str_hash(), freevars: freevars, tcache: ast_util::new_def_hash(), rcache: mk_rcache(), @@ -530,7 +530,7 @@ fn mk_ctxt(s: session::session, dm: resolve::def_map, amap: ast_map::map, ast_ty_to_ty_cache: map::hashmap( ast_util::hash_ty, ast_util::eq_ty), enum_var_cache: new_def_hash(), - iface_method_cache: new_def_hash(), + trait_method_cache: new_def_hash(), ty_param_bounds: map::int_hash(), inferred_modes: map::int_hash(), borrowings: map::int_hash(), @@ -578,7 +578,7 @@ fn mk_t_with_id(cx: ctxt, st: sty, o_def_id: option<ast::def_id>) -> t { ty_param(_, _) { flags |= has_params as uint; } ty_var(_) | ty_var_integral(_) { flags |= needs_infer as uint; } ty_self { flags |= has_self as uint; } - ty_enum(_, substs) | ty_class(_, substs) | ty_iface(_, substs) { + ty_enum(_, substs) | ty_class(_, substs) | ty_trait(_, substs) { flags |= sflags(substs); } ty_box(m) | ty_uniq(m) | ty_vec(m) | ty_evec(m, _) | @@ -704,8 +704,8 @@ fn mk_tup(cx: ctxt, ts: ~[t]) -> t { mk_t(cx, ty_tup(ts)) } fn mk_fn(cx: ctxt, fty: fn_ty) -> t { mk_t(cx, ty_fn(fty)) } -fn mk_iface(cx: ctxt, did: ast::def_id, substs: substs) -> t { - mk_t(cx, ty_iface(did, substs)) +fn mk_trait(cx: ctxt, did: ast::def_id, substs: substs) -> t { + mk_t(cx, ty_trait(did, substs)) } fn mk_class(cx: ctxt, class_id: ast::def_id, substs: substs) -> t { @@ -775,7 +775,7 @@ fn maybe_walk_ty(ty: t, f: fn(t) -> bool) { maybe_walk_ty(tm.ty, f); } ty_enum(_, substs) | ty_class(_, substs) | - ty_iface(_, substs) { + ty_trait(_, substs) { for substs.tps.each |subty| { maybe_walk_ty(subty, f); } } ty_rec(fields) { @@ -824,8 +824,8 @@ fn fold_sty(sty: sty, fldop: fn(t) -> t) -> sty { ty_enum(tid, substs) { ty_enum(tid, fold_substs(substs, fldop)) } - ty_iface(did, substs) { - ty_iface(did, fold_substs(substs, fldop)) + ty_trait(did, substs) { + ty_trait(did, fold_substs(substs, fldop)) } ty_rec(fields) { let new_fields = do vec::map(fields) |fl| { @@ -924,8 +924,8 @@ fn fold_regions_and_ty( ty_class(def_id, substs) { ty::mk_class(cx, def_id, fold_substs(substs, fldr, fldt)) } - ty_iface(def_id, substs) { - ty::mk_iface(cx, def_id, fold_substs(substs, fldr, fldt)) + ty_trait(def_id, substs) { + ty::mk_trait(cx, def_id, fold_substs(substs, fldr, fldt)) } sty @ ty_fn(_) { fold_sty_to_ty(cx, sty, |t| fldfnt(t)) @@ -1074,7 +1074,7 @@ fn type_is_bool(ty: t) -> bool { get(ty).struct == ty_bool } fn type_is_structural(ty: t) -> bool { alt get(ty).struct { ty_rec(_) | ty_class(*) | ty_tup(_) | ty_enum(*) | ty_fn(_) | - ty_iface(*) | ty_evec(_, vstore_fixed(_)) + ty_trait(*) | ty_evec(_, vstore_fixed(_)) | ty_estr(vstore_fixed(_)) { true } _ { false } } @@ -1497,7 +1497,7 @@ fn type_kind(cx: ctxt, ty: t) -> kind { else { kind_implicitly_copyable() } } } - ty_iface(_, _) { kind_implicitly_copyable() } + ty_trait(_, _) { kind_implicitly_copyable() } ty_rptr(_, _) { kind_implicitly_copyable() } // Unique boxes and vecs have the kind of their contained type, @@ -1669,7 +1669,7 @@ fn is_instantiable(cx: ctxt, r_ty: t) -> bool { } } - ty_iface(_, _) { + ty_trait(_, _) { false } @@ -1834,7 +1834,7 @@ fn type_is_pod(cx: ctxt, ty: t) -> bool { ty_str | ty_box(_) | ty_uniq(_) | ty_vec(_) | ty_fn(_) | ty_estr(vstore_uniq) | ty_estr(vstore_box) | ty_evec(_, vstore_uniq) | ty_evec(_, vstore_box) | - ty_iface(_, _) | ty_rptr(_,_) | ty_opaque_box { result = false; } + ty_trait(_, _) | ty_rptr(_,_) | ty_opaque_box { result = false; } // Structural types ty_enum(did, substs) { let variants = enum_variants(cx, did); @@ -2066,7 +2066,7 @@ fn hash_type_structure(st: sty) -> uint { h } ty_uniq(mt) { hash_subty(37u, mt.ty) } - ty_iface(did, substs) { + ty_trait(did, substs) { let mut h = hash_def(40u, did); hash_substs(h, substs) } @@ -2402,7 +2402,7 @@ fn ty_sort_str(cx: ctxt, t: t) -> str { ty_rptr(_, _) { "&-ptr" } ty_rec(_) { "record" } ty_fn(_) { "fn" } - ty_iface(id, _) { #fmt["iface %s", item_path_str(cx, id)] } + ty_trait(id, _) { #fmt["trait %s", item_path_str(cx, id)] } ty_class(id, _) { #fmt["class %s", item_path_str(cx, id)] } ty_tup(_) { "tuple" } ty_var(_) { "variable" } @@ -2513,25 +2513,25 @@ fn def_has_ty_params(def: ast::def) -> bool { } } -fn store_iface_methods(cx: ctxt, id: ast::node_id, ms: @~[method]) { - cx.iface_method_cache.insert(ast_util::local_def(id), ms); +fn store_trait_methods(cx: ctxt, id: ast::node_id, ms: @~[method]) { + cx.trait_method_cache.insert(ast_util::local_def(id), ms); } -fn iface_methods(cx: ctxt, id: ast::def_id) -> @~[method] { - alt cx.iface_method_cache.find(id) { +fn trait_methods(cx: ctxt, id: ast::def_id) -> @~[method] { + alt cx.trait_method_cache.find(id) { some(ms) { ret ms; } _ {} } // Local interfaces are supposed to have been added explicitly. assert id.crate != ast::local_crate; - let result = csearch::get_iface_methods(cx, id); - cx.iface_method_cache.insert(id, result); + let result = csearch::get_trait_methods(cx, id); + cx.trait_method_cache.insert(id, result); result } -fn impl_iface(cx: ctxt, id: ast::def_id) -> option<t> { +fn impl_trait(cx: ctxt, id: ast::def_id) -> option<t> { if id.crate == ast::local_crate { - #debug("(impl_iface) searching for iface impl %?", id); + #debug("(impl_trait) searching for trait impl %?", id); alt cx.items.find(id.node) { some(ast_map::node_item(@{node: ast::item_impl( _, _, some(@{id: id, _}), _, _), _}, _)) { @@ -2540,13 +2540,13 @@ fn impl_iface(cx: ctxt, id: ast::def_id) -> option<t> { some(ast_map::node_item(@{node: ast::item_class(_, _, _, _, _, _), _},_)) { alt cx.def_map.find(id.node) { - some(def_ty(iface_id)) { + some(def_ty(trait_id)) { // XXX: Doesn't work cross-crate. - #debug("(impl_iface) found iface id %?", iface_id); - some(node_id_to_type(cx, iface_id.node)) + #debug("(impl_trait) found trait id %?", trait_id); + some(node_id_to_type(cx, trait_id.node)) } some(x) { - cx.sess.bug(#fmt("impl_iface: iface ref is in iface map \ + cx.sess.bug(#fmt("impl_trait: trait ref is in trait map \ but is bound to %?", x)); } none { @@ -2557,13 +2557,13 @@ fn impl_iface(cx: ctxt, id: ast::def_id) -> option<t> { _ { none } } } else { - csearch::get_impl_iface(cx, id) + csearch::get_impl_trait(cx, id) } } fn ty_to_def_id(ty: t) -> option<ast::def_id> { alt get(ty).struct { - ty_iface(id, _) | ty_class(id, _) | ty_enum(id, _) { + ty_trait(id, _) | ty_class(id, _) | ty_enum(id, _) { some(id) } _ { none } diff --git a/src/rustc/middle/typeck.rs b/src/rustc/middle/typeck.rs index 92fbac20885..aaad7841d4c 100644 --- a/src/rustc/middle/typeck.rs +++ b/src/rustc/middle/typeck.rs @@ -5,7 +5,7 @@ typeck.rs, an introduction The type checker is responsible for: 1. Determining the type of each expression -2. Resolving methods and ifaces +2. Resolving methods and traits 3. Guaranteeing that most type rules are met ("most?", you say, "why most?" Well, dear reader, read on) @@ -81,28 +81,28 @@ enum method_origin { // fully statically resolved method method_static(ast::def_id), - // method invoked on a type parameter with a bounded iface + // method invoked on a type parameter with a bounded trait method_param(method_param), - // method invoked on a boxed iface - method_iface(ast::def_id, uint), + // method invoked on a boxed trait + method_trait(ast::def_id, uint), } // details for a method invoked with a receiver whose type is a type parameter -// with a bounded iface. +// with a bounded trait. #[auto_serialize] type method_param = { - // the iface containing the method to be invoked - iface_id: ast::def_id, + // the trait containing the method to be invoked + trait_id: ast::def_id, - // index of the method to be invoked amongst the iface's methods + // index of the method to be invoked amongst the trait's methods method_num: uint, // index of the type parameter (from those that are in scope) that is // the type of the receiver param_num: uint, - // index of the bound for this type parameter which specifies the iface + // index of the bound for this type parameter which specifies the trait bound_num: uint }; @@ -140,9 +140,9 @@ enum vtable_origin { vtable_param(uint, uint), /* Dynamic vtable, comes from something known to have an interface - type. def_id refers to the iface item, tys are the substs + type. def_id refers to the trait item, tys are the substs */ - vtable_iface(ast::def_id, ~[ty::t]), + vtable_trait(ast::def_id, ~[ty::t]), } type vtable_map = hashmap<ast::node_id, vtable_res>; diff --git a/src/rustc/middle/typeck/astconv.rs b/src/rustc/middle/typeck/astconv.rs index c48c46151e7..2561c66940a 100644 --- a/src/rustc/middle/typeck/astconv.rs +++ b/src/rustc/middle/typeck/astconv.rs @@ -21,7 +21,7 @@ * region, or `type_rscope`, which permits the self region if the type in * question is parameterized by a region. * - * Unlike the `ast_conv` iface, the region scope can change as we descend + * Unlike the `ast_conv` trait, the region scope can change as we descend * the type. This is to accommodate the fact that (a) fn types are binding * scopes and (b) the default region may change. To understand case (a), * consider something like: @@ -304,8 +304,8 @@ fn ast_ty_to_ty<AC: ast_conv, RS: region_scope copy>( ty::mk_param(tcx, n, id) } ast::def_self(_) { - // n.b.: resolve guarantees that the self type only appears in an - // iface, which we rely upon in various places when creating + // n.b.: resolve guarantees that the self type only appears in a + // trait, which we rely upon in various places when creating // substs check_path_args(tcx, path, NO_TPS | NO_REGIONS); ty::mk_self(tcx) diff --git a/src/rustc/middle/typeck/check.rs b/src/rustc/middle/typeck/check.rs index 5f2aa608e62..647498a97e1 100644 --- a/src/rustc/middle/typeck/check.rs +++ b/src/rustc/middle/typeck/check.rs @@ -30,7 +30,7 @@ can be broken down into several distinct phases: final assignments of the various region variables if there is some flexibility. -- vtable: find and records the impls to use for each iface bound that +- vtable: find and records the impls to use for each trait bound that appears on a type parameter. - writeback: writes the final types within a function body, replacing @@ -358,7 +358,7 @@ fn check_item(ccx: @crate_ctxt, it: @ast::item) { let self_ty = ccx.to_ty(rscope::type_rscope(rp), ty); for ms.each |m| { check_method(ccx, m, self_ty);} } - ast::item_class(tps, ifaces, members, ctor, m_dtor, rp) { + ast::item_class(tps, traits, members, ctor, m_dtor, rp) { let tcx = ccx.tcx; let class_t = ty::node_id_to_type(tcx, it.id); // typecheck the ctor @@ -1090,8 +1090,8 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, // Something of a hack: special rules for comparison operators that // simply unify LHS and RHS. This helps with inference as LHS and RHS // do not need to be "resolvable". Some tests, particularly those with - // complicated iface requirements, fail without this---I think this code - // can be removed if we improve iface resolution to be more eager when + // complicated trait requirements, fail without this---I think this code + // can be removed if we improve trait resolution to be more eager when // possible. ast::expr_binary(ast::eq, lhs, rhs) | ast::expr_binary(ast::ne, lhs, rhs) | @@ -1392,7 +1392,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, alt ty::get(t_1).struct { // This will be looked up later on - ty::ty_iface(*) {} + ty::ty_trait(*) {} _ { if ty::type_is_nil(t_e) { @@ -1518,7 +1518,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, } ty::ty_class(base_id, substs) { // This is just for fields -- the same code handles - // methods in both classes and ifaces + // methods in both classes and traits // (1) verify that the class id actually has a field called // field @@ -2259,9 +2259,9 @@ fn check_intrinsic_type(ccx: @crate_ctxt, it: @ast::foreign_item) { } "visit_ty" { - assert ccx.tcx.intrinsic_ifaces.contains_key(@"ty_visitor"); - let (_, visitor_iface) = ccx.tcx.intrinsic_ifaces.get(@"ty_visitor"); - (1u, ~[arg(ast::by_ref, visitor_iface)], ty::mk_nil(tcx)) + assert ccx.tcx.intrinsic_traits.contains_key(@"ty_visitor"); + let (_, visitor_trait) = ccx.tcx.intrinsic_traits.get(@"ty_visitor"); + (1u, ~[arg(ast::by_ref, visitor_trait)], ty::mk_nil(tcx)) } "frame_address" { let fty = ty::mk_fn(ccx.tcx, { diff --git a/src/rustc/middle/typeck/check/method.rs b/src/rustc/middle/typeck/check/method.rs index 3cbdfe98198..709db8733d5 100644 --- a/src/rustc/middle/typeck/check/method.rs +++ b/src/rustc/middle/typeck/check/method.rs @@ -64,8 +64,8 @@ class lookup { ty::ty_param(n, did) { self.add_candidates_from_param(n, did); } - ty::ty_iface(did, substs) { - self.add_candidates_from_iface(did, substs); + ty::ty_trait(did, substs) { + self.add_candidates_from_trait(did, substs); } ty::ty_class(did, substs) { self.add_candidates_from_class(did, substs); @@ -111,10 +111,10 @@ class lookup { self.report_static_candidate(i, did); } method_param(p) { - self.report_param_candidate(i, p.iface_id); + self.report_param_candidate(i, p.trait_id); } - method_iface(did, _) { - self.report_iface_candidate(i, did); + method_trait(did, _) { + self.report_trait_candidate(i, did); } } } @@ -148,11 +148,11 @@ class lookup { ty::item_path_str(self.tcx(), did)]); } - fn report_iface_candidate(idx: uint, did: ast::def_id) { + fn report_trait_candidate(idx: uint, did: ast::def_id) { self.tcx().sess.span_note( self.expr.span, #fmt["candidate #%u derives from the type of the receiver, \ - which is the iface `%s`", + which is the trait `%s`", (idx+1u), ty::item_path_str(self.tcx(), did)]); } @@ -161,25 +161,25 @@ class lookup { #debug["candidates_from_param"]; let tcx = self.tcx(); - let mut iface_bnd_idx = 0u; // count only iface bounds + let mut trait_bnd_idx = 0u; // count only trait bounds let bounds = tcx.ty_param_bounds.get(did.node); for vec::each(*bounds) |bound| { let (iid, bound_substs) = alt bound { ty::bound_copy | ty::bound_send | ty::bound_const { cont; /* ok */ } - ty::bound_iface(bound_t) { + ty::bound_trait(bound_t) { alt check ty::get(bound_t).struct { - ty::ty_iface(i, substs) { (i, substs) } + ty::ty_trait(i, substs) { (i, substs) } } } }; - let ifce_methods = ty::iface_methods(tcx, iid); + let ifce_methods = ty::trait_methods(tcx, iid); alt vec::position(*ifce_methods, |m| m.ident == self.m_name) { none { /* check next bound */ - iface_bnd_idx += 1u; + trait_bnd_idx += 1u; } some(pos) { @@ -187,7 +187,7 @@ class lookup { // generic parameter itself. Note that this is the only case // where this replacement is necessary: in all other cases, we // are either invoking a method directly from an impl or class - // (where the self type is not permitted), or from a iface + // (where the self type is not permitted), or from a trait // type (in which case methods that refer to self are not // permitted). let substs = {self_ty: some(self.self_ty) @@ -195,21 +195,21 @@ class lookup { self.add_candidates_from_m( substs, ifce_methods[pos], - method_param({iface_id:iid, + method_param({trait_id:iid, method_num:pos, param_num:n, - bound_num:iface_bnd_idx})); + bound_num:trait_bnd_idx})); } } } } - fn add_candidates_from_iface(did: ast::def_id, iface_substs: ty::substs) { + fn add_candidates_from_trait(did: ast::def_id, trait_substs: ty::substs) { - #debug["method_from_iface"]; + #debug["method_from_trait"]; - let ms = *ty::iface_methods(self.tcx(), did); + let ms = *ty::trait_methods(self.tcx(), did); for ms.eachi |i, m| { if m.ident != self.m_name { cont; } @@ -226,17 +226,17 @@ class lookup { self.tcx().sess.span_err( self.expr.span, "can not call a generic method through a \ - boxed iface"); + boxed trait"); } // Note: although it is illegal to invoke a method that uses self - // through a iface instance, we use a dummy subst here so that we + // through a trait instance, we use a dummy subst here so that we // can soldier on with the compilation. let substs = {self_ty: some(self.self_ty) - with iface_substs}; + with trait_substs}; self.add_candidates_from_m( - substs, m, method_iface(did, i)); + substs, m, method_trait(did, i)); } } @@ -244,7 +244,7 @@ class lookup { #debug["method_from_class"]; - let ms = *ty::iface_methods(self.tcx(), did); + let ms = *ty::trait_methods(self.tcx(), did); for ms.each |m| { if m.ident != self.m_name { cont; } @@ -275,7 +275,7 @@ class lookup { if did.crate == ast::local_crate { alt check self.tcx().items.get(did.node) { ast_map::node_method(m, _, _) { - // NDM iface/impl regions + // NDM trait/impl regions let mt = ty_of_method(self.fcx.ccx, m, ast::rp_none); ty::mk_fn(self.tcx(), {proto: ast::proto_box with mt.fty}) } diff --git a/src/rustc/middle/typeck/check/vtable.rs b/src/rustc/middle/typeck/check/vtable.rs index d410369c2ed..0c273808001 100644 --- a/src/rustc/middle/typeck/check/vtable.rs +++ b/src/rustc/middle/typeck/check/vtable.rs @@ -1,9 +1,9 @@ import check::{fn_ctxt, impl_self_ty, methods}; -fn has_iface_bounds(tps: ~[ty::param_bounds]) -> bool { +fn has_trait_bounds(tps: ~[ty::param_bounds]) -> bool { vec::any(tps, |bs| { vec::any(*bs, |b| { - alt b { ty::bound_iface(_) { true } _ { false } } + alt b { ty::bound_trait(_) { true } _ { false } } }) }) } @@ -16,7 +16,7 @@ fn lookup_vtables(fcx: @fn_ctxt, isc: resolve::iscopes, sp: span, for substs.tps.each |ty| { for vec::each(*bounds[i]) |bound| { alt bound { - ty::bound_iface(i_ty) { + ty::bound_trait(i_ty) { let i_ty = ty::subst(tcx, substs, i_ty); vec::push(result, lookup_vtable(fcx, isc, sp, ty, i_ty, allow_unsafe)); @@ -33,33 +33,33 @@ fn fixup_substs(fcx: @fn_ctxt, sp: span, id: ast::def_id, substs: ty::substs) -> ty::substs { let tcx = fcx.ccx.tcx; // use a dummy type just to package up the substs that need fixing up - let t = ty::mk_iface(tcx, id, substs); + let t = ty::mk_trait(tcx, id, substs); let t_f = fixup_ty(fcx, sp, t); alt check ty::get(t_f).struct { - ty::ty_iface(_, substs_f) { substs_f } + ty::ty_trait(_, substs_f) { substs_f } } } -fn relate_iface_tys(fcx: @fn_ctxt, sp: span, - exp_iface_ty: ty::t, act_iface_ty: ty::t) { - demand::suptype(fcx, sp, exp_iface_ty, act_iface_ty) +fn relate_trait_tys(fcx: @fn_ctxt, sp: span, + exp_trait_ty: ty::t, act_trait_ty: ty::t) { + demand::suptype(fcx, sp, exp_trait_ty, act_trait_ty) } /* Look up the vtable to use when treating an item of type <t> -as if it has type <iface_ty> +as if it has type <trait_ty> */ fn lookup_vtable(fcx: @fn_ctxt, isc: resolve::iscopes, sp: span, - ty: ty::t, iface_ty: ty::t, allow_unsafe: bool) + ty: ty::t, trait_ty: ty::t, allow_unsafe: bool) -> vtable_origin { - #debug["lookup_vtable(ty=%s, iface_ty=%s)", - fcx.infcx.ty_to_str(ty), fcx.infcx.ty_to_str(iface_ty)]; + #debug["lookup_vtable(ty=%s, trait_ty=%s)", + fcx.infcx.ty_to_str(ty), fcx.infcx.ty_to_str(trait_ty)]; let _i = indenter(); let tcx = fcx.ccx.tcx; - let (iface_id, iface_substs) = alt check ty::get(iface_ty).struct { - ty::ty_iface(did, substs) { (did, substs) } + let (trait_id, trait_substs) = alt check ty::get(trait_ty).struct { + ty::ty_trait(did, substs) { (did, substs) } }; let ty = fixup_ty(fcx, sp, ty); alt ty::get(ty).struct { @@ -70,13 +70,13 @@ fn lookup_vtable(fcx: @fn_ctxt, isc: resolve::iscopes, sp: span, ty::bound_send | ty::bound_copy | ty::bound_const { /* ignore */ } - ty::bound_iface(ity) { + ty::bound_trait(ity) { alt check ty::get(ity).struct { - ty::ty_iface(idid, substs) { - if iface_id == idid { - #debug("(checking vtable) @0 relating ty to iface ty + ty::ty_trait(idid, substs) { + if trait_id == idid { + #debug("(checking vtable) @0 relating ty to trait ty with did %?", idid); - relate_iface_tys(fcx, sp, iface_ty, ity); + relate_trait_tys(fcx, sp, trait_ty, ity); ret vtable_param(n, n_bound); } } @@ -87,13 +87,13 @@ fn lookup_vtable(fcx: @fn_ctxt, isc: resolve::iscopes, sp: span, } } - ty::ty_iface(did, substs) if iface_id == did { - #debug("(checking vtable) @1 relating ty to iface ty with did %?", + ty::ty_trait(did, substs) if trait_id == did { + #debug("(checking vtable) @1 relating ty to trait ty with did %?", did); - relate_iface_tys(fcx, sp, iface_ty, ty); + relate_trait_tys(fcx, sp, trait_ty, ty); if !allow_unsafe { - for vec::each(*ty::iface_methods(tcx, did)) |m| { + for vec::each(*ty::trait_methods(tcx, did)) |m| { if ty::type_has_self(ty::mk_fn(tcx, m.fty)) { tcx.sess.span_err( sp, "a boxed iface with self types may not be \ @@ -106,7 +106,7 @@ fn lookup_vtable(fcx: @fn_ctxt, isc: resolve::iscopes, sp: span, } } } - ret vtable_iface(did, substs.tps); + ret vtable_trait(did, substs.tps); } _ { @@ -116,15 +116,15 @@ fn lookup_vtable(fcx: @fn_ctxt, isc: resolve::iscopes, sp: span, /* For each impl in scope... */ for vec::each(*impls) |im| { // im = one specific impl - // find the iface that im implements (if any) - let of_ty = alt ty::impl_iface(tcx, im.did) { + // find the trait that im implements (if any) + let of_ty = alt ty::impl_trait(tcx, im.did) { some(of_ty) { of_ty } _ { cont; } }; // it must have the same id as the expected one alt ty::get(of_ty).struct { - ty::ty_iface(id, _) if id != iface_id { cont; } + ty::ty_trait(id, _) if id != trait_id { cont; } _ { /* ok */ } } @@ -138,19 +138,19 @@ fn lookup_vtable(fcx: @fn_ctxt, isc: resolve::iscopes, sp: span, result::ok(()) { } } - // check that desired iface type unifies - #debug("(checking vtable) @2 relating iface ty %s to \ + // check that desired trait type unifies + #debug("(checking vtable) @2 relating trait ty %s to \ of_ty %s", - fcx.infcx.ty_to_str(iface_ty), + fcx.infcx.ty_to_str(trait_ty), fcx.infcx.ty_to_str(of_ty)); let of_ty = ty::subst(tcx, substs, of_ty); - relate_iface_tys(fcx, sp, iface_ty, of_ty); + relate_trait_tys(fcx, sp, trait_ty, of_ty); // recursively process the bounds - let iface_tps = iface_substs.tps; - let substs_f = fixup_substs(fcx, sp, iface_id, substs); - connect_iface_tps(fcx, sp, substs_f.tps, - iface_tps, im.did); + let trait_tps = trait_substs.tps; + let substs_f = fixup_substs(fcx, sp, trait_id, substs); + connect_trait_tps(fcx, sp, substs_f.tps, + trait_tps, im.did); let subres = lookup_vtables(fcx, isc, sp, im_bs, substs_f, false); vec::push(found, @@ -172,7 +172,7 @@ fn lookup_vtable(fcx: @fn_ctxt, isc: resolve::iscopes, sp: span, tcx.sess.span_fatal( sp, "failed to find an implementation of interface " + - ty_to_str(tcx, iface_ty) + " for " + + ty_to_str(tcx, trait_ty) + " for " + ty_to_str(tcx, ty)); } @@ -190,16 +190,16 @@ fn fixup_ty(fcx: @fn_ctxt, sp: span, ty: ty::t) -> ty::t { } } -fn connect_iface_tps(fcx: @fn_ctxt, sp: span, impl_tys: ~[ty::t], - iface_tys: ~[ty::t], impl_did: ast::def_id) { +fn connect_trait_tps(fcx: @fn_ctxt, sp: span, impl_tys: ~[ty::t], + trait_tys: ~[ty::t], impl_did: ast::def_id) { let tcx = fcx.ccx.tcx; - let ity = option::get(ty::impl_iface(tcx, impl_did)); - let iface_ty = ty::subst_tps(tcx, impl_tys, ity); - #debug("(connect iface tps) iface type is %?, impl did is %?", - ty::get(iface_ty).struct, impl_did); - alt check ty::get(iface_ty).struct { - ty::ty_iface(_, substs) { - vec::iter2(substs.tps, iface_tys, + let ity = option::get(ty::impl_trait(tcx, impl_did)); + let trait_ty = ty::subst_tps(tcx, impl_tys, ity); + #debug("(connect trait tps) trait type is %?, impl did is %?", + ty::get(trait_ty).struct, impl_did); + alt check ty::get(trait_ty).struct { + ty::ty_trait(_, substs) { + vec::iter2(substs.tps, trait_tys, |a, b| demand::suptype(fcx, sp, a, b)); } } @@ -213,7 +213,7 @@ fn resolve_expr(ex: @ast::expr, &&fcx: @fn_ctxt, v: visit::vt<@fn_ctxt>) { some(substs) { let did = ast_util::def_id_of_def(cx.tcx.def_map.get(ex.id)); let item_ty = ty::lookup_item_type(cx.tcx, did); - if has_iface_bounds(*item_ty.bounds) { + if has_trait_bounds(*item_ty.bounds) { let impls = cx.impl_map.get(ex.id); cx.vtable_map.insert(ex.id, lookup_vtables( fcx, impls, ex.span, @@ -230,7 +230,7 @@ fn resolve_expr(ex: @ast::expr, &&fcx: @fn_ctxt, v: visit::vt<@fn_ctxt>) { alt cx.method_map.find(ex.id) { some({origin: method_static(did), _}) { let bounds = ty::lookup_item_type(cx.tcx, did).bounds; - if has_iface_bounds(*bounds) { + if has_trait_bounds(*bounds) { let callee_id = alt ex.node { ast::expr_field(_, _, _) { ex.id } _ { ast_util::op_expr_callee_id(ex) } @@ -247,7 +247,7 @@ fn resolve_expr(ex: @ast::expr, &&fcx: @fn_ctxt, v: visit::vt<@fn_ctxt>) { ast::expr_cast(src, _) { let target_ty = fcx.expr_ty(ex); alt ty::get(target_ty).struct { - ty::ty_iface(*) { + ty::ty_trait(*) { /* Casting to an interface type. Look up all impls for the cast expr... */ diff --git a/src/rustc/middle/typeck/collect.rs b/src/rustc/middle/typeck/collect.rs index 181c682fffa..16423bbd8d8 100644 --- a/src/rustc/middle/typeck/collect.rs +++ b/src/rustc/middle/typeck/collect.rs @@ -34,12 +34,12 @@ fn collect_item_types(ccx: @crate_ctxt, crate: @ast::crate) { ast::item_mod(m) { for m.items.each |intrinsic_item| { alt intrinsic_item.node { - ast::item_iface(_, _, _) { + ast::item_trait(_, _, _) { let def_id = { crate: ast::local_crate, node: intrinsic_item.id }; let substs = {self_r: none, self_ty: none, tps: ~[]}; - let ty = ty::mk_iface(ccx.tcx, def_id, substs); - ccx.tcx.intrinsic_ifaces.insert + let ty = ty::mk_trait(ccx.tcx, def_id, substs); + ccx.tcx.intrinsic_traits.insert (intrinsic_item.ident, (def_id, ty)); } _ { } @@ -128,15 +128,15 @@ fn get_enum_variant_types(ccx: @crate_ctxt, } } -fn ensure_iface_methods(ccx: @crate_ctxt, id: ast::node_id) { +fn ensure_trait_methods(ccx: @crate_ctxt, id: ast::node_id) { fn store_methods<T>(ccx: @crate_ctxt, id: ast::node_id, stuff: ~[T], f: fn@(T) -> ty::method) { - ty::store_iface_methods(ccx.tcx, id, @vec::map(stuff, f)); + ty::store_trait_methods(ccx.tcx, id, @vec::map(stuff, f)); } let tcx = ccx.tcx; alt check tcx.items.get(id) { - ast_map::node_item(@{node: ast::item_iface(_, rp, ms), _}, _) { + ast_map::node_item(@{node: ast::item_trait(_, rp, ms), _}, _) { store_methods::<ast::ty_method>(ccx, id, ms, |m| { ty_of_ty_method(ccx, m, rp) }); @@ -154,14 +154,14 @@ fn ensure_iface_methods(ccx: @crate_ctxt, id: ast::node_id) { /** * Checks that a method from an impl/class conforms to the signature of - * the same method as declared in the iface. + * the same method as declared in the trait. * * # Parameters * * - impl_m: the method in the impl * - impl_tps: the type params declared on the impl itself (not the method!) - * - if_m: the method in the iface - * - if_substs: the substitutions used on the type of the iface + * - if_m: the method in the trait + * - if_substs: the substitutions used on the type of the trait * - self_ty: the self type of the impl */ fn compare_impl_method(tcx: ty::ctxt, sp: span, @@ -184,10 +184,10 @@ fn compare_impl_method(tcx: ty::ctxt, sp: span, ret; } - // Perform substitutions so that the iface/impl methods are expressed + // Perform substitutions so that the trait/impl methods are expressed // in terms of the same set of type/region parameters: - // - replace iface type parameters with those from `if_substs` - // - replace method parameters on the iface with fresh, dummy parameters + // - replace trait type parameters with those from `if_substs` + // - replace method parameters on the trait with fresh, dummy parameters // that correspond to the parameters we will find on the impl // - replace self region with a fresh, dummy region let dummy_self_r = ty::re_free(0, ty::br_self); @@ -223,25 +223,25 @@ fn compare_impl_method(tcx: ty::ctxt, sp: span, } } -fn check_methods_against_iface(ccx: @crate_ctxt, +fn check_methods_against_trait(ccx: @crate_ctxt, tps: ~[ast::ty_param], rp: ast::region_param, selfty: ty::t, - a_ifacety: @ast::iface_ref, + a_trait_ty: @ast::trait_ref, ms: ~[converted_method]) { let tcx = ccx.tcx; - let (did, tpt) = instantiate_iface_ref(ccx, a_ifacety, rp); + let (did, tpt) = instantiate_trait_ref(ccx, a_trait_ty, rp); if did.crate == ast::local_crate { - ensure_iface_methods(ccx, did.node); + ensure_trait_methods(ccx, did.node); } - for vec::each(*ty::iface_methods(tcx, did)) |if_m| { + for vec::each(*ty::trait_methods(tcx, did)) |if_m| { alt vec::find(ms, |m| if_m.ident == m.mty.ident) { some({mty: m, id, span}) { if m.purity != if_m.purity { ccx.tcx.sess.span_err( span, #fmt["method `%s`'s purity \ - not match the iface method's \ + not match the trait method's \ purity", *m.ident]); } compare_impl_method( @@ -250,7 +250,7 @@ fn check_methods_against_iface(ccx: @crate_ctxt, } none { tcx.sess.span_err( - a_ifacety.path.span, + a_trait_ty.path.span, #fmt["missing method `%s`", *if_m.ident]); } } // alt @@ -314,17 +314,17 @@ fn convert(ccx: @crate_ctxt, it: @ast::item) { let cms = convert_methods(ccx, ms, rp, i_bounds, selfty); for ifce.each |t| { - check_methods_against_iface(ccx, tps, rp, selfty, t, cms); + check_methods_against_trait(ccx, tps, rp, selfty, t, cms); } } - ast::item_iface(*) { + ast::item_trait(*) { let tpt = ty_of_item(ccx, it); - #debug["item_iface(it.id=%d, tpt.ty=%s)", + #debug["item_trait(it.id=%d, tpt.ty=%s)", it.id, ty_to_str(tcx, tpt.ty)]; write_ty_to_tcx(tcx, it.id, tpt.ty); - ensure_iface_methods(ccx, it.id); + ensure_trait_methods(ccx, it.id); } - ast::item_class(tps, ifaces, members, ctor, m_dtor, rp) { + ast::item_class(tps, traits, members, ctor, m_dtor, rp) { // Write the class type let tpt = ty_of_item(ccx, it); write_ty_to_tcx(tcx, it.id, tpt.ty); @@ -362,7 +362,7 @@ fn convert(ccx: @crate_ctxt, it: @ast::item) { rp: rp, ty: t_dtor}); }; - ensure_iface_methods(ccx, it.id); + ensure_trait_methods(ccx, it.id); // Write the type of each of the members let (fields, methods) = split_class_items(members); @@ -372,16 +372,16 @@ fn convert(ccx: @crate_ctxt, it: @ast::item) { let {bounds, substs} = mk_substs(ccx, tps, rp); let selfty = ty::mk_class(tcx, local_def(it.id), substs); let cms = convert_methods(ccx, methods, rp, bounds, selfty); - for ifaces.each |ifce| { - check_methods_against_iface(ccx, tps, rp, selfty, ifce, cms); + for traits.each |ifce| { + check_methods_against_trait(ccx, tps, rp, selfty, ifce, cms); // FIXME #2434---this is somewhat bogus, but it seems that - // the id of iface_ref is also the id of the impl, and so + // the id of trait_ref is also the id of the impl, and so // we want to store the "self type" of the impl---in this // case, the class. The reason I say this is somewhat // bogus (and should be refactored) is that the tcache // stores the class type for ifce.id but the node_type - // table stores the iface type. Weird. Probably just + // table stores the trait type. Weird. Probably just // adding a "self type" table rather than overloading the // tcache would be ok, or else adding more than one id. tcx.tcache.insert(local_def(ifce.id), tpt); @@ -427,16 +427,16 @@ fn ty_of_ty_method(self: @crate_ctxt, tps: ty_param_bounds(self, m.tps), fty: ty_of_fn_decl(self, type_rscope(rp), ast::proto_bare, m.decl, none), - // assume public, because this is only invoked on iface methods + // assume public, because this is only invoked on trait methods purity: m.decl.purity, vis: ast::public} } /* - Instantiates the path for the given iface reference, assuming that - it's bound to a valid iface type. Returns the def_id for the defining - iface. Fails if the type is a type other than an iface type. + Instantiates the path for the given trait reference, assuming that + it's bound to a valid trait type. Returns the def_id for the defining + trait. Fails if the type is a type other than an trait type. */ -fn instantiate_iface_ref(ccx: @crate_ctxt, t: @ast::iface_ref, +fn instantiate_trait_ref(ccx: @crate_ctxt, t: @ast::trait_ref, rp: ast::region_param) -> (ast::def_id, ty_param_substs_and_ty) { @@ -449,7 +449,7 @@ fn instantiate_iface_ref(ccx: @crate_ctxt, t: @ast::iface_ref, ast::def_ty(t_id) { let tpt = astconv::ast_path_to_ty(ccx, rscope, t_id, t.path, t.id); alt ty::get(tpt.ty).struct { - ty::ty_iface(*) { + ty::ty_trait(*) { (t_id, tpt) } _ { sess.span_fatal(sp, err); } @@ -520,9 +520,9 @@ fn ty_of_item(ccx: @crate_ctxt, it: @ast::item) tcx.tcache.insert(local_def(it.id), tpt); ret tpt; } - ast::item_iface(tps, rp, ms) { + ast::item_trait(tps, rp, ms) { let {bounds, substs} = mk_substs(ccx, tps, rp); - let t = ty::mk_iface(tcx, local_def(it.id), substs); + let t = ty::mk_trait(tcx, local_def(it.id), substs); let tpt = {bounds: bounds, rp: rp, ty: t}; tcx.tcache.insert(local_def(it.id), tpt); ret tpt; @@ -558,11 +558,11 @@ fn ty_param_bounds(ccx: @crate_ctxt, ast::bound_send { ~[ty::bound_send] } ast::bound_copy { ~[ty::bound_copy] } ast::bound_const { ~[ty::bound_const] } - ast::bound_iface(t) { + ast::bound_trait(t) { let ity = ast_ty_to_ty(ccx, empty_rscope, t); alt ty::get(ity).struct { - ty::ty_iface(*) { - ~[ty::bound_iface(ity)] + ty::ty_trait(*) { + ~[ty::bound_trait(ity)] } _ { ccx.tcx.sess.span_err( diff --git a/src/rustc/middle/typeck/infer.rs b/src/rustc/middle/typeck/infer.rs index 6f97f0b635c..bdcc3dea7fb 100644 --- a/src/rustc/middle/typeck/infer.rs +++ b/src/rustc/middle/typeck/infer.rs @@ -1781,10 +1781,10 @@ fn super_tys<C:combine>( } } - (ty::ty_iface(a_id, a_substs), ty::ty_iface(b_id, b_substs)) + (ty::ty_trait(a_id, a_substs), ty::ty_trait(b_id, b_substs)) if a_id == b_id { do self.substs(a_substs, b_substs).chain |substs| { - ok(ty::mk_iface(tcx, a_id, substs)) + ok(ty::mk_trait(tcx, a_id, substs)) } } diff --git a/src/rustc/util/ppaux.rs b/src/rustc/util/ppaux.rs index 674f79ece79..c8238d6b057 100644 --- a/src/rustc/util/ppaux.rs +++ b/src/rustc/util/ppaux.rs @@ -4,7 +4,7 @@ import middle::ty::{arg, bound_region, br_anon, br_named, canon_mode}; import middle::ty::{ck_block, ck_box, ck_uniq, constr, ctxt, field, method}; import middle::ty::{mt, re_bound, re_free, re_scope, re_var, region, t}; import middle::ty::{ty_bool, ty_bot, ty_box, ty_class, ty_constr, ty_enum}; -import middle::ty::{ty_estr, ty_evec, ty_float, ty_fn, ty_iface, ty_int}; +import middle::ty::{ty_estr, ty_evec, ty_float, ty_fn, ty_trait, ty_int}; import middle::ty::{ty_nil, ty_opaque_box, ty_opaque_closure_ptr, ty_param}; import middle::ty::{ty_ptr, ty_rec, ty_rptr, ty_self, ty_str, ty_tup}; import middle::ty::{ty_type, ty_uniq, ty_uint, ty_var, ty_var_integral}; @@ -213,7 +213,7 @@ fn ty_to_str(cx: ctxt, typ: t) -> str { let base = ast_map::path_to_str(path); parameterized(cx, base, substs.self_r, substs.tps) } - ty_iface(did, substs) { + ty_trait(did, substs) { let path = ty::item_path(cx, did); let base = ast_map::path_to_str(path); parameterized(cx, base, substs.self_r, substs.tps) |
