diff options
| author | Dylan MacKenzie <ecstaticmorse@gmail.com> | 2020-04-28 13:04:48 -0700 |
|---|---|---|
| committer | Dylan MacKenzie <ecstaticmorse@gmail.com> | 2020-05-22 13:34:41 -0700 |
| commit | d2bacb18d2bf9eadca86fe7c1483e38ce774750e (patch) | |
| tree | 53b5422832d3ee0495333ace7ae1364341d1e8ed | |
| parent | 4d9e9c6d4ec11dcfa1e89040f894c9400828a9fb (diff) | |
| download | rust-d2bacb18d2bf9eadca86fe7c1483e38ce774750e.tar.gz rust-d2bacb18d2bf9eadca86fe7c1483e38ce774750e.zip | |
Ensure that `new_self_ty` has no escaping bound vars
Otherwise inserting it to the `Binder` used by `trait_ref` would cause problems. This is just to be extra carefult: we aren't going to start recommending that the user start using HKTs anytime soon.
| -rw-r--r-- | src/librustc_trait_selection/traits/error_reporting/mod.rs | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/librustc_trait_selection/traits/error_reporting/mod.rs b/src/librustc_trait_selection/traits/error_reporting/mod.rs index 20de0b786ed..c59abd36021 100644 --- a/src/librustc_trait_selection/traits/error_reporting/mod.rs +++ b/src/librustc_trait_selection/traits/error_reporting/mod.rs @@ -1385,6 +1385,8 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> { trait_ref: &ty::PolyTraitRef<'tcx>, new_self_ty: Ty<'tcx>, ) -> PredicateObligation<'tcx> { + assert!(!new_self_ty.has_escaping_bound_vars()); + let trait_ref = trait_ref.map_bound_ref(|tr| ty::TraitRef { substs: self.tcx.mk_substs_trait(new_self_ty, &tr.substs[1..]), ..*tr |
