Skip to content

Commit d7d3920

Browse files
committed
Auto merge of #31710 - eddyb:reify, r=nikomatsakis
Distinguish fn item types to allow reification from nothing to fn pointers. The first commit is a rebase of #26284, except for files that have moved since. This is a [breaking-change], due to: * each FFI function has a distinct type, like all other functions currently do * all generic parameters on functions are recorded in their item types, e.g.: `size_of::<u8>` & `size_of::<i8>`'s types differ despite their identical signature. * function items are zero-sized, which will stop transmutes from working on them The first two cases are handled in most cases with the new coerce-unify logic, which will combine incompatible function item types into function pointers, at the outer-most level of if-else chains, match arms and array literals. The last case is specially handled during type-checking such that transmutes from a function item type to a pointer or integer type will continue to work for another release cycle, but are being linted against. To get rid of warnings and ensure your code will continue to compile, cast to a pointer before transmuting.
2 parents 4efc86e + 8fa4770 commit d7d3920

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

clean/inline.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ pub fn build_external_trait(cx: &DocContext, tcx: &TyCtxt,
164164
fn build_external_function(cx: &DocContext, tcx: &TyCtxt, did: DefId) -> clean::Function {
165165
let t = tcx.lookup_item_type(did);
166166
let (decl, style, abi) = match t.ty.sty {
167-
ty::TyBareFn(_, ref f) => ((did, &f.sig).clean(cx), f.unsafety, f.abi),
167+
ty::TyFnDef(_, _, ref f) => ((did, &f.sig).clean(cx), f.unsafety, f.abi),
168168
_ => panic!("bad function"),
169169
};
170170

clean/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1663,7 +1663,8 @@ impl<'tcx> Clean<Type> for ty::Ty<'tcx> {
16631663
mutability: mt.mutbl.clean(cx),
16641664
type_: box mt.ty.clean(cx),
16651665
},
1666-
ty::TyBareFn(_, ref fty) => BareFunction(box BareFunctionDecl {
1666+
ty::TyFnDef(_, _, ref fty) |
1667+
ty::TyFnPtr(ref fty) => BareFunction(box BareFunctionDecl {
16671668
unsafety: fty.unsafety,
16681669
generics: Generics {
16691670
lifetimes: Vec::new(),

0 commit comments

Comments
 (0)