mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-13 09:05:00 +00:00
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*)!
This commit is contained in:
parent
38650b69ca
commit
2dea8ec630
@ -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());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user