Skip to content

Commit eeb9fd4

Browse files
Lambdariszhuyunxing
authored andcommitted
coverage. Improve code style
1 parent 9c357e6 commit eeb9fd4

File tree

2 files changed

+21
-42
lines changed

2 files changed

+21
-42
lines changed

src/tools/compiletest/src/runtest.rs

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -277,19 +277,11 @@ impl<'test> TestCx<'test> {
277277
Ui | MirOpt => false,
278278
mode => panic!("unimplemented for mode {:?}", mode),
279279
};
280-
if test_should_run {
281-
self.run_if_enabled()
282-
} else {
283-
WillExecute::No
284-
}
280+
if test_should_run { self.run_if_enabled() } else { WillExecute::No }
285281
}
286282

287283
fn run_if_enabled(&self) -> WillExecute {
288-
if self.config.run_enabled() {
289-
WillExecute::Yes
290-
} else {
291-
WillExecute::Disabled
292-
}
284+
if self.config.run_enabled() { WillExecute::Yes } else { WillExecute::Disabled }
293285
}
294286

295287
fn should_run_successfully(&self, pm: Option<PassMode>) -> bool {
@@ -2742,11 +2734,7 @@ impl<'test> TestCx<'test> {
27422734
/// The revision, ignored for incremental compilation since it wants all revisions in
27432735
/// the same directory.
27442736
fn safe_revision(&self) -> Option<&str> {
2745-
if self.config.mode == Incremental {
2746-
None
2747-
} else {
2748-
self.revision
2749-
}
2737+
if self.config.mode == Incremental { None } else { self.revision }
27502738
}
27512739

27522740
/// Gets the absolute path to the directory where all output for the given
@@ -2969,11 +2957,7 @@ impl<'test> TestCx<'test> {
29692957

29702958
fn charset() -> &'static str {
29712959
// FreeBSD 10.1 defaults to GDB 6.1.1 which doesn't support "auto" charset
2972-
if cfg!(target_os = "freebsd") {
2973-
"ISO-8859-1"
2974-
} else {
2975-
"UTF-8"
2976-
}
2960+
if cfg!(target_os = "freebsd") { "ISO-8859-1" } else { "UTF-8" }
29772961
}
29782962

29792963
fn run_rustdoc_test(&self) {
@@ -4775,11 +4759,7 @@ impl<'test> TestCx<'test> {
47754759
for output_file in files {
47764760
println!("Actual {} saved to {}", kind, output_file.display());
47774761
}
4778-
if self.config.bless {
4779-
0
4780-
} else {
4781-
1
4782-
}
4762+
if self.config.bless { 0 } else { 1 }
47834763
}
47844764

47854765
fn check_and_prune_duplicate_outputs(

src/tools/coverage-dump/src/covfun.rs

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,6 @@ pub(crate) fn dump_covfun_mappings(
7575
println!(" true = {}", expression_resolver.format_term(r#true));
7676
println!(" false = {}", expression_resolver.format_term(r#false));
7777
}
78-
79-
MappingKind::MCDCDecision { .. } => {}
8078
_ => (),
8179
}
8280
}
@@ -162,29 +160,30 @@ impl<'a> Parser<'a> {
162160
match high {
163161
0 => unreachable!("zero kind should have already been handled as a code mapping"),
164162
2 => Ok(MappingKind::Skip),
165-
4 | 6 => {
163+
4 => {
166164
let r#true = self.read_simple_term()?;
167165
let r#false = self.read_simple_term()?;
168-
if high == 6 {
169-
let condition_id = self.read_uleb128_u32()?;
170-
let true_next_id = self.read_uleb128_u32()?;
171-
let false_next_id = self.read_uleb128_u32()?;
172-
Ok(MappingKind::MCDCBranch {
173-
r#true,
174-
r#false,
175-
condition_id,
176-
true_next_id,
177-
false_next_id,
178-
})
179-
} else {
180-
Ok(MappingKind::Branch { r#true, r#false })
181-
}
166+
Ok(MappingKind::Branch { r#true, r#false })
182167
}
183168
5 => {
184169
let bitmap_idx = self.read_uleb128_u32()?;
185170
let conditions_num = self.read_uleb128_u32()?;
186171
Ok(MappingKind::MCDCDecision { bitmap_idx, conditions_num })
187172
}
173+
6 => {
174+
let r#true = self.read_simple_term()?;
175+
let r#false = self.read_simple_term()?;
176+
let condition_id = self.read_uleb128_u32()?;
177+
let true_next_id = self.read_uleb128_u32()?;
178+
let false_next_id = self.read_uleb128_u32()?;
179+
Ok(MappingKind::MCDCBranch {
180+
r#true,
181+
r#false,
182+
condition_id,
183+
true_next_id,
184+
false_next_id,
185+
})
186+
}
188187

189188
_ => Err(anyhow!("unknown mapping kind: {raw_mapping_kind:#x}")),
190189
}

0 commit comments

Comments
 (0)