Skip to content

Commit e10fd31

Browse files
committed
auto merge of #14170 : pcwalton/rust/detildestr-misclibs, r=alexcrichton
r? @brson
2 parents 2a7a391 + 351a564 commit e10fd31

File tree

223 files changed

+1996
-1785
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

223 files changed

+1996
-1785
lines changed

src/compiletest/compiletest.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ pub fn parse_config(args: Vec<~str> ) -> Config {
152152
"(none)" != opt_str2(matches.opt_str("adb-test-dir")) &&
153153
!opt_str2(matches.opt_str("adb-test-dir")).is_empty(),
154154
lldb_python_dir: matches.opt_str("lldb-python-dir"),
155-
test_shard: test::opt_shard(matches.opt_str("test-shard")),
155+
test_shard: test::opt_shard(matches.opt_str("test-shard")
156+
.map(|x| x.to_strbuf())),
156157
verbose: matches.opt_present("verbose")
157158
}
158159
}
@@ -235,7 +236,10 @@ pub fn run_tests(config: &Config) {
235236

236237
pub fn test_opts(config: &Config) -> test::TestOpts {
237238
test::TestOpts {
238-
filter: config.filter.clone(),
239+
filter: match config.filter {
240+
None => None,
241+
Some(ref filter) => Some(filter.to_strbuf()),
242+
},
239243
run_ignored: config.run_ignored,
240244
logfile: config.logfile.clone(),
241245
run_tests: true,
@@ -314,7 +318,9 @@ pub fn make_test_name(config: &Config, testfile: &Path) -> test::TestName {
314318
format!("{}/{}", dir.unwrap_or(""), filename.unwrap_or(""))
315319
}
316320

317-
test::DynTestName(format!("[{}] {}", config.mode, shorten(testfile)))
321+
test::DynTestName(format_strbuf!("[{}] {}",
322+
config.mode,
323+
shorten(testfile)))
318324
}
319325

320326
pub fn make_test_closure(config: &Config, testfile: &Path) -> test::TestFn {

src/libarena/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ mod tests {
530530
}
531531

532532
struct Noncopy {
533-
string: ~str,
533+
string: StrBuf,
534534
array: Vec<int> ,
535535
}
536536

@@ -539,7 +539,7 @@ mod tests {
539539
let arena = TypedArena::new();
540540
for _ in range(0, 100000) {
541541
arena.alloc(Noncopy {
542-
string: "hello world".to_owned(),
542+
string: "hello world".to_strbuf(),
543543
array: vec!( 1, 2, 3, 4, 5 ),
544544
});
545545
}
@@ -550,7 +550,7 @@ mod tests {
550550
let arena = TypedArena::new();
551551
b.iter(|| {
552552
arena.alloc(Noncopy {
553-
string: "hello world".to_owned(),
553+
string: "hello world".to_strbuf(),
554554
array: vec!( 1, 2, 3, 4, 5 ),
555555
})
556556
})
@@ -560,7 +560,7 @@ mod tests {
560560
pub fn bench_noncopy_nonarena(b: &mut Bencher) {
561561
b.iter(|| {
562562
box Noncopy {
563-
string: "hello world".to_owned(),
563+
string: "hello world".to_strbuf(),
564564
array: vec!( 1, 2, 3, 4, 5 ),
565565
}
566566
})
@@ -571,7 +571,7 @@ mod tests {
571571
let arena = Arena::new();
572572
b.iter(|| {
573573
arena.alloc(|| Noncopy {
574-
string: "hello world".to_owned(),
574+
string: "hello world".to_strbuf(),
575575
array: vec!( 1, 2, 3, 4, 5 ),
576576
})
577577
})

src/libcollections/lru_cache.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -270,23 +270,23 @@ mod tests {
270270

271271
#[test]
272272
fn test_put_update() {
273-
let mut cache: LruCache<~str, Vec<u8>> = LruCache::new(1);
274-
cache.put("1".to_owned(), vec![10, 10]);
275-
cache.put("1".to_owned(), vec![10, 19]);
276-
assert_opt_eq(cache.get(&"1".to_owned()), vec![10, 19]);
273+
let mut cache: LruCache<StrBuf, Vec<u8>> = LruCache::new(1);
274+
cache.put("1".to_strbuf(), vec![10, 10]);
275+
cache.put("1".to_strbuf(), vec![10, 19]);
276+
assert_opt_eq(cache.get(&"1".to_strbuf()), vec![10, 19]);
277277
assert_eq!(cache.len(), 1);
278278
}
279279

280280
#[test]
281281
fn test_expire_lru() {
282-
let mut cache: LruCache<~str, ~str> = LruCache::new(2);
283-
cache.put("foo1".to_owned(), "bar1".to_owned());
284-
cache.put("foo2".to_owned(), "bar2".to_owned());
285-
cache.put("foo3".to_owned(), "bar3".to_owned());
286-
assert!(cache.get(&"foo1".to_owned()).is_none());
287-
cache.put("foo2".to_owned(), "bar2update".to_owned());
288-
cache.put("foo4".to_owned(), "bar4".to_owned());
289-
assert!(cache.get(&"foo3".to_owned()).is_none());
282+
let mut cache: LruCache<StrBuf, StrBuf> = LruCache::new(2);
283+
cache.put("foo1".to_strbuf(), "bar1".to_strbuf());
284+
cache.put("foo2".to_strbuf(), "bar2".to_strbuf());
285+
cache.put("foo3".to_strbuf(), "bar3".to_strbuf());
286+
assert!(cache.get(&"foo1".to_strbuf()).is_none());
287+
cache.put("foo2".to_strbuf(), "bar2update".to_strbuf());
288+
cache.put("foo4".to_strbuf(), "bar4".to_strbuf());
289+
assert!(cache.get(&"foo3".to_strbuf()).is_none());
290290
}
291291

292292
#[test]

src/libglob/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ impl Pattern {
310310
* brackets. The resulting string will, when compiled into a `Pattern`,
311311
* match the input string and nothing else.
312312
*/
313-
pub fn escape(s: &str) -> ~str {
313+
pub fn escape(s: &str) -> StrBuf {
314314
let mut escaped = StrBuf::new();
315315
for c in s.chars() {
316316
match c {
@@ -325,7 +325,7 @@ impl Pattern {
325325
}
326326
}
327327
}
328-
escaped.into_owned()
328+
escaped
329329
}
330330

331331
/**
@@ -767,8 +767,8 @@ mod test {
767767
#[test]
768768
fn test_pattern_escape() {
769769
let s = "_[_]_?_*_!_";
770-
assert_eq!(Pattern::escape(s), "_[[]_[]]_[?]_[*]_!_".to_owned());
771-
assert!(Pattern::new(Pattern::escape(s)).matches(s));
770+
assert_eq!(Pattern::escape(s), "_[[]_[]]_[?]_[*]_!_".to_strbuf());
771+
assert!(Pattern::new(Pattern::escape(s).as_slice()).matches(s));
772772
}
773773

774774
#[test]

src/libgraphviz/lib.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -433,10 +433,10 @@ impl<'a> LabelText<'a> {
433433
}
434434

435435
/// Renders text as string suitable for a label in a .dot file.
436-
pub fn escape(&self) -> ~str {
436+
pub fn escape(&self) -> StrBuf {
437437
match self {
438-
&LabelStr(ref s) => s.as_slice().escape_default(),
439-
&EscStr(ref s) => LabelText::escape_str(s.as_slice()).into_owned(),
438+
&LabelStr(ref s) => s.as_slice().escape_default().to_strbuf(),
439+
&EscStr(ref s) => LabelText::escape_str(s.as_slice()).to_strbuf(),
440440
}
441441
}
442442
}
@@ -661,11 +661,14 @@ mod tests {
661661
}
662662
}
663663

664-
fn test_input(g: LabelledGraph) -> IoResult<~str> {
664+
fn test_input(g: LabelledGraph) -> IoResult<StrBuf> {
665665
let mut writer = MemWriter::new();
666666
render(&g, &mut writer).unwrap();
667667
let mut r = BufReader::new(writer.get_ref());
668-
r.read_to_str()
668+
match r.read_to_str() {
669+
Ok(string) => Ok(string.to_strbuf()),
670+
Err(err) => Err(err),
671+
}
669672
}
670673

671674
// All of the tests use raw-strings as the format for the expected outputs,

src/libhexfloat/lib.rs

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,30 +70,39 @@ pub fn macro_registrar(register: |Name, SyntaxExtension|) {
7070

7171
//Check if the literal is valid (as LLVM expects),
7272
//and return a descriptive error if not.
73-
fn hex_float_lit_err(s: &str) -> Option<(uint, ~str)> {
73+
fn hex_float_lit_err(s: &str) -> Option<(uint, StrBuf)> {
7474
let mut chars = s.chars().peekable();
7575
let mut i = 0;
7676
if chars.peek() == Some(&'-') { chars.next(); i+= 1 }
77-
if chars.next() != Some('0') { return Some((i, "Expected '0'".to_owned())); } i+=1;
78-
if chars.next() != Some('x') { return Some((i, "Expected 'x'".to_owned())); } i+=1;
77+
if chars.next() != Some('0') {
78+
return Some((i, "Expected '0'".to_strbuf()));
79+
} i+=1;
80+
if chars.next() != Some('x') {
81+
return Some((i, "Expected 'x'".to_strbuf()));
82+
} i+=1;
7983
let mut d_len = 0;
8084
for _ in chars.take_while(|c| c.is_digit_radix(16)) { chars.next(); i+=1; d_len += 1;}
81-
if chars.next() != Some('.') { return Some((i, "Expected '.'".to_owned())); } i+=1;
85+
if chars.next() != Some('.') {
86+
return Some((i, "Expected '.'".to_strbuf()));
87+
} i+=1;
8288
let mut f_len = 0;
8389
for _ in chars.take_while(|c| c.is_digit_radix(16)) { chars.next(); i+=1; f_len += 1;}
8490
if d_len == 0 && f_len == 0 {
85-
return Some((i, "Expected digits before or after decimal point".to_owned()));
91+
return Some((i, "Expected digits before or after decimal \
92+
point".to_strbuf()));
8693
}
87-
if chars.next() != Some('p') { return Some((i, "Expected 'p'".to_owned())); } i+=1;
94+
if chars.next() != Some('p') {
95+
return Some((i, "Expected 'p'".to_strbuf()));
96+
} i+=1;
8897
if chars.peek() == Some(&'-') { chars.next(); i+= 1 }
8998
let mut e_len = 0;
9099
for _ in chars.take_while(|c| c.is_digit()) { chars.next(); i+=1; e_len += 1}
91100
if e_len == 0 {
92-
return Some((i, "Expected exponent digits".to_owned()));
101+
return Some((i, "Expected exponent digits".to_strbuf()));
93102
}
94103
match chars.next() {
95104
None => None,
96-
Some(_) => Some((i, "Expected end of string".to_owned()))
105+
Some(_) => Some((i, "Expected end of string".to_strbuf()))
97106
}
98107
}
99108

src/liblog/directive.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use std::cmp;
1313

1414
#[deriving(Show, Clone)]
1515
pub struct LogDirective {
16-
pub name: Option<~str>,
16+
pub name: Option<StrBuf>,
1717
pub level: u32,
1818
}
1919

@@ -64,7 +64,7 @@ pub fn parse_logging_spec(spec: &str) -> Vec<LogDirective> {
6464
}
6565
};
6666
dirs.push(LogDirective {
67-
name: name.map(|s| s.to_owned()),
67+
name: name.map(|s| s.to_strbuf()),
6868
level: log_level,
6969
});
7070
}
@@ -80,13 +80,13 @@ mod tests {
8080
let dirs = parse_logging_spec("crate1::mod1=1,crate1::mod2,crate2=4");
8181
let dirs = dirs.as_slice();
8282
assert_eq!(dirs.len(), 3);
83-
assert_eq!(dirs[0].name, Some("crate1::mod1".to_owned()));
83+
assert_eq!(dirs[0].name, Some("crate1::mod1".to_strbuf()));
8484
assert_eq!(dirs[0].level, 1);
8585

86-
assert_eq!(dirs[1].name, Some("crate1::mod2".to_owned()));
86+
assert_eq!(dirs[1].name, Some("crate1::mod2".to_strbuf()));
8787
assert_eq!(dirs[1].level, ::MAX_LOG_LEVEL);
8888

89-
assert_eq!(dirs[2].name, Some("crate2".to_owned()));
89+
assert_eq!(dirs[2].name, Some("crate2".to_strbuf()));
9090
assert_eq!(dirs[2].level, 4);
9191
}
9292

@@ -96,7 +96,7 @@ mod tests {
9696
let dirs = parse_logging_spec("crate1::mod1=1=2,crate2=4");
9797
let dirs = dirs.as_slice();
9898
assert_eq!(dirs.len(), 1);
99-
assert_eq!(dirs[0].name, Some("crate2".to_owned()));
99+
assert_eq!(dirs[0].name, Some("crate2".to_strbuf()));
100100
assert_eq!(dirs[0].level, 4);
101101
}
102102

@@ -106,7 +106,7 @@ mod tests {
106106
let dirs = parse_logging_spec("crate1::mod1=noNumber,crate2=4");
107107
let dirs = dirs.as_slice();
108108
assert_eq!(dirs.len(), 1);
109-
assert_eq!(dirs[0].name, Some("crate2".to_owned()));
109+
assert_eq!(dirs[0].name, Some("crate2".to_strbuf()));
110110
assert_eq!(dirs[0].level, 4);
111111
}
112112

@@ -116,7 +116,7 @@ mod tests {
116116
let dirs = parse_logging_spec("crate1::mod1=wrong,crate2=warn");
117117
let dirs = dirs.as_slice();
118118
assert_eq!(dirs.len(), 1);
119-
assert_eq!(dirs[0].name, Some("crate2".to_owned()));
119+
assert_eq!(dirs[0].name, Some("crate2".to_strbuf()));
120120
assert_eq!(dirs[0].level, ::WARN);
121121
}
122122

@@ -128,7 +128,7 @@ mod tests {
128128
assert_eq!(dirs.len(), 2);
129129
assert_eq!(dirs[0].name, None);
130130
assert_eq!(dirs[0].level, 2);
131-
assert_eq!(dirs[1].name, Some("crate2".to_owned()));
131+
assert_eq!(dirs[1].name, Some("crate2".to_strbuf()));
132132
assert_eq!(dirs[1].level, 4);
133133
}
134134
}

src/liblog/lib.rs

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ fn enabled(level: u32, module: &str,
307307
// Search for the longest match, the vector is assumed to be pre-sorted.
308308
for directive in iter.rev() {
309309
match directive.name {
310-
Some(ref name) if !module.starts_with(*name) => {},
310+
Some(ref name) if !module.starts_with(name.as_slice()) => {},
311311
Some(..) | None => {
312312
return level <= directive.level
313313
}
@@ -362,8 +362,16 @@ mod tests {
362362

363363
#[test]
364364
fn match_full_path() {
365-
let dirs = [LogDirective { name: Some("crate2".to_owned()), level: 3 },
366-
LogDirective { name: Some("crate1::mod1".to_owned()), level: 2 }];
365+
let dirs = [
366+
LogDirective {
367+
name: Some("crate2".to_strbuf()),
368+
level: 3
369+
},
370+
LogDirective {
371+
name: Some("crate1::mod1".to_strbuf()),
372+
level: 2
373+
}
374+
];
367375
assert!(enabled(2, "crate1::mod1", dirs.iter()));
368376
assert!(!enabled(3, "crate1::mod1", dirs.iter()));
369377
assert!(enabled(3, "crate2", dirs.iter()));
@@ -372,39 +380,49 @@ mod tests {
372380

373381
#[test]
374382
fn no_match() {
375-
let dirs = [LogDirective { name: Some("crate2".to_owned()), level: 3 },
376-
LogDirective { name: Some("crate1::mod1".to_owned()), level: 2 }];
383+
let dirs = [
384+
LogDirective { name: Some("crate2".to_strbuf()), level: 3 },
385+
LogDirective { name: Some("crate1::mod1".to_strbuf()), level: 2 }
386+
];
377387
assert!(!enabled(2, "crate3", dirs.iter()));
378388
}
379389

380390
#[test]
381391
fn match_beginning() {
382-
let dirs = [LogDirective { name: Some("crate2".to_owned()), level: 3 },
383-
LogDirective { name: Some("crate1::mod1".to_owned()), level: 2 }];
392+
let dirs = [
393+
LogDirective { name: Some("crate2".to_strbuf()), level: 3 },
394+
LogDirective { name: Some("crate1::mod1".to_strbuf()), level: 2 }
395+
];
384396
assert!(enabled(3, "crate2::mod1", dirs.iter()));
385397
}
386398

387399
#[test]
388400
fn match_beginning_longest_match() {
389-
let dirs = [LogDirective { name: Some("crate2".to_owned()), level: 3 },
390-
LogDirective { name: Some("crate2::mod".to_owned()), level: 4 },
391-
LogDirective { name: Some("crate1::mod1".to_owned()), level: 2 }];
401+
let dirs = [
402+
LogDirective { name: Some("crate2".to_strbuf()), level: 3 },
403+
LogDirective { name: Some("crate2::mod".to_strbuf()), level: 4 },
404+
LogDirective { name: Some("crate1::mod1".to_strbuf()), level: 2 }
405+
];
392406
assert!(enabled(4, "crate2::mod1", dirs.iter()));
393407
assert!(!enabled(4, "crate2", dirs.iter()));
394408
}
395409

396410
#[test]
397411
fn match_default() {
398-
let dirs = [LogDirective { name: None, level: 3 },
399-
LogDirective { name: Some("crate1::mod1".to_owned()), level: 2 }];
412+
let dirs = [
413+
LogDirective { name: None, level: 3 },
414+
LogDirective { name: Some("crate1::mod1".to_strbuf()), level: 2 }
415+
];
400416
assert!(enabled(2, "crate1::mod1", dirs.iter()));
401417
assert!(enabled(3, "crate2::mod2", dirs.iter()));
402418
}
403419

404420
#[test]
405421
fn zero_level() {
406-
let dirs = [LogDirective { name: None, level: 3 },
407-
LogDirective { name: Some("crate1::mod1".to_owned()), level: 0 }];
422+
let dirs = [
423+
LogDirective { name: None, level: 3 },
424+
LogDirective { name: Some("crate1::mod1".to_strbuf()), level: 0 }
425+
];
408426
assert!(!enabled(1, "crate1::mod1", dirs.iter()));
409427
assert!(enabled(3, "crate2::mod2", dirs.iter()));
410428
}

0 commit comments

Comments
 (0)