Skip to content

Commit 52ef462

Browse files
committed
Rebasing changes
1 parent 3e62637 commit 52ef462

Some content is hidden

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

80 files changed

+851
-487
lines changed

src/libcollections/ringbuf.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,8 @@ impl<T> RingBuf<T> {
243243
/// buf.push(5i);
244244
/// buf.push(3);
245245
/// buf.push(4);
246-
/// assert_eq!(buf.iter().collect::<Vec<&int>>().as_slice(), &[&5, &3, &4]);
246+
/// let b: &[_] = &[&5, &3, &4];
247+
/// assert_eq!(buf.iter().collect::<Vec<&int>>().as_slice(), b);
247248
/// ```
248249
pub fn iter<'a>(&'a self) -> Items<'a, T> {
249250
Items{index: 0, rindex: self.nelts, lo: self.lo, elts: self.elts.as_slice()}
@@ -263,7 +264,8 @@ impl<T> RingBuf<T> {
263264
/// for num in buf.mut_iter() {
264265
/// *num = *num - 2;
265266
/// }
266-
/// assert_eq!(buf.mut_iter().collect::<Vec<&mut int>>().as_slice(), &[&mut 3, &mut 1, &mut 2]);
267+
/// let b: &[_] = &[&mut 3, &mut 1, &mut 2];
268+
/// assert_eq!(buf.mut_iter().collect::<Vec<&mut int>>().as_slice(), b);
267269
/// ```
268270
pub fn mut_iter<'a>(&'a mut self) -> MutItems<'a, T> {
269271
let start_index = raw_index(self.lo, self.elts.len(), 0);

src/libcollections/str.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1971,7 +1971,7 @@ mod tests {
19711971
use std::iter::order;
19721972
// official Unicode test data
19731973
// from http://www.unicode.org/Public/UCD/latest/ucd/auxiliary/GraphemeBreakTest.txt
1974-
let test_same = [
1974+
let test_same: [(_, &[_]), .. 325] = [
19751975
("\u0020\u0020", &["\u0020", "\u0020"]), ("\u0020\u0308\u0020", &["\u0020\u0308",
19761976
"\u0020"]), ("\u0020\u000D", &["\u0020", "\u000D"]), ("\u0020\u0308\u000D",
19771977
&["\u0020\u0308", "\u000D"]), ("\u0020\u000A", &["\u0020", "\u000A"]),
@@ -2180,7 +2180,7 @@ mod tests {
21802180
("\u0646\u200D\u0020", &["\u0646\u200D", "\u0020"]),
21812181
];
21822182

2183-
let test_diff = [
2183+
let test_diff: [(_, &[_], &[_]), .. 23] = [
21842184
("\u0020\u0903", &["\u0020\u0903"], &["\u0020", "\u0903"]), ("\u0020\u0308\u0903",
21852185
&["\u0020\u0308\u0903"], &["\u0020\u0308", "\u0903"]), ("\u000D\u0308\u0903",
21862186
&["\u000D", "\u0308\u0903"], &["\u000D", "\u0308", "\u0903"]), ("\u000A\u0308\u0903",
@@ -2229,9 +2229,11 @@ mod tests {
22292229
// test the indices iterators
22302230
let s = "a̐éö̲\r\n";
22312231
let gr_inds = s.grapheme_indices(true).collect::<Vec<(uint, &str)>>();
2232-
assert_eq!(gr_inds.as_slice(), &[(0u, "a̐"), (3, "é"), (6, "ö̲"), (11, "\r\n")]);
2232+
let b: &[_] = &[(0u, "a̐"), (3, "é"), (6, "ö̲"), (11, "\r\n")];
2233+
assert_eq!(gr_inds.as_slice(), b);
22332234
let gr_inds = s.grapheme_indices(true).rev().collect::<Vec<(uint, &str)>>();
2234-
assert_eq!(gr_inds.as_slice(), &[(11, "\r\n"), (6, "ö̲"), (3, "é"), (0u, "a̐")]);
2235+
let b: &[_] = &[(11, "\r\n"), (6, "ö̲"), (3, "é"), (0u, "a̐")];
2236+
assert_eq!(gr_inds.as_slice(), b);
22352237
let mut gr_inds = s.grapheme_indices(true);
22362238
let e1 = gr_inds.size_hint();
22372239
assert_eq!(e1, (1, Some(13)));
@@ -2243,7 +2245,8 @@ mod tests {
22432245
// make sure the reverse iterator does the right thing with "\n" at beginning of string
22442246
let s = "\n\r\n\r";
22452247
let gr = s.graphemes(true).rev().collect::<Vec<&str>>();
2246-
assert_eq!(gr.as_slice(), &["\r", "\r\n", "\n"]);
2248+
let b: &[_] = &["\r", "\r\n", "\n"];
2249+
assert_eq!(gr.as_slice(), b);
22472250
}
22482251

22492252
#[test]

src/libcollections/string.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,8 @@ impl String {
531531
///
532532
/// ```
533533
/// let s = String::from_str("hello");
534-
/// assert_eq!(s.as_bytes(), &[104, 101, 108, 108, 111]);
534+
/// let b: &[_] = &[104, 101, 108, 108, 111];
535+
/// assert_eq!(s.as_bytes(), b);
535536
/// ```
536537
#[inline]
537538
pub fn as_bytes<'a>(&'a self) -> &'a [u8] {
@@ -552,7 +553,8 @@ impl String {
552553
/// bytes[1] = 51;
553554
/// bytes[4] = 48;
554555
/// }
555-
/// assert_eq!(s.as_bytes(), &[104, 51, 108, 108, 48]);
556+
/// let b: &[_] = &[104, 51, 108, 108, 48];
557+
/// assert_eq!(s.as_bytes(), b);
556558
/// assert_eq!(s.as_slice(), "h3ll0")
557559
/// ```
558560
#[inline]

src/libcore/cmp.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,13 @@ impl Ordering {
112112
/// assert_eq!(Greater.reverse(), Less);
113113
///
114114
///
115-
/// let mut data = &mut [2u, 10, 5, 8];
115+
/// let mut data: &mut [_] = &mut [2u, 10, 5, 8];
116116
///
117117
/// // sort the array from largest to smallest.
118118
/// data.sort_by(|a, b| a.cmp(b).reverse());
119119
///
120-
/// assert_eq!(data, &mut [10u, 8, 5, 2]);
120+
/// let b: &mut [_] = &mut [10u, 8, 5, 2];
121+
/// assert!(data == b);
121122
/// ```
122123
#[inline]
123124
#[experimental]

src/libcore/option.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,10 @@ impl<T> Slice<T> for Option<T> {
530530
fn as_slice<'a>(&'a self) -> &'a [T] {
531531
match *self {
532532
Some(ref x) => slice::ref_slice(x),
533-
None => &[]
533+
None => {
534+
let result: &[_] = &[];
535+
result
536+
}
534537
}
535538
}
536539
}

src/libcore/raw.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ pub struct TraitObject {
5858
}
5959
#[cfg(not(stage0))]
6060
pub struct TraitObject {
61-
pub data: *(),
62-
pub vtable: *(),
61+
pub data: *mut (),
62+
pub vtable: *mut (),
6363
}
6464

6565
/// This trait is meant to map equivalences between raw structs and their

src/libcore/slice.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1648,6 +1648,27 @@ impl<'a,T:PartialEq, V: Slice<T>> Equiv<V> for &'a [T] {
16481648
fn equiv(&self, other: &V) -> bool { self.as_slice() == other.as_slice() }
16491649
}
16501650

1651+
#[unstable = "waiting for DST"]
1652+
impl<'a,T:PartialEq> PartialEq for &'a mut [T] {
1653+
fn eq(&self, other: & &'a mut [T]) -> bool {
1654+
self.len() == other.len() &&
1655+
order::eq(self.iter(), other.iter())
1656+
}
1657+
fn ne(&self, other: & &'a mut [T]) -> bool {
1658+
self.len() != other.len() ||
1659+
order::ne(self.iter(), other.iter())
1660+
}
1661+
}
1662+
1663+
#[unstable = "waiting for DST"]
1664+
impl<'a,T:Eq> Eq for &'a mut [T] {}
1665+
1666+
#[unstable = "waiting for DST"]
1667+
impl<'a,T:PartialEq, V: Slice<T>> Equiv<V> for &'a mut [T] {
1668+
#[inline]
1669+
fn equiv(&self, other: &V) -> bool { self.as_slice() == other.as_slice() }
1670+
}
1671+
16511672
#[unstable = "waiting for DST"]
16521673
impl<'a,T:Ord> Ord for &'a [T] {
16531674
fn cmp(&self, other: & &'a [T]) -> Ordering {

src/libcoretest/iter.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ fn test_collect() {
368368

369369
#[test]
370370
fn test_all() {
371-
let v: Box<&[int]> = box &[1i, 2, 3, 4, 5];
371+
let v: Box<[int]> = box [1i, 2, 3, 4, 5];
372372
assert!(v.iter().all(|&x| x < 10));
373373
assert!(!v.iter().all(|&x| x % 2 == 0));
374374
assert!(!v.iter().all(|&x| x > 100));
@@ -377,7 +377,7 @@ fn test_all() {
377377

378378
#[test]
379379
fn test_any() {
380-
let v: Box<&[int]> = box &[1i, 2, 3, 4, 5];
380+
let v: Box<[int]> = box [1i, 2, 3, 4, 5];
381381
assert!(v.iter().any(|&x| x < 10));
382382
assert!(v.iter().any(|&x| x % 2 == 0));
383383
assert!(!v.iter().any(|&x| x > 100));

src/libdebug/reflect.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ impl<V:TyVisitor + MovePtr> TyVisitor for MovePtrAdaptor<V> {
251251
}
252252
#[cfg(not(stage0))]
253253
fn visit_evec_fixed(&mut self, n: uint, sz: uint, align: uint,
254-
inner: *TyDesc) -> bool {
254+
inner: *const TyDesc) -> bool {
255255
self.align(align);
256256
if ! self.inner.visit_evec_fixed(n, sz, align, inner) {
257257
return false;

src/libdebug/repr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ impl<'a> TyVisitor for ReprVisitor<'a> {
342342

343343
#[cfg(not(stage0))]
344344
fn visit_evec_fixed(&mut self, n: uint, sz: uint, _align: uint,
345-
inner: *TyDesc) -> bool {
345+
inner: *const TyDesc) -> bool {
346346
let assumed_size = if sz == 0 { n } else { sz };
347347
self.get::<()>(|this, b| {
348348
this.write_vec_range(b, assumed_size, inner)

src/liblibc/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ extern {}
302302
/// A wrapper for a nullable pointer. Don't use this except for interacting
303303
/// with libc. Basically Option, but without the dependence on libstd.
304304
// If/when libprim happens, this can be removed in favor of that
305-
pub enum Nullable<type T> {
305+
pub enum Nullable<T> {
306306
Null,
307307
NotNull(T)
308308
}

src/librbml/io.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ impl Writer for SeekableMemWriter {
9696
let (left, right) = if cap <= buf.len() {
9797
(buf.slice_to(cap), buf.slice_from(cap))
9898
} else {
99-
(buf, &[])
99+
let result: (_, &[_]) = (buf, &[]);
100+
result
100101
};
101102

102103
// Do the necessary writes
@@ -142,24 +143,29 @@ mod tests {
142143
writer.write([1, 2, 3]).unwrap();
143144
writer.write([4, 5, 6, 7]).unwrap();
144145
assert_eq!(writer.tell(), Ok(8));
145-
assert_eq!(writer.get_ref(), &[0, 1, 2, 3, 4, 5, 6, 7]);
146+
let b: &[_] = &[0, 1, 2, 3, 4, 5, 6, 7];
147+
assert_eq!(writer.get_ref(), b);
146148

147149
writer.seek(0, io::SeekSet).unwrap();
148150
assert_eq!(writer.tell(), Ok(0));
149151
writer.write([3, 4]).unwrap();
150-
assert_eq!(writer.get_ref(), &[3, 4, 2, 3, 4, 5, 6, 7]);
152+
let b: &[_] = &[3, 4, 2, 3, 4, 5, 6, 7];
153+
assert_eq!(writer.get_ref(), b);
151154

152155
writer.seek(1, io::SeekCur).unwrap();
153156
writer.write([0, 1]).unwrap();
154-
assert_eq!(writer.get_ref(), &[3, 4, 2, 0, 1, 5, 6, 7]);
157+
let b: &[_] = &[3, 4, 2, 0, 1, 5, 6, 7];
158+
assert_eq!(writer.get_ref(), b);
155159

156160
writer.seek(-1, io::SeekEnd).unwrap();
157161
writer.write([1, 2]).unwrap();
158-
assert_eq!(writer.get_ref(), &[3, 4, 2, 0, 1, 5, 6, 1, 2]);
162+
let b: &[_] = &[3, 4, 2, 0, 1, 5, 6, 1, 2];
163+
assert_eq!(writer.get_ref(), b);
159164

160165
writer.seek(1, io::SeekEnd).unwrap();
161166
writer.write([1]).unwrap();
162-
assert_eq!(writer.get_ref(), &[3, 4, 2, 0, 1, 5, 6, 1, 2, 0, 1]);
167+
let b: &[_] = &[3, 4, 2, 0, 1, 5, 6, 1, 2, 0, 1];
168+
assert_eq!(writer.get_ref(), b);
163169
}
164170

165171
#[test]

src/librlibc/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
// implementations below. If pointer arithmetic is done through integers the
5050
// optimizations start to break down.
5151
extern "rust-intrinsic" {
52-
fn offset<type T>(dst: *const T, offset: int) -> *const T;
52+
fn offset<T>(dst: *const T, offset: int) -> *const T;
5353
}
5454

5555
#[no_mangle]

src/librustc/diagnostics.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ register_diagnostics!(
3434
E0015,
3535
E0016,
3636
E0017,
37-
E0018,
3837
E0019,
3938
E0020,
4039
E0021,
@@ -53,7 +52,6 @@ register_diagnostics!(
5352
E0034,
5453
E0035,
5554
E0036,
56-
E0037,
5755
E0038,
5856
E0039,
5957
E0040,
@@ -80,8 +78,6 @@ register_diagnostics!(
8078
E0061,
8179
E0062,
8280
E0063,
83-
E0064,
84-
E0065,
8581
E0066,
8682
E0067,
8783
E0068,
@@ -127,8 +123,6 @@ register_diagnostics!(
127123
E0108,
128124
E0109,
129125
E0110,
130-
E0111,
131-
E0112,
132126
E0113,
133127
E0114,
134128
E0115,

src/librustc/front/test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -477,10 +477,10 @@ fn mk_test_descs(cx: &TestCtxt) -> Gc<ast::Expr> {
477477

478478
box(GC) ast::Expr {
479479
id: ast::DUMMY_NODE_ID,
480-
node: ast::ExprAddrOf(box(GC) ast::MutImmutable,
480+
node: ast::ExprAddrOf(ast::MutImmutable,
481481
box(GC) ast::Expr {
482482
id: ast::DUMMY_NODE_ID,
483-
node: ast::ExprVec(cx.testfns.borrow().iter().map(|test| {
483+
node: ast::ExprVec(cx.testfns.iter().map(|test| {
484484
mk_test_desc_and_fn_rec(cx, test)
485485
}).collect()),
486486
span: DUMMY_SP,

src/librustc/lint/builtin.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1556,6 +1556,9 @@ declare_lint!(pub UNKNOWN_CRATE_TYPE, Deny,
15561556
declare_lint!(pub VARIANT_SIZE_DIFFERENCE, Allow,
15571557
"detects enums with widely varying variant sizes")
15581558

1559+
declare_lint!(pub TRANSMUTE_FAT_PTR, Allow,
1560+
"detects transmutes of fat pointers")
1561+
15591562
/// Does nothing as a lint pass, but registers some `Lint`s
15601563
/// which are used by other parts of the compiler.
15611564
pub struct HardwiredLints;

src/librustc/middle/astencode.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,6 +1029,8 @@ impl<'a> rbml_writer_helpers for Encoder<'a> {
10291029
}
10301030

10311031
fn emit_autoref(&mut self, ecx: &e::EncodeContext, autoref: &ty::AutoRef) {
1032+
use serialize::Encoder;
1033+
10321034
self.emit_enum("AutoRef", |this| {
10331035
match autoref {
10341036
&ty::AutoPtr(r, m, None) => {
@@ -1067,6 +1069,8 @@ impl<'a> rbml_writer_helpers for Encoder<'a> {
10671069
}
10681070

10691071
fn emit_auto_deref_ref(&mut self, ecx: &e::EncodeContext, auto_deref_ref: &ty::AutoDerefRef) {
1072+
use serialize::Encoder;
1073+
10701074
self.emit_struct("AutoDerefRef", 2, |this| {
10711075
this.emit_struct_field("autoderefs", 0, |this| auto_deref_ref.autoderefs.encode(this));
10721076
this.emit_struct_field("autoref", 1, |this| {
@@ -1081,6 +1085,8 @@ impl<'a> rbml_writer_helpers for Encoder<'a> {
10811085
}
10821086

10831087
fn emit_unsize_kind(&mut self, ecx: &e::EncodeContext, uk: &ty::UnsizeKind) {
1088+
use serialize::Encoder;
1089+
10841090
self.emit_enum("UnsizeKind", |this| {
10851091
match *uk {
10861092
ty::UnsizeLength(len) => {
@@ -1286,7 +1292,7 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
12861292
_ if ty::adjust_is_object(adjustment) => {
12871293
let method_call = MethodCall::autoobject(id);
12881294
for &method in tcx.method_map.borrow().find(&method_call).iter() {
1289-
rbml_w.tag(c::tag_table_method_map, |ebml_w| {
1295+
rbml_w.tag(c::tag_table_method_map, |rbml_w| {
12901296
rbml_w.id(id);
12911297
rbml_w.tag(c::tag_table_val, |rbml_w| {
12921298
encode_method_callee(ecx, rbml_w, method_call.adjustment, method)
@@ -1297,7 +1303,7 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
12971303
for &dr in tcx.vtable_map.borrow().find(&method_call).iter() {
12981304
rbml_w.tag(c::tag_table_vtable_map, |rbml_w| {
12991305
rbml_w.id(id);
1300-
rbml_w.tag(c::tag_table_val, |ebml_w| {
1306+
rbml_w.tag(c::tag_table_val, |rbml_w| {
13011307
encode_vtable_res_with_key(ecx, rbml_w, method_call.adjustment, dr);
13021308
})
13031309
})
@@ -1336,7 +1342,7 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
13361342
rbml_w.tag(c::tag_table_adjustments, |rbml_w| {
13371343
rbml_w.id(id);
13381344
rbml_w.tag(c::tag_table_val, |rbml_w| {
1339-
rbml_w.emit_auto_adjustment(ecx, adj);
1345+
rbml_w.emit_auto_adjustment(ecx, adjustment);
13401346
})
13411347
})
13421348
}

src/librustc/middle/check_const.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ fn check_expr(v: &mut CheckCrateVisitor, e: &Expr, is_const: bool) {
182182
// Mutable slices are allowed.
183183
ExprVec(_) => {}
184184
_ => span_err!(v.tcx.sess, e.span, E0017,
185-
"references in constants may only refer to immutable values");
185+
"references in constants may only refer to immutable values")
186186

187187
}
188188
},

src/librustc/middle/intrinsicck.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ impl<'a> IntrinsicCheckingVisitor<'a> {
9292
}
9393
}
9494

95-
fn check_transmute(&self, span: Span, from: ty::t, to: ty::t) {
95+
fn check_transmute(&self, span: Span, from: ty::t, to: ty::t, id: ast::NodeId) {
9696
if type_size_is_affected_by_type_parameters(self.tcx, from) {
9797
span_err!(self.tcx.sess, span, E0139,
9898
"cannot transmute from a type that contains type parameters");
@@ -106,6 +106,7 @@ impl<'a> IntrinsicCheckingVisitor<'a> {
106106
span: span,
107107
from: from,
108108
to: to,
109+
id: id,
109110
};
110111
self.tcx.transmute_restrictions.borrow_mut().push(restriction);
111112
}
@@ -123,7 +124,7 @@ impl<'a> Visitor<()> for IntrinsicCheckingVisitor<'a> {
123124
if bare_fn_ty.abi == RustIntrinsic => {
124125
let from = *bare_fn_ty.sig.inputs.get(0);
125126
let to = bare_fn_ty.sig.output;
126-
self.check_transmute(expr.span, from, to);
127+
self.check_transmute(expr.span, from, to, expr.id);
127128
}
128129
_ => {
129130
self.tcx

0 commit comments

Comments
 (0)