Skip to content

Commit

Permalink
Auto merge of #57835 - pnkfelix:issue-57673-remove-leaky-nested-probe…
Browse files Browse the repository at this point in the history
…, 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
  • Loading branch information
bors committed Jan 22, 2019
2 parents 4c2be9c + 33c2ceb commit 6bba352
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/librustc_typeck/check/method/probe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
Expand Down
7 changes: 7 additions & 0 deletions src/test/ui/typeck/issue-57673-ice-on-deref-of-boxed-trait.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//extern crate has_assoc_type;

//fn ice(x: Box<dyn has_assoc_type::Foo<Assoc=()>>) {
fn ice(x: Box<dyn Iterator<Item=()>>) {
*x //~ ERROR mismatched types [E0308]
}
fn main() {}
14 changes: 14 additions & 0 deletions src/test/ui/typeck/issue-57673-ice-on-deref-of-boxed-trait.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
error[E0308]: mismatched types
--> $DIR/issue-57673-ice-on-deref-of-boxed-trait.rs:5:5
|
LL | fn ice(x: Box<dyn Iterator<Item=()>>) {
| - possibly return type missing here?
LL | *x //~ ERROR mismatched types [E0308]
| ^^ expected (), found trait std::iter::Iterator
|
= note: expected type `()`
found type `(dyn std::iter::Iterator<Item=()> + 'static)`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0308`.

0 comments on commit 6bba352

Please sign in to comment.