pub trait Stream: Reader + Writer { }
-impl<T: Reader + Writer> Stream for T;
+impl<T: Reader + Writer> Stream for T {}
pub enum SeekStyle {
/// Seek from the beginning of the stream
use option::{None, Some, Option};
pub struct FsRequest(*uvll::uv_fs_t);
-impl Request for FsRequest;
+impl Request for FsRequest {}
pub struct RequestData {
complete_cb: Option<FsCallback>
ObsoletePrivVisibility,
ObsoleteTraitFuncVisibility,
ObsoleteConstPointer,
+ ObsoleteEmptyImpl,
}
impl to_bytes::IterBytes for ObsoleteSyntax {
"instead of `&const Foo` or `@const Foo`, write `&Foo` or \
`@Foo`"
),
+ ObsoleteEmptyImpl => (
+ "empty implementation",
+ "instead of `impl A;`, write `impl A {}`"
+ ),
};
self.report(sp, kind, kind_str, desc);
}
let mut meths = ~[];
- if !self.eat(&token::SEMI) {
+ if self.eat(&token::SEMI) {
+ self.obsolete(*self.span, ObsoleteEmptyImpl);
+ } else {
self.expect(&token::LBRACE);
while !self.eat(&token::RBRACE) {
meths.push(self.parse_method());
print_type(s, ty);
- if methods.len() == 0 {
- word(s.s, ";");
- end(s); // end the head-ibox
- end(s); // end the outer cbox
- } else {
- space(s.s);
- bopen(s);
- for meth in methods.iter() {
- print_method(s, *meth);
- }
- bclose(s, item.span);
+ space(s.s);
+ bopen(s);
+ for meth in methods.iter() {
+ print_method(s, *meth);
}
+ bclose(s, item.span);
}
ast::item_trait(ref generics, ref traits, ref methods) => {
head(s, visibility_qualified(item.vis, "trait"));
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 eq(&self, other: &int) -> bool { *self == *other }
}
-impl MyEq for A; //~ ERROR missing method
+impl MyEq for A {} //~ ERROR missing method
fn main() {
}
}
}
-impl<T> Trait<T> for Struct;
+impl<T> Trait<T> for Struct {}
fn main() {
}
}
-impl Trait for Struct;
+impl Trait for Struct {}
fn main() {
let stack = Struct { x: 100 };
}
}
-impl Trait for Struct;
+impl Trait for Struct {}
fn main() {
let stack = Struct { x: 987 };
}
}
-impl Trait for Struct;
+impl Trait for Struct {}
fn main() {
trait X { }
-impl X for uint;
+impl X for uint { }
trait Y { }
-impl Y for uint;
+impl Y for uint { }
trait X { }
-impl X for uint;
+impl X for uint { }
trait Y { }
-impl Y for uint;
+impl Y for uint { }
// pp-exact
trait Tr { }
-impl Tr for int;
+impl Tr for int { }
fn foo(x: ~Tr: Freeze) -> ~Tr: Freeze { x }
fn y(self) -> int { self }
}
-impl Z for int;
+impl Z for int {}
fn main() {
assert_eq!(12.x(), 12);
}
}
-impl Movable<int> for Point;
+impl Movable<int> for Point {}
pub fn main() {
let mut p = Point{ x: 1, y: 2};
}
}
-impl Movable for Point;
+impl Movable for Point {}
pub fn main() {
let mut p = Point{ x: 1, y: 2};
}
}
-impl Movable for Point;
+impl Movable for Point {}
pub fn main() {
let mut p = Point{ x: 1, y: 2};
}
}
-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() {
let mut p = Point{ x: 1, y: 2};
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 {
return x == y;
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) {
return (x + y, x - y, x * y);
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 {
return x.add(&y);
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 {
return x.add(&y).chomp(&y);
impl Foo for A { fn f(&self) -> int { 10 } }
impl Bar for A { fn g(&self) -> int { 20 } }
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) {
assert_eq!(a.f(), 10);