mir: Add a new method to statement

Avoid introducing a large number of changes when adding optional initialization fields.
This commit is contained in:
dianqk
2025-06-08 15:30:18 +08:00
parent 5ca574e85b
commit 9f9cd5e283
30 changed files with 295 additions and 330 deletions

View File

@@ -16,12 +16,16 @@ pub struct Statement<'tcx> {
pub kind: StatementKind<'tcx>,
}
impl Statement<'_> {
impl<'tcx> Statement<'tcx> {
/// Changes a statement to a nop. This is both faster than deleting instructions and avoids
/// invalidating statement indices in `Location`s.
pub fn make_nop(&mut self) {
self.kind = StatementKind::Nop
}
pub fn new(source_info: SourceInfo, kind: StatementKind<'tcx>) -> Self {
Statement { source_info, kind }
}
}
impl<'tcx> StatementKind<'tcx> {