diff --git a/compiler/rustc_session/src/utils.rs b/compiler/rustc_session/src/utils.rs index f76c69af526e9..a84f6bc66a888 100644 --- a/compiler/rustc_session/src/utils.rs +++ b/compiler/rustc_session/src/utils.rs @@ -9,7 +9,11 @@ impl Session { } /// Used by `-Z self-profile`. pub fn time(&self, what: &'static str, f: impl FnOnce() -> R) -> R { - self.prof.verbose_generic_activity(what).run(f) + if self.prof.enabled() { + return self.prof.verbose_generic_activity(what).run(f); + } else { + return f(); + } } }