Skip to content

RFC to remove some special treatment of Box by borrow checker - #130

Merged
brson merged 1 commit into
rust-lang:masterfrom
nikomatsakis:box-not-special
Jul 30, 2014
Merged

RFC to remove some special treatment of Box by borrow checker#130
brson merged 1 commit into
rust-lang:masterfrom
nikomatsakis:box-not-special

Conversation

@nikomatsakis

@nikomatsakisnikomatsakis commented Jun 19, 2014

Copy link
Copy Markdown
Contributor

@anasazi

Copy link
Copy Markdown

I don't understand the motivation for doing this (but then I've never understood the obsession everyone else has with treating unique pointers just like non-unique pointers) especially when the proposed design still special cases Box so that moves out are allowed.

I really just don't understand why we would want to make our type system more restrictive just because we can exploit information about Box that we can't about smart pointers. Seems like it would be going backward.

@zwarich

Copy link
Copy Markdown

As discussed in this week's Rust meeting, I went ahead and implemented this change to see what the fallout would be like. There are only two changes required in the Rust distribution (I'm not including tests, since they are designed to test all of the edge cases):

https://gist.github.com/zwarich/348d5726d1ef42f109ee

I'll finish going through tests and double-check that I implemented everything correctly, but this looks like minimal impact on any real-world code.

@zwarich

Copy link
Copy Markdown

@anasazi We can remove the special-casing for moves out of Box by doing something like #178. It doesn't appear to be possible to do the same thing in a safe fashion for the special cases discussed in this RFC.

@zwarich

Copy link
Copy Markdown

I went through and wrote a bunch of new test cases, and found one place I missed, which resulted in a few more changes: https://gist.github.com/zwarich/348d5726d1ef42f109ee

@brson
brson merged commit 7fabfeb into rust-lang:masterJul 30, 2014
@brson

Copy link
Copy Markdown
Contributor

@pnkfelix

Copy link
Copy Markdown
Contributor

At some point we should document the fact that NLL has gone back to adding (more) special treatment of Box<T>. One big reason we were able to justify this is that we discovered several more instances where AST-borrowck was also special casing its treatment of Box<T>, so it was more consistent overall to just special case Box<T> consistently within NLL.

@pnkfelix

Copy link
Copy Markdown
Contributor

See e.g. this snippet of conversation regarding the special treatment of Box (which was originally a concern blocking NLL from moving forward): rust-lang/rust#43234 (comment)

emilyalbini added a commit to emilyalbini/rust that referenced this pull request Nov 10, 2018
…est-for-nll, r=davidtwco
NLL: Update box insensitivity test
This is just keeping one of our tests honest with respect to NLL, in two ways:
1. Adds uses of borrows that would otherwise be too short to observe the error that we would have expected to see...
2. ... I say "would have expected" because all of the errors in this file are part of the reversion of rust-lang/rfcs#130 that is attached to NLL (you can see more discussion of this here rust-lang#43234 (comment) )
@CentrilCentril added A-typesystem Type system related proposals & ideas A-borrowck Borrow checker related proposals & ideas A-allocation Proposals relating to allocation. labels Nov 23, 2018
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-allocationProposals relating to allocation.A-borrowckBorrow checker related proposals & ideasA-typesystemType system related proposals & ideas

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@nikomatsakis@anasazi@zwarich@brson@pnkfelix@Centril