Skip to content

Commit ad9ede4

Browse files
committed
The param_env of an existential type is its function's param_env
1 parent d4ea2c4 commit ad9ede4

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/librustc/ty/mod.rs

+6
Original file line numberDiff line numberDiff line change
@@ -2857,6 +2857,12 @@ fn trait_of_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Option
28572857
fn param_env<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
28582858
def_id: DefId)
28592859
-> ParamEnv<'tcx> {
2860+
2861+
// The param_env of an existential type is its parent's param_env
2862+
if let Some(Def::Existential(_)) = tcx.describe_def(def_id) {
2863+
let parent = tcx.parent_def_id(def_id).expect("impl trait item w/o a parent");
2864+
return param_env(tcx, parent);
2865+
}
28602866
// Compute the bounds on Self and the type parameters.
28612867

28622868
let bounds = tcx.predicates_of(def_id).instantiate_identity(tcx);

0 commit comments

Comments
 (0)