diff options
| author | Michael Goulet <michael@errs.io> | 2024-01-25 17:43:35 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2024-02-06 02:22:58 +0000 |
| commit | 37184e86ea58bc90b8cd97f877d52ccce8ea02ab (patch) | |
| tree | ccdae57eb3b8210c03d14b8e6e7a558c429a63bf /compiler | |
| parent | 881b6b5149e882434a8df80a829bcfde0a2e9d37 (diff) | |
| download | rust-37184e86ea58bc90b8cd97f877d52ccce8ea02ab.tar.gz rust-37184e86ea58bc90b8cd97f877d52ccce8ea02ab.zip | |
Add some tests
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_hir_typeck/src/upvar.rs | 5 | ||||
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs | 16 |
2 files changed, 16 insertions, 5 deletions
diff --git a/compiler/rustc_hir_typeck/src/upvar.rs b/compiler/rustc_hir_typeck/src/upvar.rs index d4e072976fa..e8bdf283c4f 100644 --- a/compiler/rustc_hir_typeck/src/upvar.rs +++ b/compiler/rustc_hir_typeck/src/upvar.rs @@ -394,13 +394,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { coroutine_captures_by_ref_ty, ); - let ty::Coroutine(_, args) = *self.typeck_results.borrow().expr_ty(body.value).kind() + let ty::Coroutine(_, coroutine_args) = + *self.typeck_results.borrow().expr_ty(body.value).kind() else { bug!(); }; self.demand_eqtype( span, - args.as_coroutine().kind_ty(), + coroutine_args.as_coroutine().kind_ty(), Ty::from_closure_kind(self.tcx, closure_kind), ); } 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); |
