parent
4dacd73651
commit
4b266f1c0d
|
@ -472,7 +472,7 @@ pub trait Writer {
|
||||||
|
|
||||||
pub trait Stream: Reader + Writer { }
|
pub trait Stream: Reader + Writer { }
|
||||||
|
|
||||||
impl<T: Reader + Writer> Stream for T;
|
impl<T: Reader + Writer> Stream for T {}
|
||||||
|
|
||||||
pub enum SeekStyle {
|
pub enum SeekStyle {
|
||||||
/// Seek from the beginning of the stream
|
/// Seek from the beginning of the stream
|
||||||
|
|
|
@ -22,7 +22,7 @@ use libc::{c_int};
|
||||||
use option::{None, Some, Option};
|
use option::{None, Some, Option};
|
||||||
|
|
||||||
pub struct FsRequest(*uvll::uv_fs_t);
|
pub struct FsRequest(*uvll::uv_fs_t);
|
||||||
impl Request for FsRequest;
|
impl Request for FsRequest {}
|
||||||
|
|
||||||
pub struct RequestData {
|
pub struct RequestData {
|
||||||
complete_cb: Option<FsCallback>
|
complete_cb: Option<FsCallback>
|
||||||
|
|
|
@ -65,6 +65,7 @@ pub enum ObsoleteSyntax {
|
||||||
ObsoletePrivVisibility,
|
ObsoletePrivVisibility,
|
||||||
ObsoleteTraitFuncVisibility,
|
ObsoleteTraitFuncVisibility,
|
||||||
ObsoleteConstPointer,
|
ObsoleteConstPointer,
|
||||||
|
ObsoleteEmptyImpl,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl to_bytes::IterBytes for ObsoleteSyntax {
|
impl to_bytes::IterBytes for ObsoleteSyntax {
|
||||||
|
@ -256,6 +257,10 @@ impl ParserObsoleteMethods for Parser {
|
||||||
"instead of `&const Foo` or `@const Foo`, write `&Foo` or \
|
"instead of `&const Foo` or `@const Foo`, write `&Foo` or \
|
||||||
`@Foo`"
|
`@Foo`"
|
||||||
),
|
),
|
||||||
|
ObsoleteEmptyImpl => (
|
||||||
|
"empty implementation",
|
||||||
|
"instead of `impl A;`, write `impl A {}`"
|
||||||
|
),
|
||||||
};
|
};
|
||||||
|
|
||||||
self.report(sp, kind, kind_str, desc);
|
self.report(sp, kind, kind_str, desc);
|
||||||
|
|
|
@ -3852,7 +3852,9 @@ impl Parser {
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut meths = ~[];
|
let mut meths = ~[];
|
||||||
if !self.eat(&token::SEMI) {
|
if self.eat(&token::SEMI) {
|
||||||
|
self.obsolete(*self.span, ObsoleteEmptyImpl);
|
||||||
|
} else {
|
||||||
self.expect(&token::LBRACE);
|
self.expect(&token::LBRACE);
|
||||||
while !self.eat(&token::RBRACE) {
|
while !self.eat(&token::RBRACE) {
|
||||||
meths.push(self.parse_method());
|
meths.push(self.parse_method());
|
||||||
|
|
|
@ -587,18 +587,12 @@ pub fn print_item(s: @ps, item: &ast::item) {
|
||||||
|
|
||||||
print_type(s, ty);
|
print_type(s, ty);
|
||||||
|
|
||||||
if methods.len() == 0 {
|
space(s.s);
|
||||||
word(s.s, ";");
|
bopen(s);
|
||||||
end(s); // end the head-ibox
|
for meth in methods.iter() {
|
||||||
end(s); // end the outer cbox
|
print_method(s, *meth);
|
||||||
} else {
|
|
||||||
space(s.s);
|
|
||||||
bopen(s);
|
|
||||||
for meth in methods.iter() {
|
|
||||||
print_method(s, *meth);
|
|
||||||
}
|
|
||||||
bclose(s, item.span);
|
|
||||||
}
|
}
|
||||||
|
bclose(s, item.span);
|
||||||
}
|
}
|
||||||
ast::item_trait(ref generics, ref traits, ref methods) => {
|
ast::item_trait(ref generics, ref traits, ref methods) => {
|
||||||
head(s, visibility_qualified(item.vis, "trait"));
|
head(s, visibility_qualified(item.vis, "trait"));
|
||||||
|
|
|
@ -35,6 +35,6 @@ impl Eq for MyInt {
|
||||||
fn ne(&self, other: &MyInt) -> bool { !self.eq(other) }
|
fn ne(&self, other: &MyInt) -> bool { !self.eq(other) }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MyNum for MyInt;
|
impl MyNum for MyInt {}
|
||||||
|
|
||||||
fn mi(v: int) -> MyInt { MyInt { val: v } }
|
fn mi(v: int) -> MyInt { MyInt { val: v } }
|
||||||
|
|
|
@ -20,7 +20,7 @@ impl MyEq for int {
|
||||||
fn eq(&self, other: &int) -> bool { *self == *other }
|
fn eq(&self, other: &int) -> bool { *self == *other }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MyEq for A; //~ ERROR missing method
|
impl MyEq for A {} //~ ERROR missing method
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ trait Trait<T1> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> Trait<T> for Struct;
|
impl<T> Trait<T> for Struct {}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
||||||
|
|
|
@ -118,7 +118,7 @@ trait Trait {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Trait for Struct;
|
impl Trait for Struct {}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let stack = Struct { x: 100 };
|
let stack = Struct { x: 100 };
|
||||||
|
|
|
@ -119,7 +119,7 @@ trait Trait {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Trait for Struct;
|
impl Trait for Struct {}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let stack = Struct { x: 987 };
|
let stack = Struct { x: 987 };
|
||||||
|
|
|
@ -40,7 +40,7 @@ trait Trait {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Trait for Struct;
|
impl Trait for Struct {}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
trait X { }
|
trait X { }
|
||||||
impl X for uint;
|
impl X for uint { }
|
||||||
|
|
||||||
trait Y { }
|
trait Y { }
|
||||||
impl Y for uint;
|
impl Y for uint { }
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
trait X { }
|
trait X { }
|
||||||
impl X for uint;
|
impl X for uint { }
|
||||||
|
|
||||||
trait Y { }
|
trait Y { }
|
||||||
impl Y for uint;
|
impl Y for uint { }
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// pp-exact
|
// pp-exact
|
||||||
|
|
||||||
trait Tr { }
|
trait Tr { }
|
||||||
impl Tr for int;
|
impl Tr for int { }
|
||||||
|
|
||||||
fn foo(x: ~Tr: Freeze) -> ~Tr: Freeze { x }
|
fn foo(x: ~Tr: Freeze) -> ~Tr: Freeze { x }
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ impl Y for int {
|
||||||
fn y(self) -> int { self }
|
fn y(self) -> int { self }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Z for int;
|
impl Z for int {}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
assert_eq!(12.x(), 12);
|
assert_eq!(12.x(), 12);
|
||||||
|
|
|
@ -31,7 +31,7 @@ impl Positioned<int> for Point {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Movable<int> for Point;
|
impl Movable<int> for Point {}
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
let mut p = Point{ x: 1, y: 2};
|
let mut p = Point{ x: 1, y: 2};
|
||||||
|
|
|
@ -24,7 +24,7 @@ impl Positioned for Point {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Movable for Point;
|
impl Movable for Point {}
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
let mut p = Point{ x: 1, y: 2};
|
let mut p = Point{ x: 1, y: 2};
|
||||||
|
|
|
@ -32,7 +32,7 @@ impl Positioned for Point {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Movable for Point;
|
impl Movable for Point {}
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
let mut p = Point{ x: 1, y: 2};
|
let mut p = Point{ x: 1, y: 2};
|
||||||
|
|
|
@ -33,7 +33,7 @@ impl<S: Clone> Positioned<S> for Point<S> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: Clone + Add<S, S>> Movable<S> for Point<S>;
|
impl<S: Clone + Add<S, S>> Movable<S> for Point<S> {}
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
let mut p = Point{ x: 1, y: 2};
|
let mut p = Point{ x: 1, y: 2};
|
||||||
|
|
|
@ -19,7 +19,7 @@ impl Eq for MyInt {
|
||||||
fn ne(&self, other: &MyInt) -> bool { !self.eq(other) }
|
fn ne(&self, other: &MyInt) -> bool { !self.eq(other) }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MyNum for MyInt;
|
impl MyNum for MyInt {}
|
||||||
|
|
||||||
fn f<T:MyNum>(x: T, y: T) -> bool {
|
fn f<T:MyNum>(x: T, y: T) -> bool {
|
||||||
return x == y;
|
return x == y;
|
||||||
|
|
|
@ -31,7 +31,7 @@ impl Eq for MyInt {
|
||||||
fn ne(&self, other: &MyInt) -> bool { !self.eq(other) }
|
fn ne(&self, other: &MyInt) -> bool { !self.eq(other) }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MyNum for MyInt;
|
impl MyNum for MyInt {}
|
||||||
|
|
||||||
fn f<T:MyNum>(x: T, y: T) -> (T, T, T) {
|
fn f<T:MyNum>(x: T, y: T) -> (T, T, T) {
|
||||||
return (x + y, x - y, x * y);
|
return (x + y, x - y, x * y);
|
||||||
|
|
|
@ -20,7 +20,7 @@ impl Add<MyInt, MyInt> for MyInt {
|
||||||
fn add(&self, other: &MyInt) -> MyInt { mi(self.val + other.val) }
|
fn add(&self, other: &MyInt) -> MyInt { mi(self.val + other.val) }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MyNum for MyInt;
|
impl MyNum for MyInt {}
|
||||||
|
|
||||||
fn f<T:MyNum>(x: T, y: T) -> T {
|
fn f<T:MyNum>(x: T, y: T) -> T {
|
||||||
return x.add(&y);
|
return x.add(&y);
|
||||||
|
|
|
@ -30,7 +30,7 @@ impl Add<MyInt, MyInt> for MyInt {
|
||||||
fn add(&self, other: &MyInt) -> MyInt { self.chomp(other) }
|
fn add(&self, other: &MyInt) -> MyInt { self.chomp(other) }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MyNum for MyInt;
|
impl MyNum for MyInt {}
|
||||||
|
|
||||||
fn f<T:MyNum>(x: T, y: T) -> T {
|
fn f<T:MyNum>(x: T, y: T) -> T {
|
||||||
return x.add(&y).chomp(&y);
|
return x.add(&y).chomp(&y);
|
||||||
|
|
|
@ -19,7 +19,7 @@ struct A { x: int }
|
||||||
impl Foo for A { fn f(&self) -> int { 10 } }
|
impl Foo for A { fn f(&self) -> int { 10 } }
|
||||||
impl Bar for A { fn g(&self) -> int { 20 } }
|
impl Bar for A { fn g(&self) -> int { 20 } }
|
||||||
impl Baz for A { fn h(&self) -> int { 30 } }
|
impl Baz for A { fn h(&self) -> int { 30 } }
|
||||||
impl Quux for A;
|
impl Quux for A {}
|
||||||
|
|
||||||
fn f<T:Quux + Foo + Bar + Baz>(a: &T) {
|
fn f<T:Quux + Foo + Bar + Baz>(a: &T) {
|
||||||
assert_eq!(a.f(), 10);
|
assert_eq!(a.f(), 10);
|
||||||
|
|
Loading…
Reference in New Issue