Closed
Description
This is likely due to #55004. Consider the following code:
#![feature(extern_types)]
extern "C" {
pub type StartFn;
pub static start: StartFn;
}
This code compiles with rustc 1.31.0-nightly (e7f5d4805 2018-10-18)
, but fails with rustc 1.31.0-nightly (78ff609d7 2018-10-19)
. Error message from rustc
:
error[E0277]: the size for values of type `StartFn` cannot be known at compilation time
--> t.rs:5:23
|
5 | pub static start: StartFn;
| ^^^^^^^ doesn't have a size known at compile-time
|
= help: the trait `std::marker::Sized` is not implemented for `StartFn`
= note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
error: aborting due to previous error
For more information about this error, try `rustc --explain E0277`.
I think this code should still be accepted, and I believe #55004 accidentally broke this. One of the purposes of the extern_types
feature is to better interact with C code like this:
struct SomeOpaqueType;
extern struct SomeOpaqueType SomeGlobal;
I think Rust should accept unsized extern statics that use an extern type (possibly wrapped in a transparent newtype).
cc @oli-obk