Using repr(align(n)) in rust 1.17 nightly version

#1

Hi,

As the title says, is there any way to use repr(align(n)) attribute in rust 1.17 version? I have used #![feature(repr_align)] and #![feature(attr_literals)] in combination to enable this experimental feature but to no avail. Moreover, I cannot seem to find any alternatives to achieve exactly the same behavior as align(n). So, what options do I have in hand without updating rust to the latest version?

Thanks.

#2

Well two things:

  1. What is the error message you’re getting?
  2. What toolchain are you using? (rustup show)
    example output:
> rustup show
Default host: x86_64-pc-windows-msvc

installed toolchains
--------------------

stable-x86_64-pc-windows-gnu
stable-x86_64-pc-windows-msvc
stable-x86_64-unknown-linux-gnu
nightly-i686-pc-windows-msvc
nightly-x86_64-pc-windows-msvc (default)
nightly-x86_64-unknown-linux-gnu

installed targets for active toolchain
--------------------------------------

arm-linux-androideabi
i686-linux-android
wasm32-unknown-emscripten
x86_64-pc-windows-gnu
x86_64-pc-windows-msvc
x86_64-unknown-linux-gnu

active toolchain
----------------

nightly-x86_64-pc-windows-msvc (default)
rustc 1.33.0-nightly (c76f3c374 2019-01-18)
  1. While I would strongly recommend you update rust, I don’t know your circumstances. Therefore, could you please explain the circumstances a bit better just in case there isn’t a clear fix?

PS. The most probable reason for this is that

#![feature(MyFeature)]

is only available in nightly, so it may be possible that you’re getting an error because you’re trying to do this in stable (or beta depending on the circumstances)

#3

In older versions of Rust you can use a field with a zero sized type like [u64;0] to change the alignment of a struct.

1 Like
#4

I’m curious what environment/operating system you use that has Rust 1.17?

It’s an old version, and you’re not the first person running into problems with this particular version.

1 Like