}
}
+ fn new_thin_place<Bx: BuilderMethods<'a, 'tcx, Value = V>>(
+ bx: &mut Bx,
+ llval: V,
+ layout: TyLayout<'tcx>,
+ align: Align,
+ ) -> PlaceRef<'tcx, V> {
+ assert!(!bx.cx().type_has_metadata(layout.ty));
+ PlaceRef {
+ llval,
+ llextra: None,
+ layout,
+ align
+ }
+ }
+
pub fn alloca<Bx: BuilderMethods<'a, 'tcx, Value = V>>(
bx: &mut Bx,
layout: TyLayout<'tcx>,
}
}
mir::Place::Static(box mir::Static { def_id, ty }) => {
+ // NB: The layout of a static may be unsized as is the case when working
+ // with a static that is an extern_type.
let layout = cx.layout_of(self.monomorphize(&ty));
- PlaceRef::new_sized(bx.get_static(def_id), layout, layout.align.abi)
+ PlaceRef::new_thin_place(bx, bx.get_static(def_id), layout, layout.align.abi)
},
mir::Place::Projection(box mir::Projection {
ref base,
--- /dev/null
+-include ../tools.mk
+
+all: $(call NATIVE_STATICLIB,define-foo)
+ $(RUSTC) -ldefine-foo use-foo.rs
+ $(call RUN,use-foo) || exit 1
--- /dev/null
+#![feature(extern_types)]
+
+extern "C" {
+ type Foo;
+ static FOO: Foo;
+ fn bar(foo: *const Foo) -> u8;
+}
+
+fn main() {
+ unsafe {
+ let foo = &FOO;
+ assert_eq!(bar(foo), 42);
+ }
+}