Skip to content

Commit 6bba352

Browse files
committed
Auto merge of #57835 - pnkfelix:issue-57673-remove-leaky-nested-probe, r=arielb1
typeck: remove leaky nested probe during trait object method resolution addresses #57673 (but not marking with f-x because thats now afflicting beta channel). Fix #57216
2 parents 4c2be9c + 33c2ceb commit 6bba352

File tree

3 files changed

+28
-9
lines changed

3 files changed

+28
-9
lines changed

src/librustc_typeck/check/method/probe.rs

+7-9
Original file line numberDiff line numberDiff line change
@@ -506,15 +506,13 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
506506
match self_ty.value.value.sty {
507507
ty::Dynamic(ref data, ..) => {
508508
if let Some(p) = data.principal() {
509-
self.fcx.probe(|_| {
510-
let InferOk { value: self_ty, obligations: _ } =
511-
self.fcx.probe_instantiate_query_response(
512-
self.span, &self.orig_steps_var_values, self_ty)
513-
.unwrap_or_else(|_| {
514-
span_bug!(self.span, "{:?} was applicable but now isn't?", self_ty)
515-
});
516-
self.assemble_inherent_candidates_from_object(self_ty);
517-
});
509+
let InferOk { value: instantiated_self_ty, obligations: _ } =
510+
self.fcx.probe_instantiate_query_response(
511+
self.span, &self.orig_steps_var_values, self_ty)
512+
.unwrap_or_else(|_| {
513+
span_bug!(self.span, "{:?} was applicable but now isn't?", self_ty)
514+
});
515+
self.assemble_inherent_candidates_from_object(instantiated_self_ty);
518516
self.assemble_inherent_impl_candidates_for_type(p.def_id());
519517
}
520518
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
//extern crate has_assoc_type;
2+
3+
//fn ice(x: Box<dyn has_assoc_type::Foo<Assoc=()>>) {
4+
fn ice(x: Box<dyn Iterator<Item=()>>) {
5+
*x //~ ERROR mismatched types [E0308]
6+
}
7+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/issue-57673-ice-on-deref-of-boxed-trait.rs:5:5
3+
|
4+
LL | fn ice(x: Box<dyn Iterator<Item=()>>) {
5+
| - possibly return type missing here?
6+
LL | *x //~ ERROR mismatched types [E0308]
7+
| ^^ expected (), found trait std::iter::Iterator
8+
|
9+
= note: expected type `()`
10+
found type `(dyn std::iter::Iterator<Item=()> + 'static)`
11+
12+
error: aborting due to previous error
13+
14+
For more information about this error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)