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

freeze.md: Incorrect example #1226

Merged
merged 2 commits into from
Aug 2, 2019
Merged

Conversation

dhl
Copy link
Contributor

@dhl dhl commented Jul 23, 2019

The freeze example is meant to show that a value cannot be immutably borrowed
while the original value is modified within the same scope.

However, as the immutably borrowed value is not used after the mutation, the
borrow checker allows the example to be compiled successfully, contrary to what
we intend to demonstrate.

See #1217 for discussion.

Solution: Use the immutably borrowed value after original value is modified.

The freeze example is meant to show that a value cannot be immutably borrowed
while the original value is modified within the same scope.

However, as the immutably borrowed value is not used after the mutation, the
borrow checker allows the example to be compiled successfully, contrary to what
we intend to demonstrate.

Solution: Use the immutably borrowed value after original value is modified.
@rust-highfive
Copy link

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @marioidival (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

src/scope/borrow/freeze.md Outdated Show resolved Hide resolved
@marioidival
Copy link
Member

@dhl thank you!

@marioidival marioidival merged commit 9dfb263 into rust-lang:master Aug 2, 2019
pietroalbini added a commit to pietroalbini/rust that referenced this pull request Aug 7, 2019
Update books

## nomicon

1 commits in b7f0aba2f88a8feade70595efcfa3438e54e96c0..8a7d05615e5bc0a7fb961b4919c44f5221ee54da
2019-07-11 15:11:36 -0400 to 2019-08-07 07:46:59 -0500
- s/railguard/guardrail/ (rust-lang/nomicon#156)

## reference

5 commits in 8e7d614..b4b3536
2019-07-16 21:02:33 +0100 to 2019-08-07 02:29:50 +0200
- Update partially initialized values in drop documentation. (rust-lang/reference#648)
- Define sound and unsound (rust-lang/reference#647)
- Fix a type in the modules section: functions => modules (rust-lang/reference#645)
- Fix some links. (rust-lang/reference#642)
- Update recursion_limit default limit (rust-lang/reference#633)

## rust-by-example

14 commits in e3679e214d8db44586aca9b20aa27517007d1923..f2c15ba5ee89ae9469a2cf60494977749901d764
2019-07-15 11:13:44 -0300 to 2019-08-07 10:14:25 -0300
- Remove redundant semicolons (rust-lang/rust-by-example#1239)
- Rename "Read Lines" chapter title (rust-lang/rust-by-example#1230)
- Added space between word and inline code block in unit_testing.md (rust-lang/rust-by-example#1237)
- [typo] fix unit_testing wrong output (rust-lang/rust-by-example#1210)
- flow_control/match/binding.md: `...' -> `..=' (rust-lang/rust-by-example#1233)
- generics/impl.md: follow rustfmt style (rust-lang/rust-by-example#1236)
- freeze.md: Incorrect example (rust-lang/rust-by-example#1226)
- Make `point` consistent (rust-lang/rust-by-example#1229)
- Fix typo at error -> panic (rust-lang/rust-by-example#1227)
- Snake didn't deserve to die 🐍 (rust-lang/rust-by-example#1228)
- Reorder links in destructuring.md (rust-lang/rust-by-example#1225)
- Rename variable names for consistent in iter_result.md (rust-lang/rust-by-example#1224)
- Fix several shell output and code highlights. (rust-lang/rust-by-example#1222)
- Add new example for Rc. (rust-lang/rust-by-example#1223)

## edition-guide

5 commits in f6c8b92d4e63edd28e862be952f33861f35956f8..e58bc4ca104e890ac56af846877c874c432a64b5
2019-07-06 22:10:32 +0200 to 2019-07-31 20:14:12 +0200
- Hide extraneous `use` in anonymous lifetime example. (rust-lang/edition-guide#190)
- Attempt to clarify "no more mod.rs". (rust-lang/edition-guide#187)
- Remove -preview for rustup components. (rust-lang/edition-guide#188)
- rust-lang/edition-guide#184 More clear explanation and Title. (rust-lang/edition-guide#185)
- More clear table headers (rust-lang/edition-guide#186)

## embedded-book

2 commits in ff334e74fdb9f197e621efa6d7c3105be892e888..c5da1e11915d3f28266168baaf55822f7e3fe999
2019-07-16 13:47:34 +0000 to 2019-08-05 23:02:10 +0000
- install/verify: fix next section link  (rust-embedded/book#202)
- Syst small fix  (rust-embedded/book#198)
Centril added a commit to Centril/rust that referenced this pull request Aug 8, 2019
Update books

## nomicon

1 commits in b7f0aba2f88a8feade70595efcfa3438e54e96c0..8a7d05615e5bc0a7fb961b4919c44f5221ee54da
2019-07-11 15:11:36 -0400 to 2019-08-07 07:46:59 -0500
- s/railguard/guardrail/ (rust-lang/nomicon#156)

## reference

5 commits in 8e7d614..b4b3536
2019-07-16 21:02:33 +0100 to 2019-08-07 02:29:50 +0200
- Update partially initialized values in drop documentation. (rust-lang/reference#648)
- Define sound and unsound (rust-lang/reference#647)
- Fix a type in the modules section: functions => modules (rust-lang/reference#645)
- Fix some links. (rust-lang/reference#642)
- Update recursion_limit default limit (rust-lang/reference#633)

## rust-by-example

14 commits in e3679e214d8db44586aca9b20aa27517007d1923..f2c15ba5ee89ae9469a2cf60494977749901d764
2019-07-15 11:13:44 -0300 to 2019-08-07 10:14:25 -0300
- Remove redundant semicolons (rust-lang/rust-by-example#1239)
- Rename "Read Lines" chapter title (rust-lang/rust-by-example#1230)
- Added space between word and inline code block in unit_testing.md (rust-lang/rust-by-example#1237)
- [typo] fix unit_testing wrong output (rust-lang/rust-by-example#1210)
- flow_control/match/binding.md: `...' -> `..=' (rust-lang/rust-by-example#1233)
- generics/impl.md: follow rustfmt style (rust-lang/rust-by-example#1236)
- freeze.md: Incorrect example (rust-lang/rust-by-example#1226)
- Make `point` consistent (rust-lang/rust-by-example#1229)
- Fix typo at error -> panic (rust-lang/rust-by-example#1227)
- Snake didn't deserve to die 🐍 (rust-lang/rust-by-example#1228)
- Reorder links in destructuring.md (rust-lang/rust-by-example#1225)
- Rename variable names for consistent in iter_result.md (rust-lang/rust-by-example#1224)
- Fix several shell output and code highlights. (rust-lang/rust-by-example#1222)
- Add new example for Rc. (rust-lang/rust-by-example#1223)

## edition-guide

5 commits in f6c8b92d4e63edd28e862be952f33861f35956f8..e58bc4ca104e890ac56af846877c874c432a64b5
2019-07-06 22:10:32 +0200 to 2019-07-31 20:14:12 +0200
- Hide extraneous `use` in anonymous lifetime example. (rust-lang/edition-guide#190)
- Attempt to clarify "no more mod.rs". (rust-lang/edition-guide#187)
- Remove -preview for rustup components. (rust-lang/edition-guide#188)
- rust-lang/edition-guide#184 More clear explanation and Title. (rust-lang/edition-guide#185)
- More clear table headers (rust-lang/edition-guide#186)

## embedded-book

2 commits in ff334e74fdb9f197e621efa6d7c3105be892e888..c5da1e11915d3f28266168baaf55822f7e3fe999
2019-07-16 13:47:34 +0000 to 2019-08-05 23:02:10 +0000
- install/verify: fix next section link  (rust-embedded/book#202)
- Syst small fix  (rust-embedded/book#198)
Centril added a commit to Centril/rust that referenced this pull request Aug 8, 2019
Update books

## nomicon

1 commits in b7f0aba2f88a8feade70595efcfa3438e54e96c0..8a7d05615e5bc0a7fb961b4919c44f5221ee54da
2019-07-11 15:11:36 -0400 to 2019-08-07 07:46:59 -0500
- s/railguard/guardrail/ (rust-lang/nomicon#156)

## reference

5 commits in 8e7d614..b4b3536
2019-07-16 21:02:33 +0100 to 2019-08-07 02:29:50 +0200
- Update partially initialized values in drop documentation. (rust-lang/reference#648)
- Define sound and unsound (rust-lang/reference#647)
- Fix a type in the modules section: functions => modules (rust-lang/reference#645)
- Fix some links. (rust-lang/reference#642)
- Update recursion_limit default limit (rust-lang/reference#633)

## rust-by-example

14 commits in e3679e214d8db44586aca9b20aa27517007d1923..f2c15ba5ee89ae9469a2cf60494977749901d764
2019-07-15 11:13:44 -0300 to 2019-08-07 10:14:25 -0300
- Remove redundant semicolons (rust-lang/rust-by-example#1239)
- Rename "Read Lines" chapter title (rust-lang/rust-by-example#1230)
- Added space between word and inline code block in unit_testing.md (rust-lang/rust-by-example#1237)
- [typo] fix unit_testing wrong output (rust-lang/rust-by-example#1210)
- flow_control/match/binding.md: `...' -> `..=' (rust-lang/rust-by-example#1233)
- generics/impl.md: follow rustfmt style (rust-lang/rust-by-example#1236)
- freeze.md: Incorrect example (rust-lang/rust-by-example#1226)
- Make `point` consistent (rust-lang/rust-by-example#1229)
- Fix typo at error -> panic (rust-lang/rust-by-example#1227)
- Snake didn't deserve to die 🐍 (rust-lang/rust-by-example#1228)
- Reorder links in destructuring.md (rust-lang/rust-by-example#1225)
- Rename variable names for consistent in iter_result.md (rust-lang/rust-by-example#1224)
- Fix several shell output and code highlights. (rust-lang/rust-by-example#1222)
- Add new example for Rc. (rust-lang/rust-by-example#1223)

## edition-guide

5 commits in f6c8b92d4e63edd28e862be952f33861f35956f8..e58bc4ca104e890ac56af846877c874c432a64b5
2019-07-06 22:10:32 +0200 to 2019-07-31 20:14:12 +0200
- Hide extraneous `use` in anonymous lifetime example. (rust-lang/edition-guide#190)
- Attempt to clarify "no more mod.rs". (rust-lang/edition-guide#187)
- Remove -preview for rustup components. (rust-lang/edition-guide#188)
- rust-lang/edition-guide#184 More clear explanation and Title. (rust-lang/edition-guide#185)
- More clear table headers (rust-lang/edition-guide#186)

## embedded-book

2 commits in ff334e74fdb9f197e621efa6d7c3105be892e888..c5da1e11915d3f28266168baaf55822f7e3fe999
2019-07-16 13:47:34 +0000 to 2019-08-05 23:02:10 +0000
- install/verify: fix next section link  (rust-embedded/book#202)
- Syst small fix  (rust-embedded/book#198)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants