Add tcx::lower_impl_trait_in_trait_to_assoc_ty to avoid accessing through sess.opts.unstable_opts
This commit is contained in:
parent
7820b62d20
commit
c2238527e6
@ -1104,7 +1104,7 @@ fn should_encode_const(def_kind: DefKind) -> bool {
|
|||||||
// We only encode impl trait in trait when using `lower-impl-trait-in-trait-to-assoc-ty` unstable
|
// We only encode impl trait in trait when using `lower-impl-trait-in-trait-to-assoc-ty` unstable
|
||||||
// option.
|
// option.
|
||||||
fn should_encode_fn_impl_trait_in_trait<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> bool {
|
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
|
if tcx.lower_impl_trait_in_trait_to_assoc_ty()
|
||||||
&& let Some(assoc_item) = tcx.opt_associated_item(def_id)
|
&& let Some(assoc_item) = tcx.opt_associated_item(def_id)
|
||||||
&& assoc_item.container == ty::AssocItemContainer::TraitContainer
|
&& assoc_item.container == ty::AssocItemContainer::TraitContainer
|
||||||
&& assoc_item.kind == ty::AssocKind::Fn
|
&& assoc_item.kind == ty::AssocKind::Fn
|
||||||
|
@ -2439,6 +2439,10 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
pub fn trait_solver_next(self) -> bool {
|
pub fn trait_solver_next(self) -> bool {
|
||||||
self.sess.opts.unstable_opts.trait_solver == rustc_session::config::TraitSolver::Next
|
self.sess.opts.unstable_opts.trait_solver == rustc_session::config::TraitSolver::Next
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn lower_impl_trait_in_trait_to_assoc_ty(self) -> bool {
|
||||||
|
self.sess.opts.unstable_opts.lower_impl_trait_in_trait_to_assoc_ty
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> TyCtxtAt<'tcx> {
|
impl<'tcx> TyCtxtAt<'tcx> {
|
||||||
|
@ -23,7 +23,7 @@ fn associated_item_def_ids(tcx: TyCtxt<'_>, def_id: DefId) -> &[DefId] {
|
|||||||
let item = tcx.hir().expect_item(def_id.expect_local());
|
let item = tcx.hir().expect_item(def_id.expect_local());
|
||||||
match item.kind {
|
match item.kind {
|
||||||
hir::ItemKind::Trait(.., ref trait_item_refs) => {
|
hir::ItemKind::Trait(.., ref trait_item_refs) => {
|
||||||
if tcx.sess.opts.unstable_opts.lower_impl_trait_in_trait_to_assoc_ty {
|
if tcx.lower_impl_trait_in_trait_to_assoc_ty() {
|
||||||
// We collect RPITITs for each trait method's return type and create a
|
// We collect RPITITs for each trait method's return type and create a
|
||||||
// corresponding associated item using associated_items_for_impl_trait_in_trait
|
// corresponding associated item using associated_items_for_impl_trait_in_trait
|
||||||
// query.
|
// query.
|
||||||
@ -54,7 +54,7 @@ fn associated_item_def_ids(tcx: TyCtxt<'_>, def_id: DefId) -> &[DefId] {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
hir::ItemKind::Impl(ref impl_) => {
|
hir::ItemKind::Impl(ref impl_) => {
|
||||||
if tcx.sess.opts.unstable_opts.lower_impl_trait_in_trait_to_assoc_ty {
|
if tcx.lower_impl_trait_in_trait_to_assoc_ty() {
|
||||||
// We collect RPITITs for each trait method's return type, on the impl side too and
|
// We collect RPITITs for each trait method's return type, on the impl side too and
|
||||||
// create a corresponding associated item using
|
// create a corresponding associated item using
|
||||||
// associated_items_for_impl_trait_in_trait query.
|
// associated_items_for_impl_trait_in_trait query.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user