auto merge of #9336 : alexcrichton/rust/issue-7981, r=catamorphism

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.
This commit is contained in:
bors 2013-09-24 15:45:57 -07:00
commit a7d68adbdd
24 changed files with 36 additions and 35 deletions

View 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

View 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>

View 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);

View 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());

View 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"));

View 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 } }

View 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() {
}

View 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() {

View 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 };

View 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 };

View 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() {

View 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 { }

View 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 { }

View 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 }

View 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);

View 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};

View 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};

View 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};

View 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};

View 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;

View 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);

View 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);

View 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);

View 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);