summary refs log tree commit diff
path: root/src/doc
AgeCommit message (Collapse)AuthorLines
2020-01-28stabilize the debug_map_key_value featureAshley Mannix-9/+0
2020-01-27Auto merge of #68122 - Centril:stabilize-transparent-enums, r=petrochenkovbors-93/+0
Stabilize `#[repr(transparent)]` on `enum`s in Rust 1.42.0 # Stabilization report The following is the stabilization report for `#![feature(transparent_enums)]`. Tracking issue: https://github.com/rust-lang/rust/issues/60405 [Version target](https://forge.rust-lang.org/#current-release-versions): 1.42 (2020-01-30 => beta, 2020-03-12 => stable). ## User guide A `struct` with only a single non-ZST field (let's call it `foo`) can be marked as `#[repr(transparent)]`. Such a `struct` has the same layout and ABI as `foo`. Here, we also extend this ability to `enum`s with only one variant, subject to the same restrictions as for the equivalent `struct`. That is, you can now write: ```rust #[repr(transparent)] enum Foo { Bar(u8) } ``` which, in terms of layout and ABI, is equivalent to: ```rust #[repr(transparent)] struct Foo(u8); ``` ## Motivation This is not a major feature that will unlock new and important use-cases. The utility of `repr(transparent)` `enum`s is indeed limited. However, there is still some value in it: 1. It provides conceptual simplification of the language in terms of treating univariant `enum`s and `struct`s the same, as both are product types. Indeed, languages like Haskell only have `data` as the only way to construct user-defined ADTs in the language. 2. In rare occasions, it might be that the user started out with a univariant `enum` for whatever reason (e.g. they thought they might extend it later). Now they want to make this `enum` `transparent` without breaking users by turning it into a `struct`. By lifting the restriction here, now they can. ## Technical specification The reference specifies [`repr(transparent)` on a `struct`](https://doc.rust-lang.org/nightly/reference/type-layout.html#the-transparent-representation) as: > ### The transparent Representation > > The `transparent` representation can only be used on `struct`s that have: > - a single field with non-zero size, and > - any number of fields with size 0 and alignment 1 (e.g. `PhantomData<T>`). > > Structs with this representation have the same layout and ABI as the single non-zero sized field. > > This is different than the `C` representation because a struct with the `C` representation will always have the ABI of a `C` `struct` while, for example, a struct with the `transparent` representation with a primitive field will have the ABI of the primitive field. > > Because this representation delegates type layout to another type, it cannot be used with any other representation. Here, we amend this to include univariant `enum`s as well with the same static restrictions and the same effects on dynamic semantics. ## Tests All the relevant tests are adjusted in the PR diff but are recounted here: - `src/test/ui/repr/repr-transparent.rs` checks that `repr(transparent)` on an `enum` must be univariant, rather than having zero or more than one variant. Restrictions on the fields inside the only variants, like for those on `struct`s, are also checked here. - A number of codegen tests are provided as well: - `src/test/codegen/repr-transparent.rs` (the canonical test) - `src/test/codegen/repr-transparent-aggregates-1.rs` - `src/test/codegen/repr-transparent-aggregates-2.rs` - `src/test/codegen/repr-transparent-aggregates-3.rs` - `src/test/ui/lint/lint-ctypes-enum.rs` tests the interactions with the `improper_ctypes` lint. ## History - 2019-04-30, RFC https://github.com/rust-lang/rfcs/pull/2645 Author: @mjbshaw Reviewers: The Language Team This is the RFC that proposes allowing `#[repr(transparent)]` on `enum`s and `union`. - 2019-06-11, PR https://github.com/rust-lang/rust/pull/60463 Author: @mjbshaw Reviewers: @varkor and @rkruppe The PR implements the RFC aforementioned in full. - 2019, PR https://github.com/rust-lang/rust/pull/67323 Author: @Centril Reviewers: @davidtwco The PR reorganizes the static checks taking advantage of the fact that `struct`s and `union`s are internally represented as ADTs with a single variant. - This PR stabilizes `transparent_enums`. ## Related / possible future work The remaining work here is to figure out the semantics of `#[repr(transparent)]` on `union`s and stabilize those. This work continues to be tracked in https://github.com/rust-lang/rust/issues/60405.
2020-01-21Update cargo, booksEric Huss-0/+0
2020-01-20stabilize transparent_enumsMazdak Farrokhzad-93/+0
2020-01-18slice_patterns: remove from unstable bookMazdak Farrokhzad-32/+0
2020-01-18Auto merge of #67940 - JohnTitor:rustc-guide, r=JohnTitorbors-0/+0
Update rustc-guide r? @ghost CC: @rust-lang/wg-learning
2020-01-16Fix issue number of `infer_static_outlives_requirements`Yuki Okushi-2/+2
2020-01-16Fix issue number of `repr128`Yuki Okushi-2/+2
2020-01-16Fix issue number of `member_constraints`Yuki Okushi-2/+2
2020-01-14Update rustc-guideYuki Okushi-0/+0
2020-01-09Document sanitizers in unstable-bookTomasz Miąsko-0/+163
2020-01-09Remove sanitizer_runtime attributeTomasz Miąsko-5/+0
2020-01-06Update booksEric Huss-0/+0
2020-01-01update rustc-guideMark Mansi-0/+0
2019-12-25Remove `compiler_builtins_lib` documentationMatthew Kraai-40/+1
Fixes #67593
2019-12-14Update cargo, booksEric Huss-0/+0
2019-12-14update referenceNiko Matsakis-0/+0
2019-12-06Update rustc-guideMark Mansi-0/+0
2019-12-02Rollup merge of #66245 - tmiasko:cfg-sanitize, r=oli-obkRalf Jung-0/+36
Conditional compilation for sanitizers Configure sanitize option when compiling with a sanitizer to make it possible to execute different code depending on whether given sanitizer is enabled or not.
2019-12-01rustc_lint: Remove lint `plugin_as_library`Vadim Petrochenkov-14/+1
2019-12-01rustc_plugin: Remove support for plugin argumentsVadim Petrochenkov-4/+0
2019-12-01Conditional compilation for sanitizersTomasz Miąsko-0/+36
Configure sanitize option when compiling with a sanitizer to make it possible to execute different code depending on whether given sanitizer is enabled or not.
2019-11-25Update documentation-tests.mdParth Mehrotra-1/+1
2019-11-25Update cargo, rls, books.Eric Huss-0/+0
2019-11-24rustc_plugin: Remove support for syntactic pluginsVadim Petrochenkov-129/+1
2019-11-23Rollup merge of #61351 - GuillaumeGomez:stabilize-cfg-rustdoc, r=QuietMisdreavusMazdak Farrokhzad-0/+35
Stabilize cfg(doc) cc #43781.
2019-11-23Auto merge of #66653 - ivan:lint-name-fix, r=Centrilbors-1/+1
docs: fix lint name for `unused_variables`
2019-11-23docs: fix lint name for `unused_variables`Ivan Kozik-1/+1
2019-11-21Add entry for `const_if_match` in unstable bookDylan MacKenzie-0/+14
2019-11-21move cfg(doc) docs into a separate pageQuietMisdreavus-31/+35
2019-11-21Rename the cfg attribute from rustdoc to docGuillaume Gomez-5/+5
2019-11-21Stabilize cfg rustdocGuillaume Gomez-0/+31
2019-11-18Auto merge of #54733 - GuillaumeGomez:stabilize-rustdoc-theme, ↵bors-25/+32
r=ollie27,Dylan-DPC Stabilize rustdoc theme options Closes #54730 This PR stabilizes the `--themes` (now `--theme`) and `--theme-checker` (now `--check-theme`) options, for allowing users to add custom themes to their documentation. Rustdoc includes two themes by default: `light` and `dark`. Using the `--theme` option, you can give rustdoc a CSS file to include as an extra theme for that render. Themes are named after the CSS file used, so using `--theme /path/to/your/custom-theme.css` will add a theme called `custom-theme` to the documentation. Even though the CLI flag to add a theme is getting stabilized, there's no guarantee that a theme file will always have the same effect on documentation generated with future versions of rustdoc. To aid in ensuring that a theme will work, the flag `--check-theme` is also available, which compares the CSS rules defined by a custom theme against the ones used in the `light` theme. If the `light` theme defines a CSS rule that the custom theme does not, rustdoc will report an error. (Rustdoc also performs this check for themes given to `--theme`, but only reports a warning when a difference is found.)
2019-11-18improve error messages and documentationGuillaume Gomez-13/+21
2019-11-18Apply review commentsGuillaume Gomez-1/+1
2019-11-18Rename rustdoc options --themes and --check-themes to --theme and --check-themeGuillaume Gomez-4/+4
2019-11-18remove unstable docsGuillaume Gomez-26/+2
2019-11-18Improve documentation, add checks for themes option arguments, make sure the ↵Guillaume Gomez-1/+4
themes file names are js compatible
2019-11-18Fix typosGuillaume Gomez-2/+2
Co-Authored-By: Oliver Middleton <olliemail27@gmail.com>
2019-11-18Rename theme-checker option to check-themeGuillaume Gomez-5/+5
2019-11-18Apply review commentsGuillaume Gomez-2/+2
2019-11-18Add documentation for stabilized flagsGuillaume Gomez-1/+21
2019-11-17Auto merge of #66336 - ehuss:update-cargo-books, r=Mark-Simulacrumbors-0/+0
Update Cargo, books ## cargo 12 commits in 5da4b4d47963868d9878480197581ccbbdaece74..8280633db680dec5bfe1de25156d1a1d53e6d190 2019-10-28 21:53:41 +0000 to 2019-11-11 23:17:05 +0000 - Don't panic when parsing `/proc/stat` (rust-lang/cargo#7580) - Fix unused configuration key warning for a few keys under `build`. (rust-lang/cargo#7575) - Add back support for `BROWSER` envvar in `cargo doc --open`. (rust-lang/cargo#7576) - Only include "already existing ..." comment in gitignore on conflict (rust-lang/cargo#7570) - Add VS Code user dir to .gitignore (rust-lang/cargo#7578) - Added aliases to subcommand typo suggestions. (rust-lang/cargo#7486) - Use multiple requirement syntax consistently (rust-lang/cargo#7573) - Update verison to 0.42 (rust-lang/cargo#7568) - Expand documentation on build scripts. (rust-lang/cargo#7565) - Update crossbeam-utils requirement from 0.6 to 0.7 (rust-lang/cargo#7566) - don't download std-docs on CI (rust-lang/cargo#7513) - Change my-buddy to github-handle (rust-lang/cargo#7553) ## nomicon 2 commits in 5004ad30d69f93553ceef74439fea2159d1f769e..58e36e0e08dec5a379ac568827c058e25990d6cd 2019-10-12 19:52:40 +0200 to 2019-10-30 08:14:24 -0500 - remove references to the nursery - Add github action to replace Travis.yml (rust-lang-nursery/nomicon#172) ## reference 7 commits in 4b21b646669e0af49fae7cae301898dc4bfaa1f0..45558c464fb458affbcdcb34323946da45c8a117 2019-10-27 22:33:11 +0100 to 2019-11-08 14:47:35 +0100 - Audit code blocks. (rust-lang-nursery/reference#715) - Update coherence and orphan rules documentation to match RFC 2451 (rust-lang-nursery/reference#703) - Update organization name (rust-lang-nursery/reference#713) - State that no_implicit_prelude also applies to nested modules (rust-lang-nursery/reference#707) - expand Copy docs (rust-lang-nursery/reference#711) - github action doesn't use the nursery (rust-lang-nursery/reference#706) - Migrate to GitHub Actions. (rust-lang-nursery/reference#705) ## book 1 commits in 28fa3d15b0bc67ea5e79eeff2198e4277fc61baf..e79dd62aa63396714278d484d91d48826737f47f 2019-10-29 07:16:09 -0500 to 2019-10-30 07:33:12 -0500 - No need for an iterator here to fetch values (rust-lang/book#1957) ## rust-by-example 1 commits in f3197ddf2abab9abdbc029def8164f4a748b0d91..dcee312c66267eb5a2f6f1561354003950e29105 2019-10-29 10:17:40 -0300 to 2019-10-31 11:26:53 -0300 - refactor: simplify extracting Result from Option (rust-lang/rust-by-example#1283) ## edition-guide 2 commits in e58bc4ca104e890ac56af846877c874c432a64b5..f553fb26c60c4623ea88a1cfe731eafe0643ce34 2019-07-31 20:14:12 +0200 to 2019-10-30 08:27:42 -0500 - remove old references to the nursery - Port from Travis to GitHub Actions (rust-lang-nursery/edition-guide#192)
2019-11-16Auto merge of #66333 - mark-i-m:fix-rustc-guide-1, r=ehussbors-0/+0
Fix rustc guide again r? @ehuss Sorry, links change fast in this world...
2019-11-13Rollup merge of #66166 - GuillaumeGomez:rename-rustdoc-to-doc, r=QuietMisdreavusYuki Okushi-6/+6
rename cfg(rustdoc) into cfg(doc) Needed by https://github.com/rust-lang/rust/pull/61351 r? @QuietMisdreavus
2019-11-12Update Cargo, booksEric Huss-0/+0
2019-11-12update rustc-guideMark Mansi-0/+0
2019-11-12Rollup merge of #66267 - GuillaumeGomez:add-rustdoc-doc, r=kinnisonYuki Okushi-0/+203
Add rustdoc doc r? @kinnison
2019-11-10Add rustdoc doc page for lintsGuillaume Gomez-0/+126
2019-11-10Add rustdoc doc page on how to write documentationGuillaume Gomez-0/+77