@@ -213,15 +213,19 @@ CodeMirror.defineMode("rust", function() {
213
213
if ( content == "||" ) return cont ( poplex , pushlex ( "}" , "block" ) , block ) ;
214
214
}
215
215
if ( content == "mutable" || ( content . match ( / ^ \w + $ / ) && cx . stream . peek ( ) == ":"
216
- && ! cx . stream . match ( "::" , false ) ) ) return pass ( recliteral ) ;
216
+ && ! cx . stream . match ( "::" , false ) ) )
217
+ return pass ( record_of ( expression ) ) ;
217
218
return pass ( block ) ;
218
219
}
219
- function recliteral ( type ) {
220
- if ( content == "mutable" || content == "with" ) { cx . marked = "keyword" ; return cont ( recliteral ) ; }
221
- if ( content . match ( / ^ \w * $ / ) ) { cx . marked = "variable" ; return cont ( recliteral ) ; }
222
- if ( type == ":" ) return cont ( expression , recliteral ) ;
223
- if ( type == "}" ) return cont ( ) ;
224
- return cont ( recliteral ) ;
220
+ function record_of ( comb ) {
221
+ function ro ( type ) {
222
+ if ( content == "mutable" || content == "with" ) { cx . marked = "keyword" ; return cont ( ro ) ; }
223
+ if ( content . match ( / ^ \w * $ / ) ) { cx . marked = "variable" ; return cont ( ro ) ; }
224
+ if ( type == ":" ) return cont ( comb , ro ) ;
225
+ if ( type == "}" ) return cont ( ) ;
226
+ return cont ( ro ) ;
227
+ }
228
+ return ro ;
225
229
}
226
230
function blockvars ( type ) {
227
231
if ( type == "name" ) { cx . marked = "def" ; return cont ( blockvars ) ; }
@@ -230,7 +234,7 @@ CodeMirror.defineMode("rust", function() {
230
234
}
231
235
232
236
function letdef1 ( type ) {
233
- if ( type == ";" ) return cont ( ) ;
237
+ if ( type . match ( / [ \] \) \} ; ] / ) ) return cont ( ) ;
234
238
if ( content == "=" ) return cont ( expression , letdef2 ) ;
235
239
if ( type == "," ) return cont ( letdef1 ) ;
236
240
return pass ( pattern , maybetype , letdef1 ) ;
@@ -295,6 +299,7 @@ CodeMirror.defineMode("rust", function() {
295
299
if ( type == "atom" ) return cont ( rtypemaybeparam ) ;
296
300
if ( type == "op" || type == "obj" ) return cont ( rtype ) ;
297
301
if ( type == "fn" ) return cont ( fntype ) ;
302
+ if ( type == "{" ) return cont ( pushlex ( "{" ) , record_of ( rtype ) , poplex ) ;
298
303
return matchBrackets ( type , rtype ) ;
299
304
}
300
305
function rtypemaybeparam ( type ) {
0 commit comments