@@ -44,7 +44,8 @@ fn common_exprs() -> [ast::expr] {
44
44
[ dse ( ast:: expr_break) ,
45
45
dse ( ast:: expr_cont) ,
46
46
dse ( ast:: expr_fail ( option:: none) ) ,
47
- dse ( ast:: expr_fail ( option:: some ( @dse ( ast:: expr_lit ( @dsl ( ast:: lit_str ( "boo" ) ) ) ) ) ) ) ,
47
+ dse ( ast:: expr_fail ( option:: some (
48
+ @dse ( ast:: expr_lit ( @dsl ( ast:: lit_str ( "boo" ) ) ) ) ) ) ) ,
48
49
dse ( ast:: expr_ret ( option:: none) ) ,
49
50
dse ( ast:: expr_lit ( @dsl ( ast:: lit_nil) ) ) ,
50
51
dse ( ast:: expr_lit ( @dsl ( ast:: lit_bool ( false ) ) ) ) ,
@@ -64,9 +65,9 @@ pure fn safe_to_use_expr(e: ast::expr, tm: test_mode) -> bool {
64
65
alt tm {
65
66
tm_converge {
66
67
alt e. node {
67
- // If the fuzzer moves a block-ending-in-semicolon into callee position,
68
- // the pretty-printer can't preserve this even by parenthesizing!!
69
- // See email to marijn.
68
+ // If the fuzzer moves a block-ending-in-semicolon into callee
69
+ // position, the pretty-printer can't preserve this even by
70
+ // parenthesizing!! See email to marijn.
70
71
ast:: expr_if ( _, _, _) { false }
71
72
ast:: expr_if_check ( _, _, _) { false }
72
73
ast:: expr_block ( _) { false }
@@ -166,18 +167,21 @@ fn safe_to_replace_expr(e: ast::expr_, _tm: test_mode) -> bool {
166
167
fn safe_to_replace_ty ( t : ast:: ty_ , _tm : test_mode ) -> bool {
167
168
alt t {
168
169
ast : : ty_infer { false } // always implicit, always top level
169
- ast:: ty_bot { false } // in source, can only appear as the out type of a function
170
+ ast:: ty_bot { false } // in source, can only appear
171
+ // as the out type of a function
170
172
ast:: ty_mac ( _) { false }
171
173
_ { true }
172
174
}
173
175
}
174
176
175
177
// Replace the |i|th expr (in fold order) of |crate| with |newexpr|.
176
- fn replace_expr_in_crate ( crate : ast:: crate , i : uint , newexpr : ast:: expr , tm : test_mode ) ->
178
+ fn replace_expr_in_crate ( crate : ast:: crate , i : uint ,
179
+ newexpr : ast:: expr , tm : test_mode ) ->
177
180
ast:: crate {
178
181
let j: @mut uint = @mut 0 u;
179
182
fn fold_expr_rep ( j_ : @mut uint , i_ : uint , newexpr_ : ast:: expr_ ,
180
- original : ast:: expr_ , fld : fold:: ast_fold , tm_ : test_mode ) ->
183
+ original : ast:: expr_ , fld : fold:: ast_fold ,
184
+ tm_ : test_mode ) ->
181
185
ast:: expr_ {
182
186
* j_ += 1 u;
183
187
if i_ + 1 u == * j_ && safe_to_replace_expr ( original, tm_) {
@@ -187,20 +191,22 @@ fn replace_expr_in_crate(crate: ast::crate, i: uint, newexpr: ast::expr, tm: tes
187
191
}
188
192
}
189
193
let afp =
190
- { fold_expr: fold:: wrap ( bind fold_expr_rep ( j, i, newexpr. node , _, _, tm) )
191
- with * fold:: default_ast_fold ( ) } ;
194
+ { fold_expr: fold:: wrap ( bind fold_expr_rep ( j, i,
195
+ newexpr. node , _, _, tm) )
196
+ with * fold:: default_ast_fold ( ) } ;
192
197
let af = fold:: make_fold ( afp) ;
193
198
let crate2: @ast:: crate = @af. fold_crate ( crate ) ;
194
199
* crate2
195
200
}
196
201
197
202
198
203
// Replace the |i|th ty (in fold order) of |crate| with |newty|.
199
- fn replace_ty_in_crate ( crate : ast:: crate , i : uint , newty : ast:: ty , tm : test_mode ) ->
200
- ast:: crate {
204
+ fn replace_ty_in_crate ( crate : ast:: crate , i : uint , newty : ast:: ty ,
205
+ tm : test_mode ) -> ast:: crate {
201
206
let j: @mut uint = @mut 0 u;
202
207
fn fold_ty_rep ( j_ : @mut uint , i_ : uint , newty_ : ast:: ty_ ,
203
- original : ast:: ty_ , fld : fold:: ast_fold , tm_ : test_mode ) ->
208
+ original : ast:: ty_ , fld : fold:: ast_fold ,
209
+ tm_ : test_mode ) ->
204
210
ast:: ty_ {
205
211
* j_ += 1 u;
206
212
if i_ + 1 u == * j_ && safe_to_replace_ty ( original, tm_) {
@@ -233,8 +239,11 @@ fn check_variants_of_ast(crate: ast::crate, codemap: codemap::codemap,
233
239
let stolen = steal ( crate , cx. mode ) ;
234
240
let extra_exprs = vec:: filter ( common_exprs ( ) ,
235
241
bind safe_to_use_expr ( _, cx. mode ) ) ;
236
- check_variants_T ( crate , codemap, filename, "expr" , extra_exprs + stolen. exprs , pprust:: expr_to_str, replace_expr_in_crate, cx) ;
237
- check_variants_T ( crate , codemap, filename, "ty" , stolen. tys , pprust:: ty_to_str, replace_ty_in_crate, cx) ;
242
+ check_variants_T ( crate , codemap, filename, "expr" ,
243
+ extra_exprs + stolen. exprs , pprust:: expr_to_str,
244
+ replace_expr_in_crate, cx) ;
245
+ check_variants_T ( crate , codemap, filename, "ty" , stolen. tys ,
246
+ pprust:: ty_to_str, replace_ty_in_crate, cx) ;
238
247
}
239
248
240
249
fn check_variants_T < T : copy > (
@@ -247,7 +256,8 @@ fn check_variants_T<T: copy>(
247
256
replacer : fn @( ast:: crate , uint , T , test_mode ) -> ast:: crate ,
248
257
cx : context
249
258
) {
250
- #error ( "%s contains %u %s objects" , filename, vec:: len ( things) , thing_label) ;
259
+ #error ( "%s contains %u %s objects" , filename,
260
+ vec:: len ( things) , thing_label) ;
251
261
252
262
let L = vec:: len ( things) ;
253
263
@@ -257,8 +267,8 @@ fn check_variants_T<T: copy>(
257
267
under ( uint:: min ( L , 30 u) ) { |j|
258
268
log ( error, "With... " + stringifier ( @things[ j] ) ) ;
259
269
let crate2 = @replacer ( crate , i, things[ j] , cx. mode ) ;
260
- // It would be best to test the *crate* for stability, but testing the
261
- // string for stability is easier and ok for now.
270
+ // It would be best to test the *crate* for stability, but
271
+ // testing the string for stability is easier and ok for now.
262
272
let handler = diagnostic:: mk_handler ( none) ;
263
273
let str3 =
264
274
@as_str ( bind pprust:: print_crate (
@@ -273,8 +283,11 @@ fn check_variants_T<T: copy>(
273
283
check_roundtrip_convergence( str3, 1 u) ;
274
284
}
275
285
tm_run {
276
- let file_label = #fmt( "rusttmp/%s_%s_%u_%u" , last_part ( filename) , thing_label, i, j) ;
277
- let safe_to_run = !( content_is_dangerous_to_run ( * str3) || has_raw_pointers ( * crate2) ) ;
286
+ let file_label = #fmt( "rusttmp/%s_%s_%u_%u" ,
287
+ last_part ( filename) ,
288
+ thing_label, i, j) ;
289
+ let safe_to_run = !( content_is_dangerous_to_run ( * str3)
290
+ || has_raw_pointers ( * crate2) ) ;
278
291
check_whole_compiler ( * str3, file_label, safe_to_run) ;
279
292
}
280
293
}
@@ -292,9 +305,11 @@ enum happiness { passed, cleanly_rejected(str), known_bug(str), failed(str), }
292
305
293
306
// We'd find more bugs if we could take an AST here, but
294
307
// - that would find many "false positives" or unimportant bugs
295
- // - that would be tricky, requiring use of tasks or serialization or randomness.
308
+ // - that would be tricky, requiring use of tasks or serialization
309
+ // or randomness.
296
310
// This seems to find plenty of bugs as it is :)
297
- fn check_whole_compiler ( code : str , suggested_filename_prefix : str , allow_running : bool ) {
311
+ fn check_whole_compiler ( code : str , suggested_filename_prefix : str ,
312
+ allow_running : bool ) {
298
313
let filename = suggested_filename_prefix + ".rs" ;
299
314
write_file ( filename, code) ;
300
315
@@ -331,7 +346,9 @@ fn removeDirIfExists(filename: str) {
331
346
}
332
347
333
348
fn check_running ( exe_filename : str ) -> happiness {
334
- let p = run:: program_output ( "/Users/jruderman/scripts/timed_run_rust_program.py" , [ exe_filename] ) ;
349
+ let p = run:: program_output (
350
+ "/Users/jruderman/scripts/timed_run_rust_program.py" ,
351
+ [ exe_filename] ) ;
335
352
let comb = p. out + "\n " + p. err ;
336
353
if str:: len ( comb) > 1 u {
337
354
log ( error, "comb comb comb: " + comb) ;
@@ -352,17 +369,26 @@ fn check_running(exe_filename: str) -> happiness {
352
369
0 { passed }
353
370
100 { cleanly_rejected ( "running: explicit fail" ) }
354
371
101 | 247 { cleanly_rejected ( "running: timed out" ) }
355
- 245 | 246 | 138 | 252 { known_bug ( "https://github.com/mozilla/rust/issues/1466" ) }
356
- 136 | 248 { known_bug ( "SIGFPE - https://github.com/mozilla/rust/issues/944" ) }
357
- rc { failed( "Rust program ran but exited with status " + int:: str ( rc) ) }
372
+ 245 | 246 | 138 | 252 {
373
+ known_bug ( "https://github.com/mozilla/rust/issues/1466" )
374
+ }
375
+ 136 | 248 {
376
+ known_bug (
377
+ "SIGFPE - https://github.com/mozilla/rust/issues/944" )
378
+ }
379
+ rc {
380
+ failed( "Rust program ran but exited with status " +
381
+ int:: str ( rc) )
382
+ }
358
383
}
359
384
}
360
385
}
361
386
362
387
fn check_compiling ( filename : str ) -> happiness {
363
388
let p = run:: program_output (
364
- "/Users/jruderman/code/rust/build/x86_64-apple-darwin/stage1/bin/rustc" ,
365
- [ filename] ) ;
389
+ "/Users/jruderman/code/rust/build/x86_64-apple-darwin/\
390
+ stage1/bin/rustc",
391
+ [ filename] ) ;
366
392
367
393
//#error("Status: %d", p.status);
368
394
if p. status == 0 {
@@ -454,10 +480,11 @@ fn content_might_not_converge(code: str) -> bool {
454
480
let confusing_patterns =
455
481
[ "xfail-test",
456
482
"xfail-pretty",
457
- "self ", // crazy rules enforced by parser rather than typechecker?
483
+ "self ", // crazy rules enforced by parser not typechecker?
458
484
"spawn", // precedence issues?
459
485
"bind", // precedence issues?
460
- " be ", // don't want to replace its child with a non-call: "Non-call expression in tail call"
486
+ " be ", // don't want to replace its child with a non-call:
487
+ // "Non-call expression in tail call"
461
488
"\n \n \n \n \n " // https://github.com/mozilla/rust/issues/850
462
489
] ;
463
490
@@ -467,7 +494,8 @@ fn content_might_not_converge(code: str) -> bool {
467
494
468
495
fn file_might_not_converge( filename: str ) -> bool {
469
496
let confusing_files = [
470
- "expr-alt. rs", // pretty-printing "(a = b) = c" vs "a = b = c" and wrapping
497
+ "expr-alt. rs", // pretty-printing "(a = b) = c"
498
+ // vs "a = b = c" and wrapping
471
499
"block-arg-in -ternary. rs", // wrapping
472
500
"move -3 -unique. rs", // 0 becomes (0), but both seem reasonable. wtf?
473
501
"move -3 . rs" // 0 becomes (0), but both seem reasonable. wtf?
@@ -513,7 +541,8 @@ fn check_convergence(files: [str]) {
513
541
let s = @result:: get( io:: read_whole_file_str( file) ) ;
514
542
if !content_might_not_converge( * s) {
515
543
#error( "pp converge: %s", file) ;
516
- // Change from 7u to 2u once https://github.com/mozilla/rust/issues/850 is fixed
544
+ // Change from 7u to 2u once
545
+ // https://github.com/mozilla/rust/issues/850 is fixed
517
546
check_roundtrip_convergence( s, 7 u) ;
518
547
}
519
548
}
@@ -523,7 +552,8 @@ fn check_convergence(files: [str]) {
523
552
fn check_variants( files: [ str ] , cx: context) {
524
553
for files. each { |file|
525
554
if cx. mode == tm_converge && file_might_not_converge( file) {
526
- #error( "Skipping convergence test based on file_might_not_converge") ;
555
+ #error( "Skipping convergence test based on\
556
+ file_might_not_converge") ;
527
557
cont;
528
558
}
529
559
0 commit comments