1
Fork 0

fix ICE when computing codegen_fn_attrs on closure with non-fn parent

This commit is contained in:
Michael Goulet 2022-07-29 00:40:07 +00:00
parent 9067d5277d
commit b67ba9ba20
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 // #73631: closures inherit `#[target_feature]` annotations
if tcx.features().target_feature_11 && tcx.is_closure(did.to_def_id()) { if tcx.features().target_feature_11 && tcx.is_closure(did.to_def_id()) {
let owner_id = tcx.parent(did.to_def_id()); let owner_id = tcx.parent(did.to_def_id());
codegen_fn_attrs if tcx.def_kind(owner_id).has_codegen_attrs() {
.target_features codegen_fn_attrs
.extend(tcx.codegen_fn_attrs(owner_id).target_features.iter().copied()) .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 // 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() {}