From 8eb61a69e6269327105abdb2dc7183bd4227a3be Mon Sep 17 00:00:00 2001 From: Huon Wilson Date: Sat, 1 Feb 2014 00:42:02 +1100 Subject: [PATCH 1/2] Add test for sensible #[start] error message. Fixes #9575. --- src/test/compile-fail/issue-9575.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/test/compile-fail/issue-9575.rs diff --git a/src/test/compile-fail/issue-9575.rs b/src/test/compile-fail/issue-9575.rs new file mode 100644 index 0000000000000..cc03361ee27e1 --- /dev/null +++ b/src/test/compile-fail/issue-9575.rs @@ -0,0 +1,15 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[start] +fn start(argc: int, argv: **u8, crate_map: *u8) -> int { + //~^ ERROR start function expects type: `fn(int, **u8) -> int` + 0 +} From edb9f825c4984c4608b381618f4310dc32a232ce Mon Sep 17 00:00:00 2001 From: Huon Wilson Date: Sat, 1 Feb 2014 01:46:30 +1100 Subject: [PATCH 2/2] Remove the obsolete handler for `impl A;`. This is has been obsolete for quite a while now (including a release), so removing the special handling seems fine. (The error message is quite good still anyway.) Fixes #9580. --- src/libsyntax/parse/obsolete.rs | 5 ----- src/libsyntax/parse/parser.rs | 22 +++++++------------ src/test/compile-fail/empty-impl-semicolon.rs | 11 ++++++++++ 3 files changed, 19 insertions(+), 19 deletions(-) create mode 100644 src/test/compile-fail/empty-impl-semicolon.rs diff --git a/src/libsyntax/parse/obsolete.rs b/src/libsyntax/parse/obsolete.rs index 6aa1afee206eb..c4887d55e2a29 100644 --- a/src/libsyntax/parse/obsolete.rs +++ b/src/libsyntax/parse/obsolete.rs @@ -36,7 +36,6 @@ pub enum ObsoleteSyntax { ObsoleteUnsafeExternFn, ObsoleteTraitFuncVisibility, ObsoleteConstPointer, - ObsoleteEmptyImpl, ObsoleteLoopAsContinue, ObsoleteEnumWildcard, ObsoleteStructWildcard, @@ -110,10 +109,6 @@ impl ParserObsoleteMethods for Parser { "instead of `&const Foo` or `@const Foo`, write `&Foo` or \ `@Foo`" ), - ObsoleteEmptyImpl => ( - "empty implementation", - "instead of `impl A;`, write `impl A {}`" - ), ObsoleteLoopAsContinue => ( "`loop` instead of `continue`", "`loop` is now only used for loops and `continue` is used for \ diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 04a984ba95d92..642624adfb2b5 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -3926,21 +3926,15 @@ impl Parser { }; let mut meths = ~[]; - let inner_attrs = if self.eat(&token::SEMI) { - self.obsolete(self.last_span, ObsoleteEmptyImpl); - None - } else { - self.expect(&token::LBRACE); - let (inner_attrs, next) = self.parse_inner_attrs_and_next(); - let mut method_attrs = Some(next); - while !self.eat(&token::RBRACE) { - meths.push(self.parse_method(method_attrs)); - method_attrs = None; - } - Some(inner_attrs) - }; + self.expect(&token::LBRACE); + let (inner_attrs, next) = self.parse_inner_attrs_and_next(); + let mut method_attrs = Some(next); + while !self.eat(&token::RBRACE) { + meths.push(self.parse_method(method_attrs)); + method_attrs = None; + } - (ident, ItemImpl(generics, opt_trait, ty, meths), inner_attrs) + (ident, ItemImpl(generics, opt_trait, ty, meths), Some(inner_attrs)) } // parse a::B<~str,int> diff --git a/src/test/compile-fail/empty-impl-semicolon.rs b/src/test/compile-fail/empty-impl-semicolon.rs new file mode 100644 index 0000000000000..1a8751cb91aeb --- /dev/null +++ b/src/test/compile-fail/empty-impl-semicolon.rs @@ -0,0 +1,11 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +impl Foo; //~ ERROR expected `{` but found `;`