about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorDylan MacKenzie <ecstaticmorse@gmail.com>2020-05-18 11:18:55 -0700
committerDylan MacKenzie <ecstaticmorse@gmail.com>2020-05-22 13:34:41 -0700
commitf99519bebb2cdd90379bb2b07a0cfdeeb5d2d469 (patch)
treea90f4bc71b6aa39ee1f2faaea51ef9cd5e2aac21 /src
parent7278e29592b96207c755bedcc846b64a93aa9281 (diff)
downloadrust-f99519bebb2cdd90379bb2b07a0cfdeeb5d2d469.tar.gz
rust-f99519bebb2cdd90379bb2b07a0cfdeeb5d2d469.zip
Bail out if `output_ty` has bound variables
Diffstat (limited to 'src')
-rw-r--r--src/librustc_trait_selection/traits/error_reporting/suggestions.rs14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/librustc_trait_selection/traits/error_reporting/suggestions.rs b/src/librustc_trait_selection/traits/error_reporting/suggestions.rs
index 6712ddf0ae5..ead857ee887 100644
--- a/src/librustc_trait_selection/traits/error_reporting/suggestions.rs
+++ b/src/librustc_trait_selection/traits/error_reporting/suggestions.rs
@@ -532,11 +532,15 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
         };
         let msg = format!("use parentheses to call the {}", callable);
 
-        let new_obligation = self.mk_trait_obligation_with_new_self_ty(
-            obligation.param_env,
-            trait_ref,
-            output_ty.skip_binder(),
-        );
+        // `mk_trait_obligation_with_new_self_ty` only works for types with no escaping bound
+        // variables, so bail out if we have any.
+        let output_ty = match output_ty.no_bound_vars() {
+            Some(ty) => ty,
+            None => return,
+        };
+
+        let new_obligation =
+            self.mk_trait_obligation_with_new_self_ty(obligation.param_env, trait_ref, output_ty);
 
         match self.evaluate_obligation(&new_obligation) {
             Ok(