Skip to content

Commit 3a0d8a7

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 6647be9 commit 3a0d8a7

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
@@ -370,21 +370,22 @@ impl TestProps {
370370
}
371371

372372
use directives::*;
373+
let props = &mut *self;
373374

374375
config.push_name_value_directive(
375376
ln,
376377
ERROR_PATTERN,
377-
&mut self.error_patterns,
378+
&mut props.error_patterns,
378379
|r| r,
379380
);
380381
config.push_name_value_directive(
381382
ln,
382383
REGEX_ERROR_PATTERN,
383-
&mut self.regex_error_patterns,
384+
&mut props.regex_error_patterns,
384385
|r| r,
385386
);
386387

387-
config.push_name_value_directive(ln, DOC_FLAGS, &mut self.doc_flags, |r| r);
388+
config.push_name_value_directive(ln, DOC_FLAGS, &mut props.doc_flags, |r| r);
388389

389390
fn split_flags(flags: &str) -> Vec<String> {
390391
// Individual flags can be single-quoted to preserve spaces; see
@@ -393,6 +394,7 @@ impl TestProps {
393394
.split('\'')
394395
.enumerate()
395396
.flat_map(|(i, f)| {
397+
// (preserve line breaks)
396398
if i % 2 == 1 { vec![f] } else { f.split_whitespace().collect() }
397399
})
398400
.map(move |s| s.to_owned())
@@ -410,115 +412,125 @@ impl TestProps {
410412
|| flag.starts_with("-Cincremental=")
411413
{
412414
panic!(
415+
// (preserve line breaks)
413416
"you must use `//@ incremental` to enable incremental compilation"
414417
);
415418
}
416419
}
417-
self.compile_flags.extend(flags);
420+
props.compile_flags.extend(flags);
418421
}
419422

420423
if let Some(range) = parse_edition_range(config, ln) {
421-
self.edition = Some(range.edition_to_test(config.edition));
424+
props.edition = Some(range.edition_to_test(config.edition));
422425
}
423426

424-
config.parse_and_update_revisions(ln, &mut self.revisions);
427+
config.parse_and_update_revisions(ln, &mut props.revisions);
425428

426429
if let Some(flags) = config.parse_name_value_directive(ln, RUN_FLAGS) {
427-
self.run_flags.extend(split_flags(&flags));
430+
props.run_flags.extend(split_flags(&flags));
428431
}
429432

430-
if self.pp_exact.is_none() {
431-
self.pp_exact = config.parse_pp_exact(ln);
433+
if props.pp_exact.is_none() {
434+
props.pp_exact = config.parse_pp_exact(ln);
432435
}
433436

434-
config.set_name_directive(ln, SHOULD_ICE, &mut self.should_ice);
435-
config.set_name_directive(ln, BUILD_AUX_DOCS, &mut self.build_aux_docs);
436-
config.set_name_directive(ln, UNIQUE_DOC_OUT_DIR, &mut self.unique_doc_out_dir);
437+
config.set_name_directive(ln, SHOULD_ICE, &mut props.should_ice);
438+
config.set_name_directive(ln, BUILD_AUX_DOCS, &mut props.build_aux_docs);
439+
config.set_name_directive(
440+
// (preserve line breaks)
441+
ln,
442+
UNIQUE_DOC_OUT_DIR,
443+
&mut props.unique_doc_out_dir,
444+
);
437445

438-
config.set_name_directive(ln, FORCE_HOST, &mut self.force_host);
439-
config.set_name_directive(ln, CHECK_STDOUT, &mut self.check_stdout);
440-
config.set_name_directive(ln, CHECK_RUN_RESULTS, &mut self.check_run_results);
446+
config.set_name_directive(ln, FORCE_HOST, &mut props.force_host);
447+
config.set_name_directive(ln, CHECK_STDOUT, &mut props.check_stdout);
448+
config.set_name_directive(ln, CHECK_RUN_RESULTS, &mut props.check_run_results);
441449
config.set_name_directive(
442450
ln,
443451
DONT_CHECK_COMPILER_STDOUT,
444-
&mut self.dont_check_compiler_stdout,
452+
&mut props.dont_check_compiler_stdout,
445453
);
446454
config.set_name_directive(
447455
ln,
448456
DONT_CHECK_COMPILER_STDERR,
449-
&mut self.dont_check_compiler_stderr,
457+
&mut props.dont_check_compiler_stderr,
450458
);
451-
config.set_name_directive(ln, NO_PREFER_DYNAMIC, &mut self.no_prefer_dynamic);
459+
config.set_name_directive(ln, NO_PREFER_DYNAMIC, &mut props.no_prefer_dynamic);
452460

453461
if let Some(m) = config.parse_name_value_directive(ln, PRETTY_MODE) {
454-
self.pretty_mode = m;
462+
props.pretty_mode = m;
455463
}
456464

457465
config.set_name_directive(
466+
// (preserve line breaks)
458467
ln,
459468
PRETTY_COMPARE_ONLY,
460-
&mut self.pretty_compare_only,
469+
&mut props.pretty_compare_only,
461470
);
462471

463472
// Call a helper method to deal with aux-related directives.
464-
parse_and_update_aux(config, ln, &mut self.aux);
473+
parse_and_update_aux(config, ln, &mut props.aux);
465474

466475
config.push_name_value_directive(
476+
// (preserve line breaks)
467477
ln,
468478
EXEC_ENV,
469-
&mut self.exec_env,
479+
&mut props.exec_env,
470480
Config::parse_env,
471481
);
472482
config.push_name_value_directive(
483+
// (preserve line breaks)
473484
ln,
474485
UNSET_EXEC_ENV,
475-
&mut self.unset_exec_env,
486+
&mut props.unset_exec_env,
476487
|r| r.trim().to_owned(),
477488
);
478489
config.push_name_value_directive(
479490
ln,
480491
RUSTC_ENV,
481-
&mut self.rustc_env,
492+
&mut props.rustc_env,
482493
Config::parse_env,
483494
);
484495
config.push_name_value_directive(
485496
ln,
486497
UNSET_RUSTC_ENV,
487-
&mut self.unset_rustc_env,
498+
&mut props.unset_rustc_env,
488499
|r| r.trim().to_owned(),
489500
);
490501
config.push_name_value_directive(
502+
// (preserve line breaks)
491503
ln,
492504
FORBID_OUTPUT,
493-
&mut self.forbid_output,
505+
&mut props.forbid_output,
494506
|r| r,
495507
);
496508
config.set_name_directive(
497509
ln,
498510
CHECK_TEST_LINE_NUMBERS_MATCH,
499-
&mut self.check_test_line_numbers_match,
511+
&mut props.check_test_line_numbers_match,
500512
);
501513

502-
self.update_pass_mode(ln, config);
503-
self.update_fail_mode(ln, config);
514+
props.update_pass_mode(ln, config);
515+
props.update_fail_mode(ln, config);
504516

505-
config.set_name_directive(ln, IGNORE_PASS, &mut self.ignore_pass);
517+
config.set_name_directive(ln, IGNORE_PASS, &mut props.ignore_pass);
506518

507519
if let Some(NormalizeRule { kind, regex, replacement }) =
508520
config.parse_custom_normalization(ln)
509521
{
510522
let rule_tuple = (regex, replacement);
511523
match kind {
512-
NormalizeKind::Stdout => self.normalize_stdout.push(rule_tuple),
513-
NormalizeKind::Stderr => self.normalize_stderr.push(rule_tuple),
524+
NormalizeKind::Stdout => props.normalize_stdout.push(rule_tuple),
525+
NormalizeKind::Stderr => props.normalize_stderr.push(rule_tuple),
514526
NormalizeKind::Stderr32bit => {
515527
if config.target_cfg().pointer_width == 32 {
516-
self.normalize_stderr.push(rule_tuple);
528+
props.normalize_stderr.push(rule_tuple);
517529
}
518530
}
519531
NormalizeKind::Stderr64bit => {
520532
if config.target_cfg().pointer_width == 64 {
521-
self.normalize_stderr.push(rule_tuple);
533+
props.normalize_stderr.push(rule_tuple);
522534
}
523535
}
524536
}
@@ -528,33 +540,35 @@ impl TestProps {
528540
.parse_name_value_directive(ln, FAILURE_STATUS)
529541
.and_then(|code| code.trim().parse::<i32>().ok())
530542
{
531-
self.failure_status = Some(code);
543+
props.failure_status = Some(code);
532544
}
533545

534546
config.set_name_directive(
535547
ln,
536548
DONT_CHECK_FAILURE_STATUS,
537-
&mut self.dont_check_failure_status,
549+
&mut props.dont_check_failure_status,
538550
);
539551

540-
config.set_name_directive(ln, RUN_RUSTFIX, &mut self.run_rustfix);
552+
config.set_name_directive(ln, RUN_RUSTFIX, &mut props.run_rustfix);
541553
config.set_name_directive(
542554
ln,
543555
RUSTFIX_ONLY_MACHINE_APPLICABLE,
544-
&mut self.rustfix_only_machine_applicable,
556+
&mut props.rustfix_only_machine_applicable,
545557
);
546558
config.set_name_value_directive(
559+
// (preserve line breaks)
547560
ln,
548561
ASSEMBLY_OUTPUT,
549-
&mut self.assembly_output,
562+
&mut props.assembly_output,
550563
|r| r.trim().to_string(),
551564
);
552565
config.set_name_directive(
566+
// (preserve line breaks)
553567
ln,
554568
STDERR_PER_BITWIDTH,
555-
&mut self.stderr_per_bitwidth,
569+
&mut props.stderr_per_bitwidth,
556570
);
557-
config.set_name_directive(ln, INCREMENTAL, &mut self.incremental);
571+
config.set_name_directive(ln, INCREMENTAL, &mut props.incremental);
558572

559573
// Unlike the other `name_value_directive`s this needs to be handled manually,
560574
// because it sets a `bool` flag.
@@ -566,12 +580,13 @@ impl TestProps {
566580
.trim()
567581
.split_once('#')
568582
.filter(|(_, number)| {
583+
// (preserve line breaks)
569584
number.chars().all(|digit| digit.is_numeric())
570585
})
571586
.is_some()
572587
})
573588
{
574-
self.known_bug = true;
589+
props.known_bug = true;
575590
} else {
576591
panic!(
577592
"Invalid known-bug value: {known_bug}\nIt requires comma-separated issue references (`#000` or `chalk#000`) or `known-bug: unknown`."
@@ -584,26 +599,28 @@ impl TestProps {
584599
}
585600

586601
config.set_name_value_directive(
602+
// (preserve line breaks)
587603
ln,
588604
TEST_MIR_PASS,
589-
&mut self.mir_unit_test,
605+
&mut props.mir_unit_test,
590606
|s| s.trim().to_string(),
591607
);
592-
config.set_name_directive(ln, REMAP_SRC_BASE, &mut self.remap_src_base);
608+
config.set_name_directive(ln, REMAP_SRC_BASE, &mut props.remap_src_base);
593609

594610
if let Some(flags) = config.parse_name_value_directive(ln, LLVM_COV_FLAGS) {
595-
self.llvm_cov_flags.extend(split_flags(&flags));
611+
props.llvm_cov_flags.extend(split_flags(&flags));
596612
}
597613

598614
if let Some(flags) = config.parse_name_value_directive(ln, FILECHECK_FLAGS) {
599-
self.filecheck_flags.extend(split_flags(&flags));
615+
props.filecheck_flags.extend(split_flags(&flags));
600616
}
601617

602-
config.set_name_directive(ln, NO_AUTO_CHECK_CFG, &mut self.no_auto_check_cfg);
618+
config.set_name_directive(ln, NO_AUTO_CHECK_CFG, &mut props.no_auto_check_cfg);
603619

604-
self.update_add_minicore(ln, config);
620+
props.update_add_minicore(ln, config);
605621

606622
if let Some(flags) =
623+
// (preserve line breaks)
607624
config.parse_name_value_directive(ln, MINICORE_COMPILE_FLAGS)
608625
{
609626
let flags = split_flags(&flags);
@@ -612,25 +629,27 @@ impl TestProps {
612629
panic!("you must use `//@ edition` to configure the edition");
613630
}
614631
}
615-
self.minicore_compile_flags.extend(flags);
632+
props.minicore_compile_flags.extend(flags);
616633
}
617634

618635
if let Some(err_kind) =
636+
// (preserve line breaks)
619637
config.parse_name_value_directive(ln, DONT_REQUIRE_ANNOTATIONS)
620638
{
621-
self.dont_require_annotations
639+
props
640+
.dont_require_annotations
622641
.insert(ErrorKind::expect_from_user_str(err_kind.trim()));
623642
}
624643

625644
config.set_name_directive(
626645
ln,
627646
DISABLE_GDB_PRETTY_PRINTERS,
628-
&mut self.disable_gdb_pretty_printers,
647+
&mut props.disable_gdb_pretty_printers,
629648
);
630649
config.set_name_directive(
631650
ln,
632651
COMPARE_OUTPUT_BY_LINES,
633-
&mut self.compare_output_by_lines,
652+
&mut props.compare_output_by_lines,
634653
);
635654
},
636655
);

0 commit comments

Comments
 (0)