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

librustc: Remove cross borrowing from mutable Boxes to &mut. #15171

Merged
merged 1 commit into from
Jun 25, 2014

Conversation

pcwalton
Copy link
Contributor

This will break code like:

fn f(x: &mut int) {}

let mut a = box 1i;
f(a);

Change it to:

fn f(x: &mut int) {}

let mut a = box 1i;
f(&mut *a);

RFC 33; issue #10504.

[breaking-change]

r? @brson

This will break code like:

    fn f(x: &mut int) {}

    let mut a = box 1i;
    f(a);

Change it to:

    fn f(x: &mut int) {}

    let mut a = box 1i;
    f(&mut *a);

RFC 33; issue rust-lang#10504.

[breaking-change]
ty::ty_box(typ) | ty::ty_uniq(typ) => typ,
ty::ty_box(typ) | ty::ty_uniq(typ) => {
if mt_b.mutbl == ast::MutMutable {
return Err(ty::terr_mutability)
Copy link
Member

Choose a reason for hiding this comment

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

Is this it? I was expecting some enum variants (from auto-adjustments) and a bunch more related code to be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We still need auto-adjustment for the LHS of .. I believe this is the only place where the thing we want to remove is checked, though I could be wrong of course…

@huonw
Copy link
Member

huonw commented Jun 25, 2014

For the record: I made some measurements about Box -> & cross-borrowing. There's not many.

Doing a plain make bootstrap:

rustc: x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc
warning: borrowing Box<T> to &T
--
rustc: x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcollections
warning: borrowing Box<treemap::TreeNode<K,V>> to &treemap::TreeNode<K,V>
--
rustc: x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib/libterm
warning: borrowing <generic #1> to &std::path::posix::Path
--
rustc: x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib/libsyntax
warning: borrowing <generic #29> to &parse::token::Token
--
rustc: x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc
warning: borrowing Box<middle::ty::ClosureTy> to &middle::ty::ClosureTy
warning: borrowing Box<middle::ty::ClosureTy> to &middle::ty::ClosureTy
warning: borrowing Box<middle::ty::ClosureTy> to &middle::ty::ClosureTy
warning: borrowing <generic #280> to &syntax::ast::Item
warning: borrowing Box<middle::ty::ClosureTy> to &middle::ty::ClosureTy
warning: borrowing Box<middle::ty::ClosureTy> to &middle::ty::ClosureTy
--
rustc: x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib/libregex_macros
warning: borrowing <generic #8> to &syntax::codemap::Spanned<syntax::ast::Lit_>
warning: borrowing <generic #5> to &syntax::ast::Expr

Additional borrows in all the crate test harnesses:

rustc: x86_64-unknown-linux-gnu/stage2/test/rustctest-x86_64-unknown-linux-gnu
warning: borrowing <generic #3> to &syntax::ast::Item
warning: borrowing <generic #22> to &syntax::ast::Item
warning: borrowing <generic #23> to &syntax::ast::Item
--
rustc: x86_64-unknown-linux-gnu/stage2/test/syntaxtest-x86_64-unknown-linux-gnu
warning: borrowing <generic #1> to &ast::Pat
--
rustc: x86_64-unknown-linux-gnu/stage2/test/termtest-x86_64-unknown-linux-gnu
warning: borrowing <generic #1> to &std::path::posix::Path

@alexcrichton
Copy link
Member

@nick29581, you were a big proponent of Box -> &, so you may be interested in what @huonw has discovered.

bors added a commit that referenced this pull request Jun 25, 2014
This will break code like:

    fn f(x: &mut int) {}

    let mut a = box 1i;
    f(a);

Change it to:

    fn f(x: &mut int) {}

    let mut a = box 1i;
    f(&mut *a);

RFC 33; issue #10504.

[breaking-change]

r? @brson
@bors bors closed this Jun 25, 2014
@bors bors merged commit f6bfd2c into rust-lang:master Jun 25, 2014
BlockBlazeDev added a commit to BlockBlazeDev/rust-crypto that referenced this pull request Aug 8, 2024
Reference: rust-lang/rust#15171.

Signed-off-by: OGINO Masanori <masanori.ogino@gmail.com>
cosmycoder added a commit to cosmycoder/rust-crypto that referenced this pull request Sep 5, 2024
Reference: rust-lang/rust#15171.

Signed-off-by: OGINO Masanori <masanori.ogino@gmail.com>
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.

6 participants