Skip to content

Commit eb4c576

Browse files
ZuseZ4oli-obk
andauthored
Apply suggestions from code review
Co-authored-by: Oli Scherer <[email protected]>
1 parent 58ba12f commit eb4c576

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

compiler/rustc_codegen_ssa/src/codegen_attrs.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -875,11 +875,10 @@ fn autodiff_attrs(tcx: TyCtxt<'_>, id: DefId) -> AutoDiffAttrs {
875875
// There should only be one, since we generate a new placeholder per ad macro.
876876
// FIXME(ZuseZ4): re-enable this check. Currently we add multiple, which doesn't cause harm but
877877
// looks strange e.g. under cargo-expand.
878-
let attr = match attrs.len() {
879-
0 => return AutoDiffAttrs::error(),
880-
1 => attrs.get(0).unwrap(),
878+
let attr = match &attrs[..] {
879+
[] => return AutoDiffAttrs::error(),
880+
[attr] => attr,
881881
_ => {
882-
attrs.get(0).unwrap()
883882
//FIXME(ZuseZ4): re-enable this check
884883
//span_bug!(attrs[1].span, "cg_ssa: rustc_autodiff should only exist once per source");
885884
}
@@ -908,7 +907,7 @@ fn autodiff_attrs(tcx: TyCtxt<'_>, id: DefId) -> AutoDiffAttrs {
908907
"ForwardFirst" => DiffMode::ForwardFirst,
909908
"ReverseFirst" => DiffMode::ReverseFirst,
910909
_ => {
911-
span_bug!(attr.span, "rustc_autodiff attribute contains invalid mode");
910+
span_bug!(mode.span, "rustc_autodiff attribute contains invalid mode");
912911
}
913912
};
914913

@@ -921,7 +920,7 @@ fn autodiff_attrs(tcx: TyCtxt<'_>, id: DefId) -> AutoDiffAttrs {
921920

922921
// Then parse it into an actual DiffActivity
923922
let Ok(ret_activity) = DiffActivity::from_str(ret_symbol.as_str()) else {
924-
span_bug!(attr.span, "invalid return activity");
923+
span_bug!(ret_symbol.span, "invalid return activity");
925924
};
926925

927926
// Now parse all the intermediate (input) activities
@@ -932,19 +931,19 @@ fn autodiff_attrs(tcx: TyCtxt<'_>, id: DefId) -> AutoDiffAttrs {
932931
Some(x) => x.ident,
933932
None => {
934933
span_bug!(
935-
attr.span,
934+
arg.span(),
936935
"rustc_autodiff attribute must contain the input activity"
937936
);
938937
}
939938
}
940939
} else {
941-
span_bug!(attr.span, "rustc_autodiff attribute must contain the input activity");
940+
span_bug!(arg.span(), "rustc_autodiff attribute must contain the input activity");
942941
};
943942

944943
match DiffActivity::from_str(arg_symbol.as_str()) {
945944
Ok(arg_activity) => arg_activities.push(arg_activity),
946945
Err(_) => {
947-
span_bug!(attr.span, "invalid input activity");
946+
span_bug!(arg_symbol.span, "invalid input activity");
948947
}
949948
}
950949
}

compiler/rustc_monomorphize/src/partitioning.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1146,7 +1146,7 @@ pub(crate) fn adjust_activity_to_abi<'tcx>(
11461146
let mut new_activities = vec![];
11471147
let mut new_positions = vec![];
11481148
for (i, ty) in x.inputs().iter().enumerate() {
1149-
if ty.is_unsafe_ptr() || ty.is_ref() || ty.is_box() {
1149+
if let Some(inner_ty) = ty.builtin_deref(true).unwrap() {
11501150
if ty.is_fn_ptr() {
11511151
unimplemented!("what to do whith fn ptr?");
11521152
}

0 commit comments

Comments
 (0)