]> git.lizzy.rs Git - rust.git/commitdiff
auto merge of #9336 : alexcrichton/rust/issue-7981, r=catamorphism
authorbors <bors@rust-lang.org>
Tue, 24 Sep 2013 22:45:57 +0000 (15:45 -0700)
committerbors <bors@rust-lang.org>
Tue, 24 Sep 2013 22:45:57 +0000 (15:45 -0700)
Progress on #7981

This doesn't completely close the issue because `struct A;` is still allowed, and it's a much larger change to disallow that. I'm also not entirely sure that we want to disallow that. Regardless, punting that discussion to the issue instead.

24 files changed:
src/libstd/rt/io/mod.rs
src/libstd/rt/uv/file.rs
src/libsyntax/parse/obsolete.rs
src/libsyntax/parse/parser.rs
src/libsyntax/print/pprust.rs
src/test/auxiliary/trait_inheritance_overloading_xc.rs
src/test/compile-fail/missing-derivable-attr.rs
src/test/debug-info/generic-trait-generic-static-default-method.rs
src/test/debug-info/self-in-default-method.rs
src/test/debug-info/self-in-generic-default-method.rs
src/test/debug-info/trait-generic-static-default-method.rs
src/test/pretty/empty-impl.pp
src/test/pretty/empty-impl.rs
src/test/pretty/path-type-bounds.rs
src/test/run-pass/default-method-supertrait-vtable.rs
src/test/run-pass/issue-3979-generics.rs
src/test/run-pass/issue-3979-xcrate.rs
src/test/run-pass/issue-3979.rs
src/test/run-pass/supertrait-default-generics.rs
src/test/run-pass/trait-inheritance-overloading-simple.rs
src/test/run-pass/trait-inheritance-overloading.rs
src/test/run-pass/trait-inheritance-subst.rs
src/test/run-pass/trait-inheritance-subst2.rs
src/test/run-pass/trait-inheritance2.rs

index 6b405b0948a0fba6a5a523078bd591f5c6686e02..70fcf442f3fd50d939a21fb424557a5371ee37a7 100644 (file)
@@ -472,7 +472,7 @@ pub trait Writer {
 
 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
index ada558036cfeae2419768e52878eb73a9ead533b..54cb40c9873a5a7ef119ed36444266f448305026 100644 (file)
@@ -22,7 +22,7 @@
 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>
index b056b39eb6e89e4769985adbfecabf4ff669e906..c2c08ce9360b6256419c3c15c90940f61ccc04c2 100644 (file)
@@ -65,6 +65,7 @@ pub enum ObsoleteSyntax {
     ObsoletePrivVisibility,
     ObsoleteTraitFuncVisibility,
     ObsoleteConstPointer,
+    ObsoleteEmptyImpl,
 }
 
 impl to_bytes::IterBytes for ObsoleteSyntax {
@@ -256,6 +257,10 @@ fn obsolete(&self, sp: Span, kind: 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);
index 4aad5c24d0f3d8e07e3355f38bd32d4908d844a1..5a0ccac2cdbf2161016b0bcdda30b53a37a179f0 100644 (file)
@@ -3852,7 +3852,9 @@ fn parse_item_impl(&self, visibility: ast::visibility) -> item_info {
         }
 
         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());
index 867e4fe416b1d35ec5fda6f577dcde43e314754e..dee8d710a73ad7162d5f33daacbbeaef4f7ce7aa 100644 (file)
@@ -598,18 +598,12 @@ pub fn print_item(s: @ps, item: &ast::item) {
 
         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"));
index f938c9c56ed94eda2a9d57ec3c03dbaacfb77521..8694871417a91ce7138d4bdff203863b16baf236 100644 (file)
@@ -35,6 +35,6 @@ fn eq(&self, other: &MyInt) -> bool { self.val == other.val }
     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 } }
index eb27d51061fcca5cf6eb9cf8aabab7ee14860345..70c16e0baefb873dd2e3905e18aa2ade3d259575 100644 (file)
@@ -20,7 +20,7 @@ impl MyEq for int {
     fn eq(&self, other: &int) -> bool { *self == *other }
 }
 
-impl MyEq for A;  //~ ERROR missing method
+impl MyEq for A {}  //~ ERROR missing method
 
 fn main() {
 }
index 8523a947aac10ae6cb8f98b78fdd4fc1331ee719..4355b4b98fe2288f40b406056de389971d6fa368 100644 (file)
@@ -40,7 +40,7 @@ fn generic_static_default_method<T2>(arg1: int, arg2: &(T1, T2)) -> int {
     }
 }
 
-impl<T> Trait<T> for Struct;
+impl<T> Trait<T> for Struct {}
 
 fn main() {
 
index 53b2e9ee21de1692387cba6a6ef2c6a2b55d606e..fde58f76accb7f1050c265cf5aeb6d1a06b5e39d 100644 (file)
@@ -118,7 +118,7 @@ fn self_managed(@self, arg1: int, arg2: int) -> int {
     }
 }
 
-impl Trait for Struct;
+impl Trait for Struct {}
 
 fn main() {
     let stack = Struct { x: 100 };
index 47f589307601f2ed24c334d2c08f8dc27bdd9e06..3daf7afd4b1a4d4847701ffea609db51c26239e0 100644 (file)
@@ -119,7 +119,7 @@ fn self_managed<T>(@self, arg1: int, arg2: T) -> int {
     }
 }
 
-impl Trait for Struct;
+impl Trait for Struct {}
 
 fn main() {
     let stack = Struct { x: 987 };
index 1f6e6992e2795af4de102bbb8f911f3023816bb0..05258d53586849ad59c5f041cc13bca7fb3cc2d7 100644 (file)
@@ -40,7 +40,7 @@ fn generic_static_default_method<T>(arg1: int, arg2: T) -> int {
     }
 }
 
-impl Trait for Struct;
+impl Trait for Struct {}
 
 fn main() {
 
index af401bd25ca1e9bf1cce703d654b66bef35284ed..685cdcdaeade0b06c9761be62892111a9e24e54e 100644 (file)
@@ -1,5 +1,5 @@
 trait X { }
-impl X for uint;
+impl X for uint { }
 
 trait Y { }
-impl Y for uint;
+impl Y for uint { }
index af401bd25ca1e9bf1cce703d654b66bef35284ed..685cdcdaeade0b06c9761be62892111a9e24e54e 100644 (file)
@@ -1,5 +1,5 @@
 trait X { }
-impl X for uint;
+impl X for uint { }
 
 trait Y { }
-impl Y for uint;
+impl Y for uint { }
index a62fbdeeb185f830ed4fbe3b8411b8a5f31dd6e8..4a402132254077c6243e513e9aca61ca3feb8e73 100644 (file)
@@ -1,7 +1,7 @@
 // pp-exact
 
 trait Tr { }
-impl Tr for int;
+impl Tr for int { }
 
 fn foo(x: ~Tr: Freeze) -> ~Tr: Freeze { x }
 
index 90a2b914021244aef585368d528161f9a5b5f42e..b5790269d90ce70c05940648c5a1b9bf7420b582 100644 (file)
@@ -29,7 +29,7 @@ impl Y for int {
     fn y(self) -> int { self }
 }
 
-impl Z for int;
+impl Z for int {}
 
 fn main() {
     assert_eq!(12.x(), 12);
index 867301121daeeb743e88dd57e2be4c8980740c5a..86cdd6135ecf292f9fa8bf7d558dadd82efd2ba6 100644 (file)
@@ -31,7 +31,7 @@ fn X(&self) -> int {
     }
 }
 
-impl Movable<int> for Point;
+impl Movable<int> for Point {}
 
 pub fn main() {
     let mut p = Point{ x: 1, y: 2};
index caf6d2023169ebe4358b6a080c5d5c32d285d87d..63d2562f5412b45d842b23f866b33baf199ce0bc 100644 (file)
@@ -24,7 +24,7 @@ fn X(&self) -> int {
     }
 }
 
-impl Movable for Point;
+impl Movable for Point {}
 
 pub fn main() {
     let mut p = Point{ x: 1, y: 2};
index 2e53fb5d3f92f399e6bda09618672a766774e1c0..4f69342830b93c22a90fa2be936dbc533eea0d26 100644 (file)
@@ -32,7 +32,7 @@ fn X(&self) -> int {
     }
 }
 
-impl Movable for Point;
+impl Movable for Point {}
 
 pub fn main() {
     let mut p = Point{ x: 1, y: 2};
index ae7e18d532b7951777719e05a511ba9b9a08f650..2cfc22111a73fe2ee87eab374d5ad67a5fa17c85 100644 (file)
@@ -33,7 +33,7 @@ fn X(&self) -> 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() {
     let mut p = Point{ x: 1, y: 2};
index 041452176e0e3eecd80bc1bfe9f86d6b29ba621c..3a0f2dd9464dadf58036c930de045e16af476ef0 100644 (file)
@@ -19,7 +19,7 @@ fn eq(&self, other: &MyInt) -> bool { self.val == other.val }
     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;
index d5321ea52983a25778eb347546e4c64eb1fc7795..fb19bfa674fd8ec9eee83d61242d7cfd43bb8ac4 100644 (file)
@@ -31,7 +31,7 @@ fn eq(&self, other: &MyInt) -> bool { self.val == other.val }
     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);
index 479f293a396e30fb81b791599c0a9ae28cd18d11..cd57e6a7dd05966caf8cf8cfccb07ef290bf2576 100644 (file)
@@ -20,7 +20,7 @@ impl Add<MyInt, MyInt> for MyInt {
     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);
index 214505172a51a6287a50a2b1e3cd74a800f39131..ebddfafc3b4381ffb262011469684e4e206a0c5d 100644 (file)
@@ -30,7 +30,7 @@ impl Add<MyInt, MyInt> for MyInt {
     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);
index 6046da412174f2d156ba1adad3ed641f5b176e08..7fa895ddf988802b1896224c67f1448b1e119962 100644 (file)
@@ -19,7 +19,7 @@ struct A { x: int }
 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);