Skip to content

Fix pointer value in the 'complex example' on stack/heap#30115

Merged
bors merged 1 commit into
rust-lang:masterfrom
nilcons-contrib:fix-book-stack
Dec 1, 2015
Merged

Fix pointer value in the 'complex example' on stack/heap#30115
bors merged 1 commit into
rust-lang:masterfrom
nilcons-contrib:fix-book-stack

Conversation

@klao

@klao klao commented Nov 30, 2015

Copy link
Copy Markdown
Contributor

The f argument will reference the actual value in the d box, not the box in the bar's stack frame.

I am just learning Rust, so I don't know how to explain this well, but just from f's type it is clear that it will be a pointer to an i32, not a pointer to a pointer. Some println!("{:p}", ...)'s can easily confirm this.

I would actually suggest to remove/simplify this part of the example. This is a subtle issue that can easily confuse people at the early stages of familiarizing with the language. (As I got confused by it. :))

The `f` argument will reference the actual value in the `d` box, not the
box in the `bar`'s stack frame.
@rust-highfive

Copy link
Copy Markdown
Contributor

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Manishearth (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.

@Manishearth

Copy link
Copy Markdown
Member

r? @steveklabnik

@steveklabnik

Copy link
Copy Markdown
Contributor

@bors: r+ rollup

@bors

bors commented Nov 30, 2015

Copy link
Copy Markdown
Collaborator

📌 Commit 7728742 has been approved by steveklabnik

@bors

bors commented Nov 30, 2015

Copy link
Copy Markdown
Collaborator

⌛ Testing commit 7728742 with merge 937efb3...

@steveklabnik

Copy link
Copy Markdown
Contributor

Thank you! I agree that this could use some simplification.

@steveklabnik

Copy link
Copy Markdown
Contributor

Oh, and for why: https://users.rust-lang.org/t/im-having-trouble-following-an-example-in-the-stack-and-the-heap/3666/6 <- we found this bug recently, but I hadn't had the time to update the example.

@bors

bors commented Nov 30, 2015

Copy link
Copy Markdown
Collaborator

💔 Test failed - auto-mac-64-nopt-t

@klao

klao commented Nov 30, 2015

Copy link
Copy Markdown
Contributor Author

Great explanation in the linked thread, thanks!

@steveklabnik

Copy link
Copy Markdown
Contributor

@bors: retry

steveklabnik added a commit to steveklabnik/rust that referenced this pull request Nov 30, 2015
…teveklabnik

The `f` argument will reference the actual value in the `d` box, not the box in the `bar`'s stack frame.

I am just learning Rust, so I don't know how to explain this well, but just from `f`'s type it is clear that it will be a pointer to an `i32`, not a pointer to a pointer. Some `println!("{:p}", ...)`'s can easily confirm this.

I would actually suggest to remove/simplify this part of the example. This is a subtle issue that can easily confuse people at the early stages of familiarizing with the language. (As I got confused by it. :))
bors added a commit that referenced this pull request Dec 1, 2015
@bors bors merged commit 7728742 into rust-lang:master Dec 1, 2015
@klao klao deleted the fix-book-stack branch December 1, 2015 16:07
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.

5 participants