Skip to content

Commit f6723a9

Browse files
committed
improve comments on safe_to_unsafe_fn_ty and coerce_closure_fn_ty
1 parent 7a20a3f commit f6723a9

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/librustc/ty/context.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1708,7 +1708,9 @@ slice_interners!(
17081708
);
17091709

17101710
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.
17121714
pub fn safe_to_unsafe_fn_ty(self, sig: PolyFnSig<'tcx>) -> Ty<'tcx> {
17131715
assert_eq!(sig.unsafety(), hir::Unsafety::Normal);
17141716
self.mk_fn_ptr(sig.map_bound(|sig| ty::FnSig {
@@ -1717,7 +1719,10 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
17171719
}))
17181720
}
17191721

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)`.
17211726
pub fn coerce_closure_fn_ty(self, sig: PolyFnSig<'tcx>) -> Ty<'tcx> {
17221727
let converted_sig = sig.map_bound(|s| {
17231728
let params_iter = match s.inputs()[0].sty {
@@ -1731,8 +1736,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
17311736
s.output(),
17321737
s.variadic,
17331738
hir::Unsafety::Normal,
1734-
abi::Abi::Rust
1735-
)
1739+
abi::Abi::Rust,
1740+
)
17361741
});
17371742

17381743
self.mk_fn_ptr(converted_sig)

0 commit comments

Comments
 (0)