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

Fix reborrows of &mut pointers #28873

Merged
merged 1 commit into from
Oct 7, 2015
Merged

Fix reborrows of &mut pointers #28873

merged 1 commit into from
Oct 7, 2015

Conversation

dotdash
Copy link
Contributor

@dotdash dotdash commented Oct 6, 2015

Fixes #28839

@rust-highfive
Copy link
Collaborator

r? @nikomatsakis

(rust_highfive has picked a reviewer for you, use r? to override)

@nikomatsakis
Copy link
Contributor

r=me with comment

@dotdash
Copy link
Contributor Author

dotdash commented Oct 6, 2015

@bors r=nikomatsakis 73396b5

@Manishearth
Copy link
Member

---- [compile-fail] compile-fail/borrowck-loan-of-static-data-issue-27616.rs stdout ----

error: unexpected compiler error or warning: '/Users/rustbuild/src/rust-buildbot/slave/auto-mac-64-nopt-t/build/src/test/compile-fail/borrowck-loan-of-static-data-issue-27616.rs:26:5: 26:23 error: cannot assign to `*s` because it is borrowed [E0506]'
status: exit code: 101
command: x86_64-apple-darwin/stage2/bin/rustc /Users/rustbuild/src/rust-buildbot/slave/auto-mac-64-nopt-t/build/src/test/compile-fail/borrowck-loan-of-static-data-issue-27616.rs -L x86_64-apple-darwin/test/compile-fail/ --target=x86_64-apple-darwin -L x86_64-apple-darwin/test/compile-fail/borrowck-loan-of-static-data-issue-27616.stage2-x86_64-apple-darwin.compile-fail.libaux -C prefer-dynamic -o x86_64-apple-darwin/test/compile-fail/borrowck-loan-of-static-data-issue-27616.stage2-x86_64-apple-darwin --cfg rtopt -L x86_64-apple-darwin/rt
stdout:
------------------------------------------

------------------------------------------
stderr:
------------------------------------------
/Users/rustbuild/src/rust-buildbot/slave/auto-mac-64-nopt-t/build/src/test/compile-fail/borrowck-loan-of-static-data-issue-27616.rs:26:5: 26:23 error: cannot assign to `*s` because it is borrowed [E0506]
/Users/rustbuild/src/rust-buildbot/slave/auto-mac-64-nopt-t/build/src/test/compile-fail/borrowck-loan-of-static-data-issue-27616.rs:26     *s = String::new(); //~ ERROR use of moved value
                                                                                                                                           ^~~~~~~~~~~~~~~~~~
/Users/rustbuild/src/rust-buildbot/slave/auto-mac-64-nopt-t/build/src/test/compile-fail/borrowck-loan-of-static-data-issue-27616.rs:23:38: 23:39 note: borrow of `*s` occurs here
/Users/rustbuild/src/rust-buildbot/slave/auto-mac-64-nopt-t/build/src/test/compile-fail/borrowck-loan-of-static-data-issue-27616.rs:23     let alias: &'static mut String = s;
                                                                                                                                                                            ^
error: aborting due to previous error

------------------------------------------

@bors
Copy link
Contributor

bors commented Oct 7, 2015

⌛ Testing commit 73396b5 with merge 7de3c81...

@bors
Copy link
Contributor

bors commented Oct 7, 2015

💔 Test failed - auto-mac-64-opt

@dotdash
Copy link
Contributor Author

dotdash commented Oct 7, 2015

@bors r=nikomatsakis d96ef0b

The test originally said cannot assign but was in the wrong directory. It was adjusted to accept the new, wrong error message in #28519. I reverted it back to the original check.

@bors
Copy link
Contributor

bors commented Oct 7, 2015

⌛ Testing commit d96ef0b with merge eb5076c...

@bors
Copy link
Contributor

bors commented Oct 7, 2015

💔 Test failed - auto-linux-32-opt

@dotdash
Copy link
Contributor Author

dotdash commented Oct 7, 2015

The failure on bors looks retry worthy, but I'm also getting a pretty failure locally, which I don't know how to fix.

running 1 test
test [pretty] run-pass/issue-28839.rs ... FAILED

failures:

---- [pretty] run-pass/issue-28839.rs stdout ----

error: pretty-printed source does not match expected source

expected:
------------------------------------------
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

pub struct Foo;

pub fn get_foo2<'a>(foo: &'a mut Option<&'a mut Foo>) -> &'a mut Foo {
    match foo {

        // Ensure that this is not considered a move, but rather a reborrow.
        &mut Some(ref mut x) => *x,
        &mut None => panic!(),
    }
}

fn main() { }

------------------------------------------
actual:
------------------------------------------
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

pub struct Foo;

pub fn get_foo2<'a>(foo: &'a mut Option<&'a mut Foo>) -> &'a mut Foo {
    match foo {


        // Ensure that this is not considered a move, but rather a reborrow.
        &mut Some(ref mut x) => *x,
        &mut None => panic!(),
    }
}

fn main() { }

------------------------------------------


thread '[pretty] run-pass/issue-28839.rs' panicked at 'explicit panic', /home/bs/src/rust/src/compiletest/runtest.rs:298

@dotdash
Copy link
Contributor Author

dotdash commented Oct 7, 2015

@bors r=nikomatsakis 4da796f

Marked the test to be ignored by pretty, same bug as #23623

bors added a commit that referenced this pull request Oct 7, 2015
@bors
Copy link
Contributor

bors commented Oct 7, 2015

⌛ Testing commit 4da796f with merge 3cee9e2...

@bors bors merged commit 4da796f into rust-lang:master Oct 7, 2015
@dotdash dotdash deleted the 28339 branch January 31, 2016 15:28
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