diff options
| author | Felix S. Klock II <pnkfelix@pnkfx.org> | 2019-01-22 13:51:30 +0100 |
|---|---|---|
| committer | Felix S. Klock II <pnkfelix@pnkfx.org> | 2019-01-22 14:45:13 +0100 |
| commit | 2dea8ec630eebabee46bc51b3ea14fe5e88834c1 (patch) | |
| tree | 9d6ff0b427b1f35f34e3b5877b702a061f347cd9 | |
| parent | 38650b69cafbff61d71a275ced1e9866a08a36c0 (diff) | |
| download | rust-2dea8ec630eebabee46bc51b3ea14fe5e88834c1.tar.gz rust-2dea8ec630eebabee46bc51b3ea14fe5e88834c1.zip | |
Do not initiate nested probe within `assemble_probe`.
In particular, the table entries (associated with type-variables created during the probe) must persist as long as the candidates assembled during the probe. If you make a nested probe without creating a nested `ProbeContext`, the table entries are popped at the end of the nested probe, while the type-variables would leak out via the assembled candidates attached to `self` (the outer `ProbeContext`). This causes an ICE (*if you are lucky*)!
| -rw-r--r-- | src/librustc_typeck/check/method/probe.rs | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/src/librustc_typeck/check/method/probe.rs b/src/librustc_typeck/check/method/probe.rs index 9a828ce0177..b849be52a92 100644 --- a/src/librustc_typeck/check/method/probe.rs +++ b/src/librustc_typeck/check/method/probe.rs @@ -506,15 +506,13 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> { match self_ty.value.value.sty { ty::Dynamic(ref data, ..) => { if let Some(p) = data.principal() { - self.fcx.probe(|_| { - let InferOk { value: self_ty, obligations: _ } = - self.fcx.probe_instantiate_query_response( - self.span, &self.orig_steps_var_values, self_ty) - .unwrap_or_else(|_| { - span_bug!(self.span, "{:?} was applicable but now isn't?", self_ty) - }); - self.assemble_inherent_candidates_from_object(self_ty); - }); + let InferOk { value: instantiated_self_ty, obligations: _ } = + self.fcx.probe_instantiate_query_response( + self.span, &self.orig_steps_var_values, self_ty) + .unwrap_or_else(|_| { + span_bug!(self.span, "{:?} was applicable but now isn't?", self_ty) + }); + self.assemble_inherent_candidates_from_object(instantiated_self_ty); self.assemble_inherent_impl_candidates_for_type(p.def_id()); } } |
