]> git.lizzy.rs Git - rust.git/commitdiff
The param_env of an existential type is its function's param_env
authorOliver Schneider <github35764891676564198441@oli-obk.de>
Wed, 13 Jun 2018 16:52:01 +0000 (18:52 +0200)
committerOliver Schneider <github35764891676564198441@oli-obk.de>
Wed, 13 Jun 2018 16:52:01 +0000 (18:52 +0200)
src/librustc/ty/mod.rs

index f947ed456862451ed361eac87bc11b993c84c7fd..89b652907bc05f79795d8ef4f58ef53c5869fa2d 100644 (file)
@@ -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);