Skip to content

Commit

Permalink
Clean up todos
Browse files Browse the repository at this point in the history
Also add some span_bugs where it is unreachable
  • Loading branch information
JulianKnodt committed Mar 1, 2021
1 parent aff18fa commit 1dda668
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 55 deletions.
15 changes: 4 additions & 11 deletions compiler/rustc_mir/src/borrow_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -629,18 +629,11 @@ impl<'cx, 'tcx> dataflow::ResultsVisitor<'cx, 'tcx> for MirBorrowckCtxt<'cx, 'tc

StatementKind::CopyNonOverlapping(box rustc_middle::mir::CopyNonOverlapping {
..
/*
src,
dst,
count,
*/
}) => {
unreachable!()
/*
self.consume_operand(location, (src, span), flow_state);
self.consume_operand(location, (dst, span), flow_state);
self.consume_operand(location, (count, span), flow_state);
*/
span_bug!(
span,
"Unexpected CopyNonOverlapping, should only appear after lower_intrinsics",
)
}
StatementKind::Nop
| StatementKind::Coverage(..)
Expand Down
39 changes: 5 additions & 34 deletions compiler/rustc_mir/src/borrow_check/type_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1521,40 +1521,11 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
}
}
StatementKind::CopyNonOverlapping(box rustc_middle::mir::CopyNonOverlapping {
ref src,
ref dst,
ref count,
}) => {
let op_src_ty = self.normalize(src.ty(body, self.tcx()), location);
let op_dst_ty = self.normalize(dst.ty(body, self.tcx()), location);
// since CopyNonOverlapping is parametrized by 1 type,
// we only need to check that they are equal and not keep an extra parameter.
if let Err(terr) = self.eq_types(
op_src_ty,
op_dst_ty,
location.to_locations(),
ConstraintCategory::Internal,
) {
span_mirbug!(
self,
stmt,
"bad arg ({:?} != {:?}): {:?}",
op_src_ty,
op_dst_ty,
terr
);
}

let op_cnt_ty = self.normalize(count.ty(body, self.tcx()), location);
if let Err(terr) = self.eq_types(
op_cnt_ty,
tcx.types.usize,
location.to_locations(),
ConstraintCategory::Internal,
) {
span_mirbug!(self, stmt, "bad arg ({:?} != usize): {:?}", op_cnt_ty, terr);
}
}
..
}) => span_bug!(
stmt.source_info.span,
"Unexpected StatementKind::CopyNonOverlapping, should only appear after lowering_intrinsics",
),
StatementKind::FakeRead(..)
| StatementKind::StorageLive(..)
| StatementKind::StorageDead(..)
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_mir/src/dataflow/impls/borrows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,8 @@ impl<'tcx> dataflow::GenKillAnalysis<'tcx> for Borrows<'_, 'tcx> {
| mir::StatementKind::Retag { .. }
| mir::StatementKind::AscribeUserType(..)
| mir::StatementKind::Coverage(..)
| mir::StatementKind::CopyNonOverlapping(..)
| mir::StatementKind::Nop => {}

mir::StatementKind::CopyNonOverlapping(..) => todo!(),
}
}

Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_mir/src/dataflow/impls/storage_liveness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,8 @@ impl<'mir, 'tcx> dataflow::GenKillAnalysis<'tcx> for MaybeRequiresStorage<'mir,
| StatementKind::FakeRead(..)
| StatementKind::Nop
| StatementKind::Retag(..)
| StatementKind::CopyNonOverlapping(..)
| StatementKind::StorageLive(..) => {}

StatementKind::CopyNonOverlapping(..) => todo!(),
}
}

Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_mir/src/dataflow/move_paths/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,8 @@ impl<'b, 'a, 'tcx> Gatherer<'b, 'a, 'tcx> {
StatementKind::Retag { .. }
| StatementKind::AscribeUserType(..)
| StatementKind::Coverage(..)
| StatementKind::CopyNonOverlapping(..)
| StatementKind::Nop => {}

StatementKind::CopyNonOverlapping(..) => todo!(),
}
}

Expand Down
3 changes: 0 additions & 3 deletions compiler/rustc_mir/src/interpret/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,9 +323,6 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
let result = Scalar::from_uint(truncated_bits, layout.size);
self.write_scalar(result, dest)?;
}
sym::copy_nonoverlapping => {
self.copy_nonoverlapping(args[0], args[1], args[2])?;
}
sym::copy => {
let elem_ty = instance.substs.type_at(0);
let elem_layout = self.layout_of(elem_ty)?;
Expand Down
44 changes: 43 additions & 1 deletion compiler/rustc_mir/src/transform/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,49 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
);
}
}
_ => {}
StatementKind::CopyNonOverlapping(box rustc_middle::mir::CopyNonOverlapping {
ref src,
ref dst,
ref count,
}) => {
let src_ty = src.ty(&self.body.local_decls, self.tcx);
let op_src_ty = if let Some(src_deref) = src_ty.builtin_deref(true) {
src_deref.ty
} else {
self.fail(
location,
format!("Expected src to be ptr in copy_nonoverlapping, got: {}", src_ty),
);
return;
};
let dst_ty = dst.ty(&self.body.local_decls, self.tcx);
let op_dst_ty = if let Some(dst_deref) = dst_ty.builtin_deref(true) {
dst_deref.ty
} else {
self.fail(
location,
format!("Expected dst to be ptr in copy_nonoverlapping, got: {}", dst_ty),
);
return;
};
// since CopyNonOverlapping is parametrized by 1 type,
// we only need to check that they are equal and not keep an extra parameter.
if op_src_ty != op_dst_ty {
self.fail(location, format!("bad arg ({:?} != {:?})", op_src_ty, op_dst_ty));
}

let op_cnt_ty = count.ty(&self.body.local_decls, self.tcx);
if op_cnt_ty != self.tcx.types.usize {
self.fail(location, format!("bad arg ({:?} != usize)", op_cnt_ty))
}
}
StatementKind::SetDiscriminant { .. }
| StatementKind::StorageLive(..)
| StatementKind::StorageDead(..)
| StatementKind::LlvmInlineAsm(..)
| StatementKind::Retag(_, _)
| StatementKind::Coverage(_)
| StatementKind::Nop => {}
}

self.super_statement(statement, location);
Expand Down

0 comments on commit 1dda668

Please sign in to comment.