This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed
compiler/rustc_middle/src/ty Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -2362,6 +2362,20 @@ impl<'tcx> Ty<'tcx> {
23622362 /// to represent the closure kind, because it has not yet been
23632363 /// inferred. Once upvar inference (in `rustc_hir_analysis/src/check/upvar.rs`)
23642364 /// is complete, that type variable will be unified.
2365+ ///
2366+ /// To be noted that you can use [`ClosureArgs::kind()`] or [`CoroutineClosureArgs::kind()`]
2367+ /// to get the same information, which you can get by calling [`GenericArgs::as_closure()`]
2368+ /// or [`GenericArgs::as_coroutine_closure()`], depending on the type of the closure.
2369+ ///
2370+ /// Otherwise, this method can be used as follows:
2371+ ///
2372+ /// ```rust,ignore (snippet of compiler code)
2373+ /// let TyKind::Closure(def_id, [closure_fn_kind_ty, ..]) = closure_ty.kind()
2374+ /// && let Some(closure_kind) = closure_fn_kind_ty.expect_ty().to_opt_closure_kind()
2375+ /// {
2376+ /// // your code
2377+ /// }
2378+ /// ```
23652379 pub fn to_opt_closure_kind ( self ) -> Option < ty:: ClosureKind > {
23662380 match self . kind ( ) {
23672381 Int ( int_ty) => match int_ty {
You can’t perform that action at this time.
0 commit comments