From 9f9cd5e2837f57504b92b5acbadb48ff0cb9e29c Mon Sep 17 00:00:00 2001 From: dianqk Date: Sun, 8 Jun 2025 15:30:18 +0800 Subject: mir: Add a `new` method to `statement` Avoid introducing a large number of changes when adding optional initialization fields. --- compiler/rustc_middle/src/mir/statement.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'compiler/rustc_middle') diff --git a/compiler/rustc_middle/src/mir/statement.rs b/compiler/rustc_middle/src/mir/statement.rs index d98b40f0fcf..d16477adb77 100644 --- a/compiler/rustc_middle/src/mir/statement.rs +++ b/compiler/rustc_middle/src/mir/statement.rs @@ -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> { -- cgit 1.4.1-3-g733a5