summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src
diff options
context:
space:
mode:
authorYuki Okushi <jtitor@2k36.org>2022-05-04 17:13:14 +0900
committerGitHub <noreply@github.com>2022-05-04 17:13:14 +0900
commitd0a7a4c6e65017fb50e8734e65cd04282bf1e461 (patch)
tree3f71b889b4050e5255c48e7535556e97621cfc39 /compiler/rustc_trait_selection/src
parentb255bf9eb47778b9c8e26d046ac558701143b921 (diff)
parent574bee35fb2ea0a94e5045bc714ab3884500648e (diff)
downloadrust-d0a7a4c6e65017fb50e8734e65cd04282bf1e461.tar.gz
rust-d0a7a4c6e65017fb50e8734e65cd04282bf1e461.zip
Rollup merge of #96679 - ricked-twice:issue-96223-fix, r=jackh726
Quick fix for #96223.

This PR is a quick fix regarding #96223.

As mentioned in the issue, others modification could be added to not elide types with bound vars from suggestions.

Special thanks to ``@jackh726`` for mentoring and ``@Manishearth`` for minimal test case.

r? ``@jackh726``
Diffstat (limited to 'compiler/rustc_trait_selection/src')
-rw-r--r--compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
index a3d3c7c0cf3..bfb8ce6f105 100644
--- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
+++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
@@ -866,7 +866,13 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
                 return false;
             }
 
-            let orig_ty = old_pred.self_ty().skip_binder();
+            // This is a quick fix to resolve an ICE (#96223).
+            // This change should probably be deeper.
+            // As suggested by @jackh726, `mk_trait_obligation_with_new_self_ty` could take a `Binder<(TraitRef, Ty)>
+            // instead of `Binder<Ty>` leading to some changes to its call places.
+            let Some(orig_ty) = old_pred.self_ty().no_bound_vars() else {
+                return false;
+            };
             let mk_result = |new_ty| {
                 let obligation =
                     self.mk_trait_obligation_with_new_self_ty(param_env, old_pred, new_ty);