@@ -769,32 +769,32 @@ impl<'a> CrateLoader<'a> {
769769 }
770770
771771 fn inject_profiler_runtime ( & mut self , krate : & ast:: Crate ) {
772- if self . sess . instrument_coverage ( )
773- || self . sess . opts . debugging_opts . profile
774- || self . sess . opts . cg . profile_generate . enabled ( )
772+ let profiler_runtime = & self . sess . opts . debugging_opts . profiler_runtime ;
773+
774+ if !( profiler_runtime. is_some ( )
775+ && ( self . sess . instrument_coverage ( )
776+ || self . sess . opts . debugging_opts . profile
777+ || self . sess . opts . cg . profile_generate . enabled ( ) ) )
775778 {
776- if let Some ( name) =
777- self . sess . opts . debugging_opts . profiler_runtime . as_deref ( ) . map ( Symbol :: intern)
778- {
779- info ! ( "loading profiler" ) ;
780-
781- if name == sym:: profiler_builtins
782- && self . sess . contains_name ( & krate. attrs , sym:: no_core)
783- {
784- self . sess . err (
785- "`profiler_builtins` crate (required by compiler options) \
786- is not compatible with crate attribute `#![no_core]`",
787- ) ;
788- }
779+ return ;
780+ }
789781
790- let cnum = self . resolve_crate ( name, DUMMY_SP , CrateDepKind :: Implicit , None ) ;
791- let data = self . cstore . get_crate_data ( cnum) ;
782+ info ! ( "loading profiler" ) ;
792783
793- // Sanity check the loaded crate to ensure it is indeed a profiler runtime
794- if !data. is_profiler_runtime ( ) {
795- self . sess . err ( & format ! ( "the crate `{}` is not a profiler runtime" , name) ) ;
796- }
797- }
784+ let name = Symbol :: intern ( profiler_runtime. as_ref ( ) . unwrap ( ) ) ;
785+ if name == sym:: profiler_builtins && self . sess . contains_name ( & krate. attrs , sym:: no_core) {
786+ self . sess . err (
787+ "`profiler_builtins` crate (required by compiler options) \
788+ is not compatible with crate attribute `#![no_core]`",
789+ ) ;
790+ }
791+
792+ let cnum = self . resolve_crate ( name, DUMMY_SP , CrateDepKind :: Implicit , None ) ;
793+ let data = self . cstore . get_crate_data ( cnum) ;
794+
795+ // Sanity check the loaded crate to ensure it is indeed a profiler runtime
796+ if !data. is_profiler_runtime ( ) {
797+ self . sess . err ( & format ! ( "the crate `{}` is not a profiler runtime" , name) ) ;
798798 }
799799 }
800800
0 commit comments