Skip to content

Commit 457da90

Browse files
committed
---
yaml --- r: 223839 b: refs/heads/beta c: 137a699 h: refs/heads/master i: 223837: eb78f94 223835: 6c93bda 223831: af15de7 223823: ea954f3 223807: c7af9a6 v: v3
1 parent d266196 commit 457da90

File tree

16 files changed

+308
-41
lines changed

16 files changed

+308
-41
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ refs/tags/0.9: 36870b185fc5f5486636d4515f0e22677493f225
2323
refs/tags/0.10: ac33f2b15782272ae348dbd7b14b8257b2148b5a
2424
refs/tags/0.11.0: e1247cb1d0d681be034adb4b558b5a0c0d5720f9
2525
refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
26-
refs/heads/beta: d673bdef0f6902bed833d66c9817930e4e4c83bd
26+
refs/heads/beta: 137a699cc3a03e90f9e2aa04a7b163e7776706db
2727
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
2828
refs/heads/tmp: 938f5d7af401e2d8238522fed4a612943b6e77fd
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f

branches/beta/AUTHORS.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -958,7 +958,7 @@ Santiago Rodriguez <[email protected]>
958958
Saurabh Anand <[email protected]>
959959
Scott Jenkins <[email protected]>
960960
Scott Lawrence <[email protected]>
961-
Scott Olson <scott@scott-olson.org>
961+
Scott Olson <scott@solson.me>
962962
Sean Bowe <[email protected]>
963963
Sean Chalmers <[email protected]>
964964
Sean Collins <[email protected]>

branches/beta/configure

Lines changed: 38 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -988,29 +988,44 @@ if [ ! -z "$CFG_ENABLE_CLANG" ]
988988
then
989989
case "$CC" in
990990
(''|*clang)
991-
CFG_CLANG_VERSION=$($CFG_CC \
992-
--version \
993-
| grep version \
994-
| sed 's/.*\(version .*\)/\1/; s/.*based on \(LLVM .*\))/\1/' \
995-
| cut -d ' ' -f 2)
996-
997-
case $CFG_CLANG_VERSION in
998-
(3.2* | 3.3* | 3.4* | 3.5* | 3.6* | 3.7*)
999-
step_msg "found ok version of CLANG: $CFG_CLANG_VERSION"
1000-
if [ -z "$CC" ]
1001-
then
1002-
CFG_CC="clang"
1003-
CFG_CXX="clang++"
1004-
fi
1005-
;;
1006-
(*)
1007-
err "bad CLANG version: $CFG_CLANG_VERSION, need >=3.0svn"
1008-
;;
1009-
esac
1010-
;;
1011-
(*)
1012-
msg "skipping CFG_ENABLE_CLANG version check; provided CC=$CC"
1013-
;;
991+
CFG_CLANG_REPORTED_VERSION=$($CFG_CC --version | grep version)
992+
993+
if [[ $CFG_CLANG_REPORTED_VERSION == *"(based on LLVM "* ]]
994+
then
995+
CFG_CLANG_VERSION=$(echo $CFG_CLANG_REPORTED_VERSION | sed 's/.*(based on LLVM \(.*\))/\1/')
996+
elif [[ $CFG_CLANG_REPORTED_VERSION == "Apple LLVM"* ]]
997+
then
998+
CFG_OSX_CLANG_VERSION=$(echo $CFG_CLANG_REPORTED_VERSION | sed 's/.*version \(.*\) .*/\1/')
999+
else
1000+
CFG_CLANG_VERSION=$(echo $CFG_CLANG_REPORTED_VERSION | sed 's/.*version \(.*\) .*/\1/')
1001+
fi
1002+
1003+
if [ ! -z "$CFG_OSX_CLANG_VERSION" ]
1004+
then
1005+
case $CFG_OSX_CLANG_VERSION in
1006+
(7.0*)
1007+
step_msg "found ok version of APPLE CLANG: $CFG_OSX_CLANG_VERSION"
1008+
;;
1009+
(*)
1010+
err "bad APPLE CLANG version: $CFG_OSX_CLANG_VERSION, need >=7.0"
1011+
;;
1012+
esac
1013+
else
1014+
case $CFG_CLANG_VERSION in
1015+
(3.2* | 3.3* | 3.4* | 3.5* | 3.6* | 3.7*)
1016+
step_msg "found ok version of CLANG: $CFG_CLANG_VERSION"
1017+
;;
1018+
(*)
1019+
err "bad CLANG version: $CFG_CLANG_VERSION, need >=3.0svn"
1020+
;;
1021+
esac
1022+
fi
1023+
1024+
if [ -z "$CC" ]
1025+
then
1026+
CFG_CC="clang"
1027+
CFG_CXX="clang++"
1028+
fi
10141029
esac
10151030
fi
10161031

branches/beta/src/etc/errorck.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,18 @@
2323
errcode_map = {}
2424
error_re = re.compile("(E\d\d\d\d)")
2525

26+
# In the register_long_diagnostics! macro, entries look like this:
27+
#
28+
# EXXXX: r##"
29+
# <Long diagnostic message>
30+
# "##,
31+
#
32+
# These two variables are for detecting the beginning and end of diagnostic
33+
# messages so that duplicate error codes are not reported when a code occurs
34+
# inside a diagnostic message
35+
long_diag_begin = "r##\""
36+
long_diag_end = "\"##"
37+
2638
for (dirpath, dirnames, filenames) in os.walk(src_dir):
2739
if "src/test" in dirpath or "src/llvm" in dirpath:
2840
# Short circuit for fast
@@ -35,7 +47,14 @@
3547
path = os.path.join(dirpath, filename)
3648

3749
with open(path, 'r') as f:
50+
inside_long_diag = False
3851
for line_num, line in enumerate(f, start=1):
52+
if inside_long_diag:
53+
# Skip duplicate error code checking for this line
54+
if long_diag_end in line:
55+
inside_long_diag = False
56+
continue
57+
3958
match = error_re.search(line)
4059
if match:
4160
errcode = match.group(1)
@@ -47,6 +66,9 @@
4766
else:
4867
errcode_map[errcode] = new_record
4968

69+
if long_diag_begin in line:
70+
inside_long_diag = True
71+
5072
errors = False
5173
all_errors = []
5274

branches/beta/src/libcollections/str.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,14 @@ impl str {
550550
core_str::StrExt::slice_unchecked(self, begin, end)
551551
}
552552

553+
/// Takes a bytewise mutable slice from a string.
554+
///
555+
/// Same as `slice_unchecked`, but works with `&mut str` instead of `&str`.
556+
#[unstable(feature = "str_slice_mut", reason = "recently added")]
557+
pub unsafe fn slice_mut_unchecked(&mut self, begin: usize, end: usize) -> &mut str {
558+
core_str::StrExt::slice_mut_unchecked(self, begin, end)
559+
}
560+
553561
/// Returns a slice of the string from the character range [`begin`..`end`).
554562
///
555563
/// That is, start at the `begin`-th code point of the string and continue
@@ -776,7 +784,7 @@ impl str {
776784
///
777785
/// # Examples
778786
/// ```
779-
/// # #![feature(collections)]
787+
/// # #![feature(str_split_at)]
780788
/// let s = "Löwe 老虎 Léopard";
781789
/// let first_space = s.find(' ').unwrap_or(s.len());
782790
/// let (a, b) = s.split_at(first_space);
@@ -785,10 +793,18 @@ impl str {
785793
/// assert_eq!(b, " 老虎 Léopard");
786794
/// ```
787795
#[inline]
796+
#[unstable(feature = "str_split_at", reason = "recently added")]
788797
pub fn split_at(&self, mid: usize) -> (&str, &str) {
789798
core_str::StrExt::split_at(self, mid)
790799
}
791800

801+
/// Divide one mutable string slice into two at an index.
802+
#[inline]
803+
#[unstable(feature = "str_split_at", reason = "recently added")]
804+
pub fn split_at_mut(&mut self, mid: usize) -> (&mut str, &mut str) {
805+
core_str::StrExt::split_at_mut(self, mid)
806+
}
807+
792808
/// An iterator over the codepoints of `self`.
793809
///
794810
/// # Examples

branches/beta/src/libcollections/string.rs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -979,6 +979,38 @@ impl ops::Index<ops::RangeFull> for String {
979979
}
980980
}
981981

982+
#[cfg(not(stage0))]
983+
#[stable(feature = "derefmut_for_string", since = "1.2.0")]
984+
impl ops::IndexMut<ops::Range<usize>> for String {
985+
#[inline]
986+
fn index_mut(&mut self, index: ops::Range<usize>) -> &mut str {
987+
&mut self[..][index]
988+
}
989+
}
990+
#[cfg(not(stage0))]
991+
#[stable(feature = "derefmut_for_string", since = "1.2.0")]
992+
impl ops::IndexMut<ops::RangeTo<usize>> for String {
993+
#[inline]
994+
fn index_mut(&mut self, index: ops::RangeTo<usize>) -> &mut str {
995+
&mut self[..][index]
996+
}
997+
}
998+
#[cfg(not(stage0))]
999+
#[stable(feature = "derefmut_for_string", since = "1.2.0")]
1000+
impl ops::IndexMut<ops::RangeFrom<usize>> for String {
1001+
#[inline]
1002+
fn index_mut(&mut self, index: ops::RangeFrom<usize>) -> &mut str {
1003+
&mut self[..][index]
1004+
}
1005+
}
1006+
#[stable(feature = "derefmut_for_string", since = "1.2.0")]
1007+
impl ops::IndexMut<ops::RangeFull> for String {
1008+
#[inline]
1009+
fn index_mut(&mut self, _index: ops::RangeFull) -> &mut str {
1010+
unsafe { mem::transmute(&mut *self.vec) }
1011+
}
1012+
}
1013+
9821014
#[stable(feature = "rust1", since = "1.0.0")]
9831015
impl ops::Deref for String {
9841016
type Target = str;
@@ -989,6 +1021,14 @@ impl ops::Deref for String {
9891021
}
9901022
}
9911023

1024+
#[stable(feature = "derefmut_for_string", since = "1.2.0")]
1025+
impl ops::DerefMut for String {
1026+
#[inline]
1027+
fn deref_mut(&mut self) -> &mut str {
1028+
unsafe { mem::transmute(&mut self.vec[..]) }
1029+
}
1030+
}
1031+
9921032
/// Wrapper type providing a `&String` reference via `Deref`.
9931033
#[unstable(feature = "collections")]
9941034
#[deprecated(since = "1.2.0",

branches/beta/src/libcollectionstest/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![feature(ascii)]
1112
#![feature(append)]
1213
#![feature(bitset)]
1314
#![feature(bitvec)]
@@ -43,6 +44,7 @@
4344
#![feature(str_char)]
4445
#![feature(str_escape)]
4546
#![feature(str_match_indices)]
47+
#![feature(str_split_at)]
4648
#![feature(str_utf16)]
4749
#![feature(box_str)]
4850
#![feature(subslice_offset)]

branches/beta/src/libcollectionstest/str.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,18 @@ fn test_split_at() {
701701
assert_eq!(b, "");
702702
}
703703

704+
#[test]
705+
fn test_split_at_mut() {
706+
use std::ascii::AsciiExt;
707+
let mut s = "Hello World".to_string();
708+
{
709+
let (a, b) = s.split_at_mut(5);
710+
a.make_ascii_uppercase();
711+
b.make_ascii_lowercase();
712+
}
713+
assert_eq!(s, "HELLO world");
714+
}
715+
704716
#[test]
705717
#[should_panic]
706718
fn test_split_at_boundscheck() {

branches/beta/src/libcore/str/mod.rs

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,6 +1116,23 @@ mod traits {
11161116
}
11171117
}
11181118

1119+
/// Returns a mutable slice of the given string from the byte range
1120+
/// [`begin`..`end`).
1121+
#[stable(feature = "derefmut_for_string", since = "1.2.0")]
1122+
impl ops::IndexMut<ops::Range<usize>> for str {
1123+
#[inline]
1124+
fn index_mut(&mut self, index: ops::Range<usize>) -> &mut str {
1125+
// is_char_boundary checks that the index is in [0, .len()]
1126+
if index.start <= index.end &&
1127+
self.is_char_boundary(index.start) &&
1128+
self.is_char_boundary(index.end) {
1129+
unsafe { self.slice_mut_unchecked(index.start, index.end) }
1130+
} else {
1131+
super::slice_error_fail(self, index.start, index.end)
1132+
}
1133+
}
1134+
}
1135+
11191136
/// Returns a slice of the string from the beginning to byte
11201137
/// `end`.
11211138
///
@@ -1138,6 +1155,21 @@ mod traits {
11381155
}
11391156
}
11401157

1158+
/// Returns a mutable slice of the string from the beginning to byte
1159+
/// `end`.
1160+
#[stable(feature = "derefmut_for_string", since = "1.2.0")]
1161+
impl ops::IndexMut<ops::RangeTo<usize>> for str {
1162+
#[inline]
1163+
fn index_mut(&mut self, index: ops::RangeTo<usize>) -> &mut str {
1164+
// is_char_boundary checks that the index is in [0, .len()]
1165+
if self.is_char_boundary(index.end) {
1166+
unsafe { self.slice_mut_unchecked(0, index.end) }
1167+
} else {
1168+
super::slice_error_fail(self, 0, index.end)
1169+
}
1170+
}
1171+
}
1172+
11411173
/// Returns a slice of the string from `begin` to its end.
11421174
///
11431175
/// Equivalent to `self[begin .. self.len()]`.
@@ -1159,6 +1191,21 @@ mod traits {
11591191
}
11601192
}
11611193

1194+
/// Returns a slice of the string from `begin` to its end.
1195+
#[stable(feature = "derefmut_for_string", since = "1.2.0")]
1196+
impl ops::IndexMut<ops::RangeFrom<usize>> for str {
1197+
#[inline]
1198+
fn index_mut(&mut self, index: ops::RangeFrom<usize>) -> &mut str {
1199+
// is_char_boundary checks that the index is in [0, .len()]
1200+
if self.is_char_boundary(index.start) {
1201+
let len = self.len();
1202+
unsafe { self.slice_mut_unchecked(index.start, len) }
1203+
} else {
1204+
super::slice_error_fail(self, index.start, self.len())
1205+
}
1206+
}
1207+
}
1208+
11621209
#[stable(feature = "rust1", since = "1.0.0")]
11631210
impl ops::Index<ops::RangeFull> for str {
11641211
type Output = str;
@@ -1168,6 +1215,14 @@ mod traits {
11681215
self
11691216
}
11701217
}
1218+
1219+
#[stable(feature = "derefmut_for_string", since = "1.2.0")]
1220+
impl ops::IndexMut<ops::RangeFull> for str {
1221+
#[inline]
1222+
fn index_mut(&mut self, _index: ops::RangeFull) -> &mut str {
1223+
self
1224+
}
1225+
}
11711226
}
11721227

11731228
/// Methods for string slices
@@ -1204,6 +1259,7 @@ pub trait StrExt {
12041259
fn char_len(&self) -> usize;
12051260
fn slice_chars<'a>(&'a self, begin: usize, end: usize) -> &'a str;
12061261
unsafe fn slice_unchecked<'a>(&'a self, begin: usize, end: usize) -> &'a str;
1262+
unsafe fn slice_mut_unchecked<'a>(&'a mut self, begin: usize, end: usize) -> &'a mut str;
12071263
fn starts_with<'a, P: Pattern<'a>>(&'a self, pat: P) -> bool;
12081264
fn ends_with<'a, P: Pattern<'a>>(&'a self, pat: P) -> bool
12091265
where P::Searcher: ReverseSearcher<'a>;
@@ -1223,6 +1279,7 @@ pub trait StrExt {
12231279
where P::Searcher: ReverseSearcher<'a>;
12241280
fn find_str<'a, P: Pattern<'a>>(&'a self, pat: P) -> Option<usize>;
12251281
fn split_at(&self, mid: usize) -> (&str, &str);
1282+
fn split_at_mut(&mut self, mid: usize) -> (&mut str, &mut str);
12261283
fn slice_shift_char<'a>(&'a self) -> Option<(char, &'a str)>;
12271284
fn subslice_offset(&self, inner: &str) -> usize;
12281285
fn as_ptr(&self) -> *const u8;
@@ -1379,6 +1436,14 @@ impl StrExt for str {
13791436
})
13801437
}
13811438

1439+
#[inline]
1440+
unsafe fn slice_mut_unchecked(&mut self, begin: usize, end: usize) -> &mut str {
1441+
mem::transmute(Slice {
1442+
data: self.as_ptr().offset(begin as isize),
1443+
len: end - begin,
1444+
})
1445+
}
1446+
13821447
#[inline]
13831448
fn starts_with<'a, P: Pattern<'a>>(&'a self, pat: P) -> bool {
13841449
pat.is_prefix_of(self)
@@ -1527,6 +1592,20 @@ impl StrExt for str {
15271592
}
15281593
}
15291594

1595+
fn split_at_mut(&mut self, mid: usize) -> (&mut str, &mut str) {
1596+
// is_char_boundary checks that the index is in [0, .len()]
1597+
if self.is_char_boundary(mid) {
1598+
let len = self.len();
1599+
unsafe {
1600+
let self2: &mut str = mem::transmute_copy(&self);
1601+
(self.slice_mut_unchecked(0, mid),
1602+
self2.slice_mut_unchecked(mid, len))
1603+
}
1604+
} else {
1605+
slice_error_fail(self, 0, mid)
1606+
}
1607+
}
1608+
15301609
#[inline]
15311610
fn slice_shift_char(&self) -> Option<(char, &str)> {
15321611
if self.is_empty() {

0 commit comments

Comments
 (0)