Skip to content

Commit e44b40c

Browse files
committed
auto merge of #9712 : ben0x539/rust/obsolete-syntax, r=pcwalton
Mostly as per a short discussion on irc. (@cmr) 08:46 < cmr> so I'm thinking Obsolete{Let,With,FieldTerminator,ClassTraits,ModeInFnType,MoveInit,BinaryMove,I mplSyntax,MutOwnedPointer,MutVector,RecordType,RecordPattern,PostFnTySigil,Newty pEnum,Mode,ImplicitSelf,LifetimeNotation,Purity,StaticMethod,ConstItem,FixedLeng thVectorType} 08:46 < cmr> Those are the ones that are older than 0.6 08:46 < cmr> (at least!) This PR removes these specific "obsolete syntax"/"suggestion for change" errors and just lets the parser run into regular parser errors for long-invalid syntax. I also removed `ObsoletePrivSection` which apparently dates further back than cmr or I could recall and `ObsoleteUnenforcedBound` which seemed unused. Also I removed `ObsoleteNewtypeEnum`.
2 parents 3f32898 + fa41150 commit e44b40c

29 files changed

+358
-528
lines changed

src/libsyntax/ast.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -531,9 +531,7 @@ pub enum Expr_ {
531531
ExprWhile(@Expr, Block),
532532
// FIXME #6993: change to Option<Name>
533533
ExprForLoop(@Pat, @Expr, Block, Option<Ident>),
534-
/* Conditionless loop (can be exited with break, cont, or ret)
535-
Same semantics as while(true) { body }, but typestate knows that the
536-
(implicit) condition is always true. */
534+
// Conditionless loop (can be exited with break, cont, or ret)
537535
// FIXME #6993: change to Option<Name>
538536
ExprLoop(Block, Option<Ident>),
539537
ExprMatch(@Expr, ~[Arm]),

src/libsyntax/parse/obsolete.rs

Lines changed: 2 additions & 166 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,10 @@ Obsolete syntax that becomes too hard to parse can be
1717
removed.
1818
*/
1919

20-
use ast::{Expr, ExprLit, lit_nil, Attribute};
21-
use ast;
20+
use ast::{Expr, ExprLit, lit_nil};
2221
use codemap::{Span, respan};
2322
use parse::parser::Parser;
24-
use parse::token::{keywords, Token};
23+
use parse::token::Token;
2524
use parse::token;
2625

2726
use std::str;
@@ -30,32 +29,9 @@ use std::to_bytes;
3029
/// The specific types of unsupported syntax
3130
#[deriving(Eq)]
3231
pub enum ObsoleteSyntax {
33-
ObsoleteLet,
34-
ObsoleteFieldTerminator,
35-
ObsoleteWith,
36-
ObsoleteClassTraits,
37-
ObsoletePrivSection,
38-
ObsoleteModeInFnType,
39-
ObsoleteMoveInit,
40-
ObsoleteBinaryMove,
4132
ObsoleteSwap,
4233
ObsoleteUnsafeBlock,
43-
ObsoleteUnenforcedBound,
44-
ObsoleteImplSyntax,
45-
ObsoleteMutOwnedPointer,
46-
ObsoleteMutVector,
47-
ObsoleteRecordType,
48-
ObsoleteRecordPattern,
49-
ObsoletePostFnTySigil,
5034
ObsoleteBareFnType,
51-
ObsoleteNewtypeEnum,
52-
ObsoleteMode,
53-
ObsoleteImplicitSelf,
54-
ObsoleteLifetimeNotation,
55-
ObsoletePurity,
56-
ObsoleteStaticMethod,
57-
ObsoleteConstItem,
58-
ObsoleteFixedLengthVectorType,
5935
ObsoleteNamedExternModule,
6036
ObsoleteMultipleLocalDecl,
6137
ObsoleteMutWithMultipleBindings,
@@ -87,50 +63,12 @@ pub trait ParserObsoleteMethods {
8763
fn token_is_obsolete_ident(&self, ident: &str, token: &Token) -> bool;
8864
fn is_obsolete_ident(&self, ident: &str) -> bool;
8965
fn eat_obsolete_ident(&self, ident: &str) -> bool;
90-
fn try_parse_obsolete_with(&self) -> bool;
91-
fn try_parse_obsolete_priv_section(&self, attrs: &[Attribute]) -> bool;
9266
}
9367

9468
impl ParserObsoleteMethods for Parser {
9569
/// Reports an obsolete syntax non-fatal error.
9670
fn obsolete(&self, sp: Span, kind: ObsoleteSyntax) {
9771
let (kind_str, desc) = match kind {
98-
ObsoleteLet => (
99-
"`let` in field declaration",
100-
"declare fields as `field: Type`"
101-
),
102-
ObsoleteFieldTerminator => (
103-
"field declaration terminated with semicolon",
104-
"fields are now separated by commas"
105-
),
106-
ObsoleteWith => (
107-
"with",
108-
"record update is done with `..`, e.g. \
109-
`MyStruct { foo: bar, .. baz }`"
110-
),
111-
ObsoleteClassTraits => (
112-
"class traits",
113-
"implemented traits are specified on the impl, as in \
114-
`impl foo : bar {`"
115-
),
116-
ObsoletePrivSection => (
117-
"private section",
118-
"the `priv` keyword is applied to individual items, methods, \
119-
and fields"
120-
),
121-
ObsoleteModeInFnType => (
122-
"mode without identifier in fn type",
123-
"to use a (deprecated) mode in a fn type, you should \
124-
give the argument an explicit name (like `&&v: int`)"
125-
),
126-
ObsoleteMoveInit => (
127-
"initializer-by-move",
128-
"Write `let foo = move bar` instead"
129-
),
130-
ObsoleteBinaryMove => (
131-
"binary move",
132-
"Write `foo = move bar` instead"
133-
),
13472
ObsoleteSwap => (
13573
"swap",
13674
"Use std::util::{swap, replace} instead"
@@ -139,79 +77,10 @@ impl ParserObsoleteMethods for Parser {
13977
"non-standalone unsafe block",
14078
"use an inner `unsafe { ... }` block instead"
14179
),
142-
ObsoleteUnenforcedBound => (
143-
"unenforced type parameter bound",
144-
"use trait bounds on the functions that take the type as \
145-
arguments, not on the types themselves"
146-
),
147-
ObsoleteImplSyntax => (
148-
"colon-separated impl syntax",
149-
"write `impl Trait for Type`"
150-
),
151-
ObsoleteMutOwnedPointer => (
152-
"const or mutable owned pointer",
153-
"mutability inherits through `~` pointers; place the `~` box
154-
in a mutable location, like a mutable local variable or an \
155-
`@mut` box"
156-
),
157-
ObsoleteMutVector => (
158-
"const or mutable vector",
159-
"mutability inherits through `~` pointers; place the vector \
160-
in a mutable location, like a mutable local variable or an \
161-
`@mut` box"
162-
),
163-
ObsoleteRecordType => (
164-
"structural record type",
165-
"use a structure instead"
166-
),
167-
ObsoleteRecordPattern => (
168-
"structural record pattern",
169-
"use a structure instead"
170-
),
171-
ObsoletePostFnTySigil => (
172-
"fn sigil in postfix position",
173-
"Rather than `fn@`, `fn~`, or `fn&`, \
174-
write `@fn`, `~fn`, and `&fn` respectively"
175-
),
17680
ObsoleteBareFnType => (
17781
"bare function type",
17882
"use `&fn` or `extern fn` instead"
17983
),
180-
ObsoleteNewtypeEnum => (
181-
"newtype enum",
182-
"instead of `enum Foo = int`, write `struct Foo(int)`"
183-
),
184-
ObsoleteMode => (
185-
"obsolete argument mode",
186-
"replace `-` or `++` mode with `+`"
187-
),
188-
ObsoleteImplicitSelf => (
189-
"implicit self",
190-
"use an explicit `self` declaration or declare the method as \
191-
static"
192-
),
193-
ObsoleteLifetimeNotation => (
194-
"`/` lifetime notation",
195-
"instead of `&foo/bar`, write `&'foo bar`; instead of \
196-
`bar/&foo`, write `&bar<'foo>"
197-
),
198-
ObsoletePurity => (
199-
"pure function",
200-
"remove `pure`"
201-
),
202-
ObsoleteStaticMethod => (
203-
"`static` notation",
204-
"`static` is superfluous; remove it"
205-
),
206-
ObsoleteConstItem => (
207-
"`const` item",
208-
"`const` items are now `static` items; replace `const` with \
209-
`static`"
210-
),
211-
ObsoleteFixedLengthVectorType => (
212-
"fixed-length vector notation",
213-
"instead of `[T * N]`, write `[T, ..N]`"
214-
),
21584
ObsoleteNamedExternModule => (
21685
"named external module",
21786
"instead of `extern mod foo { ... }`, write `mod foo { \
@@ -297,37 +166,4 @@ impl ParserObsoleteMethods for Parser {
297166
false
298167
}
299168
}
300-
301-
fn try_parse_obsolete_with(&self) -> bool {
302-
if *self.token == token::COMMA
303-
&& self.look_ahead(1,
304-
|t| self.token_is_obsolete_ident("with", t)) {
305-
self.bump();
306-
}
307-
if self.eat_obsolete_ident("with") {
308-
self.obsolete(*self.last_span, ObsoleteWith);
309-
self.parse_expr();
310-
true
311-
} else {
312-
false
313-
}
314-
}
315-
316-
fn try_parse_obsolete_priv_section(&self, attrs: &[Attribute])
317-
-> bool {
318-
if self.is_keyword(keywords::Priv) &&
319-
self.look_ahead(1, |t| *t == token::LBRACE) {
320-
self.obsolete(*self.span, ObsoletePrivSection);
321-
self.eat_keyword(keywords::Priv);
322-
self.bump();
323-
while *self.token != token::RBRACE {
324-
self.parse_single_struct_field(ast::private, attrs.to_owned());
325-
}
326-
self.bump();
327-
true
328-
} else {
329-
false
330-
}
331-
}
332-
333169
}

0 commit comments

Comments
 (0)