@@ -296,24 +296,19 @@ impl<'tcx> ClosureSubsts<'tcx> {
296
296
}
297
297
298
298
/// Returns the closure kind for this closure; may return a type
299
- /// variable during inference.
299
+ /// variable during inference. To get the closure kind during
300
+ /// inference, use `infcx.closure_kind(def_id, substs)`.
300
301
pub fn closure_kind_ty ( self , def_id : DefId , tcx : TyCtxt < ' _ , ' _ , ' _ > ) -> Ty < ' tcx > {
301
302
self . split ( def_id, tcx) . closure_kind_ty
302
303
}
303
304
304
305
/// Returns the type representing the closure signature for this
305
- /// closure; may contain type variables during inference.
306
+ /// closure; may contain type variables during inference. To get
307
+ /// the closure signature during inference, use
308
+ /// `infcx.fn_sig(def_id)`.
306
309
pub fn closure_sig_ty ( self , def_id : DefId , tcx : TyCtxt < ' _ , ' _ , ' _ > ) -> Ty < ' tcx > {
307
310
self . split ( def_id, tcx) . closure_sig_ty
308
311
}
309
-
310
- /// Extracts the signature from the closure.
311
- pub fn closure_sig ( self , def_id : DefId , tcx : TyCtxt < ' _ , ' _ , ' _ > ) -> ty:: PolyFnSig < ' tcx > {
312
- match & self . split ( def_id, tcx) . closure_sig_ty . sty {
313
- ty:: TyFnPtr ( sig) => * sig,
314
- t => bug ! ( "closure_sig_ty is not a fn-ptr: {:?}" , t) ,
315
- }
316
- }
317
312
}
318
313
319
314
impl < ' tcx > ClosureSubsts < ' tcx > {
@@ -323,6 +318,16 @@ impl<'tcx> ClosureSubsts<'tcx> {
323
318
pub fn closure_kind ( self , def_id : DefId , tcx : TyCtxt < ' _ , ' tcx , ' tcx > ) -> ty:: ClosureKind {
324
319
self . split ( def_id, tcx) . closure_kind_ty . to_opt_closure_kind ( ) . unwrap ( )
325
320
}
321
+
322
+ /// Extracts the signature from the closure; only usable outside
323
+ /// of an inference context, because in that context we know that
324
+ /// there are no type variables.
325
+ pub fn closure_sig ( self , def_id : DefId , tcx : TyCtxt < ' _ , ' tcx , ' tcx > ) -> ty:: PolyFnSig < ' tcx > {
326
+ match self . closure_sig_ty ( def_id, tcx) . sty {
327
+ ty:: TyFnPtr ( sig) => sig,
328
+ ref t => bug ! ( "closure_sig_ty is not a fn-ptr: {:?}" , t) ,
329
+ }
330
+ }
326
331
}
327
332
328
333
impl < ' a , ' gcx , ' tcx > ClosureSubsts < ' tcx > {
0 commit comments