@@ -35,7 +35,7 @@ use rustc_span::symbol::sym;
35
35
use rustc_span:: { BytePos , FileName , InnerSpan , Pos , Span } ;
36
36
use rustc_target:: spec:: { MergeFunctions , SanitizerSet } ;
37
37
38
- use crate :: errors:: ErrorCreatingRemarkDir ;
38
+ use crate :: errors:: { ErrorCreatingRemarkDir , AutodiffWithoutLto } ;
39
39
use std:: any:: Any ;
40
40
use std:: borrow:: Cow ;
41
41
use std:: fs;
@@ -382,9 +382,6 @@ fn generate_lto_work<B: ExtraBackendMethods>(
382
382
import_only_modules : Vec < ( SerializedModule < B :: ModuleBuffer > , WorkProduct ) > ,
383
383
) -> Vec < ( WorkItem < B > , u64 ) > {
384
384
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);
388
385
389
386
if !needs_fat_lto. is_empty ( ) {
390
387
assert ! ( needs_thin_lto. is_empty( ) ) ;
@@ -397,7 +394,10 @@ fn generate_lto_work<B: ExtraBackendMethods>(
397
394
// We are adding a single work item, so the cost doesn't matter.
398
395
vec ! [ ( WorkItem :: LTO ( module) , 0 ) ]
399
396
} else {
400
- assert ! ( autodiff. is_empty( ) ) ;
397
+ if !autodiff. is_empty ( ) {
398
+ let dcx = cgcx. create_dcx ( ) ;
399
+ dcx. emit_fatal ( AutodiffWithoutLto { } ) ;
400
+ }
401
401
assert ! ( needs_fat_lto. is_empty( ) ) ;
402
402
let ( lto_modules, copy_jobs) = B :: run_thin_lto ( cgcx, needs_thin_lto, import_only_modules)
403
403
. unwrap_or_else ( |e| e. raise ( ) ) ;
0 commit comments