File tree 1 file changed +14
-0
lines changed
compiler/rustc_middle/src/ty
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> {
2362
2362
/// to represent the closure kind, because it has not yet been
2363
2363
/// inferred. Once upvar inference (in `rustc_hir_analysis/src/check/upvar.rs`)
2364
2364
/// 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
+ /// ```
2365
2379
pub fn to_opt_closure_kind ( self ) -> Option < ty:: ClosureKind > {
2366
2380
match self . kind ( ) {
2367
2381
Int ( int_ty) => match int_ty {
You can’t perform that action at this time.
0 commit comments