Skip to content

Commit c223852

Browse files
committed
Add tcx::lower_impl_trait_in_trait_to_assoc_ty to avoid accessing through sess.opts.unstable_opts
1 parent 7820b62 commit c223852

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

compiler/rustc_metadata/src/rmeta/encoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1104,7 +1104,7 @@ fn should_encode_const(def_kind: DefKind) -> bool {
11041104
// We only encode impl trait in trait when using `lower-impl-trait-in-trait-to-assoc-ty` unstable
11051105
// option.
11061106
fn should_encode_fn_impl_trait_in_trait<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> bool {
1107-
if tcx.sess.opts.unstable_opts.lower_impl_trait_in_trait_to_assoc_ty
1107+
if tcx.lower_impl_trait_in_trait_to_assoc_ty()
11081108
&& let Some(assoc_item) = tcx.opt_associated_item(def_id)
11091109
&& assoc_item.container == ty::AssocItemContainer::TraitContainer
11101110
&& assoc_item.kind == ty::AssocKind::Fn

compiler/rustc_middle/src/ty/context.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2439,6 +2439,10 @@ impl<'tcx> TyCtxt<'tcx> {
24392439
pub fn trait_solver_next(self) -> bool {
24402440
self.sess.opts.unstable_opts.trait_solver == rustc_session::config::TraitSolver::Next
24412441
}
2442+
2443+
pub fn lower_impl_trait_in_trait_to_assoc_ty(self) -> bool {
2444+
self.sess.opts.unstable_opts.lower_impl_trait_in_trait_to_assoc_ty
2445+
}
24422446
}
24432447

24442448
impl<'tcx> TyCtxtAt<'tcx> {

compiler/rustc_ty_utils/src/assoc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ fn associated_item_def_ids(tcx: TyCtxt<'_>, def_id: DefId) -> &[DefId] {
2323
let item = tcx.hir().expect_item(def_id.expect_local());
2424
match item.kind {
2525
hir::ItemKind::Trait(.., ref trait_item_refs) => {
26-
if tcx.sess.opts.unstable_opts.lower_impl_trait_in_trait_to_assoc_ty {
26+
if tcx.lower_impl_trait_in_trait_to_assoc_ty() {
2727
// We collect RPITITs for each trait method's return type and create a
2828
// corresponding associated item using associated_items_for_impl_trait_in_trait
2929
// query.
@@ -54,7 +54,7 @@ fn associated_item_def_ids(tcx: TyCtxt<'_>, def_id: DefId) -> &[DefId] {
5454
}
5555
}
5656
hir::ItemKind::Impl(ref impl_) => {
57-
if tcx.sess.opts.unstable_opts.lower_impl_trait_in_trait_to_assoc_ty {
57+
if tcx.lower_impl_trait_in_trait_to_assoc_ty() {
5858
// We collect RPITITs for each trait method's return type, on the impl side too and
5959
// create a corresponding associated item using
6060
// associated_items_for_impl_trait_in_trait query.

0 commit comments

Comments
 (0)