Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stabilize #![feature(repr_align_enum)] in Rust 1.37.0 #61229

Merged
merged 2 commits into from
Jun 10, 2019

Conversation

Centril
Copy link
Contributor

@Centril Centril commented May 27, 2019

On an enum item, you may now write:

#[repr(align(X))]
enum Foo {
    // ...
}

This has equivalent effects to first defining:

#[repr(align(X))]
struct AlignX<T>(T);

and then using AlignX<Foo> in Foo's stead.

r? @nagisa

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 27, 2019
@Centril Centril added T-lang Relevant to the language team, which will review and decide on the PR/issue. relnotes Marks issues that should be documented in the release notes of the next release. labels May 27, 2019
@Centril Centril added this to the 1.37 milestone May 27, 2019
@Centril
Copy link
Contributor Author

Centril commented May 27, 2019

Stabilization proposal

I propose that we stabilize #![feature(repr_align_enum)].

@rfcbot merge

Tracking issue: #57996
Version target: 1.37 (2019-07-04 => beta, 2019-08-15 => stable).

What is stabilized

On an enum item, you may now write:

#[repr(align(X))]
enum Foo {
    // ...
}

This has equivalent effects to first defining:

#[repr(align(X))]
struct AlignX<T>(T);

and then using AlignX<Foo> in Foo's stead.

The documentation on #[repr(align(X))] may be found in the reference.

What is not stabilized

There's not much to say here. #[repr(align(X))] is already allowed on struct and union items. As this extends align(X) to enum items, the story for align(X) with respect to sorts of type definitions should be complete.

Divergences from RFC

There was no RFC. Rather, we decided in a language team meeting to accept this experimentally since we felt that it was a minor consistent extension of an already existing concept.

Tests

The tests can be primarily seen in the PR itself. Here are some of them:

Motivation

As aforementioned, the effects of this proposal with respect to dynamic semantics can be achieved through a generic wrapper struct AlignX<T>. However, it is not particularly convenient to achieve the desired effect through AlignX<T> particularly when the enum in question is part of a public API. This disconnects said enum from the alignment and infects pattern matching, construction, and denoting the type-with-alignment. By permitting #[repr(align(X))] on enum items, both ease of writing and reading can be improved.

History

@rfcbot
Copy link

rfcbot commented May 27, 2019

Team member @Centril has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

@rfcbot rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. labels May 27, 2019
@Centril
Copy link
Contributor Author

Centril commented May 27, 2019

N.B. Aaron is on leave so I've checked his box.

@Centril
Copy link
Contributor Author

Centril commented May 30, 2019

@rfcbot review

@rfcbot rfcbot added the final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. label May 30, 2019
@rfcbot
Copy link

rfcbot commented May 30, 2019

🔔 This is now entering its final comment period, as per the review above. 🔔

@rfcbot rfcbot removed the proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. label May 30, 2019
@nagisa
Copy link
Member

nagisa commented Jun 1, 2019

r=me on the implementation.

@rfcbot rfcbot added finished-final-comment-period The final comment period is finished for this PR / Issue. and removed final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. labels Jun 9, 2019
@rfcbot
Copy link

rfcbot commented Jun 9, 2019

The final comment period, with a disposition to merge, as per the review above, is now complete.

As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed.

The RFC will be merged soon.

@Centril
Copy link
Contributor Author

Centril commented Jun 9, 2019

@bors r=nagisa rollup

@bors
Copy link
Contributor

bors commented Jun 9, 2019

📌 Commit c25e3d2 has been approved by nagisa

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 9, 2019
@bors
Copy link
Contributor

bors commented Jun 9, 2019

⌛ Testing commit c25e3d2 with merge 0fd591e98800aa8a6b9a4afcea8d0747959c26fb...

@bors
Copy link
Contributor

bors commented Jun 9, 2019

💔 Test failed - checks-travis

@rust-highfive
Copy link
Collaborator

The job dist-i686-apple of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
wry
xmoto
zxing-cpp
==> Downloading https://homebrew.bintray.com/bottles/xz-5.2.4.high_sierra.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/e7/e7be50f4ee00e35887f3957263334eb3baba59e8c061919060f9259351be6880?__gda__=exp=1560122410~hmac=ff3b1fd66b475b6357fb85564f91f7d0e95a25d42fb11c788a3b5fcc5039ac25&response-content-disposition=attachment%3Bfilename%3D%22xz-5.2.4.high_sierra.bottle.tar.gz%22&response-content-type=application%2Fgzip&requestInfo=U2FsdGVkX1-ppjJMwH4RuT0t2QPM7jLUyxDjIHi9ORa_cKJcchX2SkhU6ocu6CXQFBgA41Ayr6X7gryyOLHixWdWbRHI2xHU63l6-PlEYCoix26ap16DqYzRrUVu2e_A6ksWJQUCoxcbWBShi-aBTQ&response-X-Checksum-Sha1=32dc0b28e61f32b40c20e2993418aa8cb6e746d5&response-X-Checksum-Sha2=e7be50f4ee00e35887f3957263334eb3baba59e8c061919060f9259351be6880
🍺  /usr/local/Cellar/xz/5.2.4: 92 files, 1MB
==> `brew cleanup` has not been run in 30 days, running now...
Removing: /Users/travis/Library/Caches/Homebrew/boost-1.66.0.high_sierra.bottle.tar.gz... (84.6MB)
Removing: /Users/travis/Library/Caches/Homebrew/carthage-0.28.0.high_sierra.bottle.tar.gz... (8.3MB)
---
Pruned 0 symbolic links and 5 directories from /usr/local
==> Installing dependencies for swig: pcre
==> Installing swig dependency: pcre
==> Downloading https://homebrew.bintray.com/bottles/pcre-8.43.high_sierra.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/03/0389911a93a88efd4a69b52dea8ecb872fdb55bcfff45d2f7313be5f79730861?__gda__=exp=1560122422~hmac=4910980d19e42b0c47c538ae0e50dbc88998de365a8b867635c1ce5346e5435d&response-content-disposition=attachment%3Bfilename%3D%22pcre-8.43.high_sierra.bottle.tar.gz%22&response-content-type=application%2Fgzip&requestInfo=U2FsdGVkX19gO6txci2x5E6RRpnZanHZzxUuAuiv9JIgpd2xiXC1DLoNpJGAkLe6qw7kPoW2ytxqjrUxeUeRcyKZ7i9DsynDPo8veBnmlb8X2KuxdooiCAo1319vzfn9vL9iPLZiS91sDdRKuFrHrA&response-X-Checksum-Sha1=c67d4b99bb245f0ea56b34118dd6325b06a7250c&response-X-Checksum-Sha2=0389911a93a88efd4a69b52dea8ecb872fdb55bcfff45d2f7313be5f79730861
🍺  /usr/local/Cellar/pcre/8.43: 204 files, 5.5MB
==> Installing swig
==> Downloading https://homebrew.bintray.com/bottles/swig-4.0.0.high_sierra.bottle.tar.gz
==> Downloading https://homebrew.bintray.com/bottles/swig-4.0.0.high_sierra.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/ae/aed79cb436b3a0ac5812c4085e3121ffd62866397b8c7eaa06815ed8ec1e22b7?__gda__=exp=1560122425~hmac=a61ffb58af1e6ab0b66819e8d7392115e7ab0823371a75bb2614f738484cd3db&response-content-disposition=attachment%3Bfilename%3D%22swig-4.0.0.high_sierra.bottle.tar.gz%22&response-content-type=application%2Fgzip&requestInfo=U2FsdGVkX1-N90OjFFvEWwgzdOVOuKc5HjVYYEPZcI0oRGXd2X3-mWE4A5Sl0nYelONALRnJ7WkZz7_Q-b6qIQsyIefbJAd_-x-Fqik_E8FOZzu1WO_82jbYXlWlz3R6gBoUNANDQTvTVXKNjahwoQ&response-X-Checksum-Sha1=a9c428aee4337d91061a69c02d7ae508b627d03f&response-X-Checksum-Sha2=aed79cb436b3a0ac5812c4085e3121ffd62866397b8c7eaa06815ed8ec1e22b7
🍺  /usr/local/Cellar/swig/4.0.0: 722 files, 5.4MB
travis_time:end:0288dc8c:start=1560121361975314000,finish=1560121742640534000,duration=380665220000
travis_fold:end:install
travis_fold:start:before_script.1
---
[00:03:20]       Memory: 8 GB
[00:03:20]       Boot ROM Version: VMW71.00V.7581552.B64.1801142334
[00:03:20]       Apple ROM Info: [MS_VM_CERT/SHA1/27d66596a61c48dd3dc7216fd715126e33f59ae7]Welcome to the Virtual Machine
[00:03:20]       SMC Version (system): 2.8f0
[00:03:20]       Serial Number (system): VMMnv4xSQhlq
[00:03:20] 
[00:03:20] hw.ncpu: 4
[00:03:20] hw.byteorder: 1234
[00:03:20] hw.memsize: 8589934592
---
[00:07:57] [RUSTC-TIMING] syntax_pos test:false 5.630
[00:07:57]    Compiling rustc_errors v0.0.0 (/Users/travis/build/rust-lang/rust/src/librustc_errors)
[00:08:08] [RUSTC-TIMING] rustc_errors test:false 11.135
[00:08:18] [RUSTC-TIMING] rustc_target test:false 20.884
No output has been received in the last 30m0s, this potentially indicates a stalled build or something wrong with the build itself.
Check the details on how to adjust your build configuration on: https://docs.travis-ci.com/user/common-build-problems/#Build-times-out-because-no-output-was-received
The build has been terminated

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jun 9, 2019
@Centril
Copy link
Contributor Author

Centril commented Jun 9, 2019

@bors retry spurious 30 min

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 9, 2019
@bors
Copy link
Contributor

bors commented Jun 9, 2019

⌛ Testing commit c25e3d2 with merge 61a60ce...

bors added a commit that referenced this pull request Jun 9, 2019
Stabilize #![feature(repr_align_enum)] in Rust 1.37.0

On an `enum` item, you may now write:

```rust
#[repr(align(X))]
enum Foo {
    // ...
}
```

This has equivalent effects to first defining:

```rust
#[repr(align(X))]
struct AlignX<T>(T);
```

and then using `AlignX<Foo>` in `Foo`'s stead.

r? @nagisa
@bors
Copy link
Contributor

bors commented Jun 10, 2019

☀️ Test successful - checks-travis, status-appveyor
Approved by: nagisa
Pushing 61a60ce to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jun 10, 2019
@bors bors merged commit c25e3d2 into rust-lang:master Jun 10, 2019
@Centril Centril deleted the stabilize-repr_align_enum branch June 10, 2019 02:37
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request Aug 29, 2019
Pkgsrc changes:
 * Add a patch to llvm to deal with const dli_saddr.
 * Adapt two other patches.
 * Cross-build currently fails, so i386, powerpc and sparc64 bootstrap
   kits for 1.37.0 are built natively.  Missing aarch64 hardware, so that's
   not available yet.
 * Bump bootstrap requirements to 1.36.0 except for armv7-unknown-netbsd-eabihf
   which I've not managed to cross-build.

Upstream changes:

Version 1.37.0 (2019-08-15)
==========================

Language
--------
- `#[must_use]` will now warn if the type is contained in a [tuple][61100],
  [`Box`][62228], or an [array][62235] and unused.
- [You can now use the `cfg` and `cfg_attr` attributes on
  generic parameters.][61547]
- [You can now use enum variants through type alias.][61682] e.g. You can
  write the following:
  ```rust
  type MyOption = Option<u8>;

  fn increment_or_zero(x: MyOption) -> u8 {
      match x {
          MyOption::Some(y) => y + 1,
          MyOption::None => 0,
      }
  }
  ```
- [You can now use `_` as an identifier for consts.][61347] e.g. You can write
  `const _: u32 = 5;`.
- [You can now use `#[repr(align(X)]` on enums.][61229]
- [The  `?`/_"Kleene"_ macro operator is now available in the
  2015 edition.][60932]

Compiler
--------
- [You can now enable Profile-Guided Optimization with the `-C profile-generate`
  and `-C profile-use` flags.][61268] For more information on how to use profile
  guided optimization, please refer to the [rustc book][rustc-book-pgo].
- [The `rust-lldb` wrapper script should now work again.][61827]

Libraries
---------
- [`mem::MaybeUninit<T>` is now ABI-compatible with `T`.][61802]

Stabilized APIs
---------------
- [`BufReader::buffer`]
- [`BufWriter::buffer`]
- [`Cell::from_mut`]
- [`Cell<[T]>::as_slice_of_cells`][`Cell<slice>::as_slice_of_cells`]
- [`DoubleEndedIterator::nth_back`]
- [`Option::xor`]
- [`Wrapping::reverse_bits`]
- [`i128::reverse_bits`]
- [`i16::reverse_bits`]
- [`i32::reverse_bits`]
- [`i64::reverse_bits`]
- [`i8::reverse_bits`]
- [`isize::reverse_bits`]
- [`slice::copy_within`]
- [`u128::reverse_bits`]
- [`u16::reverse_bits`]
- [`u32::reverse_bits`]
- [`u64::reverse_bits`]
- [`u8::reverse_bits`]
- [`usize::reverse_bits`]

Cargo
-----
- [`Cargo.lock` files are now included by default when publishing executable crates
  with executables.][cargo/7026]
- [You can now specify `default-run="foo"` in `[package]` to specify the
  default executable to use for `cargo run`.][cargo/7056]

Misc
----

Compatibility Notes
-------------------
- [Using `...` for inclusive range patterns will now warn by default.][61342]
  Please transition your code to using the `..=` syntax for inclusive
  ranges instead.
- [Using a trait object without the `dyn` will now warn by default.][61203]
  Please transition your code to use `dyn Trait` for trait objects instead.

[62228]: rust-lang/rust#62228
[62235]: rust-lang/rust#62235
[61802]: rust-lang/rust#61802
[61827]: rust-lang/rust#61827
[61547]: rust-lang/rust#61547
[61682]: rust-lang/rust#61682
[61268]: rust-lang/rust#61268
[61342]: rust-lang/rust#61342
[61347]: rust-lang/rust#61347
[61100]: rust-lang/rust#61100
[61203]: rust-lang/rust#61203
[61229]: rust-lang/rust#61229
[60932]: rust-lang/rust#60932
[cargo/7026]: rust-lang/cargo#7026
[cargo/7056]: rust-lang/cargo#7056
[`BufReader::buffer`]: https://doc.rust-lang.org/std/io/struct.BufReader.html#method.buffer
[`BufWriter::buffer`]: https://doc.rust-lang.org/std/io/struct.BufWriter.html#method.buffer
[`Cell::from_mut`]: https://doc.rust-lang.org/std/cell/struct.Cell.html#method.from_mut
[`Cell<slice>::as_slice_of_cells`]: https://doc.rust-lang.org/std/cell/struct.Cell.html#method.as_slice_of_cells
[`DoubleEndedIterator::nth_back`]: https://doc.rust-lang.org/std/iter/trait.DoubleEndedIterator.html#method.nth_back
[`Option::xor`]: https://doc.rust-lang.org/std/option/enum.Option.html#method.xor
[`RefCell::try_borrow_unguarded`]: https://doc.rust-lang.org/std/cell/struct.RefCell.html#method.try_borrow_unguarded
[`Wrapping::reverse_bits`]: https://doc.rust-lang.org/std/num/struct.Wrapping.html#method.reverse_bits
[`i128::reverse_bits`]: https://doc.rust-lang.org/std/primitive.i128.html#method.reverse_bits
[`i16::reverse_bits`]: https://doc.rust-lang.org/std/primitive.i16.html#method.reverse_bits
[`i32::reverse_bits`]: https://doc.rust-lang.org/std/primitive.i32.html#method.reverse_bits
[`i64::reverse_bits`]: https://doc.rust-lang.org/std/primitive.i64.html#method.reverse_bits
[`i8::reverse_bits`]: https://doc.rust-lang.org/std/primitive.i8.html#method.reverse_bits
[`isize::reverse_bits`]: https://doc.rust-lang.org/std/primitive.isize.html#method.reverse_bits
[`slice::copy_within`]: https://doc.rust-lang.org/std/primitive.slice.html#method.copy_within
[`u128::reverse_bits`]: https://doc.rust-lang.org/std/primitive.u128.html#method.reverse_bits
[`u16::reverse_bits`]: https://doc.rust-lang.org/std/primitive.u16.html#method.reverse_bits
[`u32::reverse_bits`]: https://doc.rust-lang.org/std/primitive.u32.html#method.reverse_bits
[`u64::reverse_bits`]: https://doc.rust-lang.org/std/primitive.u64.html#method.reverse_bits
[`u8::reverse_bits`]: https://doc.rust-lang.org/std/primitive.u8.html#method.reverse_bits
[`usize::reverse_bits`]: https://doc.rust-lang.org/std/primitive.usize.html#method.reverse_bits
[rustc-book-pgo]: https://doc.rust-lang.org/rustc/profile-guided-optimization.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. finished-final-comment-period The final comment period is finished for this PR / Issue. merged-by-bors This PR was explicitly merged by bors. relnotes Marks issues that should be documented in the release notes of the next release. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants