Skip to content

Test & remove an obsolete syntax error #11966

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions src/libsyntax/parse/obsolete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ pub enum ObsoleteSyntax {
ObsoleteUnsafeExternFn,
ObsoleteTraitFuncVisibility,
ObsoleteConstPointer,
ObsoleteEmptyImpl,
ObsoleteLoopAsContinue,
ObsoleteEnumWildcard,
ObsoleteStructWildcard,
Expand Down Expand Up @@ -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 \
Expand Down
22 changes: 8 additions & 14 deletions src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
11 changes: 11 additions & 0 deletions src/test/compile-fail/empty-impl-semicolon.rs
Original file line number Diff line number Diff line change
@@ -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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

impl Foo; //~ ERROR expected `{` but found `;`
15 changes: 15 additions & 0 deletions src/test/compile-fail/issue-9575.rs
Original file line number Diff line number Diff line change
@@ -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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test appears to be completely unrelated.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I see you did intend to include it based on the comment from #9575. I just wasn't expecting it given the PR title.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry; the title was meant to be parsed as (add a test) & (remove an obsolete syntax error).