Skip to content

Commit 75954a1

Browse files
committed
Implement param_env for RPITITs assoc type
1 parent 3f1900f commit 75954a1

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

compiler/rustc_middle/src/query/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,6 +1324,7 @@ rustc_queries! {
13241324
/// might want to use `reveal_all()` method to change modes.
13251325
query param_env(def_id: DefId) -> ty::ParamEnv<'tcx> {
13261326
desc { |tcx| "computing normalized predicates of `{}`", tcx.def_path_str(def_id) }
1327+
feedable
13271328
}
13281329

13291330
/// Like `param_env`, but returns the `ParamEnv` in `Reveal::All` mode.

compiler/rustc_ty_utils/src/assoc.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,8 @@ fn impl_associated_item_for_impl_trait_in_trait(
342342
fn_has_self_parameter: false,
343343
});
344344

345+
impl_assoc_ty.param_env(tcx.param_env(impl_fn_def_id));
346+
345347
// Copy impl_defaultness of the containing function.
346348
impl_assoc_ty.impl_defaultness(tcx.impl_defaultness(impl_fn_def_id));
347349

compiler/rustc_ty_utils/src/ty.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ use rustc_hir as hir;
33
use rustc_hir::def::DefKind;
44
use rustc_index::bit_set::BitSet;
55
use rustc_middle::ty::{
6-
self, Binder, EarlyBinder, Predicate, PredicateKind, ToPredicate, Ty, TyCtxt,
7-
TypeSuperVisitable, TypeVisitable, TypeVisitor,
6+
self, Binder, EarlyBinder, ImplTraitInTraitData, Predicate, PredicateKind, ToPredicate, Ty,
7+
TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitor,
88
};
99
use rustc_session::config::TraitSolver;
1010
use rustc_span::def_id::{DefId, CRATE_DEF_ID};
@@ -117,6 +117,13 @@ fn adt_sized_constraint(tcx: TyCtxt<'_>, def_id: DefId) -> &[Ty<'_>] {
117117

118118
/// See `ParamEnv` struct definition for details.
119119
fn param_env(tcx: TyCtxt<'_>, def_id: DefId) -> ty::ParamEnv<'_> {
120+
let def_id =
121+
if let Some(ImplTraitInTraitData::Trait { fn_def_id, .. }) = tcx.opt_rpitit_info(def_id) {
122+
fn_def_id
123+
} else {
124+
def_id
125+
};
126+
120127
// Compute the bounds on Self and the type parameters.
121128
let ty::InstantiatedPredicates { mut predicates, .. } =
122129
tcx.predicates_of(def_id).instantiate_identity(tcx);

0 commit comments

Comments
 (0)