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
This commit is contained in:
Yuki Okushi 2022-07-30 07:39:53 +09:00 committed by GitHub
commit c1a5c11c57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 3 deletions

View File

@ -3165,9 +3165,11 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: DefId) -> CodegenFnAttrs {
// #73631: closures inherit `#[target_feature]` annotations
if tcx.features().target_feature_11 && tcx.is_closure(did.to_def_id()) {
let owner_id = tcx.parent(did.to_def_id());
codegen_fn_attrs
.target_features
.extend(tcx.codegen_fn_attrs(owner_id).target_features.iter().copied())
if tcx.def_kind(owner_id).has_codegen_attrs() {
codegen_fn_attrs
.target_features
.extend(tcx.codegen_fn_attrs(owner_id).target_features.iter().copied());
}
}
// If a function uses #[target_feature] it can't be inlined into general

View File

@ -0,0 +1,9 @@
// check-pass
#![feature(target_feature_11)]
struct S<T>(T)
where
[T; (|| {}, 1).1]: Copy;
fn main() {}