Skip to content

Commit b4b0ef3

Browse files
committed
Addressed feedback
1 parent c131063 commit b4b0ef3

File tree

3 files changed

+10
-11
lines changed

3 files changed

+10
-11
lines changed

compiler/rustc_mir/src/transform/coverage/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use rustc_span::{CharPos, Pos, SourceFile, Span, Symbol};
3434

3535
/// A simple error message wrapper for `coverage::Error`s.
3636
#[derive(Debug)]
37-
pub(self) struct Error {
37+
struct Error {
3838
message: String,
3939
}
4040

compiler/rustc_mir/src/transform/coverage/test_macros/src/lib.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,5 @@ use proc_macro::TokenStream;
22

33
#[proc_macro]
44
pub fn let_bcb(item: TokenStream) -> TokenStream {
5-
format!("let bcb{} = graph::BasicCoverageBlock::from_usize({}); let _ = {};", item, item, item)
6-
.parse()
7-
.unwrap()
5+
format!("let bcb{} = graph::BasicCoverageBlock::from_usize({});", item, item).parse().unwrap()
86
}

compiler/rustc_mir/src/transform/coverage/tests.rs

+8-7
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ use rustc_middle::mir::*;
3535
use rustc_middle::ty::{self, DebruijnIndex, TyS, TypeFlags};
3636
use rustc_span::{self, BytePos, Pos, Span, DUMMY_SP};
3737

38+
// All `TEMP_BLOCK` targets should be replaced before calling `to_body() -> mir::Body`.
39+
const TEMP_BLOCK: BasicBlock = BasicBlock::MAX;
40+
3841
fn dummy_ty() -> &'static TyS<'static> {
3942
thread_local! {
4043
static DUMMY_TYS: &'static TyS<'static> = Box::leak(box TyS::make_for_test(
@@ -123,7 +126,7 @@ impl<'tcx> MockBlocks<'tcx> {
123126
if branch_index > branches.len() {
124127
branches.push((branches.len() as u128, old_otherwise));
125128
while branches.len() < branch_index {
126-
branches.push((branches.len() as u128, START_BLOCK));
129+
branches.push((branches.len() as u128, TEMP_BLOCK));
127130
}
128131
to_block
129132
} else {
@@ -143,7 +146,7 @@ impl<'tcx> MockBlocks<'tcx> {
143146
TerminatorKind::Call {
144147
func: Operand::Copy(self.dummy_place.clone()),
145148
args: vec![],
146-
destination: Some((self.dummy_place.clone(), START_BLOCK)),
149+
destination: Some((self.dummy_place.clone(), TEMP_BLOCK)),
147150
cleanup: None,
148151
from_hir_call: false,
149152
fn_span: DUMMY_SP,
@@ -152,16 +155,14 @@ impl<'tcx> MockBlocks<'tcx> {
152155
}
153156

154157
fn goto(&mut self, some_from_block: Option<BasicBlock>) -> BasicBlock {
155-
self.add_block_from(some_from_block, TerminatorKind::Goto { target: START_BLOCK })
158+
self.add_block_from(some_from_block, TerminatorKind::Goto { target: TEMP_BLOCK })
156159
}
157160

158161
fn switchint(&mut self, some_from_block: Option<BasicBlock>) -> BasicBlock {
159-
let move_ = |place: Place<'tcx>| Operand::Move(place);
160-
let discriminant = Place::from(self.new_temp());
161162
let switchint_kind = TerminatorKind::SwitchInt {
162-
discr: move_(discriminant),
163+
discr: Operand::Move(Place::from(self.new_temp())),
163164
switch_ty: dummy_ty(),
164-
targets: SwitchTargets::static_if(0, START_BLOCK, START_BLOCK),
165+
targets: SwitchTargets::static_if(0, TEMP_BLOCK, TEMP_BLOCK),
165166
};
166167
self.add_block_from(some_from_block, switchint_kind)
167168
}

0 commit comments

Comments
 (0)