From ad9ede4d645902b41a1cde2b96cb1fef379ba295 Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Wed, 13 Jun 2018 18:52:01 +0200 Subject: [PATCH] The param_env of an existential type is its function's param_env --- src/librustc/ty/mod.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index f947ed456862..89b652907bc0 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -2857,6 +2857,12 @@ fn trait_of_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Option fn param_env<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> ParamEnv<'tcx> { + + // The param_env of an existential type is its parent's param_env + if let Some(Def::Existential(_)) = tcx.describe_def(def_id) { + let parent = tcx.parent_def_id(def_id).expect("impl trait item w/o a parent"); + return param_env(tcx, parent); + } // Compute the bounds on Self and the type parameters. let bounds = tcx.predicates_of(def_id).instantiate_identity(tcx);