使用 Rust 对齐功能(issue 33626)
Use of Rust alignment feature (issue 33626)
RFC 1358 suggested an alignment attribute #[repr(align="N")]
and it was accepted. Rust issue 33626 将此功能合并到夜间版本中。
我无法通过 rustc 1.19.0-nightly (777ee2079 2017-05-01)
使用此功能。如果我编译 没有 功能门(#![feature(repr_align)]
):
#[repr(align="16")]
struct Foo {
bar: u32,
}
我收到以下错误说明:
error: the struct `#[repr(align(u16))]` attribute is experimental (see issue #33626)
--> foo.rs:3:1
|
3 | / struct Foo {
4 | | bar: u32,
5 | | }
| |_^
|
= help: add #![feature(repr_align)] to the crate attributes to enable
当我用 功能门编译 时,错误消息显示:
error[E0552]: unrecognized representation hint
--> foo.rs:3:8
|
3 | #[repr(align="16")]
| ^^^^^^^^^^
我也尝试了第一个错误信息提示的版本(尽管它不符合问题),但仍然没有成功。对齐功能的正确使用方法是什么?
与
attribute literals (Playground):
#![feature(repr_align)]
#![feature(attr_literals)]
#[repr(align(16))]
struct Foo {
bar: u32,
}
这在最新的开发版本中是已知的(PR #41673). Searching "repr align" 在 Rust 编译器的代码库中,
所有出现都依赖于属性文字,因此似乎尚未支持记录的形式 repr(align="N")
。
RFC 1358 suggested an alignment attribute #[repr(align="N")]
and it was accepted. Rust issue 33626 将此功能合并到夜间版本中。
我无法通过 rustc 1.19.0-nightly (777ee2079 2017-05-01)
使用此功能。如果我编译 没有 功能门(#![feature(repr_align)]
):
#[repr(align="16")]
struct Foo {
bar: u32,
}
我收到以下错误说明:
error: the struct `#[repr(align(u16))]` attribute is experimental (see issue #33626)
--> foo.rs:3:1
|
3 | / struct Foo {
4 | | bar: u32,
5 | | }
| |_^
|
= help: add #![feature(repr_align)] to the crate attributes to enable
当我用 功能门编译 时,错误消息显示:
error[E0552]: unrecognized representation hint
--> foo.rs:3:8
|
3 | #[repr(align="16")]
| ^^^^^^^^^^
我也尝试了第一个错误信息提示的版本(尽管它不符合问题),但仍然没有成功。对齐功能的正确使用方法是什么?
与 attribute literals (Playground):
#![feature(repr_align)]
#![feature(attr_literals)]
#[repr(align(16))]
struct Foo {
bar: u32,
}
这在最新的开发版本中是已知的(PR #41673). Searching "repr align" 在 Rust 编译器的代码库中,
所有出现都依赖于属性文字,因此似乎尚未支持记录的形式 repr(align="N")
。