@@ -210,6 +210,7 @@ where
210
210
let mut roots = FxHashSet :: default ( ) ;
211
211
let mut codegen_units = FxHashMap :: default ( ) ;
212
212
let is_incremental_build = tcx. sess . opts . incremental . is_some ( ) ;
213
+ let is_debug_incremental = is_incremental_build && tcx. sess . opts . optimize == OptLevel :: No ;
213
214
let mut internalization_candidates = FxHashSet :: default ( ) ;
214
215
215
216
// Determine if monomorphizations instantiated in this crate will be made
@@ -227,11 +228,11 @@ where
227
228
InstantiationMode :: LocalCopy => continue ,
228
229
}
229
230
230
- let characteristic_def_id = characteristic_def_id_of_mono_item ( tcx, mono_item) ;
231
+ let characteristic_def_id = characteristic_def_id_of_mono_item ( tcx, mono_item, is_debug_incremental ) ;
231
232
let is_volatile = is_incremental_build && mono_item. is_generic_fn ( ) ;
232
233
233
234
let codegen_unit_name = match ( characteristic_def_id, mono_item. is_local ( ) ) {
234
- ( Some ( def_id) , false ) if is_incremental_build && tcx . sess . opts . optimize == OptLevel :: No => {
235
+ ( Some ( def_id) , false ) if is_debug_incremental => {
235
236
let crate_name = tcx. crate_name ( def_id. krate ) ;
236
237
cgu_name_builder. build_cgu_name ( LOCAL_CRATE , & [ & * crate_name. as_str ( ) , if mono_item. has_closure_generic_argument ( ) { "has_closure" } else { "" } ] , Some ( "cgu" ) )
237
238
} ,
@@ -720,7 +721,12 @@ fn internalize_symbols<'tcx>(
720
721
fn characteristic_def_id_of_mono_item < ' tcx > (
721
722
tcx : TyCtxt < ' tcx > ,
722
723
mono_item : MonoItem < ' tcx > ,
724
+ is_debug_incremental : bool ,
723
725
) -> Option < DefId > {
726
+ if is_debug_incremental {
727
+ return mono_item. def_id ( ) ;
728
+ }
729
+
724
730
match mono_item {
725
731
MonoItem :: Fn ( instance) => {
726
732
let def_id = match instance. def {
0 commit comments