Skip to content

Commit

Permalink
Properly implement should_encode_fn_impl_trait_in_trait using new uns…
Browse files Browse the repository at this point in the history
…table option
  • Loading branch information
spastorino committed Mar 1, 2023
1 parent 811a1ca commit 73e2fe0
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions compiler/rustc_metadata/src/rmeta/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1101,9 +1101,18 @@ fn should_encode_const(def_kind: DefKind) -> bool {
}
}

// Return `false` to avoid encoding impl trait in trait, while we don't use the query.
fn should_encode_fn_impl_trait_in_trait<'tcx>(_tcx: TyCtxt<'tcx>, _def_id: DefId) -> bool {
false
// We only encode impl trait in trait when using `lower-impl-trait-in-trait-to-assoc-ty` unstable
// option.
fn should_encode_fn_impl_trait_in_trait<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> bool {
if tcx.sess.opts.unstable_opts.lower_impl_trait_in_trait_to_assoc_ty
&& let Some(assoc_item) = tcx.opt_associated_item(def_id)
&& assoc_item.container == ty::AssocItemContainer::TraitContainer
&& assoc_item.kind == ty::AssocKind::Fn
{
true
} else {
false
}
}

impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
Expand Down

0 comments on commit 73e2fe0

Please sign in to comment.