Skip to content

Commit 86224c0

Browse files
---
yaml --- r: 102515 b: refs/heads/auto c: d9fadbc h: refs/heads/master i: 102513: f89d1b7 102511: 2863f3a v: v3
1 parent 601e00d commit 86224c0

File tree

4 files changed

+18
-8
lines changed

4 files changed

+18
-8
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1313
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1414
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1515
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
16-
refs/heads/auto: 339603426e65896a06fcebf63f3d751f242ee820
16+
refs/heads/auto: d9fadbc04f5bbd520e4ce8665ac128288e9846c0
1717
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1818
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1919
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/src/librustc/middle/trans/cleanup.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ impl<'a> CleanupHelperMethods<'a> for FunctionContext<'a> {
662662
// Check if a landing pad block exists; if not, create one.
663663
{
664664
let mut scopes = self.scopes.borrow_mut();
665-
let last_scope = scopes.get().mut_last();
665+
let last_scope = scopes.get().mut_last().unwrap();
666666
match last_scope.cached_landing_pad {
667667
Some(llbb) => { return llbb; }
668668
None => {

branches/auto/src/libstd/vec.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2031,7 +2031,7 @@ pub trait MutableVector<'a, T> {
20312031
fn mut_iter(self) -> MutItems<'a, T>;
20322032

20332033
/// Returns a mutable pointer to the last item in the vector.
2034-
fn mut_last(self) -> &'a mut T;
2034+
fn mut_last(self) -> Option<&'a mut T>;
20352035

20362036
/// Returns a reversed iterator that allows modifying each value
20372037
fn mut_rev_iter(self) -> RevMutItems<'a, T>;
@@ -2298,10 +2298,10 @@ impl<'a,T> MutableVector<'a, T> for &'a mut [T] {
22982298
}
22992299

23002300
#[inline]
2301-
fn mut_last(self) -> &'a mut T {
2301+
fn mut_last(self) -> Option<&'a mut T> {
23022302
let len = self.len();
2303-
if len == 0 { fail!("mut_last: empty vector") }
2304-
&mut self[len - 1]
2303+
if len == 0 { return None; }
2304+
Some(&mut self[len - 1])
23052305
}
23062306

23072307
#[inline]
@@ -4305,6 +4305,16 @@ mod tests {
43054305
let mut y: &mut [int] = [];
43064306
assert!(y.mut_pop_ref().is_none());
43074307
}
4308+
4309+
#[test]
4310+
fn test_mut_last() {
4311+
let mut x = [1, 2, 3, 4, 5];
4312+
let h = x.mut_last();
4313+
assert_eq!(*h.unwrap(), 5);
4314+
4315+
let mut y: &mut [int] = [];
4316+
assert!(y.mut_last().is_none());
4317+
}
43084318
}
43094319

43104320
#[cfg(test)]

branches/auto/src/libsyntax/opt_vec.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ impl<T> OptVec<T> {
6262
}
6363
}
6464

65-
pub fn mut_last<'a>(&'a mut self) -> &'a mut T {
65+
pub fn mut_last<'a>(&'a mut self) -> Option<&'a mut T> {
6666
match *self {
6767
Vec(ref mut v) => v.mut_last(),
68-
Empty => fail!("mut_last on empty opt_vec")
68+
Empty => None
6969
}
7070
}
7171

0 commit comments

Comments
 (0)