Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Borrow checking for overloaded indexing
Closes #15525
- Loading branch information
Showing
9 changed files
with
96 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright 2014 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. | ||
|
||
struct MyVec<T> { | ||
data: Vec<T>, | ||
} | ||
|
||
impl<T> Index<uint, T> for MyVec<T> { | ||
fn index<'a>(&'a self, &i: &uint) -> &'a T { | ||
self.data.get(i) | ||
} | ||
} | ||
|
||
fn main() { | ||
let v = MyVec { data: vec!(box 1i, box 2, box 3) }; | ||
let good = &v[0]; // Shouldn't fail here | ||
let bad = v[0]; | ||
//~^ ERROR cannot move out of dereference (dereference is implicit, due to indexing) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2bc6547
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
saw approval from pnkfelix
at nrc@2bc6547
2bc6547
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
merging nick29581/rust/index-bck = 2bc6547 into auto
2bc6547
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nick29581/rust/index-bck = 2bc6547 merged ok, testing candidate = 6c35d51
2bc6547
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all tests pass:
success: http://buildbot.rust-lang.org/builders/auto-mac-32-opt/builds/350
success: http://buildbot.rust-lang.org/builders/auto-mac-64-opt/builds/351
success: http://buildbot.rust-lang.org/builders/auto-mac-64-nopt-c/builds/350
success: http://buildbot.rust-lang.org/builders/auto-mac-64-nopt-t/builds/351
success: http://buildbot.rust-lang.org/builders/auto-linux-32-opt/builds/353
success: http://buildbot.rust-lang.org/builders/auto-linux-32-nopt-c/builds/354
success: http://buildbot.rust-lang.org/builders/auto-linux-32-nopt-t/builds/353
success: http://buildbot.rust-lang.org/builders/auto-linux-64-opt/builds/359
success: http://buildbot.rust-lang.org/builders/auto-linux-64-nopt-c/builds/354
success: http://buildbot.rust-lang.org/builders/auto-linux-64-nopt-t/builds/353
success: http://buildbot.rust-lang.org/builders/auto-linux-64-x-android-t/builds/356
success: http://buildbot.rust-lang.org/builders/auto-win-32-opt/builds/354
success: http://buildbot.rust-lang.org/builders/auto-win-32-nopt-t/builds/354
success: http://buildbot.rust-lang.org/builders/auto-win-32-nopt-c/builds/355
2bc6547
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fast-forwarding master to auto = 6c35d51