@@ -17,11 +17,10 @@ Obsolete syntax that becomes too hard to parse can be
1717removed.
1818*/
1919
20- use ast:: { Expr , ExprLit , lit_nil, Attribute } ;
21- use ast;
20+ use ast:: { Expr , ExprLit , lit_nil} ;
2221use codemap:: { Span , respan} ;
2322use parse:: parser:: Parser ;
24- use parse:: token:: { keywords , Token } ;
23+ use parse:: token:: Token ;
2524use parse:: token;
2625
2726use std:: str;
@@ -30,32 +29,9 @@ use std::to_bytes;
3029/// The specific types of unsupported syntax
3130#[ deriving( Eq ) ]
3231pub 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
9468impl 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