diff options
| author | Oliver Schneider <github35764891676564198441@oli-obk.de> | 2018-06-13 18:52:01 +0200 |
|---|---|---|
| committer | Oliver Schneider <github35764891676564198441@oli-obk.de> | 2018-06-13 18:52:01 +0200 |
| commit | ad9ede4d645902b41a1cde2b96cb1fef379ba295 (patch) | |
| tree | 522b1ea7c80bdd09f069bead8cbd4fb9e7cab2cc | |
| parent | d4ea2c43f5ef165b902a0ac709111db2be491c4c (diff) | |
| download | rust-ad9ede4d645902b41a1cde2b96cb1fef379ba295.tar.gz rust-ad9ede4d645902b41a1cde2b96cb1fef379ba295.zip | |
The param_env of an existential type is its function's param_env
| -rw-r--r-- | src/librustc/ty/mod.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index f947ed45686..89b652907bc 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); |
