Skip to content

Commit c1a5c11

Browse files
authored
Rollup merge of #99881 - compiler-errors:issue-99876, r=tmiasko
fix ICE when computing codegen_fn_attrs on closure with non-fn parent Other call sites check `has_codegen_attrs` first, so let's do that too. Fixes #99876
2 parents 59320d5 + b67ba9b commit c1a5c11

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

compiler/rustc_typeck/src/collect.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -3165,9 +3165,11 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: DefId) -> CodegenFnAttrs {
31653165
// #73631: closures inherit `#[target_feature]` annotations
31663166
if tcx.features().target_feature_11 && tcx.is_closure(did.to_def_id()) {
31673167
let owner_id = tcx.parent(did.to_def_id());
3168-
codegen_fn_attrs
3169-
.target_features
3170-
.extend(tcx.codegen_fn_attrs(owner_id).target_features.iter().copied())
3168+
if tcx.def_kind(owner_id).has_codegen_attrs() {
3169+
codegen_fn_attrs
3170+
.target_features
3171+
.extend(tcx.codegen_fn_attrs(owner_id).target_features.iter().copied());
3172+
}
31713173
}
31723174

31733175
// If a function uses #[target_feature] it can't be inlined into general
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// check-pass
2+
3+
#![feature(target_feature_11)]
4+
5+
struct S<T>(T)
6+
where
7+
[T; (|| {}, 1).1]: Copy;
8+
9+
fn main() {}

0 commit comments

Comments
 (0)