diff options
| author | Sa4dUs <dmmarcelo27@gmail.com> | 2025-03-02 23:38:55 +0100 |
|---|---|---|
| committer | Sa4dUs <dmmarcelo27@gmail.com> | 2025-03-02 23:58:07 +0100 |
| commit | 6b29bb6680e0df3bbcd8e9defdf0ad142e80cdf0 (patch) | |
| tree | 33343dc195fb3f714279e45ebfd3264001d88565 /compiler/rustc_codegen_ssa/src | |
| parent | 7c4a55c2ac6497629c273ccd00e185583542f0d2 (diff) | |
| download | rust-6b29bb6680e0df3bbcd8e9defdf0ad142e80cdf0.tar.gz rust-6b29bb6680e0df3bbcd8e9defdf0ad142e80cdf0.zip | |
Prevent ICE in autodiff validation by emitting user-friendly errors
Diffstat (limited to 'compiler/rustc_codegen_ssa/src')
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/codegen_attrs.rs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/compiler/rustc_codegen_ssa/src/codegen_attrs.rs b/compiler/rustc_codegen_ssa/src/codegen_attrs.rs index 673740b4aab..c8f13dc0bae 100644 --- a/compiler/rustc_codegen_ssa/src/codegen_attrs.rs +++ b/compiler/rustc_codegen_ssa/src/codegen_attrs.rs @@ -930,13 +930,19 @@ fn autodiff_attrs(tcx: TyCtxt<'_>, id: DefId) -> Option<AutoDiffAttrs> { } } + // Validate input and return activities + let mut msg = "".to_string(); for &input in &arg_activities { if !valid_input_activity(mode, input) { - span_bug!(attr.span(), "Invalid input activity {} for {} mode", input, mode); + msg = format!("Invalid input activity {} for {} mode", input, mode); } } if !valid_ret_activity(mode, ret_activity) { - span_bug!(attr.span(), "Invalid return activity {} for {} mode", ret_activity, mode); + msg = format!("Invalid return activity {} for {} mode", ret_activity, mode); + } + if msg != "".to_string() { + tcx.dcx().struct_span_err(attr.span(), msg).with_note("invalid activity").emit(); + return Some(AutoDiffAttrs::error()); } Some(AutoDiffAttrs { mode, ret_activity, input_activity: arg_activities }) |
