auto merge of #4861 : sethpink/rust/incoming, r=catamorphism
Fix for issue #4830.
This commit is contained in:
commit
9d7014e55c
@ -39,7 +39,6 @@ pub enum ObsoleteSyntax {
|
||||
ObsoleteFieldTerminator,
|
||||
ObsoleteStructCtor,
|
||||
ObsoleteWith,
|
||||
ObsoleteClassMethod,
|
||||
ObsoleteClassTraits,
|
||||
ObsoletePrivSection,
|
||||
ObsoleteModeInFnType,
|
||||
@ -85,10 +84,6 @@ pub impl Parser {
|
||||
"record update is done with `..`, e.g. \
|
||||
`MyStruct { foo: bar, .. baz }`"
|
||||
),
|
||||
ObsoleteClassMethod => (
|
||||
"class method",
|
||||
"methods should be defined inside impls"
|
||||
),
|
||||
ObsoleteClassTraits => (
|
||||
"class traits",
|
||||
"implemented traits are specified on the impl, as in \
|
||||
|
@ -72,7 +72,7 @@ use parse::lexer::TokenAndSpan;
|
||||
use parse::obsolete::{ObsoleteClassTraits, ObsoleteModeInFnType};
|
||||
use parse::obsolete::{ObsoleteLet, ObsoleteFieldTerminator};
|
||||
use parse::obsolete::{ObsoleteMoveInit, ObsoleteBinaryMove};
|
||||
use parse::obsolete::{ObsoleteStructCtor, ObsoleteWith, ObsoleteClassMethod};
|
||||
use parse::obsolete::{ObsoleteStructCtor, ObsoleteWith};
|
||||
use parse::obsolete::{ObsoleteSyntax, ObsoleteLowerCaseKindBounds};
|
||||
use parse::obsolete::{ObsoleteUnsafeBlock};
|
||||
use parse::prec::{as_prec, token_to_binop};
|
||||
@ -3002,52 +3002,29 @@ pub impl Parser {
|
||||
}
|
||||
|
||||
fn parse_single_class_item(vis: visibility) -> @struct_field {
|
||||
let obsolete_let = self.eat_obsolete_ident("let");
|
||||
if obsolete_let { self.obsolete(copy self.last_span, ObsoleteLet) }
|
||||
|
||||
let parse_obsolete_method =
|
||||
!((obsolete_let || self.is_keyword(~"mut") ||
|
||||
!self.is_any_keyword(copy self.token))
|
||||
&& !self.token_is_pound_or_doc_comment(copy self.token));
|
||||
|
||||
if !parse_obsolete_method {
|
||||
let a_var = self.parse_instance_var(vis);
|
||||
match self.token {
|
||||
token::SEMI => {
|
||||
self.obsolete(copy self.span, ObsoleteFieldTerminator);
|
||||
self.bump();
|
||||
}
|
||||
token::COMMA => {
|
||||
self.bump();
|
||||
}
|
||||
token::RBRACE => {}
|
||||
_ => {
|
||||
self.span_fatal(copy self.span,
|
||||
fmt!("expected `;`, `,`, or '}' but \
|
||||
found `%s`",
|
||||
token_to_str(self.reader,
|
||||
self.token)));
|
||||
}
|
||||
}
|
||||
a_var
|
||||
} else {
|
||||
self.obsolete(copy self.span, ObsoleteClassMethod);
|
||||
self.parse_method();
|
||||
// bogus value
|
||||
@spanned(
|
||||
self.span.lo,
|
||||
self.span.hi,
|
||||
ast::struct_field_ {
|
||||
kind: unnamed_field,
|
||||
id: self.get_id(),
|
||||
ty: @ast::Ty {
|
||||
id: self.get_id(),
|
||||
node: ty_nil,
|
||||
span: copy self.span,
|
||||
}
|
||||
}
|
||||
)
|
||||
if self.eat_obsolete_ident("let") {
|
||||
self.obsolete(copy self.last_span, ObsoleteLet);
|
||||
}
|
||||
|
||||
let a_var = self.parse_instance_var(vis);
|
||||
match self.token {
|
||||
token::SEMI => {
|
||||
self.obsolete(copy self.span, ObsoleteFieldTerminator);
|
||||
self.bump();
|
||||
}
|
||||
token::COMMA => {
|
||||
self.bump();
|
||||
}
|
||||
token::RBRACE => {}
|
||||
_ => {
|
||||
self.span_fatal(copy self.span,
|
||||
fmt!("expected `;`, `,`, or '}' but \
|
||||
found `%s`",
|
||||
token_to_str(self.reader,
|
||||
self.token)));
|
||||
}
|
||||
}
|
||||
a_var
|
||||
}
|
||||
|
||||
fn parse_dtor(attrs: ~[attribute]) -> class_contents {
|
||||
@ -3062,6 +3039,8 @@ pub impl Parser {
|
||||
return members(~[]);
|
||||
}
|
||||
|
||||
let attrs = self.parse_outer_attributes();
|
||||
|
||||
if self.eat_keyword(~"priv") {
|
||||
return members(~[self.parse_single_class_item(private)])
|
||||
}
|
||||
@ -3070,8 +3049,6 @@ pub impl Parser {
|
||||
return members(~[self.parse_single_class_item(public)]);
|
||||
}
|
||||
|
||||
let attrs = self.parse_outer_attributes();
|
||||
|
||||
if self.try_parse_obsolete_struct_ctor() {
|
||||
return members(~[]);
|
||||
}
|
||||
|
@ -29,14 +29,6 @@ struct s {
|
||||
//~^ ERROR obsolete syntax: struct constructor
|
||||
}
|
||||
|
||||
struct ss {
|
||||
fn foo() { }
|
||||
//~^ ERROR obsolete syntax: class method
|
||||
#[whatever]
|
||||
fn foo() { }
|
||||
//~^ ERROR obsolete syntax: class method
|
||||
}
|
||||
|
||||
struct q : r {
|
||||
//~^ ERROR obsolete syntax: class traits
|
||||
}
|
||||
|
16
src/test/run-pass/issue-4830.rs
Normal file
16
src/test/run-pass/issue-4830.rs
Normal file
@ -0,0 +1,16 @@
|
||||
// Copyright 2012 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.
|
||||
|
||||
pub struct Scheduler {
|
||||
/// The event loop used to drive the scheduler and perform I/O
|
||||
priv event_loop: ~int
|
||||
}
|
||||
|
||||
pub fn main() { }
|
Loading…
Reference in New Issue
Block a user