Skip to content

Commit 1af62fd

Browse files
committed
---
yaml --- r: 49535 b: refs/heads/master c: 7948149 h: refs/heads/master i: 49533: 2a9bb6d 49531: 2e8be8f 49527: 57d9303 49519: ac0b0f2 49503: 6630d2d 49471: e208a91 49407: 21b8cad v: v3
1 parent 2e4ef0b commit 1af62fd

File tree

17 files changed

+65
-14
lines changed

17 files changed

+65
-14
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 29e8b6ea9b63c5cc1cd91cc5eb756820f7fe50b7
2+
refs/heads/master: 794814945674d27a4fb68aedcea86c39dd5ccd4e
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: f7a2371c176663d59062ec5158f39faecba45768
55
refs/heads/try: 2a8fb58d79e685d5ca07b039badcf2ae3ef077ea

trunk/src/libcore/container.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,12 @@ pub trait Map<K, V>: Mutable {
3838
/// Iterate over the map and mutate the contained values
3939
fn mutate_values(&mut self, f: &fn(&K, &mut V) -> bool);
4040

41-
/// Return the value corresponding to the key in the map
41+
/// Return a reference to the value corresponding to the key
4242
fn find(&self, key: &K) -> Option<&'self V>;
4343

44+
/// Return a mutable reference to the value corresponding to the key
45+
//fn find_mut(&mut self, key: &K) -> Option<&'self mut V>;
46+
4447
/// Insert a key-value pair into the map. An existing value for a
4548
/// key is replaced by the new value. Return true if the key did
4649
/// not already exist in the map.

trunk/src/libcore/core.rc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ Implicitly, all crates behave as if they included the following prologue:
5151
#[warn(vecs_implicitly_copyable)];
5252
#[deny(non_camel_case_types)];
5353
#[allow(deprecated_mutable_fields)];
54+
#[deny(deprecated_self)];
5455
#[allow(deprecated_drop)];
5556

5657
// On Linux, link to the runtime with -lrt.

trunk/src/libcore/repr.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ use managed;
2424
use ptr;
2525
use reflect;
2626
use reflect::{MovePtr, MovePtrAdaptor, align};
27+
use str;
2728
use sys;
2829
use to_str::ToStr;
2930
use vec::UnboxedVecRepr;

trunk/src/libcore/str.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,21 +1020,22 @@ pub fn each_chari(s: &str, it: &fn(uint, char) -> bool) {
10201020
/// Iterates over the chars in a string in reverse
10211021
#[inline(always)]
10221022
pub fn each_char_reverse(s: &str, it: &fn(char) -> bool) {
1023-
each_chari_reverse(s, |_, c| it(c))
1023+
let mut pos = 0;
1024+
let len = s.char_len();
1025+
while pos > 0 {
1026+
let CharRange {ch, next} = char_range_at_reverse(s, pos);
1027+
pos = next;
1028+
if !it(ch) { break; }
1029+
}
10241030
}
10251031

10261032
// Iterates over the chars in a string in reverse, with indices
10271033
#[inline(always)]
10281034
pub fn each_chari_reverse(s: &str, it: &fn(uint, char) -> bool) {
1029-
let mut pos = s.len();
10301035
let mut ch_pos = s.char_len();
1031-
while pos > 0 {
1032-
let CharRange {ch, next} = char_range_at_reverse(s, pos);
1033-
pos = next;
1036+
for s.each_char_reverse |ch| {
10341037
ch_pos -= 1;
1035-
10361038
if !it(ch_pos, ch) { break; }
1037-
10381039
}
10391040
}
10401041

@@ -3660,10 +3661,10 @@ mod tests {
36603661
fn test_each_char_reverse() {
36613662
let s = ~"ศไทย中华Việt Nam";
36623663
let v = ~['ศ','ไ','ท','ย','中','华','V','i','ệ','t',' ','N','a','m'];
3663-
let mut pos = v.len();
3664+
let mut pos = 0;
36643665
for s.each_char_reverse |ch| {
3665-
pos -= 1;
36663666
fail_unless!(ch == v[pos]);
3667+
pos += 1;
36673668
}
36683669
}
36693670

trunk/src/libcore/vec.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2547,6 +2547,7 @@ impl<A:Clone> Clone for ~[A] {
25472547
#[cfg(test)]
25482548
mod tests {
25492549
use option::{None, Option, Some};
2550+
use option;
25502551
use sys;
25512552
use vec::*;
25522553
use cmp::*;

trunk/src/libfuzzer/fuzzer.rc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#[allow(non_camel_case_types)];
2626
#[allow(deprecated_mode)];
2727
#[allow(deprecated_pattern)];
28+
#[deny(deprecated_self)];
2829

2930
extern mod core(vers = "0.6");
3031
extern mod std(vers = "0.6");

trunk/src/librust/rust.rc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
// FIXME #2238 Make commands run and test emit proper file endings on winds
1313
// FIXME #2238 Make run only accept source that emits an executable
1414

15+
#[deny(deprecated_self)];
16+
1517
#[link(name = "rust",
1618
vers = "0.6",
1719
uuid = "4a24da33-5cc8-4037-9352-2cbe9bd9d27c",

trunk/src/librustc/driver/driver.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ use util::common::time;
2525
use util::ppaux;
2626

2727
use core::int;
28+
use core::io::WriterUtil;
2829
use core::io;
2930
use core::os;
3031
use core::str;

trunk/src/librustc/middle/kind.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ use syntax::{visit, ast_util};
5656
// primitives in the stdlib are explicitly annotated to only take sendable
5757
// types.
5858

59+
use core::hashmap::linear::LinearSet;
60+
5961
pub static try_adding: &'static str = "Try adding a move";
6062

6163
pub type rval_map = HashMap<node_id, ()>;

trunk/src/librustc/rustc.rc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#[allow(non_camel_case_types)];
2525
#[allow(deprecated_mode)];
2626
#[warn(deprecated_pattern)];
27+
#[deny(deprecated_self)];
2728

2829
#[no_core];
2930

trunk/src/librustdoc/rustdoc.rc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#[no_core];
2323

2424
#[allow(non_implicitly_copyable_typarams)];
25+
#[deny(deprecated_self)];
2526

2627
extern mod core(vers = "0.6");
2728
extern mod std(vers = "0.6");

trunk/src/librustdoc/trim_pass.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ is interpreted as the brief description.
1818
use pass::Pass;
1919
use text_pass;
2020

21+
use core::str;
22+
2123
pub fn mk_pass() -> Pass {
2224
text_pass::mk_pass(~"trim", |s| s.trim().to_owned() )
2325
}

trunk/src/librusti/rusti.rc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
#[allow(vecs_implicitly_copyable,
2424
non_implicitly_copyable_typarams)];
25+
#[deny(deprecated_self)];
2526

2627
extern mod core(vers = "0.6");
2728
extern mod std(vers = "0.6");

trunk/src/librustpkg/rustpkg.rc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#[no_core];
2121
#[allow(vecs_implicitly_copyable,
2222
non_implicitly_copyable_typarams)];
23+
#[deny(deprecated_self)];
2324

2425
extern mod core(vers = "0.6");
2526
extern mod std(vers = "0.6");

trunk/src/libstd/std.rc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ not required in or otherwise suitable for the core library.
2828

2929
#[allow(vecs_implicitly_copyable)];
3030
#[deny(non_camel_case_types)];
31+
#[deny(deprecated_self)];
3132
#[allow(deprecated_mutable_fields)];
3233

3334
#[no_core];

trunk/src/libstd/treemap.rs

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ impl<K: TotalOrd, V> Map<K, V> for TreeMap<K, V> {
135135
mutate_values(&mut self.root, f);
136136
}
137137

138-
/// Return the value corresponding to the key in the map
138+
/// Return a reference to the value corresponding to the key
139139
fn find(&self, key: &K) -> Option<&'self V> {
140140
let mut current: &'self Option<~TreeNode<K, V>> = &self.root;
141141
loop {
@@ -189,6 +189,12 @@ pub impl<K: TotalOrd, V> TreeMap<K, V> {
189189
fn iter(&self) -> TreeMapIterator<'self, K, V> {
190190
TreeMapIterator{stack: ~[], node: &self.root}
191191
}
192+
193+
/// Return a mutable reference to the value corresponding to the key
194+
#[inline(always)]
195+
fn find_mut(&mut self, key: &K) -> Option<&'self mut V> {
196+
find_mut(&mut self.root, key)
197+
}
192198
}
193199

194200
/// Lazy forward iterator over a map
@@ -584,8 +590,20 @@ fn split<K: TotalOrd, V>(node: &mut ~TreeNode<K, V>) {
584590
}
585591
}
586592

587-
fn insert<K: TotalOrd, V>(node: &mut Option<~TreeNode<K, V>>, key: K,
588-
value: V) -> bool {
593+
fn find_mut<K: TotalOrd, V>(node: &'r mut Option<~TreeNode<K, V>>, key: &K) -> Option<&'r mut V> {
594+
match *node {
595+
Some(ref mut x) => {
596+
match key.cmp(&x.key) {
597+
Less => find_mut(&mut x.left, key),
598+
Greater => find_mut(&mut x.right, key),
599+
Equal => Some(&mut x.value),
600+
}
601+
}
602+
None => None
603+
}
604+
}
605+
606+
fn insert<K: TotalOrd, V>(node: &mut Option<~TreeNode<K, V>>, key: K, value: V) -> bool {
589607
match *node {
590608
Some(ref mut save) => {
591609
match key.cmp(&save.key) {
@@ -716,6 +734,19 @@ mod test_treemap {
716734
fail_unless!(m.find(&2) == None);
717735
}
718736

737+
#[test]
738+
fn test_find_mut() {
739+
let mut m = TreeMap::new();
740+
fail_unless!(m.insert(1, 12));
741+
fail_unless!(m.insert(2, 8));
742+
fail_unless!(m.insert(5, 14));
743+
let new = 100;
744+
match m.find_mut(&5) {
745+
None => fail!(), Some(x) => *x = new
746+
}
747+
assert_eq!(m.find(&5), Some(&new));
748+
}
749+
719750
#[test]
720751
fn insert_replace() {
721752
let mut m = TreeMap::new();

0 commit comments

Comments
 (0)