You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While the original implementation (rust-lang/rust#44295) seems to document a size of 0 and an alignment of 1 for extern types, the current state seems to be that they are unsized (rust-lang/rust#49708).
It even goes a little further by not considering them values.
Compiling playground v0.0.1 (/playground)
error[E0423]: expected value, found foreign type `foo`
--> src/main.rs:11:28
|
11 | std::mem::size_of_val(&foo);
| ^^^ not a value
error[E0423]: expected value, found foreign type `foo`
--> src/main.rs:12:29
|
12 | std::mem::align_of_val(&foo);
| ^^^ not a value
error[E0277]: the size for values of type `foo` cannot be known at compilation time
--> src/main.rs:9:25
|
9 | std::mem::size_of::<foo>();
| ^^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `foo`
error[E0277]: the size for values of type `foo` cannot be known at compilation time
--> src/main.rs:10:26
|
10 | std::mem::align_of::<foo>();
| ^^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `foo`
This is hard to emulate, though, as unsized types are not considered FFI-safe.
The text was updated successfully, but these errors were encountered:
error[E0423]: expected value, found foreign type `foo`
--> src/main.rs:11:28
|
11 | std::mem::size_of_val(&foo);
| ^^^ not a value
error[E0423]: expected value, found foreign type `foo`
--> src/main.rs:12:29
|
12 | std::mem::align_of_val(&foo);
| ^^^ not a value
Because you're treating it like struct foo; where the initializer uses the same name. extern type foo; isn't meant to be instantiated in normal safe Rust code.
While the original implementation (rust-lang/rust#44295) seems to document a size of 0 and an alignment of 1 for
extern
types, the current state seems to be that they are unsized (rust-lang/rust#49708).It even goes a little further by not considering them values.
This is hard to emulate, though, as unsized types are not considered FFI-safe.
The text was updated successfully, but these errors were encountered: