Skip to content

Commit 80a7b3d

Browse files
Make SimplifyCfg::new a const fn
1 parent dd4eb5c commit 80a7b3d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

compiler/rustc_mir_transform/src/simplify.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ use std::borrow::Cow;
3838
use std::convert::TryInto;
3939

4040
pub struct SimplifyCfg {
41-
label: String,
41+
label: &'static str,
4242
}
4343

4444
impl SimplifyCfg {
45-
pub fn new(label: &str) -> Self {
46-
SimplifyCfg { label: format!("SimplifyCfg-{}", label) }
45+
pub const fn new(label: &'static str) -> Self {
46+
SimplifyCfg { label }
4747
}
4848
}
4949

@@ -57,7 +57,7 @@ pub fn simplify_cfg(tcx: TyCtxt<'tcx>, body: &mut Body<'_>) {
5757

5858
impl<'tcx> MirPass<'tcx> for SimplifyCfg {
5959
fn name(&self) -> Cow<'_, str> {
60-
Cow::Borrowed(&self.label)
60+
Cow::Owned(format!("SimplifyCfg-{}", self.label))
6161
}
6262

6363
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {

0 commit comments

Comments
 (0)