about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src/traits
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2024-01-25 17:43:35 +0000
committerMichael Goulet <michael@errs.io>2024-02-06 02:22:58 +0000
commit37184e86ea58bc90b8cd97f877d52ccce8ea02ab (patch)
treeccdae57eb3b8210c03d14b8e6e7a558c429a63bf /compiler/rustc_trait_selection/src/traits
parent881b6b5149e882434a8df80a829bcfde0a2e9d37 (diff)
downloadrust-37184e86ea58bc90b8cd97f877d52ccce8ea02ab.tar.gz
rust-37184e86ea58bc90b8cd97f877d52ccce8ea02ab.zip
Add some tests
Diffstat (limited to 'compiler/rustc_trait_selection/src/traits')
-rw-r--r--compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs16
1 files changed, 13 insertions, 3 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs b/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs
index 75aedd5cd22..dda68fd4244 100644
--- a/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs
+++ b/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs
@@ -371,9 +371,19 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
         obligation: &PolyTraitObligation<'tcx>,
         candidates: &mut SelectionCandidateSet<'tcx>,
     ) {
-        if let Some(closure_kind) = obligation.self_ty().skip_binder().to_opt_closure_kind()
-            && let Some(goal_kind) =
-                obligation.predicate.skip_binder().trait_ref.args.type_at(1).to_opt_closure_kind()
+        let self_ty = obligation.self_ty().skip_binder();
+        let target_kind_ty = obligation.predicate.skip_binder().trait_ref.args.type_at(1);
+
+        // `to_opt_closure_kind` is kind of ICEy when it sees non-int types.
+        if !(self_ty.is_integral() || self_ty.is_ty_var()) {
+            return;
+        }
+        if !(target_kind_ty.is_integral() || self_ty.is_ty_var()) {
+            return;
+        }
+
+        if let Some(closure_kind) = self_ty.to_opt_closure_kind()
+            && let Some(goal_kind) = target_kind_ty.to_opt_closure_kind()
         {
             if closure_kind.extends(goal_kind) {
                 candidates.vec.push(AsyncFnKindHelperCandidate);