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
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue