Skip to content

Commit 8398c50

Browse files
committed
---
yaml --- r: 162590 b: refs/heads/try c: f5b795d h: refs/heads/master v: v3
1 parent 9913b3f commit 8398c50

File tree

34 files changed

+175
-425
lines changed

34 files changed

+175
-425
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 9146a919b616e39e528e4d7100d16eef52f1f852
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: cafe2966770ff377aad6dd9fd808e68055587c58
5-
refs/heads/try: 48ca6d1840818e4a8977d00ed62cf0e8e0e5d193
5+
refs/heads/try: f5b795dc82edb4488bf237b470a68fcfec505bac
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
88
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

branches/try/src/compiletest/errors.rs

Lines changed: 56 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
10+
use self::WhichLine::*;
1011

1112
use std::ascii::AsciiExt;
1213
use std::io::{BufferedReader, File};
@@ -18,28 +19,74 @@ pub struct ExpectedError {
1819
pub msg: String,
1920
}
2021

21-
pub static EXPECTED_PATTERN : &'static str = r"//~(?P<adjusts>\^*)\s*(?P<kind>\S*)\s*(?P<msg>.*)";
22+
/// Looks for either "//~| KIND MESSAGE" or "//~^^... KIND MESSAGE"
23+
/// The former is a "follow" that inherits its target from the preceding line;
24+
/// the latter is an "adjusts" that goes that many lines up.
25+
///
26+
/// Goal is to enable tests both like: //~^^^ ERROR go up three
27+
/// and also //~^ ERROR message one for the preceding line, and
28+
/// //~| ERROR message two for that same line.
29+
30+
pub static EXPECTED_PATTERN : &'static str =
31+
r"//~(?P<follow>\|)?(?P<adjusts>\^*)\s*(?P<kind>\S*)\s*(?P<msg>.*)";
32+
33+
#[deriving(PartialEq, Show)]
34+
enum WhichLine { ThisLine, FollowPrevious(uint), AdjustBackward(uint) }
2235

2336
// Load any test directives embedded in the file
2437
pub fn load_errors(re: &Regex, testfile: &Path) -> Vec<ExpectedError> {
2538
let mut rdr = BufferedReader::new(File::open(testfile).unwrap());
2639

40+
// `last_nonfollow_error` tracks the most recently seen
41+
// line with an error template that did not use the
42+
// follow-syntax, "//~| ...".
43+
//
44+
// (pnkfelix could not find an easy way to compose Iterator::scan
45+
// and Iterator::filter_map to pass along this information into
46+
// `parse_expected`. So instead I am storing that state here and
47+
// updating it in the map callback below.)
48+
let mut last_nonfollow_error = None;
49+
2750
rdr.lines().enumerate().filter_map(|(line_no, ln)| {
28-
parse_expected(line_no + 1, ln.unwrap().as_slice(), re)
51+
parse_expected(last_nonfollow_error,
52+
line_no + 1,
53+
ln.unwrap().as_slice(), re)
54+
.map(|(which, error)| {
55+
match which {
56+
FollowPrevious(_) => {}
57+
_ => last_nonfollow_error = Some(error.line),
58+
}
59+
error
60+
})
2961
}).collect()
3062
}
3163

32-
fn parse_expected(line_num: uint, line: &str, re: &Regex) -> Option<ExpectedError> {
64+
fn parse_expected(last_nonfollow_error: Option<uint>,
65+
line_num: uint,
66+
line: &str,
67+
re: &Regex) -> Option<(WhichLine, ExpectedError)> {
3368
re.captures(line).and_then(|caps| {
3469
let adjusts = caps.name("adjusts").len();
3570
let kind = caps.name("kind").to_ascii_lower();
3671
let msg = caps.name("msg").trim().to_string();
72+
let follow = caps.name("follow").len() > 0;
73+
74+
let (which, line) = if follow {
75+
assert!(adjusts == 0, "use either //~| or //~^, not both.");
76+
let line = last_nonfollow_error.unwrap_or_else(|| {
77+
panic!("encountered //~| without preceding //~^ line.")
78+
});
79+
(FollowPrevious(line), line)
80+
} else {
81+
let which =
82+
if adjusts > 0 { AdjustBackward(adjusts) } else { ThisLine };
83+
let line = line_num - adjusts;
84+
(which, line)
85+
};
3786

38-
debug!("line={} kind={} msg={}", line_num, kind, msg);
39-
Some(ExpectedError {
40-
line: line_num - adjusts,
41-
kind: kind,
42-
msg: msg,
43-
})
87+
debug!("line={} which={} kind={} msg={}", line_num, which, kind, msg);
88+
Some((which, ExpectedError { line: line,
89+
kind: kind,
90+
msg: msg, }))
4491
})
4592
}

branches/try/src/doc/reference.md

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1689,20 +1689,7 @@ methods in such an implementation can only be used as direct calls on the
16891689
values of the type that the implementation targets. In such an implementation,
16901690
the trait type and `for` after `impl` are omitted. Such implementations are
16911691
limited to nominal types (enums, structs), and the implementation must appear
1692-
in the same module or a sub-module as the `self` type:
1693-
1694-
```
1695-
struct Point {x: int, y: int}
1696-
1697-
impl Point {
1698-
fn log(&self) {
1699-
println!("Point is at ({}, {})", self.x, self.y);
1700-
}
1701-
}
1702-
1703-
let my_point = Point {x: 10, y:11};
1704-
my_point.log();
1705-
```
1692+
in the same module or a sub-module as the `self` type.
17061693

17071694
When a trait _is_ specified in an `impl`, all methods declared as part of the
17081695
trait must be implemented, with matching types and type parameter counts.

branches/try/src/etc/emacs/rust-mode.el

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@
3131
(modify-syntax-entry ?\" "\"" table)
3232
(modify-syntax-entry ?\\ "\\" table)
3333

34+
;; _ is a word-char
35+
(modify-syntax-entry ?_ "w" table)
36+
3437
;; Comments
3538
(modify-syntax-entry ?/ ". 124b" table)
3639
(modify-syntax-entry ?* ". 23" table)
@@ -394,7 +397,7 @@ This is written mainly to be used as `beginning-of-defun-function' for Rust.
394397
Don't move to the beginning of the line. `beginning-of-defun',
395398
which calls this, does that afterwards."
396399
(interactive "p")
397-
(re-search-backward (concat "^\\(" rust-top-item-beg-re "\\)\\_>")
400+
(re-search-backward (concat "^\\(" rust-top-item-beg-re "\\)\\b")
398401
nil 'move (or arg 1)))
399402

400403
(defun rust-end-of-defun ()

branches/try/src/libcollections/vec.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,18 +1248,14 @@ pub struct MoveItems<T> {
12481248
impl<T> MoveItems<T> {
12491249
#[inline]
12501250
/// Drops all items that have not yet been moved and returns the empty vector.
1251-
pub fn into_inner(mut self) -> Vec<T> {
1251+
pub fn unwrap(mut self) -> Vec<T> {
12521252
unsafe {
12531253
for _x in self { }
12541254
let MoveItems { allocation, cap, ptr: _ptr, end: _end } = self;
12551255
mem::forget(self);
12561256
Vec { ptr: allocation, cap: cap, len: 0 }
12571257
}
12581258
}
1259-
1260-
/// Deprecated, use into_inner() instead
1261-
#[deprecated = "renamed to into_inner()"]
1262-
pub fn unwrap(self) -> Vec<T> { self.into_inner() }
12631259
}
12641260

12651261
impl<T> Iterator<T> for MoveItems<T> {

branches/try/src/libcore/cell.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -256,19 +256,15 @@ impl<T> RefCell<T> {
256256
}
257257

258258
/// Consumes the `RefCell`, returning the wrapped value.
259-
#[unstable = "recently renamed per RFC 430"]
260-
pub fn into_inner(self) -> T {
259+
#[unstable = "may be renamed, depending on global conventions"]
260+
pub fn unwrap(self) -> T {
261261
// Since this function takes `self` (the `RefCell`) by value, the
262262
// compiler statically verifies that it is not currently borrowed.
263263
// Therefore the following assertion is just a `debug_assert!`.
264264
debug_assert!(self.borrow.get() == UNUSED);
265-
unsafe { self.value.into_inner() }
265+
unsafe{self.value.unwrap()}
266266
}
267267

268-
/// Deprecated, use into_inner() instead
269-
#[deprecated = "renamed to into_inner()"]
270-
pub fn unwrap(self) -> T { self.into_inner() }
271-
272268
/// Attempts to immutably borrow the wrapped value.
273269
///
274270
/// The borrow lasts until the returned `Ref` exits scope. Multiple
@@ -522,9 +518,5 @@ impl<T> UnsafeCell<T> {
522518
#[inline]
523519
#[unstable = "conventions around the name `unwrap` are still under \
524520
development"]
525-
pub unsafe fn into_inner(self) -> T { self.value }
526-
527-
/// Deprecated, use into_inner() instead
528-
#[deprecated = "renamed to into_inner()"]
529-
pub unsafe fn unwrap(self) -> T { self.into_inner() }
521+
pub unsafe fn unwrap(self) -> T { self.value }
530522
}

branches/try/src/libcore/slice.rs

Lines changed: 0 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1104,21 +1104,6 @@ macro_rules! iterator {
11041104
}
11051105
}
11061106

1107-
macro_rules! make_slice {
1108-
($t: ty -> $result: ty: $start: expr, $end: expr) => {{
1109-
let diff = $end as uint - $start as uint;
1110-
let len = if mem::size_of::<T>() == 0 {
1111-
diff
1112-
} else {
1113-
diff / mem::size_of::<$t>()
1114-
};
1115-
unsafe {
1116-
transmute::<_, $result>(RawSlice { data: $start as *const T, len: len })
1117-
}
1118-
}}
1119-
}
1120-
1121-
11221107
/// Immutable slice iterator
11231108
#[experimental = "needs review"]
11241109
pub struct Items<'a, T: 'a> {
@@ -1127,36 +1112,6 @@ pub struct Items<'a, T: 'a> {
11271112
marker: marker::ContravariantLifetime<'a>
11281113
}
11291114

1130-
#[experimental]
1131-
impl<'a, T> ops::Slice<uint, [T]> for Items<'a, T> {
1132-
fn as_slice_(&self) -> &[T] {
1133-
self.as_slice()
1134-
}
1135-
fn slice_from_or_fail<'b>(&'b self, from: &uint) -> &'b [T] {
1136-
use ops::Slice;
1137-
self.as_slice().slice_from_or_fail(from)
1138-
}
1139-
fn slice_to_or_fail<'b>(&'b self, to: &uint) -> &'b [T] {
1140-
use ops::Slice;
1141-
self.as_slice().slice_to_or_fail(to)
1142-
}
1143-
fn slice_or_fail<'b>(&'b self, from: &uint, to: &uint) -> &'b [T] {
1144-
use ops::Slice;
1145-
self.as_slice().slice_or_fail(from, to)
1146-
}
1147-
}
1148-
1149-
impl<'a, T> Items<'a, T> {
1150-
/// View the underlying data as a subslice of the original data.
1151-
///
1152-
/// This has the same lifetime as the original slice, and so the
1153-
/// iterator can continue to be used while this exists.
1154-
#[experimental]
1155-
pub fn as_slice(&self) -> &'a [T] {
1156-
make_slice!(T -> &'a [T]: self.ptr, self.end)
1157-
}
1158-
}
1159-
11601115
iterator!{struct Items -> *const T, &'a T}
11611116

11621117
#[experimental = "needs review"]
@@ -1201,57 +1156,6 @@ pub struct MutItems<'a, T: 'a> {
12011156
marker2: marker::NoCopy
12021157
}
12031158

1204-
#[experimental]
1205-
impl<'a, T> ops::Slice<uint, [T]> for MutItems<'a, T> {
1206-
fn as_slice_<'b>(&'b self) -> &'b [T] {
1207-
make_slice!(T -> &'b [T]: self.ptr, self.end)
1208-
}
1209-
fn slice_from_or_fail<'b>(&'b self, from: &uint) -> &'b [T] {
1210-
use ops::Slice;
1211-
self.as_slice_().slice_from_or_fail(from)
1212-
}
1213-
fn slice_to_or_fail<'b>(&'b self, to: &uint) -> &'b [T] {
1214-
use ops::Slice;
1215-
self.as_slice_().slice_to_or_fail(to)
1216-
}
1217-
fn slice_or_fail<'b>(&'b self, from: &uint, to: &uint) -> &'b [T] {
1218-
use ops::Slice;
1219-
self.as_slice_().slice_or_fail(from, to)
1220-
}
1221-
}
1222-
1223-
#[experimental]
1224-
impl<'a, T> ops::SliceMut<uint, [T]> for MutItems<'a, T> {
1225-
fn as_mut_slice_<'b>(&'b mut self) -> &'b mut [T] {
1226-
make_slice!(T -> &'b mut [T]: self.ptr, self.end)
1227-
}
1228-
fn slice_from_or_fail_mut<'b>(&'b mut self, from: &uint) -> &'b mut [T] {
1229-
use ops::SliceMut;
1230-
self.as_mut_slice_().slice_from_or_fail_mut(from)
1231-
}
1232-
fn slice_to_or_fail_mut<'b>(&'b mut self, to: &uint) -> &'b mut [T] {
1233-
use ops::SliceMut;
1234-
self.as_mut_slice_().slice_to_or_fail_mut(to)
1235-
}
1236-
fn slice_or_fail_mut<'b>(&'b mut self, from: &uint, to: &uint) -> &'b mut [T] {
1237-
use ops::SliceMut;
1238-
self.as_mut_slice_().slice_or_fail_mut(from, to)
1239-
}
1240-
}
1241-
1242-
impl<'a, T> MutItems<'a, T> {
1243-
/// View the underlying data as a subslice of the original data.
1244-
///
1245-
/// To avoid creating `&mut` references that alias, this is forced
1246-
/// to consume the iterator. Consider using the `Slice` and
1247-
/// `SliceMut` implementations for obtaining slices with more
1248-
/// restricted lifetimes that do not consume the iterator.
1249-
#[experimental]
1250-
pub fn into_slice(self) -> &'a mut [T] {
1251-
make_slice!(T -> &'a mut [T]: self.ptr, self.end)
1252-
}
1253-
}
1254-
12551159
iterator!{struct MutItems -> *mut T, &'a mut T}
12561160

12571161
#[experimental = "needs review"]

branches/try/src/libcore/str.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1277,19 +1277,14 @@ pub mod traits {
12771277
}
12781278

12791279
/// Any string that can be represented as a slice
1280-
pub trait Str for Sized? {
1280+
pub trait Str {
12811281
/// Work with `self` as a slice.
12821282
fn as_slice<'a>(&'a self) -> &'a str;
12831283
}
12841284

1285-
impl Str for str {
1285+
impl<'a> Str for &'a str {
12861286
#[inline]
1287-
fn as_slice<'a>(&'a self) -> &'a str { self }
1288-
}
1289-
1290-
impl<'a, Sized? S> Str for &'a S where S: Str {
1291-
#[inline]
1292-
fn as_slice(&self) -> &str { Str::as_slice(*self) }
1287+
fn as_slice<'a>(&'a self) -> &'a str { *self }
12931288
}
12941289

12951290
/// Methods for string slices

branches/try/src/libcoretest/slice.rs

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -33,52 +33,3 @@ fn binary_search_not_found() {
3333
let b = [1i, 2, 4, 5, 6, 8];
3434
assert!(b.binary_search(|v| v.cmp(&9)) == NotFound(6));
3535
}
36-
37-
#[test]
38-
fn iterator_to_slice() {
39-
macro_rules! test {
40-
($data: expr) => {{
41-
let data: &mut [_] = &mut $data;
42-
let other_data: &mut [_] = &mut $data;
43-
44-
{
45-
let mut iter = data.iter();
46-
assert_eq!(iter[], other_data[]);
47-
48-
iter.next();
49-
assert_eq!(iter[], other_data[1..]);
50-
51-
iter.next_back();
52-
assert_eq!(iter[], other_data[1..2]);
53-
54-
let s = iter.as_slice();
55-
iter.next();
56-
assert_eq!(s, other_data[1..2]);
57-
}
58-
{
59-
let mut iter = data.iter_mut();
60-
assert_eq!(iter[], other_data[]);
61-
// mutability:
62-
assert!(iter[mut] == other_data);
63-
64-
iter.next();
65-
assert_eq!(iter[], other_data[1..]);
66-
assert!(iter[mut] == other_data[mut 1..]);
67-
68-
iter.next_back();
69-
70-
assert_eq!(iter[], other_data[1..2]);
71-
assert!(iter[mut] == other_data[mut 1..2]);
72-
73-
let s = iter.into_slice();
74-
assert!(s == other_data[mut 1..2]);
75-
}
76-
}}
77-
}
78-
79-
// try types of a variety of sizes
80-
test!([(1u64, 1u64, 1u8), (2, 2, 2), (3, 3, 3)]);
81-
test!([1u64,2,3]);
82-
test!([1u8,2,3]);
83-
test!([(),(),()]);
84-
}

branches/try/src/librustc/lint/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -827,5 +827,5 @@ pub fn check_crate(tcx: &ty::ctxt,
827827
}
828828

829829
tcx.sess.abort_if_errors();
830-
*tcx.node_lint_levels.borrow_mut() = cx.node_levels.into_inner();
830+
*tcx.node_lint_levels.borrow_mut() = cx.node_levels.unwrap();
831831
}

0 commit comments

Comments
 (0)