Skip to content

Commit dc32847

Browse files
committed
Prepare TestProps::load_from for handler extraction
This step consists of two changes: - Renaming `self` to `props` - Inserting temporary comments to preserve line breaks This will make it easier to verify that the main migration commit preserves all of the lines being migrated.
1 parent 8401398 commit dc32847

File tree

1 file changed

+71
-52
lines changed

1 file changed

+71
-52
lines changed

src/tools/compiletest/src/directives.rs

Lines changed: 71 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -360,21 +360,22 @@ impl TestProps {
360360
}
361361

362362
use directives::*;
363+
let props = &mut *self;
363364

364365
config.push_name_value_directive(
365366
ln,
366367
ERROR_PATTERN,
367-
&mut self.error_patterns,
368+
&mut props.error_patterns,
368369
|r| r,
369370
);
370371
config.push_name_value_directive(
371372
ln,
372373
REGEX_ERROR_PATTERN,
373-
&mut self.regex_error_patterns,
374+
&mut props.regex_error_patterns,
374375
|r| r,
375376
);
376377

377-
config.push_name_value_directive(ln, DOC_FLAGS, &mut self.doc_flags, |r| r);
378+
config.push_name_value_directive(ln, DOC_FLAGS, &mut props.doc_flags, |r| r);
378379

379380
fn split_flags(flags: &str) -> Vec<String> {
380381
// Individual flags can be single-quoted to preserve spaces; see
@@ -383,6 +384,7 @@ impl TestProps {
383384
.split('\'')
384385
.enumerate()
385386
.flat_map(|(i, f)| {
387+
// (preserve line breaks)
386388
if i % 2 == 1 { vec![f] } else { f.split_whitespace().collect() }
387389
})
388390
.map(move |s| s.to_owned())
@@ -400,115 +402,125 @@ impl TestProps {
400402
|| flag.starts_with("-Cincremental=")
401403
{
402404
panic!(
405+
// (preserve line breaks)
403406
"you must use `//@ incremental` to enable incremental compilation"
404407
);
405408
}
406409
}
407-
self.compile_flags.extend(flags);
410+
props.compile_flags.extend(flags);
408411
}
409412

410413
if let Some(range) = parse_edition_range(config, ln) {
411-
self.edition = Some(range.edition_to_test(config.edition));
414+
props.edition = Some(range.edition_to_test(config.edition));
412415
}
413416

414-
config.parse_and_update_revisions(ln, &mut self.revisions);
417+
config.parse_and_update_revisions(ln, &mut props.revisions);
415418

416419
if let Some(flags) = config.parse_name_value_directive(ln, RUN_FLAGS) {
417-
self.run_flags.extend(split_flags(&flags));
420+
props.run_flags.extend(split_flags(&flags));
418421
}
419422

420-
if self.pp_exact.is_none() {
421-
self.pp_exact = config.parse_pp_exact(ln);
423+
if props.pp_exact.is_none() {
424+
props.pp_exact = config.parse_pp_exact(ln);
422425
}
423426

424-
config.set_name_directive(ln, SHOULD_ICE, &mut self.should_ice);
425-
config.set_name_directive(ln, BUILD_AUX_DOCS, &mut self.build_aux_docs);
426-
config.set_name_directive(ln, UNIQUE_DOC_OUT_DIR, &mut self.unique_doc_out_dir);
427+
config.set_name_directive(ln, SHOULD_ICE, &mut props.should_ice);
428+
config.set_name_directive(ln, BUILD_AUX_DOCS, &mut props.build_aux_docs);
429+
config.set_name_directive(
430+
// (preserve line breaks)
431+
ln,
432+
UNIQUE_DOC_OUT_DIR,
433+
&mut props.unique_doc_out_dir,
434+
);
427435

428-
config.set_name_directive(ln, FORCE_HOST, &mut self.force_host);
429-
config.set_name_directive(ln, CHECK_STDOUT, &mut self.check_stdout);
430-
config.set_name_directive(ln, CHECK_RUN_RESULTS, &mut self.check_run_results);
436+
config.set_name_directive(ln, FORCE_HOST, &mut props.force_host);
437+
config.set_name_directive(ln, CHECK_STDOUT, &mut props.check_stdout);
438+
config.set_name_directive(ln, CHECK_RUN_RESULTS, &mut props.check_run_results);
431439
config.set_name_directive(
432440
ln,
433441
DONT_CHECK_COMPILER_STDOUT,
434-
&mut self.dont_check_compiler_stdout,
442+
&mut props.dont_check_compiler_stdout,
435443
);
436444
config.set_name_directive(
437445
ln,
438446
DONT_CHECK_COMPILER_STDERR,
439-
&mut self.dont_check_compiler_stderr,
447+
&mut props.dont_check_compiler_stderr,
440448
);
441-
config.set_name_directive(ln, NO_PREFER_DYNAMIC, &mut self.no_prefer_dynamic);
449+
config.set_name_directive(ln, NO_PREFER_DYNAMIC, &mut props.no_prefer_dynamic);
442450

443451
if let Some(m) = config.parse_name_value_directive(ln, PRETTY_MODE) {
444-
self.pretty_mode = m;
452+
props.pretty_mode = m;
445453
}
446454

447455
config.set_name_directive(
456+
// (preserve line breaks)
448457
ln,
449458
PRETTY_COMPARE_ONLY,
450-
&mut self.pretty_compare_only,
459+
&mut props.pretty_compare_only,
451460
);
452461

453462
// Call a helper method to deal with aux-related directives.
454-
parse_and_update_aux(config, ln, &mut self.aux);
463+
parse_and_update_aux(config, ln, &mut props.aux);
455464

456465
config.push_name_value_directive(
466+
// (preserve line breaks)
457467
ln,
458468
EXEC_ENV,
459-
&mut self.exec_env,
469+
&mut props.exec_env,
460470
Config::parse_env,
461471
);
462472
config.push_name_value_directive(
473+
// (preserve line breaks)
463474
ln,
464475
UNSET_EXEC_ENV,
465-
&mut self.unset_exec_env,
476+
&mut props.unset_exec_env,
466477
|r| r.trim().to_owned(),
467478
);
468479
config.push_name_value_directive(
469480
ln,
470481
RUSTC_ENV,
471-
&mut self.rustc_env,
482+
&mut props.rustc_env,
472483
Config::parse_env,
473484
);
474485
config.push_name_value_directive(
475486
ln,
476487
UNSET_RUSTC_ENV,
477-
&mut self.unset_rustc_env,
488+
&mut props.unset_rustc_env,
478489
|r| r.trim().to_owned(),
479490
);
480491
config.push_name_value_directive(
492+
// (preserve line breaks)
481493
ln,
482494
FORBID_OUTPUT,
483-
&mut self.forbid_output,
495+
&mut props.forbid_output,
484496
|r| r,
485497
);
486498
config.set_name_directive(
487499
ln,
488500
CHECK_TEST_LINE_NUMBERS_MATCH,
489-
&mut self.check_test_line_numbers_match,
501+
&mut props.check_test_line_numbers_match,
490502
);
491503

492-
self.update_pass_mode(ln, config);
493-
self.update_fail_mode(ln, config);
504+
props.update_pass_mode(ln, config);
505+
props.update_fail_mode(ln, config);
494506

495-
config.set_name_directive(ln, IGNORE_PASS, &mut self.ignore_pass);
507+
config.set_name_directive(ln, IGNORE_PASS, &mut props.ignore_pass);
496508

497509
if let Some(NormalizeRule { kind, regex, replacement }) =
498510
config.parse_custom_normalization(ln)
499511
{
500512
let rule_tuple = (regex, replacement);
501513
match kind {
502-
NormalizeKind::Stdout => self.normalize_stdout.push(rule_tuple),
503-
NormalizeKind::Stderr => self.normalize_stderr.push(rule_tuple),
514+
NormalizeKind::Stdout => props.normalize_stdout.push(rule_tuple),
515+
NormalizeKind::Stderr => props.normalize_stderr.push(rule_tuple),
504516
NormalizeKind::Stderr32bit => {
505517
if config.target_cfg().pointer_width == 32 {
506-
self.normalize_stderr.push(rule_tuple);
518+
props.normalize_stderr.push(rule_tuple);
507519
}
508520
}
509521
NormalizeKind::Stderr64bit => {
510522
if config.target_cfg().pointer_width == 64 {
511-
self.normalize_stderr.push(rule_tuple);
523+
props.normalize_stderr.push(rule_tuple);
512524
}
513525
}
514526
}
@@ -518,33 +530,35 @@ impl TestProps {
518530
.parse_name_value_directive(ln, FAILURE_STATUS)
519531
.and_then(|code| code.trim().parse::<i32>().ok())
520532
{
521-
self.failure_status = Some(code);
533+
props.failure_status = Some(code);
522534
}
523535

524536
config.set_name_directive(
525537
ln,
526538
DONT_CHECK_FAILURE_STATUS,
527-
&mut self.dont_check_failure_status,
539+
&mut props.dont_check_failure_status,
528540
);
529541

530-
config.set_name_directive(ln, RUN_RUSTFIX, &mut self.run_rustfix);
542+
config.set_name_directive(ln, RUN_RUSTFIX, &mut props.run_rustfix);
531543
config.set_name_directive(
532544
ln,
533545
RUSTFIX_ONLY_MACHINE_APPLICABLE,
534-
&mut self.rustfix_only_machine_applicable,
546+
&mut props.rustfix_only_machine_applicable,
535547
);
536548
config.set_name_value_directive(
549+
// (preserve line breaks)
537550
ln,
538551
ASSEMBLY_OUTPUT,
539-
&mut self.assembly_output,
552+
&mut props.assembly_output,
540553
|r| r.trim().to_string(),
541554
);
542555
config.set_name_directive(
556+
// (preserve line breaks)
543557
ln,
544558
STDERR_PER_BITWIDTH,
545-
&mut self.stderr_per_bitwidth,
559+
&mut props.stderr_per_bitwidth,
546560
);
547-
config.set_name_directive(ln, INCREMENTAL, &mut self.incremental);
561+
config.set_name_directive(ln, INCREMENTAL, &mut props.incremental);
548562

549563
// Unlike the other `name_value_directive`s this needs to be handled manually,
550564
// because it sets a `bool` flag.
@@ -556,12 +570,13 @@ impl TestProps {
556570
.trim()
557571
.split_once('#')
558572
.filter(|(_, number)| {
573+
// (preserve line breaks)
559574
number.chars().all(|digit| digit.is_numeric())
560575
})
561576
.is_some()
562577
})
563578
{
564-
self.known_bug = true;
579+
props.known_bug = true;
565580
} else {
566581
panic!(
567582
"Invalid known-bug value: {known_bug}\nIt requires comma-separated issue references (`#000` or `chalk#000`) or `known-bug: unknown`."
@@ -574,26 +589,28 @@ impl TestProps {
574589
}
575590

576591
config.set_name_value_directive(
592+
// (preserve line breaks)
577593
ln,
578594
TEST_MIR_PASS,
579-
&mut self.mir_unit_test,
595+
&mut props.mir_unit_test,
580596
|s| s.trim().to_string(),
581597
);
582-
config.set_name_directive(ln, REMAP_SRC_BASE, &mut self.remap_src_base);
598+
config.set_name_directive(ln, REMAP_SRC_BASE, &mut props.remap_src_base);
583599

584600
if let Some(flags) = config.parse_name_value_directive(ln, LLVM_COV_FLAGS) {
585-
self.llvm_cov_flags.extend(split_flags(&flags));
601+
props.llvm_cov_flags.extend(split_flags(&flags));
586602
}
587603

588604
if let Some(flags) = config.parse_name_value_directive(ln, FILECHECK_FLAGS) {
589-
self.filecheck_flags.extend(split_flags(&flags));
605+
props.filecheck_flags.extend(split_flags(&flags));
590606
}
591607

592-
config.set_name_directive(ln, NO_AUTO_CHECK_CFG, &mut self.no_auto_check_cfg);
608+
config.set_name_directive(ln, NO_AUTO_CHECK_CFG, &mut props.no_auto_check_cfg);
593609

594-
self.update_add_minicore(ln, config);
610+
props.update_add_minicore(ln, config);
595611

596612
if let Some(flags) =
613+
// (preserve line breaks)
597614
config.parse_name_value_directive(ln, MINICORE_COMPILE_FLAGS)
598615
{
599616
let flags = split_flags(&flags);
@@ -602,25 +619,27 @@ impl TestProps {
602619
panic!("you must use `//@ edition` to configure the edition");
603620
}
604621
}
605-
self.minicore_compile_flags.extend(flags);
622+
props.minicore_compile_flags.extend(flags);
606623
}
607624

608625
if let Some(err_kind) =
626+
// (preserve line breaks)
609627
config.parse_name_value_directive(ln, DONT_REQUIRE_ANNOTATIONS)
610628
{
611-
self.dont_require_annotations
629+
props
630+
.dont_require_annotations
612631
.insert(ErrorKind::expect_from_user_str(err_kind.trim()));
613632
}
614633

615634
config.set_name_directive(
616635
ln,
617636
DISABLE_GDB_PRETTY_PRINTERS,
618-
&mut self.disable_gdb_pretty_printers,
637+
&mut props.disable_gdb_pretty_printers,
619638
);
620639
config.set_name_directive(
621640
ln,
622641
COMPARE_OUTPUT_BY_LINES,
623-
&mut self.compare_output_by_lines,
642+
&mut props.compare_output_by_lines,
624643
);
625644
},
626645
);

0 commit comments

Comments
 (0)