@@ -35,7 +35,7 @@ use rustc_span::symbol::sym;
3535use rustc_span:: { BytePos , FileName , InnerSpan , Pos , Span } ;
3636use rustc_target:: spec:: { MergeFunctions , SanitizerSet } ;
3737
38- use crate :: errors:: ErrorCreatingRemarkDir ;
38+ use crate :: errors:: { ErrorCreatingRemarkDir , AutodiffWithoutLto } ;
3939use std:: any:: Any ;
4040use std:: borrow:: Cow ;
4141use std:: fs;
@@ -382,9 +382,6 @@ fn generate_lto_work<B: ExtraBackendMethods>(
382382 import_only_modules : Vec < ( SerializedModule < B :: ModuleBuffer > , WorkProduct ) > ,
383383) -> Vec < ( WorkItem < B > , u64 ) > {
384384 let _prof_timer = cgcx. prof . generic_activity ( "codegen_generate_lto_work" ) ;
385- //let error_msg = format!("Found {} Functions, but {} TypeTrees", autodiff.len(), typetrees.len());
386- // Don't assert yet, bc. apparently we add them later.
387- //assert!(autodiff.len() == typetrees.len(), "{}", error_msg);
388385
389386 if !needs_fat_lto. is_empty ( ) {
390387 assert ! ( needs_thin_lto. is_empty( ) ) ;
@@ -397,7 +394,10 @@ fn generate_lto_work<B: ExtraBackendMethods>(
397394 // We are adding a single work item, so the cost doesn't matter.
398395 vec ! [ ( WorkItem :: LTO ( module) , 0 ) ]
399396 } else {
400- assert ! ( autodiff. is_empty( ) ) ;
397+ if !autodiff. is_empty ( ) {
398+ let dcx = cgcx. create_dcx ( ) ;
399+ dcx. emit_fatal ( AutodiffWithoutLto { } ) ;
400+ }
401401 assert ! ( needs_fat_lto. is_empty( ) ) ;
402402 let ( lto_modules, copy_jobs) = B :: run_thin_lto ( cgcx, needs_thin_lto, import_only_modules)
403403 . unwrap_or_else ( |e| e. raise ( ) ) ;
0 commit comments