@@ -17,11 +17,10 @@ Obsolete syntax that becomes too hard to parse can be
17
17
removed.
18
18
*/
19
19
20
- use ast:: { Expr , ExprLit , lit_nil, Attribute } ;
21
- use ast;
20
+ use ast:: { Expr , ExprLit , lit_nil} ;
22
21
use codemap:: { Span , respan} ;
23
22
use parse:: parser:: Parser ;
24
- use parse:: token:: { keywords , Token } ;
23
+ use parse:: token:: Token ;
25
24
use parse:: token;
26
25
27
26
use std:: str;
@@ -30,32 +29,9 @@ use std::to_bytes;
30
29
/// The specific types of unsupported syntax
31
30
#[ deriving( Eq ) ]
32
31
pub enum ObsoleteSyntax {
33
- ObsoleteLet ,
34
- ObsoleteFieldTerminator ,
35
- ObsoleteWith ,
36
- ObsoleteClassTraits ,
37
- ObsoletePrivSection ,
38
- ObsoleteModeInFnType ,
39
- ObsoleteMoveInit ,
40
- ObsoleteBinaryMove ,
41
32
ObsoleteSwap ,
42
33
ObsoleteUnsafeBlock ,
43
- ObsoleteUnenforcedBound ,
44
- ObsoleteImplSyntax ,
45
- ObsoleteMutOwnedPointer ,
46
- ObsoleteMutVector ,
47
- ObsoleteRecordType ,
48
- ObsoleteRecordPattern ,
49
- ObsoletePostFnTySigil ,
50
34
ObsoleteBareFnType ,
51
- ObsoleteNewtypeEnum ,
52
- ObsoleteMode ,
53
- ObsoleteImplicitSelf ,
54
- ObsoleteLifetimeNotation ,
55
- ObsoletePurity ,
56
- ObsoleteStaticMethod ,
57
- ObsoleteConstItem ,
58
- ObsoleteFixedLengthVectorType ,
59
35
ObsoleteNamedExternModule ,
60
36
ObsoleteMultipleLocalDecl ,
61
37
ObsoleteMutWithMultipleBindings ,
@@ -87,50 +63,12 @@ pub trait ParserObsoleteMethods {
87
63
fn token_is_obsolete_ident ( & self , ident : & str , token : & Token ) -> bool ;
88
64
fn is_obsolete_ident ( & self , ident : & str ) -> bool ;
89
65
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 ;
92
66
}
93
67
94
68
impl ParserObsoleteMethods for Parser {
95
69
/// Reports an obsolete syntax non-fatal error.
96
70
fn obsolete ( & self , sp : Span , kind : ObsoleteSyntax ) {
97
71
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
- ) ,
134
72
ObsoleteSwap => (
135
73
"swap" ,
136
74
"Use std::util::{swap, replace} instead"
@@ -139,79 +77,10 @@ impl ParserObsoleteMethods for Parser {
139
77
"non-standalone unsafe block" ,
140
78
"use an inner `unsafe { ... }` block instead"
141
79
) ,
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
- ) ,
176
80
ObsoleteBareFnType => (
177
81
"bare function type" ,
178
82
"use `&fn` or `extern fn` instead"
179
83
) ,
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
- ) ,
215
84
ObsoleteNamedExternModule => (
216
85
"named external module" ,
217
86
"instead of `extern mod foo { ... }`, write `mod foo { \
@@ -297,37 +166,4 @@ impl ParserObsoleteMethods for Parser {
297
166
false
298
167
}
299
168
}
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
-
333
169
}
0 commit comments