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

clarify when reading uninititalized memory is allowed #852

Merged
merged 4 commits into from
Sep 2, 2020

Conversation

RalfJung
Copy link
Member

This should hopefully help avoid confusion like this one.

@ehuss ehuss added the S-needs-reviewer The pull request poses questions that need to be answered by non-maintainers of the reference label Jul 20, 2020
Copy link
Contributor

@Havvy Havvy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly nits. Only real concern is "compound types" since it's not a term used elsewhere in the reference.

src/behavior-considered-undefined.md Outdated Show resolved Hide resolved
src/behavior-considered-undefined.md Outdated Show resolved Hide resolved
@@ -57,6 +57,11 @@ code.
> **Note**: `rustc` achieves this with the unstable
> `rustc_layout_scalar_valid_range_*` attributes.

Note that uninitialized memory is also implicitly invalid for any type that has
a restricted set of valid values. In other words, the only cases in which
reading uninitialized memory is permitted is inside `union`s, and between the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can probably just minimize the second part to just "padding". We also don't define "compound type" anywhere, so it's probably best not to use it. We do define "user defined type" for struct/enum/union though.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's all "types with fields" though that I mean by "compound type" -- so, including tuples and arrays.

src/behavior-considered-undefined.md Outdated Show resolved Hide resolved
RalfJung and others added 2 commits September 1, 2020 14:45
Co-authored-by: Ryan Scheel <Ryan.havvy@gmail.com>
@RalfJung
Copy link
Member Author

RalfJung commented Sep 1, 2020

Mostly nits. Only real concern is "compound types" since it's not a term used elsewhere in the reference.

I tried rewording that, what do you think?

Copy link
Contributor

@Havvy Havvy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM except the one nit.

I don't really like using parentheticals, but a quick search for padding in the reference, and we don't say much about its properties at all. I'm going to file a follow-up issue for properly explaining it.

If you can merge this yourself, r=me after the suggested change.

src/behavior-considered-undefined.md Outdated Show resolved Hide resolved
Co-authored-by: Ryan Scheel <Ryan.havvy@gmail.com>
@RalfJung
Copy link
Member Author

RalfJung commented Sep 2, 2020

@Havvy I don't have merge permissions in this repo.

@Havvy Havvy merged commit 25391db into rust-lang:master Sep 2, 2020
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Sep 3, 2020
Update books

## reference

4 commits in 1b6c4b0afab97c0230433466c97167bbbe8445f6..25391dba46262f882fa846beefaff54a966a8fa5
2020-08-18 17:04:28 -0700 to 2020-09-02 07:22:55 -0700
- clarify when reading uninititalized memory is allowed (rust-lang/reference#852)
- Update patterns chapter, add rest patterns. (rust-lang/reference#876)
- Improve Type-Coersion Documentation (rust-lang/reference#843)
- Added variable back into example. (rust-lang/reference#880)

## book

3 commits in c0a6a61b8205da14ac955425f74258ffd8ee065d..e5ed97128302d5fa45dbac0e64426bc7649a558c
2020-08-14 14:21:49 -0500 to 2020-08-31 12:53:40 -0500
- Fix type mismatch in listing 10-5 (rust-lang/book#2441)
- Update ppendix-06-translation.md (rust-lang/book#2437)
- Correct no-listing-10-result-in-tests: Take tests module out of the main function (rust-lang/book#2430)

## rust-by-example

3 commits in 80a10e22140e28392b99d24ed02f4c6d8cb770a0..19f0a0372af497b34369cf182d9d16156cab2969
2020-08-08 09:56:46 -0300 to 2020-08-26 09:38:48 -0300
- prefer `length` over `size` when talking about number of elements vs. bytesize (rust-lang/rust-by-example#1372)
- Split out variable shadowing into a separate example (rust-lang/rust-by-example#1370)
- Update extern crate related sections (rust-lang/rust-by-example#1369)

## edition-guide

1 commits in bd6e4a9f59c5c1545f572266af77f5c7a5bad6d1..81f16863014de60b53de401d71ff904d163ee030
2020-07-12 17:37:08 -0500 to 2020-08-27 13:56:31 -0700
- Fix a small typo. (rust-lang/edition-guide#218)
@RalfJung RalfJung deleted the uninit branch October 11, 2020 22:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-needs-reviewer The pull request poses questions that need to be answered by non-maintainers of the reference
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants