Skip to content

Commit

Permalink
Rollup merge of #99881 - compiler-errors:issue-99876, r=tmiasko
Browse files Browse the repository at this point in the history
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
  • Loading branch information
JohnTitor authored Jul 29, 2022
2 parents 59320d5 + b67ba9b commit c1a5c11
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
8 changes: 5 additions & 3 deletions compiler/rustc_typeck/src/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions src/test/ui/rfcs/rfc-2396-target_feature-11/issue-99876.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// check-pass

#![feature(target_feature_11)]

struct S<T>(T)
where
[T; (|| {}, 1).1]: Copy;

fn main() {}

0 comments on commit c1a5c11

Please sign in to comment.