Skip to content

Commit c8dd2d0

Browse files
committed
Addressed PR comments
1 parent a641996 commit c8dd2d0

File tree

18 files changed

+233
-86
lines changed

18 files changed

+233
-86
lines changed

src/compiletest/compiletest.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#![feature(env)]
2424
#![feature(core)]
2525

26-
// #![deny(warnings)]
26+
#![deny(warnings)]
2727

2828
extern crate test;
2929
extern crate getopts;

src/compiletest/errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ pub fn load_errors(testfile: &Path) -> Vec<ExpectedError> {
5858
fn parse_expected(last_nonfollow_error: Option<uint>,
5959
line_num: uint,
6060
line: &str) -> Option<(WhichLine, ExpectedError)> {
61-
let start = match line.find_str("//~") { Some(i) => i, None => return None };
61+
let start = match line.find("//~") { Some(i) => i, None => return None };
6262
let (follow, adjusts) = if line.char_at(start + 3) == '|' {
6363
(true, 0)
6464
} else {

src/compiletest/header.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ fn parse_name_directive(line: &str, directive: &str) -> bool {
330330
pub fn parse_name_value_directive(line: &str, directive: &str)
331331
-> Option<String> {
332332
let keycolon = format!("{}:", directive);
333-
match line.find_str(&keycolon) {
333+
match line.find(&keycolon) {
334334
Some(colon) => {
335335
let value = line[(colon + keycolon.len()) .. line.len()].to_string();
336336
debug!("{}: {}", directive, value);

src/compiletest/runtest.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -847,7 +847,7 @@ fn check_debugger_output(debugger_run_result: &ProcRes, check_lines: &[String])
847847
check_lines.iter().map(|s| {
848848
s
849849
.trim()
850-
.split_str("[...]")
850+
.split("[...]")
851851
.map(|x| x.to_string())
852852
.collect()
853853
}).collect();
@@ -866,7 +866,7 @@ fn check_debugger_output(debugger_run_result: &ProcRes, check_lines: &[String])
866866
None
867867
}
868868
} else {
869-
rest.find_str(frag)
869+
rest.find(frag)
870870
};
871871
match found {
872872
None => {

src/libcollections/str.rs

+17-11
Original file line numberDiff line numberDiff line change
@@ -547,8 +547,8 @@ pub trait StrExt: Index<RangeFull, Output = str> {
547547
/// ```rust
548548
/// assert!("hello".contains_char('e'));
549549
/// ```
550-
#[unstable(feature = "collections",
551-
reason = "might get removed in favour of a more generic contains()")]
550+
#[unstable(feature = "collections")]
551+
#[deprecated(since = "1.0.0", reason = "use `contains()` with a char")]
552552
fn contains_char<'a, P: Pattern<'a>>(&'a self, pat: P) -> bool {
553553
core_str::StrExt::contains_char(&self[..], pat)
554554
}
@@ -660,7 +660,7 @@ pub trait StrExt: Index<RangeFull, Output = str> {
660660
/// let v: Vec<&str> = "lionXXtigerXleopard".split('X').rev().collect();
661661
/// assert_eq!(v, vec!["leopard", "tiger", "", "lion"]);
662662
/// ```
663-
#[unstable(feature = "collections", reason = "might get removed")]
663+
#[stable(feature = "rust1", since = "1.0.0")]
664664
fn split_terminator<'a, P: Pattern<'a>>(&'a self, pat: P) -> SplitTerminator<'a, P> {
665665
core_str::StrExt::split_terminator(&self[..], pat)
666666
}
@@ -708,6 +708,8 @@ pub trait StrExt: Index<RangeFull, Output = str> {
708708
/// ```
709709
#[unstable(feature = "collections",
710710
reason = "might have its iterator type changed")]
711+
// NB: Right now MatchIndices yields `(usize, usize)`,
712+
// but it would be more consistent and useful to return `(usize, &str)`
711713
fn match_indices<'a, P: Pattern<'a>>(&'a self, pat: P) -> MatchIndices<'a, P> {
712714
core_str::StrExt::match_indices(&self[..], pat)
713715
}
@@ -723,8 +725,8 @@ pub trait StrExt: Index<RangeFull, Output = str> {
723725
/// let v: Vec<&str> = "1abcabc2".split_str("abc").collect();
724726
/// assert_eq!(v, vec!["1", "", "2"]);
725727
/// ```
726-
#[unstable(feature = "collections",
727-
reason = "might get removed in the future in favor of a more generic split()")]
728+
#[unstable(feature = "collections")]
729+
#[deprecated(since = "1.0.0", reason = "use `split()` with a `&str`")]
728730
fn split_str<'a, P: Pattern<'a>>(&'a self, pat: P) -> SplitStr<'a, P> {
729731
core_str::StrExt::split_str(&self[..], pat)
730732
}
@@ -840,7 +842,8 @@ pub trait StrExt: Index<RangeFull, Output = str> {
840842
/// ```
841843
#[stable(feature = "rust1", since = "1.0.0")]
842844
fn ends_with<'a, P: Pattern<'a>>(&'a self, pat: P) -> bool
843-
where P::Searcher: ReverseSearcher<'a> {
845+
where P::Searcher: ReverseSearcher<'a>
846+
{
844847
core_str::StrExt::ends_with(&self[..], pat)
845848
}
846849

@@ -861,7 +864,8 @@ pub trait StrExt: Index<RangeFull, Output = str> {
861864
/// ```
862865
#[stable(feature = "rust1", since = "1.0.0")]
863866
fn trim_matches<'a, P: Pattern<'a>>(&'a self, pat: P) -> &'a str
864-
where P::Searcher: DoubleEndedSearcher<'a> {
867+
where P::Searcher: DoubleEndedSearcher<'a>
868+
{
865869
core_str::StrExt::trim_matches(&self[..], pat)
866870
}
867871

@@ -902,7 +906,8 @@ pub trait StrExt: Index<RangeFull, Output = str> {
902906
/// ```
903907
#[stable(feature = "rust1", since = "1.0.0")]
904908
fn trim_right_matches<'a, P: Pattern<'a>>(&'a self, pat: P) -> &'a str
905-
where P::Searcher: ReverseSearcher<'a> {
909+
where P::Searcher: ReverseSearcher<'a>
910+
{
906911
core_str::StrExt::trim_right_matches(&self[..], pat)
907912
}
908913

@@ -1108,7 +1113,8 @@ pub trait StrExt: Index<RangeFull, Output = str> {
11081113
/// ```
11091114
#[stable(feature = "rust1", since = "1.0.0")]
11101115
fn rfind<'a, P: Pattern<'a>>(&'a self, pat: P) -> Option<usize>
1111-
where P::Searcher: ReverseSearcher<'a> {
1116+
where P::Searcher: ReverseSearcher<'a>
1117+
{
11121118
core_str::StrExt::rfind(&self[..], pat)
11131119
}
11141120

@@ -1131,8 +1137,8 @@ pub trait StrExt: Index<RangeFull, Output = str> {
11311137
/// assert_eq!(s.find_str("老虎 L"), Some(6));
11321138
/// assert_eq!(s.find_str("muffin man"), None);
11331139
/// ```
1134-
#[unstable(feature = "collections",
1135-
reason = "might get removed in favor of a more generic find in the future")]
1140+
#[unstable(feature = "collections")]
1141+
#[deprecated(since = "1.0.0", reason = "use `find()` with a `&str`")]
11361142
fn find_str<'a, P: Pattern<'a>>(&'a self, needle: P) -> Option<usize> {
11371143
core_str::StrExt::find_str(&self[..], needle)
11381144
}

src/libcore/str/mod.rs

+28-12
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,10 @@ pub unsafe fn from_c_str(s: *const i8) -> &'static str {
242242
}
243243

244244
/// Something that can be used to compare against a character
245-
#[unstable(feature = "core",
246-
reason = "definition may change as pattern-related methods are stabilized")]
245+
#[unstable(feature = "core")]
246+
#[deprecated(since = "1.0.0",
247+
reason = "use `Pattern` instead")]
248+
// NB: Rather than removing it, make it private and move it into self::pattern
247249
pub trait CharEq {
248250
/// Determine if the splitter should split at the given character
249251
fn matches(&mut self, char) -> bool;
@@ -252,6 +254,7 @@ pub trait CharEq {
252254
fn only_ascii(&self) -> bool;
253255
}
254256

257+
#[allow(deprecated) /* for CharEq */ ]
255258
impl CharEq for char {
256259
#[inline]
257260
fn matches(&mut self, c: char) -> bool { *self == c }
@@ -260,6 +263,7 @@ impl CharEq for char {
260263
fn only_ascii(&self) -> bool { (*self as u32) < 128 }
261264
}
262265

266+
#[allow(deprecated) /* for CharEq */ ]
263267
impl<F> CharEq for F where F: FnMut(char) -> bool {
264268
#[inline]
265269
fn matches(&mut self, c: char) -> bool { (*self)(c) }
@@ -268,13 +272,16 @@ impl<F> CharEq for F where F: FnMut(char) -> bool {
268272
fn only_ascii(&self) -> bool { false }
269273
}
270274

275+
#[allow(deprecated) /* for CharEq */ ]
271276
impl<'a> CharEq for &'a [char] {
272277
#[inline]
278+
#[allow(deprecated) /* for CharEq */ ]
273279
fn matches(&mut self, c: char) -> bool {
274280
self.iter().any(|&m| { let mut m = m; m.matches(c) })
275281
}
276282

277283
#[inline]
284+
#[allow(deprecated) /* for CharEq */ ]
278285
fn only_ascii(&self) -> bool {
279286
self.iter().all(|m| m.only_ascii())
280287
}
@@ -764,7 +771,7 @@ impl TwoWaySearcher {
764771
// that (u, v) is a critical factorization for the needle.
765772
#[inline]
766773
fn next(&mut self, haystack: &[u8], needle: &[u8], long_period: bool)
767-
-> Option<(usize, usize)> {
774+
-> Option<(usize, usize)> {
768775
'search: loop {
769776
// Check that we have room to search in
770777
if self.position + needle.len() > haystack.len() {
@@ -866,6 +873,8 @@ impl TwoWaySearcher {
866873
/// The internal state of an iterator that searches for matches of a substring
867874
/// within a larger string using a dynamically chosen search algorithm
868875
#[derive(Clone)]
876+
// NB: This is kept around for convenience because
877+
// it is planned to be used again in the future
869878
enum OldSearcher {
870879
TwoWay(TwoWaySearcher),
871880
TwoWayLong(TwoWaySearcher),
@@ -896,6 +905,8 @@ impl OldSearcher {
896905
}
897906

898907
#[derive(Clone)]
908+
// NB: This is kept around for convenience because
909+
// it is planned to be used again in the future
899910
struct OldMatchIndices<'a, 'b> {
900911
// constants
901912
haystack: &'a str,
@@ -921,7 +932,8 @@ impl<'a, P: Pattern<'a>> Iterator for MatchIndices<'a, P> {
921932

922933
/// An iterator over the substrings of a string separated by a given
923934
/// search string
924-
#[unstable(feature = "core", reason = "type may be removed")]
935+
#[unstable(feature = "core")]
936+
#[deprecated(since = "1.0.0", reason = "use `Split` with a `&str`")]
925937
pub struct SplitStr<'a, P: Pattern<'a>>(Split<'a, P>);
926938
impl<'a, P: Pattern<'a>> Iterator for SplitStr<'a, P> {
927939
type Item = &'a str;
@@ -1282,8 +1294,7 @@ where P::Searcher: DoubleEndedSearcher<'a> {
12821294
}
12831295

12841296
/// Return type of `StrExt::split_terminator`
1285-
#[unstable(feature = "core",
1286-
reason = "might get removed in favour of a constructor method on Split")]
1297+
#[stable(feature = "rust1", since = "1.0.0")]
12871298
pub struct SplitTerminator<'a, P: Pattern<'a>>(CharSplits<'a, P>);
12881299
delegate_iter!{pattern &'a str : SplitTerminator<'a, P>}
12891300

@@ -1421,6 +1432,7 @@ impl StrExt for str {
14211432
}
14221433

14231434
#[inline]
1435+
#[allow(deprecated) /* for SplitStr */ ]
14241436
fn split_str<'a, P: Pattern<'a>>(&'a self, pat: P) -> SplitStr<'a, P> {
14251437
SplitStr(self.split(pat))
14261438
}
@@ -1477,18 +1489,20 @@ impl StrExt for str {
14771489

14781490
#[inline]
14791491
fn starts_with<'a, P: Pattern<'a>>(&'a self, pat: P) -> bool {
1480-
pat.match_starts_at(self, 0)
1492+
pat.is_prefix_of(self)
14811493
}
14821494

14831495
#[inline]
14841496
fn ends_with<'a, P: Pattern<'a>>(&'a self, pat: P) -> bool
1485-
where P::Searcher: ReverseSearcher<'a> {
1486-
pat.match_ends_at(self, self.len())
1497+
where P::Searcher: ReverseSearcher<'a>
1498+
{
1499+
pat.is_suffix_of(self)
14871500
}
14881501

14891502
#[inline]
14901503
fn trim_matches<'a, P: Pattern<'a>>(&'a self, pat: P) -> &'a str
1491-
where P::Searcher: DoubleEndedSearcher<'a> {
1504+
where P::Searcher: DoubleEndedSearcher<'a>
1505+
{
14921506
let mut i = 0;
14931507
let mut j = 0;
14941508
let mut matcher = pat.into_searcher(self);
@@ -1521,7 +1535,8 @@ impl StrExt for str {
15211535

15221536
#[inline]
15231537
fn trim_right_matches<'a, P: Pattern<'a>>(&'a self, pat: P) -> &'a str
1524-
where P::Searcher: ReverseSearcher<'a> {
1538+
where P::Searcher: ReverseSearcher<'a>
1539+
{
15251540
let mut j = 0;
15261541
let mut matcher = pat.into_searcher(self);
15271542
if let Some((_, b)) = matcher.next_reject_back() {
@@ -1599,7 +1614,8 @@ impl StrExt for str {
15991614
}
16001615

16011616
fn rfind<'a, P: Pattern<'a>>(&'a self, pat: P) -> Option<usize>
1602-
where P::Searcher: ReverseSearcher<'a> {
1617+
where P::Searcher: ReverseSearcher<'a>
1618+
{
16031619
pat.into_searcher(self).next_match_back().map(|(i, _)| i)
16041620
}
16051621

0 commit comments

Comments
 (0)