@@ -1708,7 +1708,9 @@ slice_interners!(
1708
1708
) ;
1709
1709
1710
1710
impl < ' a , ' gcx , ' tcx > TyCtxt < ' a , ' gcx , ' tcx > {
1711
- /// Create an unsafe fn ty based on a safe fn ty.
1711
+ /// Given a `fn` type, returns an equivalent `unsafe fn` type;
1712
+ /// that is, a `fn` type that is equivalent in every way for being
1713
+ /// unsafe.
1712
1714
pub fn safe_to_unsafe_fn_ty ( self , sig : PolyFnSig < ' tcx > ) -> Ty < ' tcx > {
1713
1715
assert_eq ! ( sig. unsafety( ) , hir:: Unsafety :: Normal ) ;
1714
1716
self . mk_fn_ptr ( sig. map_bound ( |sig| ty:: FnSig {
@@ -1717,7 +1719,10 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
1717
1719
} ) )
1718
1720
}
1719
1721
1720
- /// Create an unsafe fn ty based on a safe fn ty.
1722
+ /// Given a closure signature `sig`, returns an equivalent `fn`
1723
+ /// type with the same signature. Detuples and so forth -- so
1724
+ /// e.g. if we have a sig with `Fn<(u32, i32)>` then you would get
1725
+ /// a `fn(u32, i32)`.
1721
1726
pub fn coerce_closure_fn_ty ( self , sig : PolyFnSig < ' tcx > ) -> Ty < ' tcx > {
1722
1727
let converted_sig = sig. map_bound ( |s| {
1723
1728
let params_iter = match s. inputs ( ) [ 0 ] . sty {
@@ -1731,8 +1736,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
1731
1736
s. output ( ) ,
1732
1737
s. variadic ,
1733
1738
hir:: Unsafety :: Normal ,
1734
- abi:: Abi :: Rust
1735
- )
1739
+ abi:: Abi :: Rust ,
1740
+ )
1736
1741
} ) ;
1737
1742
1738
1743
self . mk_fn_ptr ( converted_sig)
0 commit comments