diff options
Diffstat (limited to 'src')
31 files changed, 170 insertions, 158 deletions
diff --git a/src/doc/complement-cheatsheet.md b/src/doc/complement-cheatsheet.md index a92980d5e70..a2d75fc95d1 100644 --- a/src/doc/complement-cheatsheet.md +++ b/src/doc/complement-cheatsheet.md @@ -36,12 +36,42 @@ let y: ~str = x.to_str_radix(16); Use [`FromStrRadix`](http://static.rust-lang.org/doc/master/std/num/trait.FromStrRadix.html), and its helper function, [`from_str_radix`](http://static.rust-lang.org/doc/master/std/num/fn.from_str_radix.html). ~~~ -use std::num::from_str_radix; +use std::num; -let x: Option<i64> = from_str_radix("deadbeef", 16); +let x: Option<i64> = num::from_str_radix("deadbeef", 16); let y: i64 = x.unwrap(); ~~~ +**Vector of Bytes to String** + +To return a Borrowed String Slice (&str) use the str helper function [`from_utf8`](http://static.rust-lang.org/doc/master/std/str/fn.from_utf8.html). + +~~~ +use std::str; + +let bytes = ~[104u8,105u8]; +let x: Option<&str> = str::from_utf8(bytes); +let y: &str = x.unwrap(); +~~~ + +To return an Owned String (~str) use the str helper function [`from_utf8_owned`](http://static.rust-lang.org/doc/master/std/str/fn.from_utf8_owned.html). + +~~~ +use std::str; + +let x: Option<~str> = str::from_utf8_owned(~[104u8,105u8]); +let y: ~str = x.unwrap(); +~~~~ + +To return a [`MaybeOwned`](http://static.rust-lang.org/doc/master/std/str/enum.MaybeOwned.html) use the str helper function [`from_utf8_lossy`](http://static.rust-lang.org/doc/master/std/str/fn.from_utf8_owned.html). This function also replaces non-valid utf-8 sequences with U+FFFD replacement character. + +~~~ +use std::str; + +let x = bytes!(72u8,"ello ",0xF0,0x90,0x80,"World!"); +let y = str::from_utf8_lossy(x); +~~~~ + # File operations ## How do I read from a file? diff --git a/src/libfourcc/lib.rs b/src/libfourcc/lib.rs index ea82d31bbe7..df693bd1d8b 100644 --- a/src/libfourcc/lib.rs +++ b/src/libfourcc/lib.rs @@ -26,10 +26,10 @@ To load the extension and use it: extern mod fourcc; fn main() { - let val = fourcc!("\xC0\xFF\xEE!") - // val is 0xC0FFEE21 - let big_val = fourcc!("foo ", big); - // big_val is 0x21EEFFC0 + let val = fourcc!("\xC0\xFF\xEE!"); + assert_eq!(val, 0xC0FFEE21u32); + let little_val = fourcc!("foo ", little); + assert_eq!(little_val, 0x21EEFFC0u32); } ``` @@ -60,7 +60,6 @@ use syntax::parse::token; use syntax::parse::token::InternedString; #[macro_registrar] -#[cfg(not(test))] pub fn macro_registrar(register: |Name, SyntaxExtension|) { register(token::intern("fourcc"), NormalTT(~BasicMacroExpander { @@ -155,6 +154,6 @@ fn target_endian_little(cx: &ExtCtxt, sp: Span) -> bool { contains(cx.cfg(), meta) } -// Fixes LLVM assert on Windows +// FIXME (10872): This is required to prevent an LLVM assert on Windows #[test] fn dummy_test() { } diff --git a/src/librustc/metadata/tydecode.rs b/src/librustc/metadata/tydecode.rs index 00e189cdc79..c1f2a459666 100644 --- a/src/librustc/metadata/tydecode.rs +++ b/src/librustc/metadata/tydecode.rs @@ -372,7 +372,6 @@ fn parse_ty(st: &mut PState, conv: conv_did) -> ty::t { 'F' => { return ty::mk_bare_fn(st.tcx, parse_bare_fn_ty(st, |x,y| conv(x,y))); } - 'Y' => return ty::mk_type(st.tcx), '#' => { let pos = parse_hex(st); assert_eq!(next(st), ':'); diff --git a/src/librustc/metadata/tyencode.rs b/src/librustc/metadata/tyencode.rs index 08632b5c9a6..0f4a1899368 100644 --- a/src/librustc/metadata/tyencode.rs +++ b/src/librustc/metadata/tyencode.rs @@ -328,7 +328,6 @@ fn enc_sty(w: &mut MemWriter, cx: @ctxt, st: &ty::sty) { ty::ty_self(did) => { mywrite!(w, "s{}|", (cx.ds)(did)); } - ty::ty_type => mywrite!(w, "Y"), ty::ty_struct(def, ref substs) => { mywrite!(w, "a[{}|", (cx.ds)(def)); enc_substs(w, cx, substs); diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index f8c051404f0..0aa62799495 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -598,19 +598,8 @@ pub fn compare_scalar_types<'a>( ty::ty_int(_) => rslt(cx, f(signed_int)), ty::ty_uint(_) => rslt(cx, f(unsigned_int)), ty::ty_float(_) => rslt(cx, f(floating_point)), - ty::ty_type => { - rslt( - controlflow::trans_fail( - cx, None, - InternedString::new("attempt to compare values of type \ - type")), - C_nil()) - } - _ => { // Should never get here, because t is scalar. - cx.sess().bug("non-scalar type passed to \ - compare_scalar_types") - } + _ => cx.sess().bug("non-scalar type passed to compare_scalar_types") } } diff --git a/src/librustc/middle/trans/closure.rs b/src/librustc/middle/trans/closure.rs index 81c671b4952..6506fe59a5d 100644 --- a/src/librustc/middle/trans/closure.rs +++ b/src/librustc/middle/trans/closure.rs @@ -152,8 +152,12 @@ pub fn mk_closure_tys(tcx: ty::ctxt, return cdata_ty; } -pub fn allocate_cbox<'a>( - bcx: &'a Block<'a>, +fn tuplify_box_ty(tcx: ty::ctxt, t: ty::t) -> ty::t { + let ptr = ty::mk_imm_ptr(tcx, ty::mk_i8()); + ty::mk_tup(tcx, ~[ty::mk_uint(), ty::mk_nil_ptr(tcx), ptr, ptr, t]) +} + +fn allocate_cbox<'a>(bcx: &'a Block<'a>, sigil: ast::Sigil, cdata_ty: ty::t) -> Result<'a> { diff --git a/src/librustc/middle/trans/common.rs b/src/librustc/middle/trans/common.rs index 7dbf159265d..78bee6c7263 100644 --- a/src/librustc/middle/trans/common.rs +++ b/src/librustc/middle/trans/common.rs @@ -520,19 +520,6 @@ pub fn val_ty(v: ValueRef) -> Type { } } -// Let T be the content of a box @T. tuplify_box_ty(t) returns the -// representation of @T as a tuple (i.e., the ty::t version of what T_box() -// returns). -pub fn tuplify_box_ty(tcx: ty::ctxt, t: ty::t) -> ty::t { - let ptr = ty::mk_ptr( - tcx, - ty::mt {ty: ty::mk_i8(), mutbl: ast::MutImmutable} - ); - return ty::mk_tup(tcx, ~[ty::mk_uint(), ty::mk_type(tcx), - ptr, ptr, - t]); -} - // LLVM constant constructors. pub fn C_null(t: Type) -> ValueRef { unsafe { diff --git a/src/librustc/middle/trans/reflect.rs b/src/librustc/middle/trans/reflect.rs index 1a1ae97bbcd..89538731626 100644 --- a/src/librustc/middle/trans/reflect.rs +++ b/src/librustc/middle/trans/reflect.rs @@ -368,8 +368,7 @@ impl<'a> Reflector<'a> { let extra = ~[self.c_uint(p.idx)]; self.visit("param", extra) } - ty::ty_self(..) => self.leaf("self"), - ty::ty_type => self.leaf("type") + ty::ty_self(..) => self.leaf("self") } } diff --git a/src/librustc/middle/trans/type_of.rs b/src/librustc/middle/trans/type_of.rs index 00d67a60ac4..3afd4903230 100644 --- a/src/librustc/middle/trans/type_of.rs +++ b/src/librustc/middle/trans/type_of.rs @@ -119,8 +119,7 @@ pub fn sizing_type_of(cx: &CrateContext, t: ty::t) -> Type { ty::ty_box(..) | ty::ty_uniq(..) | ty::ty_ptr(..) | - ty::ty_rptr(..) | - ty::ty_type => Type::i8p(), + ty::ty_rptr(..) => Type::i8p(), ty::ty_str(ty::vstore_slice(..)) | ty::ty_vec(_, ty::vstore_slice(..)) => { @@ -263,7 +262,6 @@ pub fn type_of(cx: &CrateContext, t: ty::t) -> Type { Type::struct_([fn_ty, Type::i8p()], false) } ty::ty_trait(..) => Type::opaque_trait(), - ty::ty_type => cx.tydesc_type.ptr_to(), ty::ty_tup(..) => { let repr = adt::represent_type(cx, t); adt::type_of(cx, repr) diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 7c4cb396b3e..21124a9f741 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -756,7 +756,6 @@ pub enum sty { // on non-useful type error messages) // "Fake" types, used for trans purposes - ty_type, // type_desc* ty_unboxed_vec(mt), } @@ -1181,7 +1180,7 @@ pub fn mk_t(cx: ctxt, st: sty) -> t { flags |= get(mt.ty).flags; } &ty_nil | &ty_bool | &ty_char | &ty_int(_) | &ty_float(_) | &ty_uint(_) | - &ty_str(_) | &ty_type => {} + &ty_str(_) => {} // You might think that we could just return ty_err for // any type containing ty_err as a component, and get // rid of the has_ty_err flag -- likewise for ty_bot (with @@ -1444,8 +1443,6 @@ pub fn mk_param(cx: ctxt, n: uint, k: DefId) -> t { mk_t(cx, ty_param(param_ty { idx: n, def_id: k })) } -pub fn mk_type(cx: ctxt) -> t { mk_t(cx, ty_type) } - pub fn walk_ty(ty: t, f: |t|) { maybe_walk_ty(ty, |t| { f(t); true }); } @@ -1456,7 +1453,7 @@ pub fn maybe_walk_ty(ty: t, f: |t| -> bool) { } match get(ty).sty { ty_nil | ty_bot | ty_bool | ty_char | ty_int(_) | ty_uint(_) | ty_float(_) | - ty_str(_) | ty_type | ty_self(_) | + ty_str(_) | ty_self(_) | ty_infer(_) | ty_param(_) | ty_err => {} ty_box(ty) | ty_uniq(ty) => maybe_walk_ty(ty, f), ty_vec(ref tm, _) | ty_unboxed_vec(ref tm) | ty_ptr(ref tm) | @@ -1730,7 +1727,7 @@ pub fn type_is_unique(ty: t) -> bool { pub fn type_is_scalar(ty: t) -> bool { match get(ty).sty { ty_nil | ty_bool | ty_char | ty_int(_) | ty_float(_) | ty_uint(_) | - ty_infer(IntVar(_)) | ty_infer(FloatVar(_)) | ty_type | + ty_infer(IntVar(_)) | ty_infer(FloatVar(_)) | ty_bare_fn(..) | ty_ptr(_) => true, _ => false } @@ -2216,8 +2213,6 @@ pub fn type_contents(cx: ctxt, ty: t) -> TypeContents { } ty_unboxed_vec(mt) => TC::InteriorUnsized | tc_mt(cx, mt, cache), - ty_type => TC::None, - ty_err => { cx.sess.bug("asked to compute contents of error type"); } @@ -2401,7 +2396,6 @@ pub fn is_instantiable(cx: ctxt, r_ty: t) -> bool { ty_err | ty_param(_) | ty_self(_) | - ty_type | ty_vec(_, _) | ty_unboxed_vec(_) => { false @@ -2628,7 +2622,7 @@ pub fn type_is_pod(cx: ctxt, ty: t) -> bool { match get(ty).sty { // Scalar types ty_nil | ty_bot | ty_bool | ty_char | ty_int(_) | ty_float(_) | ty_uint(_) | - ty_type | ty_ptr(_) | ty_bare_fn(_) => result = true, + ty_ptr(_) | ty_bare_fn(_) => result = true, // Boxed types ty_box(_) | ty_uniq(_) | ty_closure(_) | ty_str(vstore_uniq) | @@ -3556,7 +3550,7 @@ pub fn occurs_check(tcx: ctxt, sp: Span, vid: TyVid, rt: t) { pub fn ty_sort_str(cx: ctxt, t: t) -> ~str { match get(t).sty { ty_nil | ty_bot | ty_bool | ty_char | ty_int(_) | - ty_uint(_) | ty_float(_) | ty_str(_) | ty_type => { + ty_uint(_) | ty_float(_) | ty_str(_) => { ::util::ppaux::ty_to_str(cx, t) } @@ -5120,9 +5114,8 @@ pub fn hash_crate_independent(tcx: ctxt, t: t, local_hash: ~str) -> u64 { } ty_infer(_) => unreachable!(), ty_err => hash.input([23]), - ty_type => hash.input([24]), ty_unboxed_vec(m) => { - hash.input([25]); + hash.input([24]); mt(&mut hash, m); } } diff --git a/src/librustc/middle/ty_fold.rs b/src/librustc/middle/ty_fold.rs index 9c923077d7d..c0977d3c43f 100644 --- a/src/librustc/middle/ty_fold.rs +++ b/src/librustc/middle/ty_fold.rs @@ -187,8 +187,7 @@ pub fn super_fold_sty<T:TypeFolder>(this: &mut T, ty::ty_str(this.fold_vstore(vst)) } ty::ty_nil | ty::ty_bot | ty::ty_bool | ty::ty_char | - ty::ty_int(_) | ty::ty_uint(_) | - ty::ty_float(_) | ty::ty_type | + ty::ty_int(_) | ty::ty_uint(_) | ty::ty_float(_) | ty::ty_err | ty::ty_infer(_) | ty::ty_param(..) | ty::ty_self(_) => { (*sty).clone() diff --git a/src/librustc/middle/typeck/check/method.rs b/src/librustc/middle/typeck/check/method.rs index f19ca049368..bdcb418b9f8 100644 --- a/src/librustc/middle/typeck/check/method.rs +++ b/src/librustc/middle/typeck/check/method.rs @@ -788,7 +788,7 @@ impl<'a> LookupContext<'a> { ty_err => None, - ty_unboxed_vec(_) | ty_type | ty_infer(TyVar(_)) => { + ty_unboxed_vec(_) | ty_infer(TyVar(_)) => { self.bug(format!("unexpected type: {}", self.ty_to_str(self_ty))); } diff --git a/src/librustc/middle/typeck/coherence.rs b/src/librustc/middle/typeck/coherence.rs index 27d52aade93..3a5f9900e3c 100644 --- a/src/librustc/middle/typeck/coherence.rs +++ b/src/librustc/middle/typeck/coherence.rs @@ -23,7 +23,7 @@ use middle::ty::{substs, t, ty_bool, ty_char, ty_bot, ty_box, ty_enum, ty_err}; use middle::ty::{ty_str, ty_vec, ty_float, ty_infer, ty_int, ty_nil}; use middle::ty::{ty_param, ty_param_bounds_and_ty, ty_ptr}; use middle::ty::{ty_rptr, ty_self, ty_struct, ty_trait, ty_tup}; -use middle::ty::{ty_type, ty_uint, ty_uniq, ty_bare_fn, ty_closure}; +use middle::ty::{ty_uint, ty_uniq, ty_bare_fn, ty_closure}; use middle::ty::{ty_unboxed_vec, type_is_ty_var}; use middle::subst::Subst; use middle::ty; @@ -82,7 +82,7 @@ fn get_base_type(inference_context: &InferCtxt, ty_nil | ty_bot | ty_bool | ty_char | ty_int(..) | ty_uint(..) | ty_float(..) | ty_str(..) | ty_vec(..) | ty_bare_fn(..) | ty_closure(..) | ty_tup(..) | - ty_infer(..) | ty_param(..) | ty_self(..) | ty_type | + ty_infer(..) | ty_param(..) | ty_self(..) | ty_unboxed_vec(..) | ty_err | ty_box(_) | ty_uniq(_) | ty_ptr(_) | ty_rptr(_, _) => { debug!("(getting base type) no base type; found {:?}", diff --git a/src/librustc/middle/typeck/variance.rs b/src/librustc/middle/typeck/variance.rs index e29add4bc95..d0420aba45f 100644 --- a/src/librustc/middle/typeck/variance.rs +++ b/src/librustc/middle/typeck/variance.rs @@ -715,8 +715,7 @@ impl<'a> ConstraintContext<'a> { self.add_constraints_from_sig(sig, variance); } - ty::ty_infer(..) | ty::ty_err | - ty::ty_type | ty::ty_unboxed_vec(..) => { + ty::ty_infer(..) | ty::ty_err | ty::ty_unboxed_vec(..) => { self.tcx().sess.bug( format!("unexpected type encountered in \ variance inference: {}", diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index afac501835d..f536e231e15 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -18,7 +18,7 @@ use middle::ty::{ReFree, ReScope, ReInfer, ReStatic, Region, ReEmpty}; use middle::ty::{ty_bool, ty_char, ty_bot, ty_box, ty_struct, ty_enum}; use middle::ty::{ty_err, ty_str, ty_vec, ty_float, ty_bare_fn, ty_closure}; -use middle::ty::{ty_nil, ty_param, ty_ptr, ty_rptr, ty_self, ty_tup, ty_type}; +use middle::ty::{ty_nil, ty_param, ty_ptr, ty_rptr, ty_self, ty_tup}; use middle::ty::{ty_uniq, ty_trait, ty_int, ty_uint, ty_unboxed_vec, ty_infer}; use middle::ty; use middle::typeck; @@ -454,7 +454,6 @@ pub fn ty_to_str(cx: ctxt, typ: t) -> ~str { region_ptr_to_str(cx, r) + mt_to_str(cx, tm) } ty_unboxed_vec(ref tm) => { format!("unboxed_vec<{}>", mt_to_str(cx, tm)) } - ty_type => ~"type", ty_tup(ref elems) => { let strs = elems.map(|elem| ty_to_str(cx, *elem)); ~"(" + strs.connect(",") + ")" diff --git a/src/libstd/io/mem.rs b/src/libstd/io/mem.rs index 363dbd88fb7..ff61ef15fa5 100644 --- a/src/libstd/io/mem.rs +++ b/src/libstd/io/mem.rs @@ -10,7 +10,6 @@ //! Readers and Writers for in-memory buffers -use cmp::max; use cmp::min; use container::Container; use option::None; @@ -20,6 +19,25 @@ use io::{Reader, Writer, Seek, Buffer, IoError, SeekStyle, IoResult}; use vec; use vec::{Vector, ImmutableVector, MutableVector, OwnedCloneableVector}; +fn combine(seek: SeekStyle, cur: uint, end: uint, offset: i64) -> IoResult<u64> { + // compute offset as signed and clamp to prevent overflow + let pos = match seek { + SeekSet => 0, + SeekEnd => end, + SeekCur => cur, + } as i64; + + if offset + pos < 0 { + Err(IoError { + kind: io::InvalidInput, + desc: "invalid seek to a negative offset", + detail: None + }) + } else { + Ok((offset + pos) as u64) + } +} + /// Writes to an owned, growable byte vector /// /// # Example @@ -92,19 +110,11 @@ impl Writer for MemWriter { } } -// FIXME(#10432) impl Seek for MemWriter { fn tell(&self) -> IoResult<u64> { Ok(self.pos as u64) } - fn seek(&mut self, pos: i64, style: SeekStyle) -> IoResult<()> { - // compute offset as signed and clamp to prevent overflow - let offset = match style { - SeekSet => { 0 } - SeekEnd => { self.buf.len() } - SeekCur => { self.pos } - } as i64; - - self.pos = max(0, offset+pos) as uint; + let new = if_ok!(combine(style, self.pos, self.buf.len(), pos)); + self.pos = new as uint; Ok(()) } } @@ -139,7 +149,7 @@ impl MemReader { /// Tests whether this reader has read all bytes in its buffer. /// /// If `true`, then this will no longer return bytes from `read`. - pub fn eof(&self) -> bool { self.pos == self.buf.len() } + pub fn eof(&self) -> bool { self.pos >= self.buf.len() } /// Acquires an immutable reference to the underlying buffer of this /// `MemReader`. @@ -172,7 +182,11 @@ impl Reader for MemReader { impl Seek for MemReader { fn tell(&self) -> IoResult<u64> { Ok(self.pos as u64) } - fn seek(&mut self, _pos: i64, _style: SeekStyle) -> IoResult<()> { fail!() } + fn seek(&mut self, pos: i64, style: SeekStyle) -> IoResult<()> { + let new = if_ok!(combine(style, self.pos, self.buf.len(), pos)); + self.pos = new as uint; + Ok(()) + } } impl Buffer for MemReader { @@ -236,24 +250,15 @@ impl<'a> Writer for BufWriter<'a> { } } -// FIXME(#10432) impl<'a> Seek for BufWriter<'a> { fn tell(&self) -> IoResult<u64> { Ok(self.pos as u64) } - fn seek(&mut self, pos: i64, style: SeekStyle) -> IoResult<()> { - // compute offset as signed and clamp to prevent overflow - let offset = match style { - SeekSet => { 0 } - SeekEnd => { self.buf.len() } - SeekCur => { self.pos } - } as i64; - - self.pos = max(0, offset+pos) as uint; + let new = if_ok!(combine(style, self.pos, self.buf.len(), pos)); + self.pos = new as uint; Ok(()) } } - /// Reads from a fixed-size byte slice /// /// # Example @@ -284,7 +289,7 @@ impl<'a> BufReader<'a> { /// Tests whether this reader has read all bytes in its buffer. /// /// If `true`, then this will no longer return bytes from `read`. - pub fn eof(&self) -> bool { self.pos == self.buf.len() } + pub fn eof(&self) -> bool { self.pos >= self.buf.len() } } impl<'a> Reader for BufReader<'a> { @@ -307,7 +312,11 @@ impl<'a> Reader for BufReader<'a> { impl<'a> Seek for BufReader<'a> { fn tell(&self) -> IoResult<u64> { Ok(self.pos as u64) } - fn seek(&mut self, _pos: i64, _style: SeekStyle) -> IoResult<()> { fail!() } + fn seek(&mut self, pos: i64, style: SeekStyle) -> IoResult<()> { + let new = if_ok!(combine(style, self.pos, self.buf.len(), pos)); + self.pos = new as uint; + Ok(()) + } } impl<'a> Buffer for BufReader<'a> { @@ -506,4 +515,42 @@ mod test { Err(..) => {} } } + + #[test] + fn seek_past_end() { + let buf = [0xff]; + let mut r = BufReader::new(buf); + r.seek(10, SeekSet).unwrap(); + assert!(r.read(&mut []).is_err()); + + let mut r = MemReader::new(~[10]); + r.seek(10, SeekSet).unwrap(); + assert!(r.read(&mut []).is_err()); + + let mut r = MemWriter::new(); + r.seek(10, SeekSet).unwrap(); + assert!(r.write([3]).is_ok()); + + let mut buf = [0]; + let mut r = BufWriter::new(buf); + r.seek(10, SeekSet).unwrap(); + assert!(r.write([3]).is_err()); + } + + #[test] + fn seek_before_0() { + let buf = [0xff]; + let mut r = BufReader::new(buf); + assert!(r.seek(-1, SeekSet).is_err()); + + let mut r = MemReader::new(~[10]); + assert!(r.seek(-1, SeekSet).is_err()); + + let mut r = MemWriter::new(); + assert!(r.seek(-1, SeekSet).is_err()); + + let mut buf = [0]; + let mut r = BufWriter::new(buf); + assert!(r.seek(-1, SeekSet).is_err()); + } } diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index 54c0d98c798..24b3d1cc4de 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -1200,19 +1200,21 @@ pub enum SeekStyle { SeekCur, } -/// # FIXME -/// * Are `u64` and `i64` the right choices? pub trait Seek { /// Return position of file cursor in the stream fn tell(&self) -> IoResult<u64>; /// Seek to an offset in a stream /// - /// A successful seek clears the EOF indicator. + /// A successful seek clears the EOF indicator. Seeking beyond EOF is + /// allowed, but seeking before position 0 is not allowed. /// - /// # FIXME + /// # Errors /// - /// * What is the behavior when seeking past the end of a stream? + /// * Seeking to a negative offset is considered an error + /// * Seeking past the end of the stream does not modify the underlying + /// stream, but the next write may cause the previous data to be filled in + /// with a bit pattern. fn seek(&mut self, pos: i64, style: SeekStyle) -> IoResult<()>; } diff --git a/src/libstd/reflect.rs b/src/libstd/reflect.rs index e441ea6ec74..1c22408592a 100644 --- a/src/libstd/reflect.rs +++ b/src/libstd/reflect.rs @@ -442,6 +442,8 @@ impl<V:TyVisitor + MovePtr> TyVisitor for MovePtrAdaptor<V> { true } + // NOTE Remove after next snapshot. + #[cfg(stage0)] fn visit_type(&mut self) -> bool { if ! self.inner.visit_type() { return false; } true diff --git a/src/libstd/repr.rs b/src/libstd/repr.rs index c0f4efba0d1..4ced74a92b7 100644 --- a/src/libstd/repr.rs +++ b/src/libstd/repr.rs @@ -601,6 +601,9 @@ impl<'a> TyVisitor for ReprVisitor<'a> { fn visit_param(&mut self, _i: uint) -> bool { true } fn visit_self(&mut self) -> bool { true } + + // NOTE Remove after next snapshot. + #[cfg(stage0)] fn visit_type(&mut self) -> bool { true } } diff --git a/src/libstd/unstable/intrinsics.rs b/src/libstd/unstable/intrinsics.rs index 105236b5f4c..b9e9c9d5a43 100644 --- a/src/libstd/unstable/intrinsics.rs +++ b/src/libstd/unstable/intrinsics.rs @@ -160,6 +160,9 @@ pub trait TyVisitor { fn visit_trait(&mut self, name: &str) -> bool; fn visit_param(&mut self, i: uint) -> bool; fn visit_self(&mut self) -> bool; + + // NOTE Remove after next snapshot. + #[cfg(stage0)] fn visit_type(&mut self) -> bool; } diff --git a/src/test/compile-fail/borrowck-call-sendfn.rs b/src/test/compile-fail/borrowck-call-sendfn.rs index 00e8a12d572..57c0deb178d 100644 --- a/src/test/compile-fail/borrowck-call-sendfn.rs +++ b/src/test/compile-fail/borrowck-call-sendfn.rs @@ -8,15 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-test #2978 - struct Foo { f: proc() } -fn call(x: @Foo) { - x.f(); //~ ERROR foo - //~^ NOTE bar +fn call(x: Foo) { + x.f(); //~ ERROR does not implement any method in scope named `f` } fn main() {} diff --git a/src/test/compile-fail/issue-5500-1.rs b/src/test/compile-fail/issue-5500-1.rs index 42812e5559c..e1779a1db86 100644 --- a/src/test/compile-fail/issue-5500-1.rs +++ b/src/test/compile-fail/issue-5500-1.rs @@ -8,15 +8,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-test - struct TrieMapIterator<'a> { - priv node: &'a uint + node: &'a uint } fn main() { let a = 5; - let _iter = TrieMapIterator{node: &a}; //~ ERROR bad - _iter.node = & + let _iter = TrieMapIterator{node: &a}; + _iter.node = & //~ ERROR cannot assign to immutable field fail!() } diff --git a/src/test/compile-fail/issue-5500.rs b/src/test/compile-fail/issue-5500.rs deleted file mode 100644 index c778e750e3a..00000000000 --- a/src/test/compile-fail/issue-5500.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-test - -fn main() { &fail!() } //~ ERROR bad diff --git a/src/test/compile-fail/issue-6762.rs b/src/test/compile-fail/issue-6801.rs index 5d6b62fe283..5d6b62fe283 100644 --- a/src/test/compile-fail/issue-6762.rs +++ b/src/test/compile-fail/issue-6801.rs diff --git a/src/test/compile-fail/issue-897-2.rs b/src/test/compile-fail/issue-897-2.rs index f2fffffb3dc..91d47cae15c 100644 --- a/src/test/compile-fail/issue-897-2.rs +++ b/src/test/compile-fail/issue-897-2.rs @@ -1,18 +1,4 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-test -// ignored because the lint pass doesn't know to ignore standard library -// stuff. - -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -29,4 +15,5 @@ fn f() -> ! { return g(); g(); //~ ERROR: unreachable statement } -fn main() { } + +fn main() { f() } diff --git a/src/test/compile-fail/issue-897.rs b/src/test/compile-fail/issue-897.rs index 7befa16c238..18e25de3eae 100644 --- a/src/test/compile-fail/issue-897.rs +++ b/src/test/compile-fail/issue-897.rs @@ -8,12 +8,14 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-test +// error-pattern: unreachable statement #[deny(unreachable_code)]; fn f() -> ! { return fail!(); - fail!(); //~ ERROR: unreachable statement + fail!(); // the unreachable statement error is in <std macro>, at this line, there + // only is a note } -fn main() { } + +fn main() { f() } diff --git a/src/test/compile-fail/view-items-at-top.rs b/src/test/compile-fail/view-items-at-top.rs index 9614c1f037e..c7c96809eec 100644 --- a/src/test/compile-fail/view-items-at-top.rs +++ b/src/test/compile-fail/view-items-at-top.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-test - extern mod extra; fn f() { diff --git a/src/test/run-fail/addr-of-bot.rs b/src/test/run-fail/issue-5500.rs index 45dbe11c76e..45dbe11c76e 100644 --- a/src/test/run-fail/addr-of-bot.rs +++ b/src/test/run-fail/issue-5500.rs diff --git a/src/test/run-pass-fulldeps/syntax-extension-fourcc.rs b/src/test/run-pass-fulldeps/syntax-extension-fourcc.rs index 40472b91e51..ab25946b643 100644 --- a/src/test/run-pass-fulldeps/syntax-extension-fourcc.rs +++ b/src/test/run-pass-fulldeps/syntax-extension-fourcc.rs @@ -11,7 +11,7 @@ // ignore-fast Feature gating doesn't work // ignore-stage1 // ignore-pretty -// ignore-android +// ignore-cross-compile #[feature(phase)]; diff --git a/src/test/run-pass/issue-3559.rs b/src/test/run-pass/issue-3559.rs index 8da800c98b8..5cc098e591c 100644 --- a/src/test/run-pass/issue-3559.rs +++ b/src/test/run-pass/issue-3559.rs @@ -8,27 +8,20 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-test #4276 +use std::hashmap::HashMap; -// rustc --test map_to_str.rs && ./map_to_str -extern mod extra; - -fn check_strs(actual: &str, expected: &str) -> bool -{ - if actual != expected - { - println!("Found %s, but expected %s", actual, expected); +fn check_strs(actual: &str, expected: &str) -> bool { + if actual != expected { + println!("Found {}, but expected {}", actual, expected); return false; } return true; } -fn tester() -{ - let mut table = std::hashmap::HashMap::new(); - table.insert(@~"one", 1); - table.insert(@~"two", 2); - assert!(check_strs(table.to_str(), ~"xxx")); // not sure what expected should be +pub fn main() { + let mut table = HashMap::new(); + table.insert(~"one", 1); + table.insert(~"two", 2); + assert!(check_strs(table.to_str(), "{one: 1, two: 2}") || + check_strs(table.to_str(), "{two: 2, one: 1}")); } - -pub fn main() {} diff --git a/src/test/run-pass/reflect-visit-type.rs b/src/test/run-pass/reflect-visit-type.rs index a0d6fc4c157..56db021e2bc 100644 --- a/src/test/run-pass/reflect-visit-type.rs +++ b/src/test/run-pass/reflect-visit-type.rs @@ -138,7 +138,6 @@ impl TyVisitor for MyVisitor { fn visit_trait(&mut self, _name: &str) -> bool { true } fn visit_param(&mut self, _i: uint) -> bool { true } fn visit_self(&mut self) -> bool { true } - fn visit_type(&mut self) -> bool { true } } fn visit_ty<T>(v: &mut MyVisitor) { |
