Change remaining "iface" occurrences to "trait"; deprecate "iface"
This commit is contained in:
parent
c2f49c46ae
commit
439afaa329
111 changed files with 194 additions and 188 deletions
|
@ -36,7 +36,7 @@ type pointy = {
|
|||
mut n : ~[mut maybe_pointy],
|
||||
mut o : {x : int, y : maybe_pointy}
|
||||
};
|
||||
// To add: objects; ifaces; anything type-parameterized?
|
||||
// To add: objects; traits; anything type-parameterized?
|
||||
|
||||
fn empty_pointy() -> @pointy {
|
||||
ret @{
|
||||
|
|
|
@ -525,7 +525,7 @@ fn test_to_str_inf() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_ifaces() {
|
||||
fn test_traits() {
|
||||
fn test<U:num::num>(ten: U) {
|
||||
assert (ten.to_int() == 10);
|
||||
|
||||
|
|
|
@ -158,7 +158,7 @@ fn test_from_fn() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_iface_get() {
|
||||
fn test_interface_get() {
|
||||
let f = from_value(~"fail");
|
||||
assert f.get() == ~"fail";
|
||||
}
|
||||
|
@ -170,7 +170,7 @@ fn test_with() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_iface_with() {
|
||||
fn test_interface_with() {
|
||||
let f = from_value(~"kale");
|
||||
assert f.with(|v| v) == ~"kale";
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ pure fn hash_bytes_keyed(buf: &[const u8], k0: u64, k1: u64) -> u64 {
|
|||
}
|
||||
|
||||
|
||||
iface streaming {
|
||||
trait streaming {
|
||||
fn input(~[u8]);
|
||||
fn input_str(~str);
|
||||
fn result() -> ~[u8];
|
||||
|
|
|
@ -230,7 +230,7 @@ fn test_to_str() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_ifaces() {
|
||||
fn test_interfaces() {
|
||||
fn test<U:num::num>(ten: U) {
|
||||
assert (ten.to_int() == 10);
|
||||
|
||||
|
|
|
@ -27,8 +27,8 @@ extern mod rustrt {
|
|||
enum seek_style { seek_set, seek_end, seek_cur, }
|
||||
|
||||
|
||||
// The raw underlying reader iface. All readers must implement this.
|
||||
iface reader {
|
||||
// The raw underlying reader trait. All readers must implement this.
|
||||
trait reader {
|
||||
// FIXME (#2004): Seekable really should be orthogonal.
|
||||
|
||||
// FIXME (#2982): This should probably return an error.
|
||||
|
@ -250,7 +250,7 @@ fn FILE_reader(f: *libc::FILE, cleanup: bool) -> reader {
|
|||
}
|
||||
}
|
||||
|
||||
// FIXME (#2004): this should either be an iface-less impl, a set of
|
||||
// FIXME (#2004): this should either be an trait-less impl, a set of
|
||||
// top-level functions that take a reader, or a set of default methods on
|
||||
// reader (which can then be called reader)
|
||||
|
||||
|
@ -335,7 +335,7 @@ enum writer_type { screen, file }
|
|||
|
||||
// FIXME (#2004): Seekable really should be orthogonal.
|
||||
// FIXME (#2004): eventually u64
|
||||
iface writer {
|
||||
trait writer {
|
||||
fn write(v: &[const u8]);
|
||||
fn seek(int, seek_style);
|
||||
fn tell() -> uint;
|
||||
|
@ -781,7 +781,7 @@ mod fsync {
|
|||
}
|
||||
|
||||
// Type of objects that may want to fsync
|
||||
iface t { fn fsync(l: level) -> int; }
|
||||
trait t { fn fsync(l: level) -> int; }
|
||||
|
||||
// Call o.fsync after executing blk
|
||||
fn obj_sync(&&o: t, opt_level: option<level>, blk: fn(&&res<t>)) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
iface base_iter<A> {
|
||||
trait base_iter<A> {
|
||||
fn each(blk: fn(A) -> bool);
|
||||
fn size_hint() -> option<uint>;
|
||||
}
|
||||
|
@ -13,10 +13,10 @@ trait extended_iter<A> {
|
|||
fn position(f: fn(A) -> bool) -> option<uint>;
|
||||
}
|
||||
|
||||
iface times {
|
||||
trait times {
|
||||
fn times(it: fn() -> bool);
|
||||
}
|
||||
iface timesi{
|
||||
trait timesi{
|
||||
fn timesi(it: fn(uint) -> bool);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
trait num {
|
||||
// FIXME: Cross-crate overloading doesn't work yet. (#2615)
|
||||
// FIXME: Interface inheritance. (#2616)
|
||||
// FIXME: Trait composition. (#2616)
|
||||
pure fn add(&&other: self) -> self;
|
||||
pure fn sub(&&other: self) -> self;
|
||||
pure fn mul(&&other: self) -> self;
|
||||
|
@ -12,6 +12,6 @@ trait num {
|
|||
|
||||
pure fn to_int() -> int;
|
||||
pure fn from_int(n: int) -> self; // FIXME (#2376) Static functions.
|
||||
// n.b. #2376 is for classes, not ifaces, but it could be generalized...
|
||||
// n.b. #2376 is for classes, not traits, but it could be generalized...
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ extern mod rustrt {
|
|||
}
|
||||
|
||||
/// A random number generator
|
||||
iface rng {
|
||||
trait rng {
|
||||
/// Return the next random integer
|
||||
fn next() -> u32;
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ extern mod rustrt {
|
|||
}
|
||||
|
||||
/// A value representing a child process
|
||||
iface program {
|
||||
trait program {
|
||||
/// Returns the process id of the program
|
||||
fn get_id() -> pid_t;
|
||||
|
||||
|
|
|
@ -955,7 +955,7 @@ fn spawn_raw(opts: task_opts, +f: fn~()) {
|
|||
*/
|
||||
type local_data_key<T: owned> = fn@(+@T);
|
||||
|
||||
iface local_data { }
|
||||
trait local_data { }
|
||||
impl<T: owned> of local_data for @T { }
|
||||
|
||||
// We use dvec because it's the best data structure in core. If TLS is used
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
iface to_bytes {
|
||||
trait to_bytes {
|
||||
fn to_bytes() -> ~[u8];
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
iface to_str { fn to_str() -> ~str; }
|
||||
trait to_str { fn to_str() -> ~str; }
|
||||
|
||||
impl of to_str for int {
|
||||
fn to_str() -> ~str { int::str(self) }
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import io::{reader, reader_util};
|
||||
|
||||
iface to_base64 {
|
||||
trait to_base64 {
|
||||
fn to_base64() -> ~str;
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,7 @@ impl of to_base64 for ~str {
|
|||
}
|
||||
}
|
||||
|
||||
iface from_base64 {
|
||||
trait from_base64 {
|
||||
fn from_base64() -> ~[u8];
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
import option::{some, none};
|
||||
import dvec::{dvec, extensions};
|
||||
|
||||
iface t<T> {
|
||||
trait t<T> {
|
||||
fn size() -> uint;
|
||||
fn add_front(T);
|
||||
fn add_back(T);
|
||||
|
|
|
@ -510,7 +510,7 @@ fn eq(value0: json, value1: json) -> bool {
|
|||
}
|
||||
}
|
||||
|
||||
iface to_json { fn to_json() -> json; }
|
||||
trait to_json { fn to_json() -> json; }
|
||||
|
||||
impl of to_json for json {
|
||||
fn to_json() -> json { self }
|
||||
|
|
|
@ -24,7 +24,7 @@ type set<K> = hashmap<K, ()>;
|
|||
|
||||
type hashmap<K, V> = chained::t<K, V>;
|
||||
|
||||
iface map<K, V: copy> {
|
||||
trait map<K, V: copy> {
|
||||
/// Return the number of elements in the map
|
||||
fn size() -> uint;
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ class tcp_socket {
|
|||
* A buffered wrapper for `net::tcp::tcp_socket`
|
||||
*
|
||||
* It is created with a call to `net::tcp::socket_buf()` and has impls that
|
||||
* satisfy both the `io::reader` and `io::writer` ifaces.
|
||||
* satisfy both the `io::reader` and `io::writer` traits.
|
||||
*/
|
||||
class tcp_socket_buf {
|
||||
let data: @tcp_buffered_socket_data;
|
||||
|
@ -764,7 +764,7 @@ impl tcp_socket for tcp_socket {
|
|||
}
|
||||
}
|
||||
|
||||
/// Implementation of `io::reader` iface for a buffered `net::tcp::tcp_socket`
|
||||
/// Implementation of `io::reader` trait for a buffered `net::tcp::tcp_socket`
|
||||
impl tcp_socket_buf of io::reader for @tcp_socket_buf {
|
||||
fn read(buf: &[mut u8], len: uint) -> uint {
|
||||
// Loop until our buffer has enough data in it for us to read from.
|
||||
|
@ -817,7 +817,7 @@ impl tcp_socket_buf of io::reader for @tcp_socket_buf {
|
|||
}
|
||||
}
|
||||
|
||||
/// Implementation of `io::reader` iface for a buffered `net::tcp::tcp_socket`
|
||||
/// Implementation of `io::reader` trait for a buffered `net::tcp::tcp_socket`
|
||||
impl tcp_socket_buf of io::writer for @tcp_socket_buf {
|
||||
fn write(data: &[const u8]) unsafe {
|
||||
let socket_data_ptr =
|
||||
|
@ -1083,11 +1083,11 @@ enum tcp_read_result {
|
|||
tcp_read_err(tcp_err_data)
|
||||
}
|
||||
|
||||
iface to_tcp_err_iface {
|
||||
trait to_tcp_err {
|
||||
fn to_tcp_err() -> tcp_err_data;
|
||||
}
|
||||
|
||||
impl of to_tcp_err_iface for uv::ll::uv_err_data {
|
||||
impl of to_tcp_err for uv::ll::uv_err_data {
|
||||
fn to_tcp_err() -> tcp_err_data {
|
||||
{ err_name: self.err_name, err_msg: self.err_msg }
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ use core;
|
|||
Core serialization interfaces.
|
||||
*/
|
||||
|
||||
iface serializer {
|
||||
trait serializer {
|
||||
// Primitive types:
|
||||
fn emit_nil();
|
||||
fn emit_uint(v: uint);
|
||||
|
@ -39,7 +39,7 @@ iface serializer {
|
|||
fn emit_tup_elt(idx: uint, f: fn());
|
||||
}
|
||||
|
||||
iface deserializer {
|
||||
trait deserializer {
|
||||
// Primitive types:
|
||||
fn read_nil() -> ();
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
export sha1;
|
||||
|
||||
/// The SHA-1 interface
|
||||
iface sha1 {
|
||||
trait sha1 {
|
||||
/// Provide message input as bytes
|
||||
fn input(~[u8]);
|
||||
/// Provide message input as string
|
||||
|
|
|
@ -13,7 +13,7 @@ type emitter = fn@(cmsp: option<(codemap::codemap, span)>,
|
|||
msg: ~str, lvl: level);
|
||||
|
||||
|
||||
iface span_handler {
|
||||
trait span_handler {
|
||||
fn span_fatal(sp: span, msg: ~str) -> !;
|
||||
fn span_err(sp: span, msg: ~str);
|
||||
fn span_warn(sp: span, msg: ~str);
|
||||
|
@ -23,7 +23,7 @@ iface span_handler {
|
|||
fn handler() -> handler;
|
||||
}
|
||||
|
||||
iface handler {
|
||||
trait handler {
|
||||
fn fatal(msg: ~str) -> !;
|
||||
fn err(msg: ~str);
|
||||
fn bump_err_count();
|
||||
|
|
|
@ -114,7 +114,7 @@ fn syntax_expander_table() -> hashmap<~str, syntax_extension> {
|
|||
// One of these is made during expansion and incrementally updated as we go;
|
||||
// when a macro expansion occurs, the resulting nodes have the backtrace()
|
||||
// -> expn_info of their expansion context stored into their span.
|
||||
iface ext_ctxt {
|
||||
trait ext_ctxt {
|
||||
fn codemap() -> codemap;
|
||||
fn parse_sess() -> parse::parse_sess;
|
||||
fn cfg() -> ast::crate_cfg;
|
||||
|
|
|
@ -383,7 +383,7 @@ impl compile of gen_init for protocol {
|
|||
}
|
||||
}
|
||||
|
||||
iface to_source {
|
||||
trait to_source {
|
||||
// Takes a thing and generates a string containing rust code for it.
|
||||
fn to_source() -> ~str;
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ enum fragment {
|
|||
from_ty(@ast::ty)
|
||||
}
|
||||
|
||||
iface qq_helper {
|
||||
trait qq_helper {
|
||||
fn span() -> span;
|
||||
fn visit(aq_ctxt, vt<aq_ctxt>);
|
||||
fn extract_mac() -> option<ast::mac_>;
|
||||
|
|
|
@ -18,7 +18,7 @@ export fold_ty_params;
|
|||
export fold_fn_decl;
|
||||
export extensions;
|
||||
|
||||
iface ast_fold {
|
||||
trait ast_fold {
|
||||
fn fold_crate(crate) -> crate;
|
||||
fn fold_crate_directive(&&@crate_directive) -> @crate_directive;
|
||||
fn fold_view_item(&&@view_item) -> @view_item;
|
||||
|
|
|
@ -9,7 +9,7 @@ export tt_reader, new_tt_reader;
|
|||
export nextch, is_eof, bump, get_str_from, new_low_level_string_reader;
|
||||
export string_reader_as_reader, tt_reader_as_reader;
|
||||
|
||||
iface reader {
|
||||
trait reader {
|
||||
fn is_eof() -> bool;
|
||||
fn next_token() -> {tok: token::token, sp: span};
|
||||
fn fatal(~str) -> !;
|
||||
|
|
|
@ -2702,6 +2702,7 @@ class parser {
|
|||
} else if self.eat_keyword(~"enum") {
|
||||
self.parse_item_enum(vis)
|
||||
} else if self.eat_keyword(~"iface") {
|
||||
self.warn(~"`iface` is deprecated; use `trait`");
|
||||
self.parse_item_trait()
|
||||
} else if self.eat_keyword(~"trait") {
|
||||
self.parse_item_trait()
|
||||
|
|
|
@ -588,7 +588,7 @@ fn print_item(s: ps, &&item: @ast::item) {
|
|||
bclose(s, item.span);
|
||||
}
|
||||
ast::item_trait(tps, methods) {
|
||||
head(s, ~"iface");
|
||||
head(s, ~"trait");
|
||||
word(s.s, *item.ident);
|
||||
print_type_params(s, tps);
|
||||
word(s.s, ~" ");
|
||||
|
|
|
@ -19,7 +19,7 @@ fn mk<T: const copy>(hasher: hashfn<T>, eqer: eqfn<T>) -> interner<T> {
|
|||
}
|
||||
|
||||
/* when traits can extend traits, we should extend index<uint,T> to get [] */
|
||||
iface interner<T: const copy> {
|
||||
trait interner<T: const copy> {
|
||||
fn intern(T) -> uint;
|
||||
pure fn get(uint) -> T;
|
||||
fn len() -> uint;
|
||||
|
|
|
@ -120,7 +120,7 @@ class annihilator : public shape::data<annihilator,shape::ptr> {
|
|||
return;
|
||||
}
|
||||
|
||||
void walk_iface2() {
|
||||
void walk_trait2() {
|
||||
walk_box2();
|
||||
}
|
||||
|
||||
|
|
|
@ -140,7 +140,7 @@ class irc : public shape::data<irc,shape::ptr> {
|
|||
}
|
||||
}
|
||||
|
||||
void walk_iface2() {
|
||||
void walk_trait2() {
|
||||
walk_box2();
|
||||
}
|
||||
|
||||
|
@ -400,7 +400,7 @@ class mark : public shape::data<mark,shape::ptr> {
|
|||
}
|
||||
}
|
||||
|
||||
void walk_iface2() {
|
||||
void walk_trait2() {
|
||||
walk_box2();
|
||||
}
|
||||
|
||||
|
|
|
@ -290,7 +290,7 @@ public:
|
|||
data<cmp,ptr_pair>::walk_rptr_contents1();
|
||||
}
|
||||
|
||||
void walk_iface2() {
|
||||
void walk_trait2() {
|
||||
data<cmp,ptr_pair>::walk_box_contents1();
|
||||
}
|
||||
|
||||
|
|
|
@ -544,7 +544,7 @@ public:
|
|||
default: abort();
|
||||
}
|
||||
}
|
||||
void walk_iface1() { DPRINT("iface"); }
|
||||
void walk_trait1() { DPRINT("trait"); }
|
||||
|
||||
void walk_tydesc1(char kind) {
|
||||
switch(kind) {
|
||||
|
@ -598,7 +598,7 @@ public:
|
|||
{ sa.set(sizeof(void *)*2, sizeof(void *)); }
|
||||
void walk_box1() { sa.set(sizeof(void *), sizeof(void *)); }
|
||||
void walk_fn1(char) { sa.set(sizeof(void *)*2, sizeof(void *)); }
|
||||
void walk_iface1() { sa.set(sizeof(void *), sizeof(void *)); }
|
||||
void walk_trait1() { sa.set(sizeof(void *), sizeof(void *)); }
|
||||
void walk_tydesc1(char) { sa.set(sizeof(void *), sizeof(void *)); }
|
||||
void walk_closure1();
|
||||
|
||||
|
@ -851,7 +851,7 @@ protected:
|
|||
void walk_uniq_contents1();
|
||||
void walk_rptr_contents1();
|
||||
void walk_fn_contents1();
|
||||
void walk_iface_contents1();
|
||||
void walk_trait_contents1();
|
||||
void walk_variant1(tag_info &tinfo, tag_variant_t variant);
|
||||
|
||||
static std::pair<uint8_t *,uint8_t *> get_vec_data_range(ptr dp);
|
||||
|
@ -927,10 +927,10 @@ public:
|
|||
dp = next_dp;
|
||||
}
|
||||
|
||||
void walk_iface1() {
|
||||
void walk_trait1() {
|
||||
ALIGN_TO(rust_alignof<void *>());
|
||||
U next_dp = dp + sizeof(void *);
|
||||
static_cast<T *>(this)->walk_iface2();
|
||||
static_cast<T *>(this)->walk_trait2();
|
||||
dp = next_dp;
|
||||
}
|
||||
|
||||
|
@ -1137,7 +1137,7 @@ void
|
|||
|
||||
template<typename T,typename U>
|
||||
void
|
||||
data<T,U>::walk_iface_contents1() {
|
||||
data<T,U>::walk_trait_contents1() {
|
||||
walk_box_contents1();
|
||||
}
|
||||
|
||||
|
@ -1234,10 +1234,10 @@ private:
|
|||
data<log,ptr>::walk_fn_contents1();
|
||||
}
|
||||
|
||||
void walk_iface2() {
|
||||
out << prefix << "iface(";
|
||||
void walk_trait2() {
|
||||
out << prefix << "trait(";
|
||||
prefix = "";
|
||||
data<log,ptr>::walk_iface_contents1();
|
||||
data<log,ptr>::walk_trait_contents1();
|
||||
out << prefix << ")";
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ mod intrinsic {
|
|||
// Remaining fields not listed
|
||||
};
|
||||
|
||||
iface ty_visitor {
|
||||
trait ty_visitor {
|
||||
fn visit_bot() -> bool;
|
||||
fn visit_nil() -> bool;
|
||||
fn visit_bool() -> bool;
|
||||
|
|
|
@ -23,7 +23,7 @@ fn pick_file(file: path, path: path) -> option<path> {
|
|||
else { option::none }
|
||||
}
|
||||
|
||||
iface filesearch {
|
||||
trait filesearch {
|
||||
fn sysroot() -> path;
|
||||
fn lib_search_paths() -> ~[path];
|
||||
fn get_target_lib_path() -> path;
|
||||
|
|
|
@ -77,7 +77,7 @@ enum extended_decode_ctxt {
|
|||
extended_decode_ctxt_(@extended_decode_ctxt_)
|
||||
}
|
||||
|
||||
iface tr {
|
||||
trait tr {
|
||||
fn tr(xcx: extended_decode_ctxt) -> self;
|
||||
}
|
||||
|
||||
|
@ -910,7 +910,7 @@ fn decode_item_ast(par_doc: ebml::doc) -> @ast::item {
|
|||
}
|
||||
|
||||
#[cfg(test)]
|
||||
iface fake_ext_ctxt {
|
||||
trait fake_ext_ctxt {
|
||||
fn cfg() -> ast::crate_cfg;
|
||||
fn parse_sess() -> parse::parse_sess;
|
||||
}
|
||||
|
|
|
@ -429,7 +429,7 @@ fn root_map() -> root_map {
|
|||
// ___________________________________________________________________________
|
||||
// Misc
|
||||
|
||||
iface ast_node {
|
||||
trait ast_node {
|
||||
fn id() -> ast::node_id;
|
||||
fn span() -> span;
|
||||
}
|
||||
|
|
|
@ -3059,7 +3059,7 @@ class Resolver {
|
|||
self_type_rib.bindings.insert(self.self_atom,
|
||||
dl_def(def_self(item.id)));
|
||||
|
||||
// Create a new rib for the interface-wide type parameters.
|
||||
// Create a new rib for the trait-wide type parameters.
|
||||
do self.with_type_parameter_rib
|
||||
(HasTypeParameters(&type_parameters, item.id, 0u,
|
||||
NormalRibKind)) {
|
||||
|
@ -3106,12 +3106,12 @@ class Resolver {
|
|||
(*self.type_ribs).pop();
|
||||
}
|
||||
|
||||
item_class(ty_params, interfaces, class_members,
|
||||
item_class(ty_params, traits, class_members,
|
||||
optional_constructor, optional_destructor) {
|
||||
|
||||
self.resolve_class(item.id,
|
||||
@copy ty_params,
|
||||
interfaces,
|
||||
traits,
|
||||
class_members,
|
||||
optional_constructor,
|
||||
optional_destructor,
|
||||
|
@ -3330,8 +3330,8 @@ class Resolver {
|
|||
bound_copy | bound_send | bound_const | bound_owned {
|
||||
// Nothing to do.
|
||||
}
|
||||
bound_trait(interface_type) {
|
||||
self.resolve_type(interface_type, visitor);
|
||||
bound_trait(trait_type) {
|
||||
self.resolve_type(trait_type, visitor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3340,7 +3340,7 @@ class Resolver {
|
|||
|
||||
fn resolve_class(id: node_id,
|
||||
type_parameters: @~[ty_param],
|
||||
interfaces: ~[@trait_ref],
|
||||
traits: ~[@trait_ref],
|
||||
class_members: ~[@class_member],
|
||||
optional_constructor: option<class_ctor>,
|
||||
optional_destructor: option<class_dtor>,
|
||||
|
@ -3359,22 +3359,22 @@ class Resolver {
|
|||
// Resolve the type parameters.
|
||||
self.resolve_type_parameters(*type_parameters, visitor);
|
||||
|
||||
// Resolve implemented interfaces.
|
||||
for interfaces.each |interface| {
|
||||
alt self.resolve_path(interface.path, TypeNS, true, visitor) {
|
||||
// Resolve implemented traits.
|
||||
for traits.each |trt| {
|
||||
alt self.resolve_path(trt.path, TypeNS, true, visitor) {
|
||||
none {
|
||||
self.session.span_err(interface.path.span,
|
||||
self.session.span_err(trt.path.span,
|
||||
~"attempt to implement a \
|
||||
nonexistent trait");
|
||||
}
|
||||
some(def) {
|
||||
// Write a mapping from the interface ID to the
|
||||
// definition of the interface into the definition
|
||||
// Write a mapping from the trait ID to the
|
||||
// definition of the trait into the definition
|
||||
// map.
|
||||
|
||||
debug!{"(resolving class) found trait def: %?", def};
|
||||
|
||||
self.record_def(interface.ref_id, def);
|
||||
self.record_def(trt.ref_id, def);
|
||||
|
||||
// XXX: This is wrong but is needed for tests to
|
||||
// pass.
|
||||
|
@ -3475,7 +3475,7 @@ class Resolver {
|
|||
// Resolve the type parameters.
|
||||
self.resolve_type_parameters(type_parameters, visitor);
|
||||
|
||||
// Resolve the interface reference, if necessary.
|
||||
// Resolve the trait reference, if necessary.
|
||||
let original_trait_refs = self.current_trait_refs;
|
||||
if trait_references.len() >= 1 {
|
||||
let mut new_trait_refs = @dvec();
|
||||
|
|
|
@ -392,8 +392,8 @@ type opt_region = option<region>;
|
|||
/// appear within a region-parameterized type is `self`.
|
||||
///
|
||||
/// `self_ty` is the type to which `self` should be remapped, if any. The
|
||||
/// `self` type is rather funny in that it can only appear on interfaces and
|
||||
/// is always substituted away to the implementing type for an interface.
|
||||
/// `self` type is rather funny in that it can only appear on traits and
|
||||
/// is always substituted away to the implementing type for a trait.
|
||||
type substs = {
|
||||
self_r: opt_region,
|
||||
self_ty: option<ty::t>,
|
||||
|
@ -477,7 +477,7 @@ enum tv_vid = uint;
|
|||
enum tvi_vid = uint;
|
||||
enum region_vid = uint;
|
||||
|
||||
iface vid {
|
||||
trait vid {
|
||||
fn to_uint() -> uint;
|
||||
fn to_str() -> ~str;
|
||||
}
|
||||
|
@ -2633,7 +2633,7 @@ fn trait_methods(cx: ctxt, id: ast::def_id) -> @~[method] {
|
|||
some(ms) { ret ms; }
|
||||
_ {}
|
||||
}
|
||||
// Local interfaces are supposed to have been added explicitly.
|
||||
// Local traits are supposed to have been added explicitly.
|
||||
assert id.crate != ast::local_crate;
|
||||
let result = csearch::get_trait_methods(cx, id);
|
||||
cx.trait_method_cache.insert(id, result);
|
||||
|
|
|
@ -142,7 +142,7 @@ enum vtable_origin {
|
|||
*/
|
||||
vtable_param(uint, uint),
|
||||
/*
|
||||
Dynamic vtable, comes from something known to have an interface
|
||||
Dynamic vtable, comes from something known to have a trait
|
||||
type. def_id refers to the trait item, tys are the substs
|
||||
*/
|
||||
vtable_trait(ast::def_id, ~[ty::t]),
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
* used as the `ast_conv`, `get_item_ty()` just looks up the item type in
|
||||
* `tcx.tcache`.
|
||||
*
|
||||
* The `region_scope` interface controls how region references are
|
||||
* The `region_scope` trait controls how region references are
|
||||
* handled. It has two methods which are used to resolve anonymous
|
||||
* region references (e.g., `&T`) and named region references (e.g.,
|
||||
* `&a.T`). There are numerous region scopes that can be used, but most
|
||||
|
@ -46,7 +46,7 @@ import check::fn_ctxt;
|
|||
import rscope::{anon_rscope, binding_rscope, empty_rscope, in_anon_rscope};
|
||||
import rscope::{in_binding_rscope, region_scope, type_rscope};
|
||||
|
||||
iface ast_conv {
|
||||
trait ast_conv {
|
||||
fn tcx() -> ty::ctxt;
|
||||
fn ccx() -> @crate_ctxt;
|
||||
fn get_item_ty(id: ast::def_id) -> ty::ty_param_bounds_and_ty;
|
||||
|
|
|
@ -85,7 +85,7 @@ class lookup {
|
|||
}
|
||||
|
||||
loop {
|
||||
// First, see whether this is an interface-bounded parameter.
|
||||
// First, see whether this is a bounded parameter.
|
||||
alt ty::get(self.self_ty).struct {
|
||||
ty::ty_param(p) {
|
||||
self.add_candidates_from_param(p.idx, p.def_id);
|
||||
|
|
|
@ -189,7 +189,7 @@ fn lookup_vtable(fcx: @fn_ctxt, sp: span, ty: ty::t, trait_ty: ty::t,
|
|||
}
|
||||
|
||||
tcx.sess.span_fatal(
|
||||
sp, ~"failed to find an implementation of interface " +
|
||||
sp, ~"failed to find an implementation of trait " +
|
||||
ty_to_str(tcx, trait_ty) + ~" for " +
|
||||
ty_to_str(tcx, ty));
|
||||
}
|
||||
|
@ -291,7 +291,7 @@ fn resolve_expr(ex: @ast::expr, &&fcx: @fn_ctxt, v: visit::vt<@fn_ctxt>) {
|
|||
visit::visit_expr(ex, fcx, v);
|
||||
}
|
||||
|
||||
// Detect points where an interface-bounded type parameter is
|
||||
// Detect points where a trait-bounded type parameter is
|
||||
// instantiated, resolve the impls for the parameters.
|
||||
fn resolve_in_block(fcx: @fn_ctxt, bl: ast::blk) {
|
||||
visit::visit_block(bl, fcx, visit::mk_vt(@{
|
||||
|
|
|
@ -587,7 +587,7 @@ fn ty_param_bounds(ccx: @crate_ctxt,
|
|||
_ {
|
||||
ccx.tcx.sess.span_err(
|
||||
t.span, ~"type parameter bounds must be \
|
||||
interface types");
|
||||
trait types");
|
||||
~[]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -476,7 +476,7 @@ impl methods<T:copy> of cres_helpers<T> for cres<T> {
|
|||
}
|
||||
}
|
||||
|
||||
iface to_str {
|
||||
trait to_str {
|
||||
fn to_str(cx: infer_ctxt) -> ~str;
|
||||
}
|
||||
|
||||
|
@ -533,7 +533,7 @@ impl<V:copy vid, T:copy to_str> of to_str for var_value<V,T> {
|
|||
}
|
||||
}
|
||||
|
||||
iface st {
|
||||
trait st {
|
||||
fn sub(infcx: infer_ctxt, b: self) -> ures;
|
||||
fn lub(infcx: infer_ctxt, b: self) -> cres<self>;
|
||||
fn glb(infcx: infer_ctxt, b: self) -> cres<self>;
|
||||
|
@ -1506,7 +1506,7 @@ impl assignment for infer_ctxt {
|
|||
// Type combining
|
||||
//
|
||||
// There are three type combiners: sub, lub, and glb. Each implements
|
||||
// the interface `combine` and contains methods for combining two
|
||||
// the trait `combine` and contains methods for combining two
|
||||
// instances of various things and yielding a new instance. These
|
||||
// combiner methods always yield a `result<T>`---failure is propagated
|
||||
// upward using `chain()` methods.
|
||||
|
@ -1520,9 +1520,9 @@ impl assignment for infer_ctxt {
|
|||
// to the `super` routine or to do other things.
|
||||
//
|
||||
// In reality, the sub operation is rather different from lub/glb, but
|
||||
// they are combined into one interface to avoid duplication (they
|
||||
// used to be separate but there were many bugs because there were two
|
||||
// copies of most routines).
|
||||
// they are combined into one trait to avoid duplication (they used to
|
||||
// be separate but there were many bugs because there were two copies
|
||||
// of most routines).
|
||||
//
|
||||
// The differences are:
|
||||
//
|
||||
|
@ -1548,7 +1548,7 @@ impl assignment for infer_ctxt {
|
|||
|
||||
type cres<T> = result<T,ty::type_err>;
|
||||
|
||||
iface combine {
|
||||
trait combine {
|
||||
fn infcx() -> infer_ctxt;
|
||||
fn tag() -> ~str;
|
||||
|
||||
|
@ -2457,7 +2457,7 @@ impl of combine for glb {
|
|||
// This is common code used by both LUB and GLB to compute the LUB/GLB
|
||||
// for pairs of variables or for variables and values.
|
||||
|
||||
iface lattice_ops {
|
||||
trait lattice_ops {
|
||||
fn bnd<T:copy>(b: bounds<T>) -> option<T>;
|
||||
fn with_bnd<T:copy>(b: bounds<T>, t: T) -> bounds<T>;
|
||||
fn ty_bot(t: ty::t) -> cres<ty::t>;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import result::result;
|
||||
|
||||
iface region_scope {
|
||||
trait region_scope {
|
||||
fn anon_region() -> result<ty::region, ~str>;
|
||||
fn named_region(id: ast::ident) -> result<ty::region, ~str>;
|
||||
}
|
||||
|
|
|
@ -242,14 +242,14 @@ fn merge_method_attrs(
|
|||
|
||||
#[test]
|
||||
fn should_extract_trait_docs() {
|
||||
let doc = test::mk_doc(~"#[doc = \"whatever\"] iface i { fn a(); }");
|
||||
let doc = test::mk_doc(~"#[doc = \"whatever\"] trait i { fn a(); }");
|
||||
assert doc.cratemod().traits()[0].desc() == some(~"whatever");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_extract_trait_method_docs() {
|
||||
let doc = test::mk_doc(
|
||||
~"iface i {\
|
||||
~"trait i {\
|
||||
#[doc = \"desc\"]\
|
||||
fn f(a: bool) -> bool;\
|
||||
}");
|
||||
|
|
|
@ -133,7 +133,7 @@ class bored {
|
|||
* neighboring hillside churchyard of St. John's, whose hidden expanse of
|
||||
* Eighteenth Century gravestones had for him a peculiar fascination.
|
||||
*/
|
||||
iface the_shunned_house {
|
||||
trait the_shunned_house {
|
||||
/**
|
||||
* Now the irony is this. In this walk, so many times repeated, the
|
||||
* world's greatest master of the terrible and the bizarre was
|
||||
|
|
|
@ -70,7 +70,7 @@ fn should_promote_desc() {
|
|||
|
||||
#[test]
|
||||
fn should_promote_trait_method_desc() {
|
||||
let doc = test::mk_doc(~"iface i { #[doc = \"desc\"] fn a(); }");
|
||||
let doc = test::mk_doc(~"trait i { #[doc = \"desc\"] fn a(); }");
|
||||
assert doc.cratemod().traits()[0].methods[0].brief == some(~"desc");
|
||||
}
|
||||
|
||||
|
|
|
@ -315,7 +315,7 @@ impl util of page_utils for ~[page] {
|
|||
}
|
||||
}
|
||||
|
||||
iface item {
|
||||
trait item {
|
||||
fn item() -> itemdoc;
|
||||
}
|
||||
|
||||
|
|
|
@ -666,28 +666,28 @@ fn write_method(ctxt: ctxt, doc: doc::methoddoc) {
|
|||
|
||||
#[test]
|
||||
fn should_write_trait_header() {
|
||||
let markdown = test::render(~"iface i { fn a(); }");
|
||||
let markdown = test::render(~"trait i { fn a(); }");
|
||||
assert str::contains(markdown, ~"## Interface `i`");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_write_trait_desc() {
|
||||
let markdown = test::render(
|
||||
~"#[doc = \"desc\"] iface i { fn a(); }");
|
||||
~"#[doc = \"desc\"] trait i { fn a(); }");
|
||||
assert str::contains(markdown, ~"desc");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_write_trait_method_header() {
|
||||
let markdown = test::render(
|
||||
~"iface i { fn a(); }");
|
||||
~"trait i { fn a(); }");
|
||||
assert str::contains(markdown, ~"### Method `a`");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_write_trait_method_signature() {
|
||||
let markdown = test::render(
|
||||
~"iface i { fn a(); }");
|
||||
~"trait i { fn a(); }");
|
||||
assert str::contains(markdown, ~"\n fn a()");
|
||||
}
|
||||
|
||||
|
|
|
@ -206,7 +206,7 @@ fn should_eliminate_desc_if_it_is_just_whitespace() {
|
|||
#[test]
|
||||
fn should_sectionalize_trait_methods() {
|
||||
let doc = test::mk_doc(
|
||||
~"iface i {
|
||||
~"trait i {
|
||||
#[doc = \"\
|
||||
# Header\n\
|
||||
Body\"]\
|
||||
|
|
|
@ -31,7 +31,7 @@ fn test() {
|
|||
const iconst: int = 0; \
|
||||
fn ifn() { } \
|
||||
enum ienum { ivar } \
|
||||
iface iiface { fn a(); } \
|
||||
trait itrait { fn a(); } \
|
||||
impl iimpl for int { fn a() { } } \
|
||||
type itype = int;";
|
||||
do astsrv::from_str(source) |srv| {
|
||||
|
@ -40,7 +40,7 @@ fn test() {
|
|||
assert doc.cratemod().items[0].name() == ~"iconst";
|
||||
assert doc.cratemod().items[1].name() == ~"itype";
|
||||
assert doc.cratemod().items[2].name() == ~"ienum";
|
||||
assert doc.cratemod().items[3].name() == ~"iiface";
|
||||
assert doc.cratemod().items[3].name() == ~"itrait";
|
||||
assert doc.cratemod().items[4].name() == ~"iimpl";
|
||||
assert doc.cratemod().items[5].name() == ~"ifn";
|
||||
assert doc.cratemod().items[6].name() == ~"imod";
|
||||
|
|
|
@ -117,28 +117,28 @@ fn should_execute_op_on_variant_desc() {
|
|||
#[test]
|
||||
fn should_execute_op_on_trait_brief() {
|
||||
let doc = test::mk_doc(
|
||||
~"#[doc = \" a \"] iface i { fn a(); }");
|
||||
~"#[doc = \" a \"] trait i { fn a(); }");
|
||||
assert doc.cratemod().traits()[0].brief() == some(~"a");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_execute_op_on_trait_desc() {
|
||||
let doc = test::mk_doc(
|
||||
~"#[doc = \" a \"] iface i { fn a(); }");
|
||||
~"#[doc = \" a \"] trait i { fn a(); }");
|
||||
assert doc.cratemod().traits()[0].desc() == some(~"a");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_execute_op_on_trait_method_brief() {
|
||||
let doc = test::mk_doc(
|
||||
~"iface i { #[doc = \" a \"] fn a(); }");
|
||||
~"trait i { #[doc = \" a \"] fn a(); }");
|
||||
assert doc.cratemod().traits()[0].methods[0].brief == some(~"a");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn should_execute_op_on_trait_method_desc() {
|
||||
let doc = test::mk_doc(
|
||||
~"iface i { #[doc = \" a \"] fn a(); }");
|
||||
~"trait i { #[doc = \" a \"] fn a(); }");
|
||||
assert doc.cratemod().traits()[0].methods[0].desc == some(~"a");
|
||||
}
|
||||
|
||||
|
@ -207,7 +207,7 @@ fn should_execute_on_item_section_bodies() {
|
|||
#[test]
|
||||
fn should_execute_on_trait_method_section_headers() {
|
||||
let doc = test::mk_doc(
|
||||
~"iface i {
|
||||
~"trait i {
|
||||
#[doc = \"\
|
||||
# Header \n\
|
||||
Body\"]\
|
||||
|
@ -219,7 +219,7 @@ fn should_execute_on_trait_method_section_headers() {
|
|||
#[test]
|
||||
fn should_execute_on_trait_method_section_bodies() {
|
||||
let doc = test::mk_doc(
|
||||
~"iface i {
|
||||
~"trait i {
|
||||
#[doc = \"\
|
||||
# Header\n\
|
||||
Body \"]\
|
||||
|
|
|
@ -218,7 +218,7 @@ fn get_method_sig(
|
|||
|
||||
#[test]
|
||||
fn should_add_trait_method_sigs() {
|
||||
let doc = test::mk_doc(~"iface i { fn a<T>() -> int; }");
|
||||
let doc = test::mk_doc(~"trait i { fn a<T>() -> int; }");
|
||||
assert doc.cratemod().traits()[0].methods[0].sig
|
||||
== some(~"fn a<T>() -> int");
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
mod animals {
|
||||
|
||||
iface noisy {
|
||||
trait noisy {
|
||||
fn speak();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#[link(name = "a", vers = "0.0")];
|
||||
#[crate_type = "lib"];
|
||||
|
||||
iface i<T> { }
|
||||
trait i<T> { }
|
||||
|
||||
fn f<T>() -> i<T> {
|
||||
impl <T> of i<T> for () { }
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#[link(name = "a", vers = "0.1")];
|
||||
#[crate_type = "lib"];
|
||||
|
||||
iface to_str {
|
||||
trait to_str {
|
||||
fn to_str() -> str;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
iface A { fn foo(); }
|
||||
iface B { fn foo(); }
|
||||
trait A { fn foo(); }
|
||||
trait B { fn foo(); }
|
||||
|
||||
fn foo<T: A B>(t: T) {
|
||||
t.foo(); //~ ERROR multiple applicable methods in scope
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// error-pattern: attempted access of field `eat` on type `noisy`
|
||||
iface noisy {
|
||||
trait noisy {
|
||||
fn speak();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// error-pattern:missing method `eat`
|
||||
iface animal {
|
||||
trait animal {
|
||||
fn eat();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
iface foo<T> { }
|
||||
trait foo<T> { }
|
||||
|
||||
fn bar(x: foo<uint>) -> foo<int> {
|
||||
ret (x as foo::<int>);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
iface foo {
|
||||
trait foo {
|
||||
fn bar(x: uint) -> self;
|
||||
}
|
||||
impl of foo for int {
|
||||
|
|
5
src/test/compile-fail/iface-keyword.rs
Normal file
5
src/test/compile-fail/iface-keyword.rs
Normal file
|
@ -0,0 +1,5 @@
|
|||
iface foo { } //~ WARN `iface` is deprecated; use `trait`
|
||||
|
||||
fn main() {
|
||||
x //~ ERROR unresolved name: x
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
iface bar { fn dup() -> self; fn blah<X>(); }
|
||||
trait bar { fn dup() -> self; fn blah<X>(); }
|
||||
impl of bar for int { fn dup() -> int { self } fn blah<X>() {} }
|
||||
impl of bar for uint { fn dup() -> uint { self } fn blah<X>() {} }
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
iface foo { fn foo(); }
|
||||
trait foo { fn foo(); }
|
||||
|
||||
impl of int for uint { fn foo() {} } //~ ERROR trait
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// error-pattern: overly deep expansion
|
||||
// issue 2258
|
||||
|
||||
iface to_opt {
|
||||
trait to_opt {
|
||||
fn to_option() -> option<self>;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
enum chan { }
|
||||
|
||||
iface channel<T> {
|
||||
trait channel<T> {
|
||||
fn send(v: T);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use std;
|
||||
|
||||
iface siphash {
|
||||
trait siphash {
|
||||
fn result() -> u64;
|
||||
fn reset();
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use std;
|
||||
|
||||
iface siphash {
|
||||
trait siphash {
|
||||
fn reset();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
iface repeat<A> { fn get() -> A; }
|
||||
trait repeat<A> { fn get() -> A; }
|
||||
|
||||
impl<A:copy> of repeat<A> for @A {
|
||||
fn get() -> A { *self }
|
||||
}
|
||||
|
||||
fn repeater<A:copy>(v: @A) -> repeat<A> {
|
||||
// Note: owned kind is not necessary as A appears in the iface type
|
||||
// Note: owned kind is not necessary as A appears in the trait type
|
||||
v as repeat::<A> // No
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// A dummy iface/impl that work close over any type. The iface will
|
||||
// A dummy trait/impl that work close over any type. The trait will
|
||||
// be parameterized by a region due to the &self/int constraint.
|
||||
|
||||
iface foo {
|
||||
trait foo {
|
||||
fn foo(i: &self/int) -> int;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
iface foo { fn foo(); }
|
||||
trait foo { fn foo(); }
|
||||
|
||||
fn to_foo<T: copy foo>(t: T) -> foo {
|
||||
t as foo //~ ERROR value may contain borrowed pointers; use `owned` bound
|
||||
|
|
|
@ -3,7 +3,7 @@ import std::map;
|
|||
import std::map::hashmap;
|
||||
import std::map::map;
|
||||
|
||||
// Test that iface types printed in error msgs include the type arguments.
|
||||
// Test that trait types printed in error msgs include the type arguments.
|
||||
|
||||
fn main() {
|
||||
let x: map<~str,~str> = map::str_hash::<~str>() as map::<~str,~str>;
|
||||
|
|
|
@ -15,7 +15,7 @@ fn new_parse_sess() -> parse::parse_sess {
|
|||
fail;
|
||||
}
|
||||
|
||||
iface fake_ext_ctxt {
|
||||
trait fake_ext_ctxt {
|
||||
fn session() -> fake_session;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ fn new_parse_sess() -> parser::parse_sess {
|
|||
fail;
|
||||
}
|
||||
|
||||
iface fake_ext_ctxt {
|
||||
trait fake_ext_ctxt {
|
||||
fn session() -> fake_session;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,15 +3,15 @@
|
|||
// checked.
|
||||
|
||||
enum an_enum = ∫
|
||||
iface an_iface { fn foo() -> &self/int; }
|
||||
trait a_trait { fn foo() -> &self/int; }
|
||||
class a_class { let x:&self/int; new(x:&self/int) { self.x = x; } }
|
||||
|
||||
fn a_fn1(e: an_enum/&a) -> an_enum/&b {
|
||||
ret e; //~ ERROR mismatched types: expected `an_enum/&b` but found `an_enum/&a`
|
||||
}
|
||||
|
||||
fn a_fn2(e: an_iface/&a) -> an_iface/&b {
|
||||
ret e; //~ ERROR mismatched types: expected `an_iface/&b` but found `an_iface/&a`
|
||||
fn a_fn2(e: a_trait/&a) -> a_trait/&b {
|
||||
ret e; //~ ERROR mismatched types: expected `a_trait/&b` but found `a_trait/&a`
|
||||
}
|
||||
|
||||
fn a_fn3(e: a_class/&a) -> a_class/&b {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
iface deref {
|
||||
trait deref {
|
||||
fn get() -> int;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
type ctxt = { v: uint };
|
||||
|
||||
iface get_ctxt {
|
||||
trait get_ctxt {
|
||||
// Here the `&` is bound in the method definition:
|
||||
fn get_ctxt() -> &ctxt;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
type ctxt = { v: uint };
|
||||
|
||||
iface get_ctxt {
|
||||
trait get_ctxt {
|
||||
fn get_ctxt() -> &self/ctxt;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
iface get_ctxt {
|
||||
trait get_ctxt {
|
||||
fn get_ctxt() -> &self/uint;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Here: foo is parameterized because it contains a method that
|
||||
// refers to self.
|
||||
|
||||
iface foo {
|
||||
trait foo {
|
||||
fn self_int() -> &self/int;
|
||||
|
||||
fn any_int() -> ∫
|
||||
|
@ -21,7 +21,7 @@ impl methods of set_foo_foo for with_foo {
|
|||
|
||||
// Bar is not region parameterized.
|
||||
|
||||
iface bar {
|
||||
trait bar {
|
||||
fn any_int() -> ∫
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
iface add {
|
||||
trait add {
|
||||
fn plus(++x: self) -> self;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
iface add {
|
||||
trait add {
|
||||
fn plus(x: self) -> self;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use std;
|
||||
fn main() {
|
||||
iface seq { }
|
||||
trait seq { }
|
||||
|
||||
impl <T> of seq<T> for ~[T] { //~ ERROR wrong number of type arguments
|
||||
/* ... */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
iface box_iface<T> {
|
||||
trait box_trait<T> {
|
||||
fn get() -> T;
|
||||
fn set(t: T);
|
||||
}
|
||||
|
@ -7,12 +7,12 @@ enum box_impl<T> = {
|
|||
mut f: T
|
||||
};
|
||||
|
||||
impl<T:copy> of box_iface<T> for box_impl<T> {
|
||||
impl<T:copy> of box_trait<T> for box_impl<T> {
|
||||
fn get() -> T { ret self.f; }
|
||||
fn set(t: T) { self.f = t; }
|
||||
}
|
||||
|
||||
fn set_box_iface<T>(b: box_iface<@const T>, v: @const T) {
|
||||
fn set_box_trait<T>(b: box_trait<@const T>, v: @const T) {
|
||||
b.set(v);
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ fn set_box_impl<T>(b: box_impl<@const T>, v: @const T) {
|
|||
|
||||
fn main() {
|
||||
let b = box_impl::<@int>({mut f: @3});
|
||||
set_box_iface(b as box_iface::<@int>, @mut 5);
|
||||
set_box_trait(b as box_trait::<@int>, @mut 5);
|
||||
//~^ ERROR values differ in mutability
|
||||
set_box_impl(b, @mut 5);
|
||||
//~^ ERROR values differ in mutability
|
||||
|
|
|
@ -4,7 +4,7 @@ fn failfn() {
|
|||
fail;
|
||||
}
|
||||
|
||||
iface i {
|
||||
trait i {
|
||||
fn foo();
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ fn new_parse_sess() -> parser::parse_sess {
|
|||
ret sess;
|
||||
}
|
||||
|
||||
iface fake_ext_ctxt {
|
||||
trait fake_ext_ctxt {
|
||||
fn session() -> fake_session;
|
||||
fn cfg() -> ast::crate_cfg;
|
||||
fn parse_sess() -> parser::parse_sess;
|
||||
|
|
|
@ -11,7 +11,7 @@ import syntax::codemap;
|
|||
import syntax::parse;
|
||||
import syntax::print::*;
|
||||
|
||||
iface fake_ext_ctxt {
|
||||
trait fake_ext_ctxt {
|
||||
fn cfg() -> ast::crate_cfg;
|
||||
fn parse_sess() -> parse::parse_sess;
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// making method calls, but only if there aren't any matches without
|
||||
// it.
|
||||
|
||||
iface iterable<A> {
|
||||
trait iterable<A> {
|
||||
fn iterate(blk: fn(A) -> bool);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
iface noisy {
|
||||
trait noisy {
|
||||
fn speak() -> int;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
iface noisy {
|
||||
trait noisy {
|
||||
fn speak();
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ enum cat_type { tuxedo, tabby, tortoiseshell }
|
|||
// Very silly -- this just returns the value of the name field
|
||||
// for any int value that's less than the meows field
|
||||
|
||||
// ok: T should be in scope when resolving the iface ref for map
|
||||
// ok: T should be in scope when resolving the trait ref for map
|
||||
class cat<T: copy> : map<int, T> {
|
||||
priv {
|
||||
// Yes, you can have negative meows
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
iface noisy {
|
||||
trait noisy {
|
||||
fn speak();
|
||||
}
|
||||
|
||||
|
|
|
@ -8,15 +8,15 @@ import dvec::{dvec, extensions};
|
|||
enum furniture { chair, couch, bed }
|
||||
enum body_part { finger, toe, nose, ear }
|
||||
|
||||
iface noisy {
|
||||
trait noisy {
|
||||
fn speak() -> int;
|
||||
}
|
||||
|
||||
iface scratchy {
|
||||
trait scratchy {
|
||||
fn scratch() -> option<furniture>;
|
||||
}
|
||||
|
||||
iface bitey {
|
||||
trait bitey {
|
||||
fn bite() -> body_part;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Test cyclic detector when using iface instances.
|
||||
// Test cyclic detector when using trait instances.
|
||||
|
||||
enum Tree = TreeR;
|
||||
type TreeR = @{
|
||||
|
@ -7,7 +7,7 @@ type TreeR = @{
|
|||
val: to_str
|
||||
};
|
||||
|
||||
iface to_str {
|
||||
trait to_str {
|
||||
fn to_str() -> ~str;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
iface to_str {
|
||||
trait to_str {
|
||||
fn to_str() -> ~str;
|
||||
}
|
||||
impl of to_str for int {
|
||||
|
@ -11,7 +11,7 @@ impl of to_str for () {
|
|||
fn to_str() -> ~str { ~"()" }
|
||||
}
|
||||
|
||||
iface map<T> {
|
||||
trait map<T> {
|
||||
fn map<U>(f: fn(T) -> U) -> ~[U];
|
||||
}
|
||||
impl <T> of map<T> for ~[T] {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
iface to_str {
|
||||
trait to_str {
|
||||
fn to_str() -> ~str;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
// This test had to do with an outdated version of the iterable iface.
|
||||
// This test had to do with an outdated version of the iterable trait.
|
||||
// However, the condition it was testing seemed complex enough to
|
||||
// warrant still having a test, so I inlined the old definitions.
|
||||
|
||||
iface iterable<A> {
|
||||
trait iterable<A> {
|
||||
fn iter(blk: fn(A));
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
iface clam<A: copy> {
|
||||
trait clam<A: copy> {
|
||||
fn chowder(y: A);
|
||||
}
|
||||
class foo<A: copy> : clam<A> {
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue