diff --git a/configure b/configure index 609a7c46e36d8..9129fc0e19e5e 100755 --- a/configure +++ b/configure @@ -371,6 +371,7 @@ opt docs 1 "build documentation" opt optimize 1 "build optimized rust code" opt optimize-cxx 1 "build optimized C++ code" opt optimize-llvm 1 "build optimized LLVM" +opt optimize-tests 1 "build tests with optimizations" opt llvm-assertions 1 "build LLVM with assertions" opt debug 0 "build with extra debug fun" opt ratchet-bench 0 "ratchet benchmarks" diff --git a/mk/tests.mk b/mk/tests.mk index 349ffc63d9701..e644248c370d2 100644 --- a/mk/tests.mk +++ b/mk/tests.mk @@ -552,7 +552,15 @@ TEST_SREQ$(1)_T_$(2)_H_$(3) = \ # The tests select when to use debug configuration on their own; # remove directive, if present, from CFG_RUSTC_FLAGS (issue #7898). -CTEST_RUSTC_FLAGS = $$(subst --cfg debug,,$$(CFG_RUSTC_FLAGS)) +CTEST_RUSTC_FLAGS := $$(subst --cfg debug,,$$(CFG_RUSTC_FLAGS)) + +# The tests can not be optimized while the rest of the compiler is optimized, so +# filter out the optimization (if any) from rustc and then figure out if we need +# to be optimized +CTEST_RUSTC_FLAGS := $$(subst -O,,$$(CTEST_RUSTC_FLAGS)) +ifndef CFG_DISABLE_OPTIMIZE_TESTS +CTEST_RUSTC_FLAGS += -O +endif CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3) := \ --compile-lib-path $$(HLIB$(1)_H_$(3)) \ diff --git a/src/libextra/crypto/sha1.rs b/src/libextra/crypto/sha1.rs index aa52902c27d11..8ee9006f6136c 100644 --- a/src/libextra/crypto/sha1.rs +++ b/src/libextra/crypto/sha1.rs @@ -159,7 +159,7 @@ impl Sha1 { } impl Digest for Sha1 { - pub fn reset(&mut self) { + fn reset(&mut self) { self.length_bits = 0; self.h[0] = 0x67452301u32; self.h[1] = 0xEFCDAB89u32; @@ -169,9 +169,9 @@ impl Digest for Sha1 { self.buffer.reset(); self.computed = false; } - pub fn input(&mut self, msg: &[u8]) { add_input(self, msg); } - pub fn result(&mut self, out: &mut [u8]) { return mk_result(self, out); } - pub fn output_bits(&self) -> uint { 160 } + fn input(&mut self, msg: &[u8]) { add_input(self, msg); } + fn result(&mut self, out: &mut [u8]) { return mk_result(self, out); } + fn output_bits(&self) -> uint { 160 } } #[cfg(test)] diff --git a/src/libextra/ebml.rs b/src/libextra/ebml.rs index f66677c21f7d1..286ebe0b8d036 100644 --- a/src/libextra/ebml.rs +++ b/src/libextra/ebml.rs @@ -305,7 +305,7 @@ pub mod reader { self.pos = r_doc.end; let str = r_doc.as_str_slice(); if lbl != str { - fail!("Expected label %s but found %s", lbl, str); + fail!("Expected label %s, found %s", lbl, str); } } } @@ -326,7 +326,7 @@ pub mod reader { r_doc.start, r_doc.end); if r_tag != (exp_tag as uint) { - fail!("expected EBML doc with tag %? but found tag %?", exp_tag, r_tag); + fail!("expected EBML doc with tag %?, found tag %?", exp_tag, r_tag); } if r_doc.end > self.parent.end { fail!("invalid EBML, child extends to 0x%x, parent to 0x%x", diff --git a/src/libextra/enum_set.rs b/src/libextra/enum_set.rs index 25501faa02e12..28ff16c43e8af 100644 --- a/src/libextra/enum_set.rs +++ b/src/libextra/enum_set.rs @@ -21,9 +21,9 @@ pub struct EnumSet { /// An iterface for casting C-like enum to uint and back. pub trait CLike { /// Converts C-like enum to uint. - pub fn to_uint(&self) -> uint; + fn to_uint(&self) -> uint; /// Converts uint to C-like enum. - pub fn from_uint(uint) -> Self; + fn from_uint(uint) -> Self; } fn bit(e: E) -> uint { @@ -142,11 +142,11 @@ mod test { } impl CLike for Foo { - pub fn to_uint(&self) -> uint { + fn to_uint(&self) -> uint { *self as uint } - pub fn from_uint(v: uint) -> Foo { + fn from_uint(v: uint) -> Foo { unsafe { cast::transmute(v) } } } diff --git a/src/libextra/num/bigint.rs b/src/libextra/num/bigint.rs index 27dfc090f8888..354696ef42060 100644 --- a/src/libextra/num/bigint.rs +++ b/src/libextra/num/bigint.rs @@ -537,7 +537,7 @@ impl ToStrRadix for BigUint { impl FromStrRadix for BigUint { /// Creates and initializes an BigUint. - pub fn from_str_radix(s: &str, radix: uint) + fn from_str_radix(s: &str, radix: uint) -> Option { BigUint::parse_bytes(s.as_bytes(), radix) } diff --git a/src/libextra/terminfo/parm.rs b/src/libextra/terminfo/parm.rs index bb59e34f98a12..10f1b330c5b55 100644 --- a/src/libextra/terminfo/parm.rs +++ b/src/libextra/terminfo/parm.rs @@ -475,103 +475,6 @@ impl FormatOp { } } -#[cfg(stage0)] -fn format(val: Param, op: FormatOp, flags: Flags) -> Result<~[u8],~str> { - let mut s = match val { - Number(d) => { - match op { - FormatString => { - return Err(~"non-number on stack with %s") - } - _ => { - let radix = match op { - FormatDigit => 10, - FormatOctal => 8, - FormatHex|FormatHEX => 16, - FormatString => util::unreachable() - }; - let mut s = ~[]; - match op { - FormatDigit => { - let sign = if flags.sign { SignAll } else { SignNeg }; - do int_to_str_bytes_common(d, radix, sign) |c| { - s.push(c); - } - } - _ => { - do int_to_str_bytes_common(d as uint, radix, SignNone) |c| { - s.push(c); - } - } - }; - if flags.precision > s.len() { - let mut s_ = vec::with_capacity(flags.precision); - let n = flags.precision - s.len(); - s_.grow(n, &('0' as u8)); - s_.push_all_move(s); - s = s_; - } - assert!(!s.is_empty(), "string conversion produced empty result"); - match op { - FormatDigit => { - if flags.space && !(s[0] == '-' as u8 || s[0] == '+' as u8) { - s.unshift(' ' as u8); - } - } - FormatOctal => { - if flags.alternate && s[0] != '0' as u8 { - s.unshift('0' as u8); - } - } - FormatHex => { - if flags.alternate { - let s_ = util::replace(&mut s, ~['0' as u8, 'x' as u8]); - s.push_all_move(s_); - } - } - FormatHEX => { - s = s.into_ascii().to_upper().into_bytes(); - if flags.alternate { - let s_ = util::replace(&mut s, ~['0' as u8, 'X' as u8]); - s.push_all_move(s_); - } - } - FormatString => util::unreachable() - } - s - } - } - } - String(s) => { - match op { - FormatString => { - let mut s = s.as_bytes().to_owned(); - if flags.precision > 0 && flags.precision < s.len() { - s.truncate(flags.precision); - } - s - } - _ => { - return Err(fmt!("non-string on stack with %%%c", op.to_char())) - } - } - } - }; - if flags.width > s.len() { - let n = flags.width - s.len(); - if flags.left { - s.grow(n, &(' ' as u8)); - } else { - let mut s_ = vec::with_capacity(flags.width); - s_.grow(n, &(' ' as u8)); - s_.push_all_move(s); - s = s_; - } - } - Ok(s) -} - -#[cfg(not(stage0))] fn format(val: Param, op: FormatOp, flags: Flags) -> Result<~[u8],~str> { let mut s = match val { Number(d) => { diff --git a/src/libextra/terminfo/parser/compiled.rs b/src/libextra/terminfo/parser/compiled.rs index 0d2badff4929b..f07263a6459fd 100644 --- a/src/libextra/terminfo/parser/compiled.rs +++ b/src/libextra/terminfo/parser/compiled.rs @@ -178,7 +178,7 @@ pub fn parse(file: @Reader, longnames: bool) -> Result<~TermInfo, ~str> { // Check magic number let magic = file.read_le_u16(); if (magic != 0x011A) { - return Err(fmt!("invalid magic number: expected %x but found %x", 0x011A, magic as uint)); + return Err(fmt!("invalid magic number: expected %x, found %x", 0x011A, magic as uint)); } let names_bytes = file.read_le_i16() as int; @@ -196,19 +196,19 @@ pub fn parse(file: @Reader, longnames: bool) -> Result<~TermInfo, ~str> { debug!("string_table_bytes = %?", string_table_bytes); if (bools_bytes as uint) > boolnames.len() { - error!("expected bools_bytes to be less than %? but found %?", boolnames.len(), + error!("expected bools_bytes to be less than %?, found %?", boolnames.len(), bools_bytes); return Err(~"incompatible file: more booleans than expected"); } if (numbers_count as uint) > numnames.len() { - error!("expected numbers_count to be less than %? but found %?", numnames.len(), + error!("expected numbers_count to be less than %?, found %?", numnames.len(), numbers_count); return Err(~"incompatible file: more numbers than expected"); } if (string_offsets_count as uint) > stringnames.len() { - error!("expected string_offsets_count to be less than %? but found %?", stringnames.len(), + error!("expected string_offsets_count to be less than %?, found %?", stringnames.len(), string_offsets_count); return Err(~"incompatible file: more string offsets than expected"); } diff --git a/src/libextra/test.rs b/src/libextra/test.rs index 8b7332ff545a4..a9c3bf98cb659 100644 --- a/src/libextra/test.rs +++ b/src/libextra/test.rs @@ -104,7 +104,7 @@ pub struct Metric { pub struct MetricMap(TreeMap<~str,Metric>); impl Clone for MetricMap { - pub fn clone(&self) -> MetricMap { + fn clone(&self) -> MetricMap { MetricMap((**self).clone()) } } diff --git a/src/libextra/treemap.rs b/src/libextra/treemap.rs index f5a61692509ad..486a7dab5c1bb 100644 --- a/src/libextra/treemap.rs +++ b/src/libextra/treemap.rs @@ -853,7 +853,7 @@ impl> Extendable<(K, V), T> for TreeMap> FromIterator for TreeSet { - pub fn from_iterator(iter: &mut Iter) -> TreeSet { + fn from_iterator(iter: &mut Iter) -> TreeSet { let mut set = TreeSet::new(); set.extend(iter); set diff --git a/src/libextra/url.rs b/src/libextra/url.rs index 581bdf2a294db..3f23cbd02abab 100644 --- a/src/libextra/url.rs +++ b/src/libextra/url.rs @@ -701,7 +701,7 @@ pub fn to_str(url: &Url) -> ~str { } impl ToStr for Url { - pub fn to_str(&self) -> ~str { + fn to_str(&self) -> ~str { to_str(self) } } diff --git a/src/librustc/back/rpath.rs b/src/librustc/back/rpath.rs index e7706815ff537..22ed0b3cf3c8b 100644 --- a/src/librustc/back/rpath.rs +++ b/src/librustc/back/rpath.rs @@ -130,19 +130,6 @@ pub fn get_absolute_rpath(lib: &Path) -> Path { os::make_absolute(lib).dir_path() } -#[cfg(stage0)] -pub fn get_install_prefix_rpath(target_triple: &str) -> Path { - let install_prefix = env!("CFG_PREFIX"); - - if install_prefix == "" { - fail!("rustc compiled without CFG_PREFIX environment variable"); - } - - let tlib = filesearch::relative_target_lib_path(target_triple); - os::make_absolute(&Path(install_prefix).push_rel(&tlib)) -} - -#[cfg(not(stage0))] pub fn get_install_prefix_rpath(target_triple: &str) -> Path { let install_prefix = env!("CFG_PREFIX"); diff --git a/src/librustc/driver/driver.rs b/src/librustc/driver/driver.rs index aa759bc821a21..ca2e33b6a6dd5 100644 --- a/src/librustc/driver/driver.rs +++ b/src/librustc/driver/driver.rs @@ -578,25 +578,6 @@ pub fn build_target_config(sopts: @session::options, return target_cfg; } -#[cfg(stage0)] -pub fn host_triple() -> ~str { - // Get the host triple out of the build environment. This ensures that our - // idea of the host triple is the same as for the set of libraries we've - // actually built. We can't just take LLVM's host triple because they - // normalize all ix86 architectures to i386. - // - // Instead of grabbing the host triple (for the current host), we grab (at - // compile time) the target triple that this rustc is built with and - // calling that (at runtime) the host triple. - let ht = env!("CFG_COMPILER_TRIPLE"); - return if ht != "" { - ht.to_owned() - } else { - fail!("rustc built without CFG_COMPILER_TRIPLE") - }; -} - -#[cfg(not(stage0))] pub fn host_triple() -> ~str { // Get the host triple out of the build environment. This ensures that our // idea of the host triple is the same as for the set of libraries we've diff --git a/src/librustc/metadata/filesearch.rs b/src/librustc/metadata/filesearch.rs index 56200a221be37..33d517f3981bb 100644 --- a/src/librustc/metadata/filesearch.rs +++ b/src/librustc/metadata/filesearch.rs @@ -200,16 +200,6 @@ fn push_if_exists(vec: &mut ~[Path], p: &Path) { // The name of the directory rustc expects libraries to be located. // On Unix should be "lib", on windows "bin" -#[cfg(stage0)] -pub fn libdir() -> ~str { - let libdir = env!("CFG_LIBDIR"); - if libdir.is_empty() { - fail!("rustc compiled without CFG_LIBDIR environment variable"); - } - libdir.to_owned() -} - -#[cfg(not(stage0))] pub fn libdir() -> ~str { (env!("CFG_LIBDIR")).to_owned() } diff --git a/src/librustc/metadata/tydecode.rs b/src/librustc/metadata/tydecode.rs index 89b30e46ac06d..a922db55a3156 100644 --- a/src/librustc/metadata/tydecode.rs +++ b/src/librustc/metadata/tydecode.rs @@ -542,12 +542,12 @@ pub fn parse_def_id(buf: &[u8]) -> ast::def_id { let crate_num = match uint::parse_bytes(crate_part, 10u) { Some(cn) => cn as int, - None => fail!("internal error: parse_def_id: crate number expected, but found %?", + None => fail!("internal error: parse_def_id: crate number expected, found %?", crate_part) }; let def_num = match uint::parse_bytes(def_part, 10u) { Some(dn) => dn as int, - None => fail!("internal error: parse_def_id: id expected, but found %?", + None => fail!("internal error: parse_def_id: id expected, found %?", def_part) }; ast::def_id { crate: crate_num, node: def_num } diff --git a/src/librustc/middle/privacy.rs b/src/librustc/middle/privacy.rs index aa7b2e55cdc63..54e7c79e97cc2 100644 --- a/src/librustc/middle/privacy.rs +++ b/src/librustc/middle/privacy.rs @@ -351,6 +351,7 @@ pub fn check_crate<'mm>(tcx: ty::ctxt, // Do not check privacy inside items with the resolve_unexported // attribute. This is used for the test runner. if !attr::contains_name(item.attrs, "!resolve_unexported") { + check_sane_privacy(tcx, item); oldvisit::visit_item(item, (method_map, visitor)); } }, @@ -540,3 +541,81 @@ pub fn check_crate<'mm>(tcx: ty::ctxt, }); oldvisit::visit_crate(crate, (method_map, visitor)); } + +/// Validates all of the visibility qualifers placed on the item given. This +/// ensures that there are no extraneous qualifiers that don't actually do +/// anything. In theory these qualifiers wouldn't parse, but that may happen +/// later on down the road... +fn check_sane_privacy(tcx: ty::ctxt, item: @ast::item) { + match item.node { + // implementations of traits don't need visibility qualifiers because + // that's controlled by having the trait in scope. + ast::item_impl(_, Some(*), _, ref methods) => { + for m in methods.iter() { + match m.vis { + ast::private | ast::public => { + tcx.sess.span_err(m.span, "unnecessary visibility") + } + ast::inherited => {} + } + } + } + + ast::item_enum(ref def, _) => { + for v in def.variants.iter() { + match v.node.vis { + ast::public => { + if item.vis == ast::public { + tcx.sess.span_err(v.span, "unnecessary `pub` \ + visibility"); + } + } + ast::private => { + if item.vis != ast::public { + tcx.sess.span_err(v.span, "unnecessary `priv` \ + visibility"); + } + } + ast::inherited => {} + } + } + } + + ast::item_struct(ref def, _) => { + for f in def.fields.iter() { + match f.node.kind { + ast::named_field(_, ast::public) => { + tcx.sess.span_err(f.span, "unnecessary `pub` \ + visibility"); + } + ast::named_field(_, ast::private) => { + // Fields should really be private by default... + } + ast::named_field(*) | ast::unnamed_field => {} + } + } + } + + ast::item_trait(_, _, ref methods) => { + for m in methods.iter() { + match *m { + ast::provided(ref m) => { + match m.vis { + ast::private | ast::public => { + tcx.sess.span_err(m.span, "unnecessary \ + visibility"); + } + ast::inherited => {} + } + } + // this is warned about in the parser + ast::required(*) => {} + } + } + } + + ast::item_impl(*) | ast::item_static(*) | ast::item_foreign_mod(*) | + ast::item_fn(*) | ast::item_mod(*) | ast::item_ty(*) | + ast::item_mac(*) => {} + } +} diff --git a/src/librustc/middle/trans/_match.rs b/src/librustc/middle/trans/_match.rs index c98d859337c3e..d9b1b97ef9ed6 100644 --- a/src/librustc/middle/trans/_match.rs +++ b/src/librustc/middle/trans/_match.rs @@ -463,7 +463,7 @@ fn assert_is_binding_or_wild(bcx: @mut Block, p: @ast::pat) { if !pat_is_binding_or_wild(bcx.tcx().def_map, p) { bcx.sess().span_bug( p.span, - fmt!("Expected an identifier pattern but found p: %s", + fmt!("Expected an identifier pattern, found p: %s", p.repr(bcx.tcx()))); } } diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index 1291a586682ab..7331b50dd107c 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -165,7 +165,7 @@ impl<'self> StatRecorder<'self> { #[unsafe_destructor] impl<'self> Drop for StatRecorder<'self> { - pub fn drop(&self) { + fn drop(&self) { if self.ccx.sess.trans_stats() { let end = time::precise_time_ns(); let elapsed = ((end - self.start) / 1_000_000) as uint; diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 2ba6930d9c5ea..d311e24080d14 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -709,10 +709,10 @@ pub fn AllBuiltinBounds() -> BuiltinBounds { } impl CLike for BuiltinBound { - pub fn to_uint(&self) -> uint { + fn to_uint(&self) -> uint { *self as uint } - pub fn from_uint(v: uint) -> BuiltinBound { + fn from_uint(v: uint) -> BuiltinBound { unsafe { cast::transmute(v) } } } @@ -3427,15 +3427,15 @@ pub fn type_err_to_str(cx: ctxt, err: &type_err) -> ~str { match *err { terr_mismatch => ~"types differ", terr_purity_mismatch(values) => { - fmt!("expected %s fn but found %s fn", + fmt!("expected %s fn, found %s fn", values.expected.to_str(), values.found.to_str()) } terr_abi_mismatch(values) => { - fmt!("expected %s fn but found %s fn", + fmt!("expected %s fn, found %s fn", values.expected.to_str(), values.found.to_str()) } terr_onceness_mismatch(values) => { - fmt!("expected %s fn but found %s fn", + fmt!("expected %s fn, found %s fn", values.expected.to_str(), values.found.to_str()) } terr_sigil_mismatch(values) => { @@ -3449,25 +3449,25 @@ pub fn type_err_to_str(cx: ctxt, err: &type_err) -> ~str { terr_ptr_mutability => ~"pointers differ in mutability", terr_ref_mutability => ~"references differ in mutability", terr_ty_param_size(values) => { - fmt!("expected a type with %? type params \ - but found one with %? type params", + fmt!("expected a type with %? type params, \ + found one with %? type params", values.expected, values.found) } terr_tuple_size(values) => { - fmt!("expected a tuple with %? elements \ - but found one with %? elements", + fmt!("expected a tuple with %? elements, \ + found one with %? elements", values.expected, values.found) } terr_record_size(values) => { - fmt!("expected a record with %? fields \ - but found one with %? fields", + fmt!("expected a record with %? fields, \ + found one with %? fields", values.expected, values.found) } terr_record_mutability => { ~"record elements differ in mutability" } terr_record_fields(values) => { - fmt!("expected a record with field `%s` but found one with field \ + fmt!("expected a record with field `%s`, found one with field \ `%s`", cx.sess.str_of(values.expected), cx.sess.str_of(values.found)) @@ -3484,22 +3484,22 @@ pub fn type_err_to_str(cx: ctxt, err: &type_err) -> ~str { } terr_regions_insufficiently_polymorphic(br, _) => { fmt!("expected bound lifetime parameter %s, \ - but found concrete lifetime", + found concrete lifetime", bound_region_ptr_to_str(cx, br)) } terr_regions_overly_polymorphic(br, _) => { fmt!("expected concrete lifetime, \ - but found bound lifetime parameter %s", + found bound lifetime parameter %s", bound_region_ptr_to_str(cx, br)) } terr_vstores_differ(k, ref values) => { - fmt!("%s storage differs: expected %s but found %s", + fmt!("%s storage differs: expected %s, found %s", terr_vstore_kind_to_str(k), vstore_to_str(cx, (*values).expected), vstore_to_str(cx, (*values).found)) } terr_trait_stores_differ(_, ref values) => { - fmt!("trait storage differs: expected %s but found %s", + fmt!("trait storage differs: expected %s, found %s", trait_store_to_str(cx, (*values).expected), trait_store_to_str(cx, (*values).found)) } @@ -3508,38 +3508,38 @@ pub fn type_err_to_str(cx: ctxt, err: &type_err) -> ~str { type_err_to_str(cx, err)) } terr_sorts(values) => { - fmt!("expected %s but found %s", + fmt!("expected %s, found %s", ty_sort_str(cx, values.expected), ty_sort_str(cx, values.found)) } terr_traits(values) => { - fmt!("expected trait %s but found trait %s", + fmt!("expected trait %s, found trait %s", item_path_str(cx, values.expected), item_path_str(cx, values.found)) } terr_builtin_bounds(values) => { if values.expected.is_empty() { - fmt!("expected no bounds but found `%s`", + fmt!("expected no bounds, found `%s`", values.found.user_string(cx)) } else if values.found.is_empty() { - fmt!("expected bounds `%s` but found no bounds", + fmt!("expected bounds `%s`, found no bounds", values.expected.user_string(cx)) } else { - fmt!("expected bounds `%s` but found bounds `%s`", + fmt!("expected bounds `%s`, found bounds `%s`", values.expected.user_string(cx), values.found.user_string(cx)) } } terr_integer_as_char => { - fmt!("expected an integral type but found char") + fmt!("expected an integral type, found char") } terr_int_mismatch(ref values) => { - fmt!("expected %s but found %s", + fmt!("expected %s, found %s", values.expected.to_str(), values.found.to_str()) } terr_float_mismatch(ref values) => { - fmt!("expected %s but found %s", + fmt!("expected %s, found %s", values.expected.to_str(), values.found.to_str()) } @@ -4345,16 +4345,16 @@ pub fn normalize_ty(cx: ctxt, t: t) -> t { } pub trait ExprTyProvider { - pub fn expr_ty(&self, ex: &ast::expr) -> t; - pub fn ty_ctxt(&self) -> ctxt; + fn expr_ty(&self, ex: &ast::expr) -> t; + fn ty_ctxt(&self) -> ctxt; } impl ExprTyProvider for ctxt { - pub fn expr_ty(&self, ex: &ast::expr) -> t { + fn expr_ty(&self, ex: &ast::expr) -> t { expr_ty(*self, ex) } - pub fn ty_ctxt(&self) -> ctxt { + fn ty_ctxt(&self) -> ctxt { *self } } @@ -4366,7 +4366,7 @@ pub fn eval_repeat_count(tcx: &T, count_expr: &ast::expr) -> const_eval::const_int(count) => if count < 0 { tcx.ty_ctxt().sess.span_err(count_expr.span, "expected positive integer for \ - repeat count but found negative integer"); + repeat count, found negative integer"); return 0; } else { return count as uint @@ -4375,26 +4375,26 @@ pub fn eval_repeat_count(tcx: &T, count_expr: &ast::expr) -> const_eval::const_float(count) => { tcx.ty_ctxt().sess.span_err(count_expr.span, "expected positive integer for \ - repeat count but found float"); + repeat count, found float"); return count as uint; } const_eval::const_str(_) => { tcx.ty_ctxt().sess.span_err(count_expr.span, "expected positive integer for \ - repeat count but found string"); + repeat count, found string"); return 0; } const_eval::const_bool(_) => { tcx.ty_ctxt().sess.span_err(count_expr.span, "expected positive integer for \ - repeat count but found boolean"); + repeat count, found boolean"); return 0; } }, Err(*) => { tcx.ty_ctxt().sess.span_err(count_expr.span, - "expected constant integer for repeat count \ - but found variable"); + "expected constant integer for repeat count, \ + found variable"); return 0; } } diff --git a/src/librustc/middle/typeck/astconv.rs b/src/librustc/middle/typeck/astconv.rs index c666e98c9c15f..ad17d5cf0dfe3 100644 --- a/src/librustc/middle/typeck/astconv.rs +++ b/src/librustc/middle/typeck/astconv.rs @@ -177,7 +177,7 @@ fn ast_path_substs( if !vec::same_length(*decl_generics.type_param_defs, path.types) { this.tcx().sess.span_fatal( path.span, - fmt!("wrong number of type arguments: expected %u but found %u", + fmt!("wrong number of type arguments: expected %u, found %u", decl_generics.type_param_defs.len(), path.types.len())); } let tps = path.types.map(|a_t| ast_ty_to_ty(this, rscope, a_t)); diff --git a/src/librustc/middle/typeck/check/_match.rs b/src/librustc/middle/typeck/check/_match.rs index d8a9350e695d7..8341bc04a92f1 100644 --- a/src/librustc/middle/typeck/check/_match.rs +++ b/src/librustc/middle/typeck/check/_match.rs @@ -159,7 +159,7 @@ pub fn check_pat_variant(pcx: &pat_ctxt, pat: @ast::pat, path: &ast::Path, fcx.infcx().type_error_message_str_with_expected(pat.span, |expected, actual| { expected.map_move_default(~"", |e| { - fmt!("mismatched types: expected `%s` but found %s", + fmt!("mismatched types: expected `%s`, found %s", e, actual)})}, Some(expected), ~"a structure pattern", None); @@ -202,7 +202,7 @@ pub fn check_pat_variant(pcx: &pat_ctxt, pat: @ast::pat, path: &ast::Path, fcx.infcx().type_error_message_str_with_expected(pat.span, |expected, actual| { expected.map_move_default(~"", |e| { - fmt!("mismatched types: expected `%s` but found %s", + fmt!("mismatched types: expected `%s`, found %s", e, actual)})}, Some(expected), ~"an enum or structure pattern", None); @@ -341,7 +341,7 @@ pub fn check_struct_pat(pcx: &pat_ctxt, pat_id: ast::NodeId, span: span, Some(&ast::def_struct(*)) | Some(&ast::def_variant(*)) => { let name = pprust::path_to_str(path, tcx.sess.intr()); tcx.sess.span_err(span, - fmt!("mismatched types: expected `%s` but found `%s`", + fmt!("mismatched types: expected `%s`, found `%s`", fcx.infcx().ty_to_str(expected), name)); } @@ -500,7 +500,7 @@ pub fn check_pat(pcx: &pat_ctxt, pat: @ast::pat, expected: ty::t) { } _ => { tcx.sess.span_err(pat.span, - fmt!("mismatched types: expected `%s` but found struct", + fmt!("mismatched types: expected `%s`, found struct", fcx.infcx().ty_to_str(expected))); error_happened = true; } @@ -536,7 +536,7 @@ pub fn check_pat(pcx: &pat_ctxt, pat: @ast::pat, expected: ty::t) { }; fcx.infcx().type_error_message_str_with_expected(pat.span, |expected, actual| { expected.map_move_default(~"", |e| { - fmt!("mismatched types: expected `%s` but found %s", + fmt!("mismatched types: expected `%s`, found %s", e, actual)})}, Some(expected), ~"tuple", Some(&type_error)); fcx.write_error(pat.id); } @@ -585,7 +585,7 @@ pub fn check_pat(pcx: &pat_ctxt, pat: @ast::pat, expected: ty::t) { pat.span, |expected, actual| { expected.map_move_default(~"", |e| { - fmt!("mismatched types: expected `%s` but found %s", + fmt!("mismatched types: expected `%s`, found %s", e, actual)})}, Some(expected), ~"a vector pattern", @@ -643,7 +643,7 @@ pub fn check_pointer_pat(pcx: &pat_ctxt, span, |expected, actual| { expected.map_move_default(~"", |e| { - fmt!("mismatched types: expected `%s` but found %s", + fmt!("mismatched types: expected `%s`, found %s", e, actual)})}, Some(expected), fmt!("%s pattern", match pointer_kind { diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs index e7ef30c4576c4..d6e0ab62fd0af 100644 --- a/src/librustc/middle/typeck/check/mod.rs +++ b/src/librustc/middle/typeck/check/mod.rs @@ -287,11 +287,11 @@ pub fn blank_fn_ctxt(ccx: @mut CrateCtxt, } impl ExprTyProvider for FnCtxt { - pub fn expr_ty(&self, ex: &ast::expr) -> ty::t { + fn expr_ty(&self, ex: &ast::expr) -> ty::t { self.expr_ty(ex) } - pub fn ty_ctxt(&self) -> ty::ctxt { + fn ty_ctxt(&self) -> ty::ctxt { self.ccx.tcx } } @@ -1310,7 +1310,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, ty::ty_bool => {} _ => fcx.type_error_message(call_expr.span, |actual| { fmt!("expected `for` closure to return `bool`, \ - but found `%s`", actual) }, + found `%s`", actual) }, output, None) } ty::mk_nil() @@ -1358,7 +1358,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, ty::ty_closure(ty::ClosureTy {sig: ref sig, _}) => sig, _ => { fcx.type_error_message(call_expr.span, |actual| { - fmt!("expected function but \ + fmt!("expected function, \ found `%s`", actual) }, fn_ty, None); &error_fn_sig } @@ -2750,7 +2750,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt, pub fn require_integral(fcx: @mut FnCtxt, sp: span, t: ty::t) { if !type_is_integral(fcx, sp, t) { fcx.type_error_message(sp, |actual| { - fmt!("mismatched types: expected integral type but found `%s`", + fmt!("mismatched types: expected integral type, found `%s`", actual) }, t, None); } @@ -3130,28 +3130,28 @@ pub fn ty_param_bounds_and_ty_for_def(fcx: @mut FnCtxt, ast::def_ty(_) | ast::def_prim_ty(_) | ast::def_ty_param(*)=> { - fcx.ccx.tcx.sess.span_bug(sp, "expected value but found type"); + fcx.ccx.tcx.sess.span_bug(sp, "expected value, found type"); } ast::def_mod(*) | ast::def_foreign_mod(*) => { - fcx.ccx.tcx.sess.span_bug(sp, "expected value but found module"); + fcx.ccx.tcx.sess.span_bug(sp, "expected value, found module"); } ast::def_use(*) => { - fcx.ccx.tcx.sess.span_bug(sp, "expected value but found use"); + fcx.ccx.tcx.sess.span_bug(sp, "expected value, found use"); } ast::def_region(*) => { - fcx.ccx.tcx.sess.span_bug(sp, "expected value but found region"); + fcx.ccx.tcx.sess.span_bug(sp, "expected value, found region"); } ast::def_typaram_binder(*) => { - fcx.ccx.tcx.sess.span_bug(sp, "expected value but found type parameter"); + fcx.ccx.tcx.sess.span_bug(sp, "expected value, found type parameter"); } ast::def_label(*) => { - fcx.ccx.tcx.sess.span_bug(sp, "expected value but found label"); + fcx.ccx.tcx.sess.span_bug(sp, "expected value, found label"); } ast::def_self_ty(*) => { - fcx.ccx.tcx.sess.span_bug(sp, "expected value but found self ty"); + fcx.ccx.tcx.sess.span_bug(sp, "expected value, found self ty"); } ast::def_method(*) => { - fcx.ccx.tcx.sess.span_bug(sp, "expected value but found method"); + fcx.ccx.tcx.sess.span_bug(sp, "expected value, found method"); } } } diff --git a/src/librustc/middle/typeck/check/vtable.rs b/src/librustc/middle/typeck/check/vtable.rs index 37f4a6ba49737..6d22f10f5b8ad 100644 --- a/src/librustc/middle/typeck/check/vtable.rs +++ b/src/librustc/middle/typeck/check/vtable.rs @@ -207,7 +207,7 @@ fn relate_trait_refs(vcx: &VtableContext, let tcx = vcx.tcx(); tcx.sess.span_err( location_info.span, - fmt!("expected %s, but found %s (%s)", + fmt!("expected %s, found %s (%s)", ppaux::trait_ref_to_str(tcx, &r_exp_trait_ref), ppaux::trait_ref_to_str(tcx, &r_act_trait_ref), ty::type_err_to_str(tcx, err))); diff --git a/src/librustc/middle/typeck/infer/doc.rs b/src/librustc/middle/typeck/infer/doc.rs index 11bfbc637169e..539418dbcb228 100644 --- a/src/librustc/middle/typeck/infer/doc.rs +++ b/src/librustc/middle/typeck/infer/doc.rs @@ -240,4 +240,4 @@ We make use of a trait-like impementation strategy to consolidate duplicated code between subtypes, GLB, and LUB computations. See the section on "Type Combining" below for details. -*/ \ No newline at end of file +*/ diff --git a/src/librustc/middle/typeck/infer/error_reporting.rs b/src/librustc/middle/typeck/infer/error_reporting.rs index 1b325dd8a4b99..d604540cd1641 100644 --- a/src/librustc/middle/typeck/infer/error_reporting.rs +++ b/src/librustc/middle/typeck/infer/error_reporting.rs @@ -76,12 +76,12 @@ use util::ppaux::UserString; use util::ppaux::note_and_explain_region; pub trait ErrorReporting { - pub fn report_region_errors(@mut self, - errors: &OptVec); + fn report_region_errors(@mut self, + errors: &OptVec); - pub fn report_and_explain_type_error(@mut self, - trace: TypeTrace, - terr: &ty::type_err); + fn report_and_explain_type_error(@mut self, + trace: TypeTrace, + terr: &ty::type_err); fn values_str(@mut self, values: &ValuePairs) -> Option<~str>; @@ -112,8 +112,8 @@ pub trait ErrorReporting { impl ErrorReporting for InferCtxt { - pub fn report_region_errors(@mut self, - errors: &OptVec) { + fn report_region_errors(@mut self, + errors: &OptVec) { for error in errors.iter() { match *error { ConcreteFailure(origin, sub, sup) => { @@ -139,7 +139,7 @@ impl ErrorReporting for InferCtxt { } } - pub fn report_and_explain_type_error(@mut self, + fn report_and_explain_type_error(@mut self, trace: TypeTrace, terr: &ty::type_err) { let tcx = self.tcx; @@ -173,7 +173,7 @@ impl ErrorReporting for InferCtxt { fn values_str(@mut self, values: &ValuePairs) -> Option<~str> { /*! - * Returns a string of the form "expected `%s` but found `%s`", + * Returns a string of the form "expected `%s`, found `%s`", * or None if this is a derived error. */ match *values { @@ -201,7 +201,7 @@ impl ErrorReporting for InferCtxt { return None; } - Some(fmt!("expected `%s` but found `%s`", + Some(fmt!("expected `%s`, found `%s`", expected.user_string(self.tcx), found.user_string(self.tcx))) } diff --git a/src/librustc/middle/typeck/infer/mod.rs b/src/librustc/middle/typeck/infer/mod.rs index 7fa7daf614901..d0993674d35d1 100644 --- a/src/librustc/middle/typeck/infer/mod.rs +++ b/src/librustc/middle/typeck/infer/mod.rs @@ -765,7 +765,7 @@ impl InferCtxt { _ => { // if I leave out : ~str, it infers &str and complains |actual: ~str| { - fmt!("mismatched types: expected `%s` but found `%s`", + fmt!("mismatched types: expected `%s`, found `%s`", self.ty_to_str(resolved_expected), actual) } } diff --git a/src/librustc/middle/typeck/mod.rs b/src/librustc/middle/typeck/mod.rs index 53ae80f19facc..61027519b5b9d 100644 --- a/src/librustc/middle/typeck/mod.rs +++ b/src/librustc/middle/typeck/mod.rs @@ -294,11 +294,11 @@ trait get_and_find_region { } impl get_and_find_region for isr_alist { - pub fn get(&self, br: ty::bound_region) -> ty::Region { + fn get(&self, br: ty::bound_region) -> ty::Region { self.find(br).unwrap() } - pub fn find(&self, br: ty::bound_region) -> Option { + fn find(&self, br: ty::bound_region) -> Option { let mut ret = None; do list::each(*self) |isr| { let (isr_br, isr_r) = *isr; diff --git a/src/librustc/rustc.rs b/src/librustc/rustc.rs index ec80d1a44ead9..195ff0dc6b695 100644 --- a/src/librustc/rustc.rs +++ b/src/librustc/rustc.rs @@ -117,16 +117,6 @@ mod std { } */ -#[cfg(stage0)] -pub fn version(argv0: &str) { - let mut vers = ~"unknown version"; - let env_vers = env!("CFG_VERSION"); - if env_vers.len() != 0 { vers = env_vers.to_owned(); } - printfln!("%s %s", argv0, vers); - printfln!("host: %s", host_triple()); -} - -#[cfg(not(stage0))] pub fn version(argv0: &str) { let vers = match option_env!("CFG_VERSION") { Some(vers) => vers, diff --git a/src/librustdoc/config.rs b/src/librustdoc/config.rs index 877338902cc07..dd43e22fc0c57 100644 --- a/src/librustdoc/config.rs +++ b/src/librustdoc/config.rs @@ -22,18 +22,18 @@ use extra::getopts; #[deriving(Clone, Eq)] pub enum OutputFormat { /// Markdown - pub Markdown, + Markdown, /// HTML, via markdown and pandoc - pub PandocHtml + PandocHtml } /// How to organize the output #[deriving(Clone, Eq)] pub enum OutputStyle { /// All in a single document - pub DocPerCrate, + DocPerCrate, /// Each module in its own document - pub DocPerMod + DocPerMod } /// The configuration for a rustdoc session diff --git a/src/librustpkg/package_source.rs b/src/librustpkg/package_source.rs index ff485342fbe98..5368f1267722c 100644 --- a/src/librustpkg/package_source.rs +++ b/src/librustpkg/package_source.rs @@ -52,18 +52,19 @@ impl PkgSrc { use conditions::nonexistent_package::cond; debug!("Pushing onto root: %s | %s", self.id.path.to_str(), self.root.to_str()); - let dir; + let dirs = pkgid_src_in_workspace(&self.id, &self.root); debug!("Checking dirs: %?", dirs); let path = dirs.iter().find(|&d| os::path_exists(d)); - match path { - Some(d) => dir = (*d).clone(), - None => dir = match self.fetch_git() { + + let dir = match path { + Some(d) => (*d).clone(), + None => match self.fetch_git() { + Some(d) => d, None => cond.raise((self.id.clone(), ~"supplied path for package dir does not \ - exist, and couldn't interpret it as a URL fragment")), - Some(d) => d + exist, and couldn't interpret it as a URL fragment")) } - } + }; if !os::path_is_dir(&dir) { cond.raise((self.id.clone(), ~"supplied path for package dir is a \ non-directory")); @@ -145,26 +146,26 @@ impl PkgSrc { let prefix = dir.components.len(); debug!("Matching against %?", self.id.short_name); do os::walk_dir(&dir) |pth| { - match pth.filename() { - Some(~"lib.rs") => PkgSrc::push_crate(&mut self.libs, - prefix, - pth), - Some(~"main.rs") => PkgSrc::push_crate(&mut self.mains, - prefix, - pth), - Some(~"test.rs") => PkgSrc::push_crate(&mut self.tests, - prefix, - pth), - Some(~"bench.rs") => PkgSrc::push_crate(&mut self.benchs, - prefix, - pth), - _ => () + let maybe_known_crate_set = match pth.filename() { + Some(filename) => match filename { + ~"lib.rs" => Some(&mut self.libs), + ~"main.rs" => Some(&mut self.mains), + ~"test.rs" => Some(&mut self.tests), + ~"bench.rs" => Some(&mut self.benchs), + _ => None + }, + _ => None + }; + + match maybe_known_crate_set { + Some(crate_set) => PkgSrc::push_crate(crate_set, prefix, pth), + None => () } true }; - if self.libs.is_empty() && self.mains.is_empty() - && self.tests.is_empty() && self.benchs.is_empty() { + let crate_sets = [&self.libs, &self.mains, &self.tests, &self.benchs]; + if crate_sets.iter().all(|crate_set| crate_set.is_empty()) { note("Couldn't infer any crates to build.\n\ Try naming a crate `main.rs`, `lib.rs`, \ diff --git a/src/librustpkg/path_util.rs b/src/librustpkg/path_util.rs index bbe84b2ecac4f..0232b6cb1051f 100644 --- a/src/librustpkg/path_util.rs +++ b/src/librustpkg/path_util.rs @@ -19,7 +19,6 @@ use std::libc::consts::os::posix88::{S_IRUSR, S_IWUSR, S_IXUSR}; use std::os::mkdir_recursive; use std::os; use messages::*; -use package_id::*; pub fn default_workspace() -> Path { let p = rust_path(); @@ -51,35 +50,34 @@ pub fn make_dir_rwx(p: &Path) -> bool { os::make_dir(p, U_RWX) } /// pkgid's short name pub fn workspace_contains_package_id(pkgid: &PkgId, workspace: &Path) -> bool { let src_dir = workspace.push("src"); + let mut found = false; do os::walk_dir(&src_dir) |p| { debug!("=> p = %s", p.to_str()); - if os::path_is_dir(p) { + + let was_found = os::path_is_dir(p) && { debug!("p = %s, path = %s [%s]", p.to_str(), pkgid.path.to_str(), - src_dir.push_rel(&pkgid.path).to_str()); + src_dir.push_rel(&pkgid.path).to_str()); - if *p == src_dir.push_rel(&pkgid.path) { - found = true; - } - else { + *p == src_dir.push_rel(&pkgid.path) || { let pf = p.filename(); - for pf in pf.iter() { - let f_ = (*pf).clone(); - let g = f_.to_str(); + do pf.iter().any |pf| { + let g = pf.to_str(); match split_version_general(g, '-') { + None => false, Some((ref might_match, ref vers)) => { debug!("might_match = %s, vers = %s", *might_match, - vers.to_str()); - if *might_match == pkgid.short_name - && (*vers == pkgid.version || pkgid.version == NoVersion) - { - found = true; - } + vers.to_str()); + *might_match == pkgid.short_name + && (pkgid.version == *vers || pkgid.version == NoVersion) } - None => () - } + } } } + }; + + if was_found { + found = true } true }; @@ -102,12 +100,9 @@ pub fn pkgid_src_in_workspace(pkgid: &PkgId, workspace: &Path) -> ~[Path] { /// Returns a src for pkgid that does exist -- None if none of them do pub fn first_pkgid_src_in_workspace(pkgid: &PkgId, workspace: &Path) -> Option { let rs = pkgid_src_in_workspace(pkgid, workspace); - for p in rs.iter() { - if os::path_exists(p) { - return Some((*p).clone()); - } - } - None + do rs.iter().find |&p| { + os::path_exists(p) + }.map(|p| (**p).clone()) } /// Figure out what the executable name for in 's build @@ -195,22 +190,31 @@ pub fn library_in_workspace(path: &Path, short_name: &str, where: Target, debug!("lib_prefix = %s and lib_filetype = %s", lib_prefix, lib_filetype); - let mut result_filename = None; - for p in dir_contents.iter() { - let mut which = 0; - let mut hash = None; - let p_path = Path((*p).clone()); - let extension = p_path.filetype(); + // Find a filename that matches the pattern: + // (lib_prefix)-hash-(version)(lib_suffix) + let paths = do dir_contents.iter().map |p| { + Path((*p).clone()) + }; + + let mut libraries = do paths.filter |p| { + let extension = p.filetype(); debug!("p = %s, p's extension is %?", p.to_str(), extension); match extension { - Some(ref s) if lib_filetype == *s => (), - _ => loop + None => false, + Some(ref s) => lib_filetype == *s } + }; + + let mut result_filename = None; + for p_path in libraries { // Find a filename that matches the pattern: (lib_prefix)-hash-(version)(lib_suffix) // and remember what the hash was let f_name = match p_path.filename() { Some(s) => s, None => loop }; + + let mut hash = None; + let mut which = 0; for piece in f_name.split_iter('-') { debug!("a piece = %s", piece); if which == 0 && piece != lib_prefix { @@ -229,26 +233,27 @@ pub fn library_in_workspace(path: &Path, short_name: &str, where: Target, break; } } + if hash.is_some() { result_filename = Some(p_path); break; } } + if result_filename.is_none() { + warn(fmt!("library_in_workspace didn't find a library in %s for %s", + dir_to_search.to_str(), short_name)); + } + // Return the filename that matches, which we now know exists // (if result_filename != None) - match result_filename { - None => { - warn(fmt!("library_in_workspace didn't find a library in %s for %s", - dir_to_search.to_str(), short_name)); - None - } - Some(result_filename) => { - let absolute_path = dir_to_search.push_rel(&result_filename); - debug!("result_filename = %s", absolute_path.to_str()); - Some(absolute_path) - } - } + let abs_path = do result_filename.map |result_filename| { + let absolute_path = dir_to_search.push_rel(result_filename); + debug!("result_filename = %s", absolute_path.to_str()); + absolute_path + }; + + abs_path } /// Returns the executable that would be installed for diff --git a/src/librustpkg/search.rs b/src/librustpkg/search.rs index d04b2c8f3701a..ea0389fed7727 100644 --- a/src/librustpkg/search.rs +++ b/src/librustpkg/search.rs @@ -13,12 +13,9 @@ use path_util::installed_library_in_workspace; /// If a library with path `p` matching pkg_id's name exists under sroot_opt, /// return Some(p). Return None if there's no such path or if sroot_opt is None. pub fn find_library_in_search_path(sroot_opt: Option<@Path>, short_name: &str) -> Option { - match sroot_opt { - Some(sroot) => { - debug!("Will search for a library with short name %s in \ - %s", short_name, (sroot.push("lib")).to_str()); - installed_library_in_workspace(short_name, sroot) - } - None => None + do sroot_opt.chain |sroot| { + debug!("Will search for a library with short name %s in \ + %s", short_name, (sroot.push("lib")).to_str()); + installed_library_in_workspace(short_name, sroot) } } diff --git a/src/librustpkg/testsuite/pass/src/fancy-lib/foo.rs b/src/librustpkg/testsuite/pass/src/fancy-lib/foo.rs index 542a6af402d05..3b233c9f6a88a 100644 --- a/src/librustpkg/testsuite/pass/src/fancy-lib/foo.rs +++ b/src/librustpkg/testsuite/pass/src/fancy-lib/foo.rs @@ -9,4 +9,4 @@ // except according to those terms. pub fn do_nothing() { -} \ No newline at end of file +} diff --git a/src/librustpkg/testsuite/pass/src/install-paths/bench.rs b/src/librustpkg/testsuite/pass/src/install-paths/bench.rs index e1641ccf07493..3d22ddc57faa3 100644 --- a/src/librustpkg/testsuite/pass/src/install-paths/bench.rs +++ b/src/librustpkg/testsuite/pass/src/install-paths/bench.rs @@ -14,4 +14,4 @@ fn g() { while(x < 1000) { x += 1; } -} \ No newline at end of file +} diff --git a/src/librustpkg/testsuite/pass/src/simple-lib/src/foo.rs b/src/librustpkg/testsuite/pass/src/simple-lib/src/foo.rs index 542a6af402d05..3b233c9f6a88a 100644 --- a/src/librustpkg/testsuite/pass/src/simple-lib/src/foo.rs +++ b/src/librustpkg/testsuite/pass/src/simple-lib/src/foo.rs @@ -9,4 +9,4 @@ // except according to those terms. pub fn do_nothing() { -} \ No newline at end of file +} diff --git a/src/libstd/cast.rs b/src/libstd/cast.rs index ff9057afb55fc..9d1d6e65901ae 100644 --- a/src/libstd/cast.rs +++ b/src/libstd/cast.rs @@ -165,20 +165,10 @@ mod tests { } } - #[cfg(stage0)] - #[test] - fn test_transmute2() { - unsafe { - assert_eq!(~[76u8, 0u8], transmute(~"L")); - } - } - - #[cfg(not(stage0))] #[test] fn test_transmute2() { unsafe { assert_eq!(~[76u8], transmute(~"L")); } } - } diff --git a/src/libstd/cell.rs b/src/libstd/cell.rs index 5a0c781fe9a87..372effad61d3c 100644 --- a/src/libstd/cell.rs +++ b/src/libstd/cell.rs @@ -13,6 +13,7 @@ #[missing_doc]; use cast::transmute_mut; +use unstable::finally::Finally; use prelude::*; /* @@ -65,18 +66,17 @@ impl Cell { /// Calls a closure with a reference to the value. pub fn with_ref(&self, op: &fn(v: &T) -> R) -> R { - let v = self.take(); - let r = op(&v); - self.put_back(v); - r + do self.with_mut_ref |ptr| { op(ptr) } } /// Calls a closure with a mutable reference to the value. pub fn with_mut_ref(&self, op: &fn(v: &mut T) -> R) -> R { - let mut v = self.take(); - let r = op(&mut v); - self.put_back(v); - r + let mut v = Some(self.take()); + do (|| { + op(v.get_mut_ref()) + }).finally { + self.put_back(v.take_unwrap()); + } } } diff --git a/src/libstd/io.rs b/src/libstd/io.rs index 07572d60917a0..2c18bd272e817 100644 --- a/src/libstd/io.rs +++ b/src/libstd/io.rs @@ -1707,20 +1707,6 @@ pub fn with_bytes_writer(f: &fn(@Writer)) -> ~[u8] { (*bytes).clone() } -#[cfg(stage0)] -pub fn with_str_writer(f: &fn(@Writer)) -> ~str { - let mut v = with_bytes_writer(f); - - // Make sure the vector has a trailing null and is proper utf8. - v.push(0); - assert!(str::is_utf8(v)); - - unsafe { - ::cast::transmute(v) - } -} - -#[cfg(not(stage0))] pub fn with_str_writer(f: &fn(@Writer)) -> ~str { str::from_bytes(with_bytes_writer(f)) } diff --git a/src/libstd/num/num.rs b/src/libstd/num/num.rs index 62452a4edff55..9e72b355bf9f9 100644 --- a/src/libstd/num/num.rs +++ b/src/libstd/num/num.rs @@ -19,7 +19,6 @@ use cmp::{Eq, ApproxEq, Ord}; use ops::{Add, Sub, Mul, Div, Rem, Neg}; use ops::{Not, BitAnd, BitOr, BitXor, Shl, Shr}; use option::{Option, Some, None}; -#[cfg(not(stage0))] use unstable::intrinsics; pub mod strconv; @@ -415,11 +414,11 @@ impl_num_cast!(f64, to_f64) impl_num_cast!(float, to_float) pub trait ToStrRadix { - pub fn to_str_radix(&self, radix: uint) -> ~str; + fn to_str_radix(&self, radix: uint) -> ~str; } pub trait FromStrRadix { - pub fn from_str_radix(str: &str, radix: uint) -> Option; + fn from_str_radix(str: &str, radix: uint) -> Option; } /// Calculates a power to a given radix, optimized for uint `pow` and `radix`. @@ -522,7 +521,6 @@ pub trait CheckedAdd: Add { fn checked_add(&self, v: &Self) -> Option; } -#[cfg(not(stage0))] impl CheckedAdd for i8 { #[inline] fn checked_add(&self, v: &i8) -> Option { @@ -533,7 +531,6 @@ impl CheckedAdd for i8 { } } -#[cfg(not(stage0))] impl CheckedAdd for i16 { #[inline] fn checked_add(&self, v: &i16) -> Option { @@ -544,7 +541,6 @@ impl CheckedAdd for i16 { } } -#[cfg(not(stage0))] impl CheckedAdd for i32 { #[inline] fn checked_add(&self, v: &i32) -> Option { @@ -555,7 +551,6 @@ impl CheckedAdd for i32 { } } -#[cfg(not(stage0))] impl CheckedAdd for i64 { #[inline] fn checked_add(&self, v: &i64) -> Option { @@ -566,7 +561,7 @@ impl CheckedAdd for i64 { } } -#[cfg(not(stage0), target_word_size = "32")] +#[cfg(target_word_size = "32")] impl CheckedAdd for int { #[inline] fn checked_add(&self, v: &int) -> Option { @@ -577,7 +572,7 @@ impl CheckedAdd for int { } } -#[cfg(not(stage0), target_word_size = "64")] +#[cfg(target_word_size = "64")] impl CheckedAdd for int { #[inline] fn checked_add(&self, v: &int) -> Option { @@ -588,7 +583,6 @@ impl CheckedAdd for int { } } -#[cfg(not(stage0))] impl CheckedAdd for u8 { #[inline] fn checked_add(&self, v: &u8) -> Option { @@ -599,7 +593,6 @@ impl CheckedAdd for u8 { } } -#[cfg(not(stage0))] impl CheckedAdd for u16 { #[inline] fn checked_add(&self, v: &u16) -> Option { @@ -610,7 +603,6 @@ impl CheckedAdd for u16 { } } -#[cfg(not(stage0))] impl CheckedAdd for u32 { #[inline] fn checked_add(&self, v: &u32) -> Option { @@ -621,7 +613,6 @@ impl CheckedAdd for u32 { } } -#[cfg(not(stage0))] impl CheckedAdd for u64 { #[inline] fn checked_add(&self, v: &u64) -> Option { @@ -632,7 +623,7 @@ impl CheckedAdd for u64 { } } -#[cfg(not(stage0), target_word_size = "32")] +#[cfg(target_word_size = "32")] impl CheckedAdd for uint { #[inline] fn checked_add(&self, v: &uint) -> Option { @@ -643,7 +634,7 @@ impl CheckedAdd for uint { } } -#[cfg(not(stage0), target_word_size = "64")] +#[cfg(target_word_size = "64")] impl CheckedAdd for uint { #[inline] fn checked_add(&self, v: &uint) -> Option { @@ -658,7 +649,6 @@ pub trait CheckedSub: Sub { fn checked_sub(&self, v: &Self) -> Option; } -#[cfg(not(stage0))] impl CheckedSub for i8 { #[inline] fn checked_sub(&self, v: &i8) -> Option { @@ -669,7 +659,6 @@ impl CheckedSub for i8 { } } -#[cfg(not(stage0))] impl CheckedSub for i16 { #[inline] fn checked_sub(&self, v: &i16) -> Option { @@ -680,7 +669,6 @@ impl CheckedSub for i16 { } } -#[cfg(not(stage0))] impl CheckedSub for i32 { #[inline] fn checked_sub(&self, v: &i32) -> Option { @@ -691,7 +679,6 @@ impl CheckedSub for i32 { } } -#[cfg(not(stage0))] impl CheckedSub for i64 { #[inline] fn checked_sub(&self, v: &i64) -> Option { @@ -702,7 +689,7 @@ impl CheckedSub for i64 { } } -#[cfg(not(stage0), target_word_size = "32")] +#[cfg(target_word_size = "32")] impl CheckedSub for int { #[inline] fn checked_sub(&self, v: &int) -> Option { @@ -713,7 +700,7 @@ impl CheckedSub for int { } } -#[cfg(not(stage0), target_word_size = "64")] +#[cfg(target_word_size = "64")] impl CheckedSub for int { #[inline] fn checked_sub(&self, v: &int) -> Option { @@ -724,7 +711,6 @@ impl CheckedSub for int { } } -#[cfg(not(stage0))] impl CheckedSub for u8 { #[inline] fn checked_sub(&self, v: &u8) -> Option { @@ -735,7 +721,6 @@ impl CheckedSub for u8 { } } -#[cfg(not(stage0))] impl CheckedSub for u16 { #[inline] fn checked_sub(&self, v: &u16) -> Option { @@ -746,7 +731,6 @@ impl CheckedSub for u16 { } } -#[cfg(not(stage0))] impl CheckedSub for u32 { #[inline] fn checked_sub(&self, v: &u32) -> Option { @@ -757,7 +741,6 @@ impl CheckedSub for u32 { } } -#[cfg(not(stage0))] impl CheckedSub for u64 { #[inline] fn checked_sub(&self, v: &u64) -> Option { @@ -768,7 +751,7 @@ impl CheckedSub for u64 { } } -#[cfg(not(stage0), target_word_size = "32")] +#[cfg(target_word_size = "32")] impl CheckedSub for uint { #[inline] fn checked_sub(&self, v: &uint) -> Option { @@ -779,7 +762,7 @@ impl CheckedSub for uint { } } -#[cfg(not(stage0), target_word_size = "64")] +#[cfg(target_word_size = "64")] impl CheckedSub for uint { #[inline] fn checked_sub(&self, v: &uint) -> Option { @@ -794,7 +777,6 @@ pub trait CheckedMul: Mul { fn checked_mul(&self, v: &Self) -> Option; } -#[cfg(not(stage0))] impl CheckedMul for i8 { #[inline] fn checked_mul(&self, v: &i8) -> Option { @@ -805,7 +787,6 @@ impl CheckedMul for i8 { } } -#[cfg(not(stage0))] impl CheckedMul for i16 { #[inline] fn checked_mul(&self, v: &i16) -> Option { @@ -816,7 +797,6 @@ impl CheckedMul for i16 { } } -#[cfg(not(stage0))] impl CheckedMul for i32 { #[inline] fn checked_mul(&self, v: &i32) -> Option { @@ -828,7 +808,7 @@ impl CheckedMul for i32 { } // FIXME: #8449: should not be disabled on 32-bit -#[cfg(not(stage0), target_word_size = "64")] +#[cfg(target_word_size = "64")] impl CheckedMul for i64 { #[inline] fn checked_mul(&self, v: &i64) -> Option { @@ -839,7 +819,7 @@ impl CheckedMul for i64 { } } -#[cfg(not(stage0), target_word_size = "32")] +#[cfg(target_word_size = "32")] impl CheckedMul for int { #[inline] fn checked_mul(&self, v: &int) -> Option { @@ -850,7 +830,7 @@ impl CheckedMul for int { } } -#[cfg(not(stage0), target_word_size = "64")] +#[cfg(target_word_size = "64")] impl CheckedMul for int { #[inline] fn checked_mul(&self, v: &int) -> Option { @@ -861,7 +841,6 @@ impl CheckedMul for int { } } -#[cfg(not(stage0))] impl CheckedMul for u8 { #[inline] fn checked_mul(&self, v: &u8) -> Option { @@ -872,7 +851,6 @@ impl CheckedMul for u8 { } } -#[cfg(not(stage0))] impl CheckedMul for u16 { #[inline] fn checked_mul(&self, v: &u16) -> Option { @@ -883,7 +861,6 @@ impl CheckedMul for u16 { } } -#[cfg(not(stage0))] impl CheckedMul for u32 { #[inline] fn checked_mul(&self, v: &u32) -> Option { @@ -895,7 +872,7 @@ impl CheckedMul for u32 { } // FIXME: #8449: should not be disabled on 32-bit -#[cfg(not(stage0), target_word_size = "64")] +#[cfg(target_word_size = "64")] impl CheckedMul for u64 { #[inline] fn checked_mul(&self, v: &u64) -> Option { @@ -906,7 +883,7 @@ impl CheckedMul for u64 { } } -#[cfg(not(stage0), target_word_size = "32")] +#[cfg(target_word_size = "32")] impl CheckedMul for uint { #[inline] fn checked_mul(&self, v: &uint) -> Option { @@ -917,7 +894,7 @@ impl CheckedMul for uint { } } -#[cfg(not(stage0), target_word_size = "64")] +#[cfg(target_word_size = "64")] impl CheckedMul for uint { #[inline] fn checked_mul(&self, v: &uint) -> Option { diff --git a/src/libstd/ops.rs b/src/libstd/ops.rs index 756b4a10d3c90..e41109ecf675b 100644 --- a/src/libstd/ops.rs +++ b/src/libstd/ops.rs @@ -105,4 +105,4 @@ mod bench { HasDtor { x : 10 }; } } -} \ No newline at end of file +} diff --git a/src/libstd/ptr.rs b/src/libstd/ptr.rs index 26653a51d6618..b13d46d540d4a 100644 --- a/src/libstd/ptr.rs +++ b/src/libstd/ptr.rs @@ -309,15 +309,6 @@ impl RawPtr for *T { /// Calculates the offset from a pointer. The offset *must* be in-bounds of /// the object, or one-byte-past-the-end. #[inline] - #[cfg(stage0)] - unsafe fn offset_inbounds(self, count: int) -> *T { - intrinsics::offset(self, count) - } - - /// Calculates the offset from a pointer. The offset *must* be in-bounds of - /// the object, or one-byte-past-the-end. - #[inline] - #[cfg(not(stage0))] unsafe fn offset_inbounds(self, count: int) -> *T { intrinsics::offset_inbounds(self, count) } @@ -361,19 +352,6 @@ impl RawPtr for *mut T { /// This method should be preferred over `offset` when the guarantee can be /// satisfied, to enable better optimization. #[inline] - #[cfg(stage0)] - unsafe fn offset_inbounds(self, count: int) -> *mut T { - intrinsics::offset(self as *T, count) as *mut T - } - - /// Calculates the offset from a pointer. The offset *must* be in-bounds of - /// the object, or one-byte-past-the-end. An arithmetic overflow is also - /// undefined behaviour. - /// - /// This method should be preferred over `offset` when the guarantee can be - /// satisfied, to enable better optimization. - #[inline] - #[cfg(not(stage0))] unsafe fn offset_inbounds(self, count: int) -> *mut T { intrinsics::offset_inbounds(self as *T, count) as *mut T } @@ -416,7 +394,7 @@ impl Add for *T { /// Add an integer value to a pointer to get an offset pointer. /// Is calculated according to the size of the type pointed to. #[inline] - pub fn add(&self, rhs: &I) -> *T { + fn add(&self, rhs: &I) -> *T { self.offset(rhs.to_int() as int) } } @@ -426,7 +404,7 @@ impl Sub for *T { /// Subtract an integer value from a pointer to get an offset pointer. /// Is calculated according to the size of the type pointed to. #[inline] - pub fn sub(&self, rhs: &I) -> *T { + fn sub(&self, rhs: &I) -> *T { self.offset(-rhs.to_int() as int) } } @@ -436,7 +414,7 @@ impl Add for *mut T { /// Add an integer value to a pointer to get an offset pointer. /// Is calculated according to the size of the type pointed to. #[inline] - pub fn add(&self, rhs: &I) -> *mut T { + fn add(&self, rhs: &I) -> *mut T { self.offset(rhs.to_int() as int) } } @@ -446,7 +424,7 @@ impl Sub for *mut T { /// Subtract an integer value from a pointer to get an offset pointer. /// Is calculated according to the size of the type pointed to. #[inline] - pub fn sub(&self, rhs: &I) -> *mut T { + fn sub(&self, rhs: &I) -> *mut T { self.offset(-rhs.to_int() as int) } } diff --git a/src/libstd/rand.rs b/src/libstd/rand.rs index 5f8fa9fddbcf7..500278fddb0b1 100644 --- a/src/libstd/rand.rs +++ b/src/libstd/rand.rs @@ -260,7 +260,7 @@ pub mod rustrt { /// A random number generator pub trait Rng { /// Return the next random integer - pub fn next(&mut self) -> u32; + fn next(&mut self) -> u32; } /// A value with a particular weight compared to other values @@ -825,7 +825,7 @@ pub struct XorShiftRng { impl Rng for XorShiftRng { #[inline] - pub fn next(&mut self) -> u32 { + fn next(&mut self) -> u32 { let x = self.x; let t = x ^ (x << 11); self.x = self.y; diff --git a/src/libstd/repr.rs b/src/libstd/repr.rs index d0970f1b6b7ad..743a47a812aed 100644 --- a/src/libstd/repr.rs +++ b/src/libstd/repr.rs @@ -158,18 +158,6 @@ impl ReprVisitor { } #[inline] - #[cfg(stage0)] - pub fn visit_ptr_inner(&self, ptr: *c_void, inner: *TyDesc) -> bool { - unsafe { - let u = ReprVisitor(ptr, self.writer); - let v = reflect::MovePtrAdaptor(u); - visit_tydesc(inner, @v as @TyVisitor); - true - } - } - - #[inline] - #[cfg(not(stage0))] pub fn visit_ptr_inner(&self, ptr: *c_void, inner: *TyDesc) -> bool { unsafe { let u = ReprVisitor(ptr, self.writer); @@ -568,18 +556,6 @@ impl TyVisitor for ReprVisitor { fn visit_closure_ptr(&self, _ck: uint) -> bool { true } } -#[cfg(stage0)] -pub fn write_repr(writer: @Writer, object: &T) { - unsafe { - let ptr = ptr::to_unsafe_ptr(object) as *c_void; - let tydesc = get_tydesc::(); - let u = ReprVisitor(ptr, writer); - let v = reflect::MovePtrAdaptor(u); - visit_tydesc(tydesc, @v as @TyVisitor) - } -} - -#[cfg(not(stage0))] pub fn write_repr(writer: @Writer, object: &T) { unsafe { let ptr = ptr::to_unsafe_ptr(object) as *c_void; diff --git a/src/libstd/rt/comm.rs b/src/libstd/rt/comm.rs index 793e244bec7b9..42d59ccdf958e 100644 --- a/src/libstd/rt/comm.rs +++ b/src/libstd/rt/comm.rs @@ -18,7 +18,8 @@ use kinds::Send; use rt; use rt::sched::Scheduler; use rt::local::Local; -use rt::select::{Select, SelectPort}; +use rt::select::{SelectInner, SelectPortInner}; +use select::{Select, SelectPort}; use unstable::atomics::{AtomicUint, AtomicOption, Acquire, Relaxed, SeqCst}; use unstable::sync::UnsafeAtomicRcBox; use util::Void; @@ -113,7 +114,9 @@ impl ChanOne { // 'do_resched' configures whether the scheduler immediately switches to // the receiving task, or leaves the sending task still running. fn try_send_inner(self, val: T, do_resched: bool) -> bool { - rtassert!(!rt::in_sched_context()); + if do_resched { + rtassert!(!rt::in_sched_context()); + } let mut this = self; let mut recvr_active = true; @@ -215,7 +218,7 @@ impl PortOne { } } -impl Select for PortOne { +impl SelectInner for PortOne { #[inline] #[cfg(not(test))] fn optimistic_check(&mut self) -> bool { unsafe { (*self.packet()).state.load(Acquire) == STATE_ONE } @@ -318,7 +321,9 @@ impl Select for PortOne { } } -impl SelectPort for PortOne { +impl Select for PortOne { } + +impl SelectPortInner for PortOne { fn recv_ready(self) -> Option { let mut this = self; let packet = this.packet(); @@ -349,6 +354,8 @@ impl SelectPort for PortOne { } } +impl SelectPort for PortOne { } + impl Peekable for PortOne { fn peek(&self) -> bool { unsafe { @@ -513,7 +520,7 @@ impl Peekable for Port { // of them, but a &Port should also be selectable so you can select2 on it // alongside a PortOne without passing the port by value in recv_ready. -impl<'self, T> Select for &'self Port { +impl<'self, T> SelectInner for &'self Port { #[inline] fn optimistic_check(&mut self) -> bool { do self.next.with_mut_ref |pone| { pone.optimistic_check() } @@ -531,7 +538,9 @@ impl<'self, T> Select for &'self Port { } } -impl Select for Port { +impl<'self, T> Select for &'self Port { } + +impl SelectInner for Port { #[inline] fn optimistic_check(&mut self) -> bool { (&*self).optimistic_check() @@ -548,7 +557,9 @@ impl Select for Port { } } -impl<'self, T> SelectPort for &'self Port { +impl Select for Port { } + +impl<'self, T> SelectPortInner for &'self Port { fn recv_ready(self) -> Option { match self.next.take().recv_ready() { Some(StreamPayload { val, next }) => { @@ -560,6 +571,8 @@ impl<'self, T> SelectPort for &'self Port { } } +impl<'self, T> SelectPort for &'self Port { } + pub struct SharedChan { // Just like Chan, but a shared AtomicOption instead of Cell priv next: UnsafeAtomicRcBox>> diff --git a/src/libstd/rt/io/comm_adapters.rs b/src/libstd/rt/io/comm_adapters.rs index 6a3e44b2a4d70..06424fee8bc12 100644 --- a/src/libstd/rt/io/comm_adapters.rs +++ b/src/libstd/rt/io/comm_adapters.rs @@ -31,9 +31,9 @@ impl> ChanWriter { } impl> Writer for ChanWriter { - pub fn write(&mut self, _buf: &[u8]) { fail!() } + fn write(&mut self, _buf: &[u8]) { fail!() } - pub fn flush(&mut self) { fail!() } + fn flush(&mut self) { fail!() } } struct ReaderPort; diff --git a/src/libstd/rt/io/mock.rs b/src/libstd/rt/io/mock.rs index b580b752bd985..c46e1372c6414 100644 --- a/src/libstd/rt/io/mock.rs +++ b/src/libstd/rt/io/mock.rs @@ -47,4 +47,4 @@ impl MockWriter { impl Writer for MockWriter { fn write(&mut self, buf: &[u8]) { (self.write)(buf) } fn flush(&mut self) { (self.flush)() } -} \ No newline at end of file +} diff --git a/src/libstd/rt/io/timer.rs b/src/libstd/rt/io/timer.rs index c7820ebf6238b..78ce52fca20ec 100644 --- a/src/libstd/rt/io/timer.rs +++ b/src/libstd/rt/io/timer.rs @@ -61,4 +61,4 @@ mod test { } } } -} \ No newline at end of file +} diff --git a/src/libstd/rt/kill.rs b/src/libstd/rt/kill.rs index 07b4ea10b6a37..83bf34941dc70 100644 --- a/src/libstd/rt/kill.rs +++ b/src/libstd/rt/kill.rs @@ -488,8 +488,8 @@ impl Death { rtassert!(self.unkillable == 0); self.unkillable = 1; - // FIXME(#7544): See corresponding fixme at the callsite in task.rs. - // NB(#8192): Doesn't work with "let _ = ..." + // NB. See corresponding comment at the callsite in task.rs. + // FIXME(#8192): Doesn't work with "let _ = ..." { use util; util::ignore(group); } // Step 1. Decide if we need to collect child failures synchronously. diff --git a/src/libstd/rt/metrics.rs b/src/libstd/rt/metrics.rs index b0c0fa5d70862..8912420645750 100644 --- a/src/libstd/rt/metrics.rs +++ b/src/libstd/rt/metrics.rs @@ -95,4 +95,4 @@ impl ToStr for SchedMetrics { self.release_no_tombstone ) } -} \ No newline at end of file +} diff --git a/src/libstd/rt/mod.rs b/src/libstd/rt/mod.rs index 1b9f28b95fb3f..3a991e92b0b5f 100644 --- a/src/libstd/rt/mod.rs +++ b/src/libstd/rt/mod.rs @@ -142,8 +142,7 @@ pub mod tube; /// Simple reimplementation of core::comm pub mod comm; -/// Routines for select()ing on pipes. -pub mod select; +mod select; // FIXME #5248 shouldn't be pub /// The runtime needs to be able to put a pointer into thread-local storage. diff --git a/src/libstd/rt/select.rs b/src/libstd/rt/select.rs index bde703af31580..19a4948af3c5a 100644 --- a/src/libstd/rt/select.rs +++ b/src/libstd/rt/select.rs @@ -8,14 +8,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use option::*; -// use either::{Either, Left, Right}; +//! Module for private, abstraction-leaking select traits. Wrapped in std::select. + use rt::kill::BlockedTask; use rt::sched::Scheduler; -use rt::local::Local; +use option::Option; -/// Trait for message-passing primitives that can be select()ed on. -pub trait Select { +pub trait SelectInner { // Returns true if data was available. fn optimistic_check(&mut self) -> bool; // Returns true if data was available. If so, shall also wake() the task. @@ -24,305 +23,6 @@ pub trait Select { fn unblock_from(&mut self) -> bool; } -/// Trait for message-passing primitives that can use the select2() convenience wrapper. -// (This is separate from the above trait to enable heterogeneous lists of ports -// that implement Select on different types to use select().) -pub trait SelectPort : Select { +pub trait SelectPortInner { fn recv_ready(self) -> Option; } - -/// Receive a message from any one of many ports at once. -pub fn select(ports: &mut [A]) -> uint { - if ports.is_empty() { - fail!("can't select on an empty list"); - } - - for (index, port) in ports.mut_iter().enumerate() { - if port.optimistic_check() { - return index; - } - } - - // If one of the ports already contains data when we go to block on it, we - // don't bother enqueueing on the rest of them, so we shouldn't bother - // unblocking from it either. This is just for efficiency, not correctness. - // (If not, we need to unblock from all of them. Length is a placeholder.) - let mut ready_index = ports.len(); - - let sched = Local::take::(); - do sched.deschedule_running_task_and_then |sched, task| { - let task_handles = task.make_selectable(ports.len()); - - for (index, (port, task_handle)) in - ports.mut_iter().zip(task_handles.move_iter()).enumerate() { - // If one of the ports has data by now, it will wake the handle. - if port.block_on(sched, task_handle) { - ready_index = index; - break; - } - } - } - - // Task resumes. Now unblock ourselves from all the ports we blocked on. - // If the success index wasn't reset, 'take' will just take all of them. - // Iterate in reverse so the 'earliest' index that's ready gets returned. - for (index, port) in ports.mut_slice(0, ready_index).mut_rev_iter().enumerate() { - if port.unblock_from() { - ready_index = index; - } - } - - assert!(ready_index < ports.len()); - return ready_index; -} - -/* FIXME(#5121, #7914) This all should be legal, but rust is not clever enough yet. - -impl <'self> Select for &'self mut Select { - fn optimistic_check(&mut self) -> bool { self.optimistic_check() } - fn block_on(&mut self, sched: &mut Scheduler, task: BlockedTask) -> bool { - self.block_on(sched, task) - } - fn unblock_from(&mut self) -> bool { self.unblock_from() } -} - -pub fn select2, TB, B: SelectPort>(mut a: A, mut b: B) - -> Either<(Option, B), (A, Option)> { - let result = { - let mut ports = [&mut a as &mut Select, &mut b as &mut Select]; - select(ports) - }; - match result { - 0 => Left ((a.recv_ready(), b)), - 1 => Right((a, b.recv_ready())), - x => fail!("impossible case in select2: %?", x) - } -} - -*/ - -#[cfg(test)] -mod test { - use super::*; - use option::*; - use rt::comm::*; - use rt::test::*; - use vec::*; - use comm::GenericChan; - use task; - use cell::Cell; - use iterator::{Iterator, range}; - - #[test] #[ignore(cfg(windows))] #[should_fail] - fn select_doesnt_get_trolled() { - select::>([]); - } - - /* non-blocking select tests */ - - #[cfg(test)] - fn select_helper(num_ports: uint, send_on_chans: &[uint]) { - // Unfortunately this does not actually test the block_on early-break - // codepath in select -- racing between the sender and the receiver in - // separate tasks is necessary to get around the optimistic check. - let (ports, chans) = unzip(from_fn(num_ports, |_| oneshot::<()>())); - let mut dead_chans = ~[]; - let mut ports = ports; - for (i, chan) in chans.move_iter().enumerate() { - if send_on_chans.contains(&i) { - chan.send(()); - } else { - dead_chans.push(chan); - } - } - let ready_index = select(ports); - assert!(send_on_chans.contains(&ready_index)); - assert!(ports.swap_remove(ready_index).recv_ready().is_some()); - let _ = dead_chans; - - // Same thing with streams instead. - // FIXME(#7971): This should be in a macro but borrowck isn't smart enough. - let (ports, chans) = unzip(from_fn(num_ports, |_| stream::<()>())); - let mut dead_chans = ~[]; - let mut ports = ports; - for (i, chan) in chans.move_iter().enumerate() { - if send_on_chans.contains(&i) { - chan.send(()); - } else { - dead_chans.push(chan); - } - } - let ready_index = select(ports); - assert!(send_on_chans.contains(&ready_index)); - assert!(ports.swap_remove(ready_index).recv_ready().is_some()); - let _ = dead_chans; - } - - #[test] - fn select_one() { - do run_in_newsched_task { select_helper(1, [0]) } - } - - #[test] - fn select_two() { - // NB. I would like to have a test that tests the first one that is - // ready is the one that's returned, but that can't be reliably tested - // with the randomized behaviour of optimistic_check. - do run_in_newsched_task { select_helper(2, [1]) } - do run_in_newsched_task { select_helper(2, [0]) } - do run_in_newsched_task { select_helper(2, [1,0]) } - } - - #[test] - fn select_a_lot() { - do run_in_newsched_task { select_helper(12, [7,8,9]) } - } - - #[test] - fn select_stream() { - use util; - use comm::GenericChan; - use iter::Times; - - // Sends 10 buffered packets, and uses select to retrieve them all. - // Puts the port in a different spot in the vector each time. - do run_in_newsched_task { - let (ports, _) = unzip(from_fn(10, |_| stream())); - let (port, chan) = stream(); - do 10.times { chan.send(31337); } - let mut ports = ports; - let mut port = Some(port); - let order = [5u,0,4,3,2,6,9,8,7,1]; - for &index in order.iter() { - // put the port in the vector at any index - util::swap(port.get_mut_ref(), &mut ports[index]); - assert!(select(ports) == index); - // get it back out - util::swap(port.get_mut_ref(), &mut ports[index]); - // NB. Not recv(), because optimistic_check randomly fails. - assert!(port.get_ref().recv_ready().unwrap() == 31337); - } - } - } - - #[test] - fn select_unkillable() { - do run_in_newsched_task { - do task::unkillable { select_helper(2, [1]) } - } - } - - /* blocking select tests */ - - #[test] - fn select_blocking() { - select_blocking_helper(true); - select_blocking_helper(false); - - fn select_blocking_helper(killable: bool) { - do run_in_newsched_task { - let (p1,_c) = oneshot(); - let (p2,c2) = oneshot(); - let mut ports = [p1,p2]; - - let (p3,c3) = oneshot(); - let (p4,c4) = oneshot(); - - let x = Cell::new((c2, p3, c4)); - do task::spawn { - let (c2, p3, c4) = x.take(); - p3.recv(); // handshake parent - c4.send(()); // normal receive - task::yield(); - c2.send(()); // select receive - } - - // Try to block before child sends on c2. - c3.send(()); - p4.recv(); - if killable { - assert!(select(ports) == 1); - } else { - do task::unkillable { assert!(select(ports) == 1); } - } - } - } - } - - #[test] - fn select_racing_senders() { - static NUM_CHANS: uint = 10; - - select_racing_senders_helper(true, ~[0,1,2,3,4,5,6,7,8,9]); - select_racing_senders_helper(false, ~[0,1,2,3,4,5,6,7,8,9]); - select_racing_senders_helper(true, ~[0,1,2]); - select_racing_senders_helper(false, ~[0,1,2]); - select_racing_senders_helper(true, ~[3,4,5,6]); - select_racing_senders_helper(false, ~[3,4,5,6]); - select_racing_senders_helper(true, ~[7,8,9]); - select_racing_senders_helper(false, ~[7,8,9]); - - fn select_racing_senders_helper(killable: bool, send_on_chans: ~[uint]) { - use rt::test::spawntask_random; - use iter::Times; - - do run_in_newsched_task { - // A bit of stress, since ordinarily this is just smoke and mirrors. - do 4.times { - let send_on_chans = send_on_chans.clone(); - do task::spawn { - let mut ports = ~[]; - for i in range(0u, NUM_CHANS) { - let (p,c) = oneshot(); - ports.push(p); - if send_on_chans.contains(&i) { - let c = Cell::new(c); - do spawntask_random { - task::yield(); - c.take().send(()); - } - } - } - // nondeterministic result, but should succeed - if killable { - select(ports); - } else { - do task::unkillable { select(ports); } - } - } - } - } - } - } - - #[test] #[ignore(cfg(windows))] - fn select_killed() { - do run_in_newsched_task { - let (success_p, success_c) = oneshot::(); - let success_c = Cell::new(success_c); - do task::try { - let success_c = Cell::new(success_c.take()); - do task::unkillable { - let (p,c) = oneshot(); - let c = Cell::new(c); - do task::spawn { - let (dead_ps, dead_cs) = unzip(from_fn(5, |_| oneshot::<()>())); - let mut ports = dead_ps; - select(ports); // should get killed; nothing should leak - c.take().send(()); // must not happen - // Make sure dead_cs doesn't get closed until after select. - let _ = dead_cs; - } - do task::spawn { - fail!(); // should kill sibling awake - } - - // wait for killed selector to close (NOT send on) its c. - // hope to send 'true'. - success_c.take().send(p.try_recv().is_none()); - } - }; - assert!(success_p.recv()); - } - } -} diff --git a/src/libstd/rt/sleeper_list.rs b/src/libstd/rt/sleeper_list.rs index d327023de978a..48012199bbef5 100644 --- a/src/libstd/rt/sleeper_list.rs +++ b/src/libstd/rt/sleeper_list.rs @@ -56,4 +56,4 @@ impl Clone for SleeperList { stack: self.stack.clone() } } -} \ No newline at end of file +} diff --git a/src/libstd/rt/task.rs b/src/libstd/rt/task.rs index b50e794cce0f3..c669f25d8b738 100644 --- a/src/libstd/rt/task.rs +++ b/src/libstd/rt/task.rs @@ -253,12 +253,10 @@ impl Task { } } - // FIXME(#7544): We pass the taskgroup into death so that it can be - // dropped while the unkillable counter is set. This should not be - // necessary except for an extraneous clone() in task/spawn.rs that - // causes a killhandle to get dropped, which mustn't receive a kill - // signal since we're outside of the unwinder's try() scope. - // { let _ = self.taskgroup.take(); } + // NB. We pass the taskgroup into death so that it can be dropped while + // the unkillable counter is set. This is necessary for when the + // taskgroup destruction code drops references on KillHandles, which + // might require using unkillable (to synchronize with an unwrapper). self.death.collect_failure(!self.unwinder.unwinding, self.taskgroup.take()); self.destroyed = true; } diff --git a/src/libstd/rt/uv/mod.rs b/src/libstd/rt/uv/mod.rs index ae5e7dd27b5f3..6c5a28b31b1e4 100644 --- a/src/libstd/rt/uv/mod.rs +++ b/src/libstd/rt/uv/mod.rs @@ -90,8 +90,8 @@ pub trait Request { } /// A type that wraps a native handle pub trait NativeHandle { - pub fn from_native_handle(T) -> Self; - pub fn native_handle(&self) -> T; + fn from_native_handle(T) -> Self; + fn native_handle(&self) -> T; } impl Loop { @@ -155,7 +155,7 @@ pub trait WatcherInterop { impl> WatcherInterop for W { /// Get the uv event loop from a Watcher - pub fn event_loop(&self) -> Loop { + fn event_loop(&self) -> Loop { unsafe { let handle = self.native_handle(); let loop_ = uvll::get_loop_for_uv_handle(handle); @@ -163,7 +163,7 @@ impl> WatcherInterop for W { } } - pub fn install_watcher_data(&mut self) { + fn install_watcher_data(&mut self) { unsafe { let data = ~WatcherData { read_cb: None, @@ -182,7 +182,7 @@ impl> WatcherInterop for W { } } - pub fn get_watcher_data<'r>(&'r mut self) -> &'r mut WatcherData { + fn get_watcher_data<'r>(&'r mut self) -> &'r mut WatcherData { unsafe { let data = uvll::get_data_for_uv_handle(self.native_handle()); let data = transmute::<&*c_void, &mut ~WatcherData>(&data); @@ -190,7 +190,7 @@ impl> WatcherInterop for W { } } - pub fn drop_watcher_data(&mut self) { + fn drop_watcher_data(&mut self) { unsafe { let data = uvll::get_data_for_uv_handle(self.native_handle()); let _data = transmute::<*c_void, ~WatcherData>(data); diff --git a/src/libstd/select.rs b/src/libstd/select.rs new file mode 100644 index 0000000000000..a92339e256244 --- /dev/null +++ b/src/libstd/select.rs @@ -0,0 +1,344 @@ +// Copyright 2013 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use cell::Cell; +use comm; +use container::Container; +use iterator::Iterator; +use option::*; +// use either::{Either, Left, Right}; +// use rt::kill::BlockedTask; +use rt::sched::Scheduler; +use rt::select::{SelectInner, SelectPortInner}; +use rt::local::Local; +use rt::rtio::EventLoop; +use task; +use vec::{OwnedVector, MutableVector}; + +/// Trait for message-passing primitives that can be select()ed on. +pub trait Select : SelectInner { } + +/// Trait for message-passing primitives that can use the select2() convenience wrapper. +// (This is separate from the above trait to enable heterogeneous lists of ports +// that implement Select on different types to use select().) +pub trait SelectPort : SelectPortInner { } + +/// Receive a message from any one of many ports at once. Returns the index of the +/// port whose data is ready. (If multiple are ready, returns the lowest index.) +pub fn select(ports: &mut [A]) -> uint { + if ports.is_empty() { + fail!("can't select on an empty list"); + } + + for (index, port) in ports.mut_iter().enumerate() { + if port.optimistic_check() { + return index; + } + } + + // If one of the ports already contains data when we go to block on it, we + // don't bother enqueueing on the rest of them, so we shouldn't bother + // unblocking from it either. This is just for efficiency, not correctness. + // (If not, we need to unblock from all of them. Length is a placeholder.) + let mut ready_index = ports.len(); + + // XXX: We're using deschedule...and_then in an unsafe way here (see #8132), + // in that we need to continue mutating the ready_index in the environment + // after letting the task get woken up. The and_then closure needs to delay + // the task from resuming until all ports have become blocked_on. + let (p,c) = comm::oneshot(); + let p = Cell::new(p); + let c = Cell::new(c); + + let sched = Local::take::(); + do sched.deschedule_running_task_and_then |sched, task| { + let task_handles = task.make_selectable(ports.len()); + + for (index, (port, task_handle)) in + ports.mut_iter().zip(task_handles.move_iter()).enumerate() { + // If one of the ports has data by now, it will wake the handle. + if port.block_on(sched, task_handle) { + ready_index = index; + break; + } + } + + let c = Cell::new(c.take()); + do sched.event_loop.callback { c.take().send_deferred(()) } + } + + // Unkillable is necessary not because getting killed is dangerous here, + // but to force the recv not to use the same kill-flag that we used for + // selecting. Otherwise a user-sender could spuriously wakeup us here. + do task::unkillable { p.take().recv(); } + + // Task resumes. Now unblock ourselves from all the ports we blocked on. + // If the success index wasn't reset, 'take' will just take all of them. + // Iterate in reverse so the 'earliest' index that's ready gets returned. + for (index, port) in ports.mut_slice(0, ready_index).mut_rev_iter().enumerate() { + if port.unblock_from() { + ready_index = index; + } + } + + assert!(ready_index < ports.len()); + return ready_index; +} + +/* FIXME(#5121, #7914) This all should be legal, but rust is not clever enough yet. + +impl <'self> Select for &'self mut Select { + fn optimistic_check(&mut self) -> bool { self.optimistic_check() } + fn block_on(&mut self, sched: &mut Scheduler, task: BlockedTask) -> bool { + self.block_on(sched, task) + } + fn unblock_from(&mut self) -> bool { self.unblock_from() } +} + +pub fn select2, TB, B: SelectPort>(mut a: A, mut b: B) + -> Either<(Option, B), (A, Option)> { + let result = { + let mut ports = [&mut a as &mut Select, &mut b as &mut Select]; + select(ports) + }; + match result { + 0 => Left ((a.recv_ready(), b)), + 1 => Right((a, b.recv_ready())), + x => fail!("impossible case in select2: %?", x) + } +} + +*/ + +#[cfg(test)] +mod test { + use super::*; + use clone::Clone; + use iter::Times; + use option::*; + use rt::comm::*; + use rt::test::*; + use vec::*; + use comm::GenericChan; + use task; + use cell::Cell; + use iterator::{Iterator, range}; + + #[test] #[ignore(cfg(windows))] #[should_fail] + fn select_doesnt_get_trolled() { + select::>([]); + } + + /* non-blocking select tests */ + + #[cfg(test)] + fn select_helper(num_ports: uint, send_on_chans: &[uint]) { + // Unfortunately this does not actually test the block_on early-break + // codepath in select -- racing between the sender and the receiver in + // separate tasks is necessary to get around the optimistic check. + let (ports, chans) = unzip(from_fn(num_ports, |_| oneshot::<()>())); + let mut dead_chans = ~[]; + let mut ports = ports; + for (i, chan) in chans.move_iter().enumerate() { + if send_on_chans.contains(&i) { + chan.send(()); + } else { + dead_chans.push(chan); + } + } + let ready_index = select(ports); + assert!(send_on_chans.contains(&ready_index)); + assert!(ports.swap_remove(ready_index).recv_ready().is_some()); + let _ = dead_chans; + + // Same thing with streams instead. + // FIXME(#7971): This should be in a macro but borrowck isn't smart enough. + let (ports, chans) = unzip(from_fn(num_ports, |_| stream::<()>())); + let mut dead_chans = ~[]; + let mut ports = ports; + for (i, chan) in chans.move_iter().enumerate() { + if send_on_chans.contains(&i) { + chan.send(()); + } else { + dead_chans.push(chan); + } + } + let ready_index = select(ports); + assert!(send_on_chans.contains(&ready_index)); + assert!(ports.swap_remove(ready_index).recv_ready().is_some()); + let _ = dead_chans; + } + + #[test] + fn select_one() { + do run_in_newsched_task { select_helper(1, [0]) } + } + + #[test] + fn select_two() { + // NB. I would like to have a test that tests the first one that is + // ready is the one that's returned, but that can't be reliably tested + // with the randomized behaviour of optimistic_check. + do run_in_newsched_task { select_helper(2, [1]) } + do run_in_newsched_task { select_helper(2, [0]) } + do run_in_newsched_task { select_helper(2, [1,0]) } + } + + #[test] + fn select_a_lot() { + do run_in_newsched_task { select_helper(12, [7,8,9]) } + } + + #[test] + fn select_stream() { + use util; + use comm::GenericChan; + + // Sends 10 buffered packets, and uses select to retrieve them all. + // Puts the port in a different spot in the vector each time. + do run_in_newsched_task { + let (ports, _) = unzip(from_fn(10, |_| stream())); + let (port, chan) = stream(); + do 10.times { chan.send(31337); } + let mut ports = ports; + let mut port = Some(port); + let order = [5u,0,4,3,2,6,9,8,7,1]; + for &index in order.iter() { + // put the port in the vector at any index + util::swap(port.get_mut_ref(), &mut ports[index]); + assert!(select(ports) == index); + // get it back out + util::swap(port.get_mut_ref(), &mut ports[index]); + // NB. Not recv(), because optimistic_check randomly fails. + assert!(port.get_ref().recv_ready().unwrap() == 31337); + } + } + } + + #[test] + fn select_unkillable() { + do run_in_newsched_task { + do task::unkillable { select_helper(2, [1]) } + } + } + + /* blocking select tests */ + + #[test] + fn select_blocking() { + select_blocking_helper(true); + select_blocking_helper(false); + + fn select_blocking_helper(killable: bool) { + do run_in_newsched_task { + let (p1,_c) = oneshot(); + let (p2,c2) = oneshot(); + let mut ports = [p1,p2]; + + let (p3,c3) = oneshot(); + let (p4,c4) = oneshot(); + + let x = Cell::new((c2, p3, c4)); + do task::spawn { + let (c2, p3, c4) = x.take(); + p3.recv(); // handshake parent + c4.send(()); // normal receive + task::yield(); + c2.send(()); // select receive + } + + // Try to block before child sends on c2. + c3.send(()); + p4.recv(); + if killable { + assert!(select(ports) == 1); + } else { + do task::unkillable { assert!(select(ports) == 1); } + } + } + } + } + + #[test] + fn select_racing_senders() { + static NUM_CHANS: uint = 10; + + select_racing_senders_helper(true, ~[0,1,2,3,4,5,6,7,8,9]); + select_racing_senders_helper(false, ~[0,1,2,3,4,5,6,7,8,9]); + select_racing_senders_helper(true, ~[0,1,2]); + select_racing_senders_helper(false, ~[0,1,2]); + select_racing_senders_helper(true, ~[3,4,5,6]); + select_racing_senders_helper(false, ~[3,4,5,6]); + select_racing_senders_helper(true, ~[7,8,9]); + select_racing_senders_helper(false, ~[7,8,9]); + + fn select_racing_senders_helper(killable: bool, send_on_chans: ~[uint]) { + use rt::test::spawntask_random; + + do run_in_newsched_task { + // A bit of stress, since ordinarily this is just smoke and mirrors. + do 4.times { + let send_on_chans = send_on_chans.clone(); + do task::spawn { + let mut ports = ~[]; + for i in range(0u, NUM_CHANS) { + let (p,c) = oneshot(); + ports.push(p); + if send_on_chans.contains(&i) { + let c = Cell::new(c); + do spawntask_random { + task::yield(); + c.take().send(()); + } + } + } + // nondeterministic result, but should succeed + if killable { + select(ports); + } else { + do task::unkillable { select(ports); } + } + } + } + } + } + } + + #[test] #[ignore(cfg(windows))] + fn select_killed() { + do run_in_newsched_task { + let (success_p, success_c) = oneshot::(); + let success_c = Cell::new(success_c); + do task::try { + let success_c = Cell::new(success_c.take()); + do task::unkillable { + let (p,c) = oneshot(); + let c = Cell::new(c); + do task::spawn { + let (dead_ps, dead_cs) = unzip(from_fn(5, |_| oneshot::<()>())); + let mut ports = dead_ps; + select(ports); // should get killed; nothing should leak + c.take().send(()); // must not happen + // Make sure dead_cs doesn't get closed until after select. + let _ = dead_cs; + } + do task::spawn { + fail!(); // should kill sibling awake + } + + // wait for killed selector to close (NOT send on) its c. + // hope to send 'true'. + success_c.take().send(p.try_recv().is_none()); + } + }; + assert!(success_p.recv()); + } + } +} diff --git a/src/libstd/std.rs b/src/libstd/std.rs index aa0bb905e9a68..c4bd0a6d04354 100644 --- a/src/libstd/std.rs +++ b/src/libstd/std.rs @@ -164,6 +164,7 @@ pub mod trie; pub mod task; pub mod comm; +pub mod select; pub mod local_data; diff --git a/src/libstd/str.rs b/src/libstd/str.rs index 0b270edc5342a..886e4d86ab643 100644 --- a/src/libstd/str.rs +++ b/src/libstd/str.rs @@ -33,8 +33,6 @@ use ptr; use ptr::RawPtr; use to_str::ToStr; use uint; -#[cfg(stage0)] -use unstable::raw::Repr; use vec; use vec::{OwnedVector, OwnedCopyableVector, ImmutableVector, MutableVector}; @@ -92,25 +90,6 @@ pub fn from_bytes_owned(vv: ~[u8]) -> ~str { /// # Failure /// /// Fails if invalid UTF-8 -#[cfg(stage0)] -pub fn from_bytes_slice<'a>(vector: &'a [u8]) -> &'a str { - unsafe { - assert!(is_utf8(vector)); - let mut s = vector.repr(); - s.len += 1; - cast::transmute(s) - } -} - -/// Converts a vector to a string slice without performing any allocations. -/// -/// Once the slice has been validated as utf-8, it is transmuted in-place and -/// returned as a '&str' instead of a '&[u8]' -/// -/// # Failure -/// -/// Fails if invalid UTF-8 -#[cfg(not(stage0))] pub fn from_bytes_slice<'a>(v: &'a [u8]) -> &'a str { assert!(is_utf8(v)); unsafe { cast::transmute(v) } @@ -134,18 +113,6 @@ impl ToStr for @str { /// # Failure /// /// Fails if invalid UTF-8 -#[cfg(stage0)] -pub fn from_byte(b: u8) -> ~str { - assert!(b < 128u8); - unsafe { cast::transmute(~[b, 0u8]) } -} - -/// Convert a byte to a UTF-8 string -/// -/// # Failure -/// -/// Fails if invalid UTF-8 -#[cfg(not(stage0))] pub fn from_byte(b: u8) -> ~str { assert!(b < 128u8); unsafe { ::cast::transmute(~[b]) } @@ -175,39 +142,13 @@ pub fn push_str(lhs: &mut ~str, rhs: &str) { #[allow(missing_doc)] pub trait StrVector { - pub fn concat(&self) -> ~str; - pub fn connect(&self, sep: &str) -> ~str; + fn concat(&self) -> ~str; + fn connect(&self, sep: &str) -> ~str; } impl<'self, S: Str> StrVector for &'self [S] { /// Concatenate a vector of strings. - #[cfg(stage0)] - pub fn concat(&self) -> ~str { - if self.is_empty() { return ~""; } - - let len = self.iter().map(|s| s.as_slice().len()).sum(); - - let mut s = with_capacity(len); - - unsafe { - do s.as_mut_buf |buf, _| { - let mut buf = buf; - for ss in self.iter() { - do ss.as_slice().as_imm_buf |ssbuf, sslen| { - let sslen = sslen - 1; - ptr::copy_memory(buf, ssbuf, sslen); - buf = buf.offset(sslen as int); - } - } - } - raw::set_len(&mut s, len); - } - s - } - - /// Concatenate a vector of strings. - #[cfg(not(stage0))] - pub fn concat(&self) -> ~str { + fn concat(&self) -> ~str { if self.is_empty() { return ~""; } let len = self.iter().map(|s| s.as_slice().len()).sum(); @@ -230,49 +171,7 @@ impl<'self, S: Str> StrVector for &'self [S] { } /// Concatenate a vector of strings, placing a given separator between each. - #[cfg(stage0)] - pub fn connect(&self, sep: &str) -> ~str { - if self.is_empty() { return ~""; } - - // concat is faster - if sep.is_empty() { return self.concat(); } - - // this is wrong without the guarantee that `self` is non-empty - let len = sep.len() * (self.len() - 1) - + self.iter().map(|s| s.as_slice().len()).sum(); - let mut s = ~""; - let mut first = true; - - s.reserve(len); - - unsafe { - do s.as_mut_buf |buf, _| { - do sep.as_imm_buf |sepbuf, seplen| { - let seplen = seplen - 1; - let mut buf = cast::transmute_mut_unsafe(buf); - for ss in self.iter() { - do ss.as_slice().as_imm_buf |ssbuf, sslen| { - let sslen = sslen - 1; - if first { - first = false; - } else { - ptr::copy_memory(buf, sepbuf, seplen); - buf = buf.offset(seplen as int); - } - ptr::copy_memory(buf, ssbuf, sslen); - buf = buf.offset(sslen as int); - } - } - } - } - raw::set_len(&mut s, len); - } - s - } - - /// Concatenate a vector of strings, placing a given separator between each. - #[cfg(not(stage0))] - pub fn connect(&self, sep: &str) -> ~str { + fn connect(&self, sep: &str) -> ~str { if self.is_empty() { return ~""; } // concat is faster @@ -578,26 +477,7 @@ Section: Comparing strings */ /// Bytewise slice equality -#[cfg(not(test), stage0)] -#[lang="str_eq"] -#[inline] -pub fn eq_slice(a: &str, b: &str) -> bool { - do a.as_imm_buf |ap, alen| { - do b.as_imm_buf |bp, blen| { - if (alen != blen) { false } - else { - unsafe { - libc::memcmp(ap as *libc::c_void, - bp as *libc::c_void, - (alen - 1) as libc::size_t) == 0 - } - } - } - } -} - -/// Bytewise slice equality -#[cfg(not(test), not(stage0))] +#[cfg(not(test))] #[lang="str_eq"] #[inline] pub fn eq_slice(a: &str, b: &str) -> bool { @@ -616,26 +496,7 @@ pub fn eq_slice(a: &str, b: &str) -> bool { } /// Bytewise slice equality -#[cfg(test, stage0)] -#[lang="str_eq"] -#[inline] -pub fn eq_slice(a: &str, b: &str) -> bool { - do a.as_imm_buf |ap, alen| { - do b.as_imm_buf |bp, blen| { - if (alen != blen) { false } - else { - unsafe { - libc::memcmp(ap as *libc::c_void, - bp as *libc::c_void, - (alen - 1) as libc::size_t) == 0 - } - } - } - } -} - -/// Bytewise slice equality -#[cfg(test, not(stage0))] +#[cfg(test)] #[inline] pub fn eq_slice(a: &str, b: &str) -> bool { do a.as_imm_buf |ap, alen| { @@ -807,17 +668,6 @@ pub fn from_utf16(v: &[u16]) -> ~str { /// Allocates a new string with the specified capacity. The string returned is /// the empty string, but has capacity for much more. -#[cfg(stage0)] -#[inline] -pub fn with_capacity(capacity: uint) -> ~str { - let mut buf = ~""; - buf.reserve(capacity); - buf -} - -/// Allocates a new string with the specified capacity. The string returned is -/// the empty string, but has capacity for much more. -#[cfg(not(stage0))] #[inline] pub fn with_capacity(capacity: uint) -> ~str { unsafe { @@ -929,25 +779,8 @@ pub mod raw { use vec; use vec::MutableVector; use unstable::raw::Slice; - #[cfg(stage0)] - use unstable::raw::String; /// Create a Rust string from a *u8 buffer of the given length - #[cfg(stage0)] - pub unsafe fn from_buf_len(buf: *u8, len: uint) -> ~str { - let mut v: ~[u8] = vec::with_capacity(len + 1); - v.as_mut_buf(|vbuf, _len| { - ptr::copy_memory(vbuf, buf as *u8, len) - }); - vec::raw::set_len(&mut v, len); - v.push(0u8); - - assert!(is_utf8(v)); - cast::transmute(v) - } - - /// Create a Rust string from a *u8 buffer of the given length - #[cfg(not(stage0))] pub unsafe fn from_buf_len(buf: *u8, len: uint) -> ~str { let mut v: ~[u8] = vec::with_capacity(len); do v.as_mut_buf |vbuf, _len| { @@ -987,15 +820,6 @@ pub mod raw { /// Converts an owned vector of bytes to a new owned string. This assumes /// that the utf-8-ness of the vector has already been validated - #[cfg(stage0)] - pub unsafe fn from_bytes_owned(mut v: ~[u8]) -> ~str { - v.push(0u8); - cast::transmute(v) - } - - /// Converts an owned vector of bytes to a new owned string. This assumes - /// that the utf-8-ness of the vector has already been validated - #[cfg(not(stage0))] #[inline] pub unsafe fn from_bytes_owned(v: ~[u8]) -> ~str { cast::transmute(v) @@ -1007,24 +831,6 @@ pub mod raw { /// Form a slice from a C string. Unsafe because the caller must ensure the /// C string has the static lifetime, or else the return value may be /// invalidated later. - #[cfg(stage0)] - pub unsafe fn c_str_to_static_slice(s: *libc::c_char) -> &'static str { - let s = s as *u8; - let mut curr = s; - let mut len = 0u; - while *curr != 0u8 { - len += 1u; - curr = ptr::offset(s, len as int); - } - let v = Slice { data: s, len: len + 1 }; - assert!(is_utf8(cast::transmute(v))); - cast::transmute(v) - } - - /// Form a slice from a C string. Unsafe because the caller must ensure the - /// C string has the static lifetime, or else the return value may be - /// invalidated later. - #[cfg(not(stage0))] pub unsafe fn c_str_to_static_slice(s: *libc::c_char) -> &'static str { let s = s as *u8; let mut curr = s; @@ -1046,29 +852,6 @@ pub mod raw { /// /// If begin is greater than end. /// If end is greater than the length of the string. - #[cfg(stage0)] - #[inline] - pub unsafe fn slice_bytes<'a>(s: &'a str, begin: uint, end: uint) -> &'a str { - do s.as_imm_buf |sbuf, n| { - assert!((begin <= end)); - assert!((end <= n)); - - cast::transmute(Slice { - data: ptr::offset(sbuf, begin as int), - len: end - begin + 1, - }) - } - } - - /// Takes a bytewise (not UTF-8) slice from a string. - /// - /// Returns the substring from [`begin`..`end`). - /// - /// # Failure - /// - /// If begin is greater than end. - /// If end is greater than the length of the string. - #[cfg(not(stage0))] #[inline] pub unsafe fn slice_bytes<'a>(s: &'a str, begin: uint, end: uint) -> &'a str { do s.as_imm_buf |sbuf, n| { @@ -1083,18 +866,6 @@ pub mod raw { } /// Appends a byte to a string. (Not UTF-8 safe). - #[cfg(stage0)] - pub unsafe fn push_byte(s: &mut ~str, b: u8) { - let new_len = s.len() + 1; - s.reserve_at_least(new_len); - do s.as_mut_buf |buf, len| { - *ptr::mut_offset(buf, len as int) = b; - } - set_len(&mut *s, new_len); - } - - /// Appends a byte to a string. (Not UTF-8 safe). - #[cfg(not(stage0))] #[inline] pub unsafe fn push_byte(s: &mut ~str, b: u8) { let v: &mut ~[u8] = cast::transmute(s); @@ -1126,23 +897,11 @@ pub mod raw { return b; } - /// Sets the length of the string and adds the null terminator - #[cfg(stage0)] - #[inline] - pub unsafe fn set_len(v: &mut ~str, new_len: uint) { - let v: **mut String = cast::transmute(v); - let repr = *v; - (*repr).fill = new_len + 1u; - let null = ptr::mut_offset(&mut ((*repr).data), new_len as int); - *null = 0u8; - } - /// Sets the length of a string /// /// This will explicitly set the size of the string, without actually /// modifing its buffers, so it is up to the caller to ensure that /// the string is actually the specified size. - #[cfg(not(stage0))] #[inline] pub unsafe fn set_len(s: &mut ~str, new_len: uint) { let v: &mut ~[u8] = cast::transmute(s); @@ -1331,13 +1090,6 @@ impl<'self> Str for @str { } impl<'self> Container for &'self str { - #[cfg(stage0)] - #[inline] - fn len(&self) -> uint { - do self.as_imm_buf |_p, n| { n - 1u } - } - - #[cfg(not(stage0))] #[inline] fn len(&self) -> uint { do self.as_imm_buf |_p, n| { n } @@ -1802,7 +1554,7 @@ impl<'self> StrSlice<'self> for &'self str { /// # Return value /// /// The original string with all occurances of `from` replaced with `to` - pub fn replace(&self, from: &str, to: &str) -> ~str { + fn replace(&self, from: &str, to: &str) -> ~str { let mut result = ~""; let mut last_end = 0; for (start, end) in self.matches_index_iter(from) { @@ -1815,26 +1567,6 @@ impl<'self> StrSlice<'self> for &'self str { } /// Copy a slice into a new unique str - #[cfg(stage0)] - #[inline] - fn to_owned(&self) -> ~str { - do self.as_imm_buf |src, len| { - assert!(len > 0); - unsafe { - let mut v = vec::with_capacity(len); - - do v.as_mut_buf |dst, _| { - ptr::copy_memory(dst, src, len - 1); - } - vec::raw::set_len(&mut v, len - 1); - v.push(0u8); - ::cast::transmute(v) - } - } - } - - /// Copy a slice into a new unique str - #[cfg(not(stage0))] #[inline] fn to_owned(&self) -> ~str { do self.as_imm_buf |src, len| { @@ -1850,16 +1582,6 @@ impl<'self> StrSlice<'self> for &'self str { } } - #[cfg(stage0)] - #[inline] - fn to_managed(&self) -> @str { - let v = at_vec::from_fn(self.len() + 1, |i| { - if i == self.len() { 0 } else { self[i] } - }); - unsafe { cast::transmute(v) } - } - - #[cfg(not(stage0))] #[inline] fn to_managed(&self) -> @str { unsafe { @@ -2008,19 +1730,6 @@ impl<'self> StrSlice<'self> for &'self str { /// Work with the byte buffer of a string as a byte slice. /// /// The byte slice does not include the null terminator. - #[cfg(stage0)] - fn as_bytes(&self) -> &'self [u8] { - unsafe { - let mut slice = self.repr(); - slice.len -= 1; - cast::transmute(slice) - } - } - - /// Work with the byte buffer of a string as a byte slice. - /// - /// The byte slice does not include the null terminator. - #[cfg(not(stage0))] fn as_bytes(&self) -> &'self [u8] { unsafe { cast::transmute(*self) } } @@ -2091,30 +1800,6 @@ impl<'self> StrSlice<'self> for &'self str { } /// Given a string, make a new string with repeated copies of it. - #[cfg(stage0)] - fn repeat(&self, nn: uint) -> ~str { - do self.as_imm_buf |buf, len| { - // ignore the NULL terminator - let len = len - 1; - let mut ret = with_capacity(nn * len); - - unsafe { - do ret.as_mut_buf |rbuf, _len| { - let mut rbuf = rbuf; - - do nn.times { - ptr::copy_memory(rbuf, buf, len); - rbuf = rbuf.offset(len as int); - } - } - raw::set_len(&mut ret, nn * len); - } - ret - } - } - - /// Given a string, make a new string with repeated copies of it. - #[cfg(not(stage0))] fn repeat(&self, nn: uint) -> ~str { do self.as_imm_buf |buf, len| { let mut ret = with_capacity(nn * len); @@ -2250,8 +1935,6 @@ pub trait OwnedStr { fn reserve(&mut self, n: uint); fn reserve_at_least(&mut self, n: uint); fn capacity(&self) -> uint; - #[cfg(stage0)] - fn to_bytes_with_null(self) -> ~[u8]; /// Work with the mutable byte buffer and length of a slice. /// @@ -2397,62 +2080,14 @@ impl OwnedStr for ~str { /// /// * s - A string /// * n - The number of bytes to reserve space for - #[cfg(stage0)] #[inline] - pub fn reserve(&mut self, n: uint) { - unsafe { - let v: *mut ~[u8] = cast::transmute(self); - (*v).reserve(n + 1); - } - } - - /// Reserves capacity for exactly `n` bytes in the given string, not including - /// the null terminator. - /// - /// Assuming single-byte characters, the resulting string will be large - /// enough to hold a string of length `n`. To account for the null terminator, - /// the underlying buffer will have the size `n` + 1. - /// - /// If the capacity for `s` is already equal to or greater than the requested - /// capacity, then no action is taken. - /// - /// # Arguments - /// - /// * s - A string - /// * n - The number of bytes to reserve space for - #[cfg(not(stage0))] - #[inline] - pub fn reserve(&mut self, n: uint) { + fn reserve(&mut self, n: uint) { unsafe { let v: &mut ~[u8] = cast::transmute(self); (*v).reserve(n); } } - /// Reserves capacity for at least `n` bytes in the given string, not including - /// the null terminator. - /// - /// Assuming single-byte characters, the resulting string will be large - /// enough to hold a string of length `n`. To account for the null terminator, - /// the underlying buffer will have the size `n` + 1. - /// - /// This function will over-allocate in order to amortize the allocation costs - /// in scenarios where the caller may need to repeatedly reserve additional - /// space. - /// - /// If the capacity for `s` is already equal to or greater than the requested - /// capacity, then no action is taken. - /// - /// # Arguments - /// - /// * s - A string - /// * n - The number of bytes to reserve space for - #[cfg(stage0)] - #[inline] - fn reserve_at_least(&mut self, n: uint) { - self.reserve(uint::next_power_of_two(n + 1u) - 1u) - } - /// Reserves capacity for at least `n` bytes in the given string. /// /// Assuming single-byte characters, the resulting string will be large @@ -2470,7 +2105,6 @@ impl OwnedStr for ~str { /// /// * s - A string /// * n - The number of bytes to reserve space for - #[cfg(not(stage0))] #[inline] fn reserve_at_least(&mut self, n: uint) { self.reserve(uint::next_power_of_two(n)) @@ -2478,17 +2112,6 @@ impl OwnedStr for ~str { /// Returns the number of single-byte characters the string can hold without /// reallocating - #[cfg(stage0)] - fn capacity(&self) -> uint { - let buf: &~[u8] = unsafe { cast::transmute(self) }; - let vcap = buf.capacity(); - assert!(vcap > 0u); - vcap - 1u - } - - /// Returns the number of single-byte characters the string can hold without - /// reallocating - #[cfg(not(stage0))] fn capacity(&self) -> uint { unsafe { let buf: &~[u8] = cast::transmute(self); @@ -2496,14 +2119,6 @@ impl OwnedStr for ~str { } } - /// Convert to a vector of bytes. This does not allocate a new - /// string, and includes the null terminator. - #[cfg(stage0)] - #[inline] - fn to_bytes_with_null(self) -> ~[u8] { - unsafe { cast::transmute(self) } - } - #[inline] fn as_mut_buf(&mut self, f: &fn(*mut u8, uint) -> T) -> T { let v: &mut ~[u8] = unsafe { cast::transmute(self) }; @@ -3208,45 +2823,6 @@ mod tests { assert_eq!("ศไทย中华Việt Nam".as_bytes(), v); } - #[cfg(stage0)] - #[test] - #[ignore(cfg(windows))] - #[should_fail] - fn test_as_bytes_fail() { - // Don't double free. (I'm not sure if this exercises the - // original problem code path anymore.) - let s = ~""; - let _bytes = s.as_bytes(); - fail!(); - } - - #[cfg(stage0)] - #[test] - #[ignore(cfg(windows))] - #[should_fail] - fn test_as_bytes_fail() { - // Don't double free. (I'm not sure if this exercises the - // original problem code path anymore.) - let s = ~""; - let _bytes = s.as_bytes_with_null(); - fail!(); - } - - #[cfg(stage0)] - #[test] - fn test_to_bytes_with_null() { - let s = ~"ศไทย中华Việt Nam"; - let v = ~[ - 224, 184, 168, 224, 185, 132, 224, 184, 151, 224, 184, 162, 228, - 184, 173, 229, 141, 142, 86, 105, 225, 187, 135, 116, 32, 78, 97, - 109, 0 - ]; - assert_eq!((~"").to_bytes_with_null(), ~[0]); - assert_eq!((~"abc").to_bytes_with_null(), - ~['a' as u8, 'b' as u8, 'c' as u8, 0]); - assert_eq!(s.to_bytes_with_null(), v); - } - #[test] #[ignore(cfg(windows))] #[should_fail] diff --git a/src/libstd/str/ascii.rs b/src/libstd/str/ascii.rs index c6ae535c19a3c..701d57388158b 100644 --- a/src/libstd/str/ascii.rs +++ b/src/libstd/str/ascii.rs @@ -19,8 +19,6 @@ use cast; use ptr; use iterator::Iterator; use vec::{CopyableVector, ImmutableVector}; -#[cfg(stage0)] -use vec::OwnedVector; use to_bytes::IterBytes; use option::{Some, None}; @@ -105,14 +103,6 @@ impl<'self> AsciiCast<&'self [Ascii]> for &'self str { unsafe { self.to_ascii_nocheck() } } - #[cfg(stage0)] - #[inline] - unsafe fn to_ascii_nocheck(&self) -> &'self [Ascii] { - let (p,len): (*u8, uint) = cast::transmute(*self); - cast::transmute((p, len - 1)) - } - - #[cfg(not(stage0))] #[inline] unsafe fn to_ascii_nocheck(&self) -> &'self [Ascii] { cast::transmute(*self) @@ -190,15 +180,6 @@ impl OwnedAsciiCast for ~str { unsafe {self.into_ascii_nocheck()} } - #[cfg(stage0)] - #[inline] - unsafe fn into_ascii_nocheck(self) -> ~[Ascii] { - let mut r: ~[Ascii] = cast::transmute(self); - r.pop(); - r - } - - #[cfg(not(stage0))] #[inline] unsafe fn into_ascii_nocheck(self) -> ~[Ascii] { cast::transmute(self) @@ -221,15 +202,6 @@ pub trait AsciiStr { } impl<'self> AsciiStr for &'self [Ascii] { - #[cfg(stage0)] - #[inline] - fn to_str_ascii(&self) -> ~str { - let mut cpy = self.to_owned(); - cpy.push(0u8.to_ascii()); - unsafe { cast::transmute(cpy) } - } - - #[cfg(not(stage0))] #[inline] fn to_str_ascii(&self) -> ~str { let cpy = self.to_owned(); @@ -253,15 +225,6 @@ impl<'self> AsciiStr for &'self [Ascii] { } impl ToStrConsume for ~[Ascii] { - #[cfg(stage0)] - #[inline] - fn into_str(self) -> ~str { - let mut cpy = self; - cpy.push(0u8.to_ascii()); - unsafe { cast::transmute(cpy) } - } - - #[cfg(not(stage0))] #[inline] fn into_str(self) -> ~str { unsafe { cast::transmute(self) } diff --git a/src/libstd/task/mod.rs b/src/libstd/task/mod.rs index 09431c05e2251..c38e6f233130b 100644 --- a/src/libstd/task/mod.rs +++ b/src/libstd/task/mod.rs @@ -38,7 +38,6 @@ use prelude::*; use cell::Cell; -use cmp::Eq; use comm::{stream, Chan, GenericChan, GenericPort, Port}; use result::Result; use result; diff --git a/src/libstd/task/spawn.rs b/src/libstd/task/spawn.rs index 10bac9325ab43..e0efc14a8871f 100644 --- a/src/libstd/task/spawn.rs +++ b/src/libstd/task/spawn.rs @@ -22,10 +22,9 @@ * * A new one of these is created each spawn_linked or spawn_supervised. * - * (2) The "tcb" is a per-task control structure that tracks a task's spawn - * configuration. It contains a reference to its taskgroup_arc, a - * reference to its node in the ancestor list (below), a flag for - * whether it's part of the 'main'/'root' taskgroup, and an optionally + * (2) The "taskgroup" is a per-task control structure that tracks a task's + * spawn configuration. It contains a reference to its taskgroup_arc, a + * reference to its node in the ancestor list (below), and an optionally * configured notification port. These are stored in TLS. * * (3) The "ancestor_list" is a cons-style list of unsafe::exclusives which @@ -84,7 +83,6 @@ use local_data; use task::{Failure, SingleThreaded}; use task::{Success, TaskOpts, TaskResult}; use task::unkillable; -use to_bytes::IterBytes; use uint; use util; use unstable::sync::Exclusive; @@ -101,29 +99,7 @@ use rt::work_queue::WorkQueue; #[cfg(test)] use comm; #[cfg(test)] use task; -// Transitionary. -#[deriving(Eq)] -enum TaskHandle { - NewTask(KillHandle), -} - -impl Clone for TaskHandle { - fn clone(&self) -> TaskHandle { - match *self { - NewTask(ref x) => NewTask(x.clone()), - } - } -} - -impl IterBytes for TaskHandle { - fn iter_bytes(&self, lsb0: bool, f: &fn(buf: &[u8]) -> bool) -> bool { - match *self { - NewTask(ref x) => x.iter_bytes(lsb0, f), - } - } -} - -struct TaskSet(HashSet); +struct TaskSet(HashSet); impl TaskSet { #[inline] @@ -131,17 +107,17 @@ impl TaskSet { TaskSet(HashSet::new()) } #[inline] - fn insert(&mut self, task: TaskHandle) { + fn insert(&mut self, task: KillHandle) { let didnt_overwrite = (**self).insert(task); assert!(didnt_overwrite); } #[inline] - fn remove(&mut self, task: &TaskHandle) { + fn remove(&mut self, task: &KillHandle) { let was_present = (**self).remove(task); assert!(was_present); } #[inline] - fn move_iter(self) -> HashSetMoveIterator { + fn move_iter(self) -> HashSetMoveIterator { (*self).move_iter() } } @@ -291,7 +267,7 @@ fn each_ancestor(list: &mut AncestorList, None => nobe_is_dead }; // Call iterator block. (If the group is dead, it's - // safe to skip it. This will leave our TaskHandle + // safe to skip it. This will leave our KillHandle // hanging around in the group even after it's freed, // but that's ok because, by virtue of the group being // dead, nobody will ever kill-all (for) over it.) @@ -338,7 +314,6 @@ pub struct Taskgroup { tasks: TaskGroupArc, // 'none' means the group has failed. // Lists of tasks who will kill us if they fail, but whom we won't kill. ancestors: AncestorList, - is_main: bool, notifier: Option, } @@ -355,14 +330,18 @@ impl Drop for Taskgroup { for x in this.notifier.mut_iter() { x.failed = true; } - // Take everybody down with us. - do access_group(&self.tasks) |tg| { - kill_taskgroup(tg, &me, self.is_main); - } + // Take everybody down with us. After this point, every + // other task in the group will see 'tg' as none, which + // indicates the whole taskgroup is failing (and forbids + // new spawns from succeeding). + let tg = do access_group(&self.tasks) |tg| { tg.take() }; + // It's safe to send kill signals outside the lock, because + // we have a refcount on all kill-handles in the group. + kill_taskgroup(tg, me); } else { // Remove ourselves from the group(s). do access_group(&self.tasks) |tg| { - leave_taskgroup(tg, &me, true); + leave_taskgroup(tg, me, true); } } // It doesn't matter whether this happens before or after dealing @@ -370,7 +349,7 @@ impl Drop for Taskgroup { // We remove ourself from every ancestor we can, so no cleanup; no // break. do each_ancestor(&mut this.ancestors, |_| {}) |ancestor_group| { - leave_taskgroup(ancestor_group, &me, false); + leave_taskgroup(ancestor_group, me, false); true }; } @@ -380,7 +359,6 @@ impl Drop for Taskgroup { pub fn Taskgroup(tasks: TaskGroupArc, ancestors: AncestorList, - is_main: bool, mut notifier: Option) -> Taskgroup { for x in notifier.mut_iter() { x.failed = false; @@ -389,7 +367,6 @@ pub fn Taskgroup(tasks: TaskGroupArc, Taskgroup { tasks: tasks, ancestors: ancestors, - is_main: is_main, notifier: notifier } } @@ -413,7 +390,7 @@ fn AutoNotify(chan: Chan) -> AutoNotify { } } -fn enlist_in_taskgroup(state: TaskGroupInner, me: TaskHandle, +fn enlist_in_taskgroup(state: TaskGroupInner, me: KillHandle, is_member: bool) -> bool { let me = Cell::new(me); // :( // If 'None', the group was failing. Can't enlist. @@ -428,8 +405,7 @@ fn enlist_in_taskgroup(state: TaskGroupInner, me: TaskHandle, } // NB: Runs in destructor/post-exit context. Can't 'fail'. -fn leave_taskgroup(state: TaskGroupInner, me: &TaskHandle, - is_member: bool) { +fn leave_taskgroup(state: TaskGroupInner, me: &KillHandle, is_member: bool) { let me = Cell::new(me); // :( // If 'None', already failing and we've already gotten a kill signal. do state.map_mut |group| { @@ -442,43 +418,23 @@ fn leave_taskgroup(state: TaskGroupInner, me: &TaskHandle, } // NB: Runs in destructor/post-exit context. Can't 'fail'. -fn kill_taskgroup(state: TaskGroupInner, me: &TaskHandle, is_main: bool) { - unsafe { - // NB: We could do the killing iteration outside of the group arc, by - // having "let mut newstate" here, swapping inside, and iterating - // after. But that would let other exiting tasks fall-through and exit - // while we were trying to kill them, causing potential - // use-after-free. A task's presence in the arc guarantees it's alive - // only while we hold the lock, so if we're failing, all concurrently - // exiting tasks must wait for us. To do it differently, we'd have to - // use the runtime's task refcounting, but that could leave task - // structs around long after their task exited. - let newstate = util::replace(state, None); - // Might already be None, if Somebody is failing simultaneously. - // That's ok; only one task needs to do the dirty work. (Might also - // see 'None' if Somebody already failed and we got a kill signal.) - if newstate.is_some() { - let TaskGroupData { members: members, descendants: descendants } = - newstate.unwrap(); - for sibling in members.move_iter() { - // Skip self - killing ourself won't do much good. - if &sibling != me { - RuntimeGlue::kill_task(sibling); - } - } - for child in descendants.move_iter() { - assert!(&child != me); - RuntimeGlue::kill_task(child); +fn kill_taskgroup(state: Option, me: &KillHandle) { + // Might already be None, if somebody is failing simultaneously. + // That's ok; only one task needs to do the dirty work. (Might also + // see 'None' if somebody already failed and we got a kill signal.) + do state.map_move |TaskGroupData { members: members, descendants: descendants }| { + for sibling in members.move_iter() { + // Skip self - killing ourself won't do much good. + if &sibling != me { + RuntimeGlue::kill_task(sibling); } - // Only one task should ever do this. - if is_main { - RuntimeGlue::kill_all_tasks(me); - } - // Do NOT restore state to Some(..)! It stays None to indicate - // that the whole taskgroup is failing, to forbid new spawns. } - // (note: multiple tasks may reach this point) - } + for child in descendants.move_iter() { + assert!(&child != me); + RuntimeGlue::kill_task(child); + } + }; + // (note: multiple tasks may reach this point) } // FIXME (#2912): Work around core-vs-coretest function duplication. Can't use @@ -490,38 +446,23 @@ fn taskgroup_key() -> local_data::Key<@@mut Taskgroup> { // Transitionary. struct RuntimeGlue; impl RuntimeGlue { - unsafe fn kill_task(task: TaskHandle) { - match task { - NewTask(handle) => { - let mut handle = handle; - do handle.kill().map_move |killed_task| { - let killed_task = Cell::new(killed_task); - do Local::borrow:: |sched| { - sched.enqueue_task(killed_task.take()); - } - }; + fn kill_task(handle: KillHandle) { + let mut handle = handle; + do handle.kill().map_move |killed_task| { + let killed_task = Cell::new(killed_task); + do Local::borrow:: |sched| { + sched.enqueue_task(killed_task.take()); } - } - } - - unsafe fn kill_all_tasks(task: &TaskHandle) { - match *task { - // FIXME(#7544): Remove the kill_all feature entirely once the - // oldsched goes away. - NewTask(ref _handle) => rtabort!("can't kill_all in newsched"), - } + }; } - fn with_task_handle_and_failing(blk: &fn(TaskHandle, bool)) { + fn with_task_handle_and_failing(blk: &fn(&KillHandle, bool)) { if in_green_task_context() { unsafe { // Can't use safe borrow, because the taskgroup destructor needs to // access the scheduler again to send kill signals to other tasks. let me = Local::unsafe_borrow::(); - // FIXME(#7544): Get rid of this clone by passing by-ref. - // Will probably have to wait until the old rt is gone. - blk(NewTask((*me).death.kill_handle.get_ref().clone()), - (*me).unwinder.unwinding) + blk((*me).death.kill_handle.get_ref(), (*me).unwinder.unwinding) } } else { rtabort!("task dying in bad context") @@ -540,15 +481,12 @@ impl RuntimeGlue { // Lazily initialize. let mut members = TaskSet::new(); let my_handle = (*me).death.kill_handle.get_ref().clone(); - members.insert(NewTask(my_handle)); + members.insert(my_handle); let tasks = Exclusive::new(Some(TaskGroupData { members: members, descendants: TaskSet::new(), })); - // FIXME(#7544): Remove the is_main flag entirely once - // the newsched goes away. The main taskgroup has no special - // behaviour. - let group = Taskgroup(tasks, AncestorList(None), false, None); + let group = Taskgroup(tasks, AncestorList(None), None); (*me).taskgroup = Some(group); (*me).taskgroup.get_ref() } @@ -563,9 +501,7 @@ impl RuntimeGlue { // Returns 'None' in the case where the child's TG should be lazily initialized. fn gen_child_taskgroup(linked: bool, supervised: bool) - -> Option<(TaskGroupArc, AncestorList, bool)> { - // FIXME(#7544): Not safe to lazily initialize in the old runtime. Remove - // this context check once 'spawn_raw_oldsched' is gone. + -> Option<(TaskGroupArc, AncestorList)> { if linked || supervised { // with_my_taskgroup will lazily initialize the parent's taskgroup if // it doesn't yet exist. We don't want to call it in the unlinked case. @@ -574,8 +510,7 @@ fn gen_child_taskgroup(linked: bool, supervised: bool) if linked { // Child is in the same group as spawner. // Child's ancestors are spawner's ancestors. - // Propagate main-ness. - Some((spawner_group.tasks.clone(), ancestors, spawner_group.is_main)) + Some((spawner_group.tasks.clone(), ancestors)) } else { // Child is in a separate group from spawner. let g = Exclusive::new(Some(TaskGroupData { @@ -596,7 +531,7 @@ fn gen_child_taskgroup(linked: bool, supervised: bool) // Child has no ancestors. AncestorList(None) }; - Some((g, a, false)) + Some((g, a)) } } } else { @@ -607,7 +542,7 @@ fn gen_child_taskgroup(linked: bool, supervised: bool) // Set up membership in taskgroup and descendantship in all ancestor // groups. If any enlistment fails, Some task was already failing, so // don't let the child task run, and undo every successful enlistment. -fn enlist_many(child: TaskHandle, child_arc: &TaskGroupArc, +fn enlist_many(child: &KillHandle, child_arc: &TaskGroupArc, ancestors: &mut AncestorList) -> bool { // Join this taskgroup. let mut result = do access_group(child_arc) |child_tg| { @@ -615,7 +550,7 @@ fn enlist_many(child: TaskHandle, child_arc: &TaskGroupArc, }; if result { // Unwinding function in case any ancestral enlisting fails - let bail: &fn(TaskGroupInner) = |tg| { leave_taskgroup(tg, &child, false) }; + let bail: &fn(TaskGroupInner) = |tg| { leave_taskgroup(tg, child, false) }; // Attempt to join every ancestor group. result = do each_ancestor(ancestors, bail) |ancestor_tg| { // Enlist as a descendant, not as an actual member. @@ -625,7 +560,7 @@ fn enlist_many(child: TaskHandle, child_arc: &TaskGroupArc, // If any ancestor group fails, need to exit this group too. if !result { do access_group(child_arc) |child_tg| { - leave_taskgroup(child_tg, &child, true); // member + leave_taskgroup(child_tg, child, true); // member } } } @@ -653,15 +588,14 @@ fn spawn_raw_newsched(mut opts: TaskOpts, f: ~fn()) { let enlist_success = do child_data.take().map_move_default(true) |child_data| { let child_data = Cell::new(child_data); // :( do Local::borrow:: |me| { - let (child_tg, ancestors, is_main) = child_data.take(); + let (child_tg, ancestors) = child_data.take(); let mut ancestors = ancestors; - // FIXME(#7544): Optimize out the xadd in this clone, somehow. - let handle = me.death.kill_handle.get_ref().clone(); + let handle = me.death.kill_handle.get_ref(); // Atomically try to get into all of our taskgroups. - if enlist_many(NewTask(handle), &child_tg, &mut ancestors) { + if enlist_many(handle, &child_tg, &mut ancestors) { // Got in. We can run the provided child body, and can also run // the taskgroup's exit-time-destructor afterward. - me.taskgroup = Some(Taskgroup(child_tg, ancestors, is_main, None)); + me.taskgroup = Some(Taskgroup(child_tg, ancestors, None)); true } else { false @@ -678,14 +612,14 @@ fn spawn_raw_newsched(mut opts: TaskOpts, f: ~fn()) { } }; - let mut task = unsafe { - if opts.sched.mode != SingleThreaded { - if opts.watched { - Task::build_child(opts.stack_size, child_wrapper) - } else { - Task::build_root(opts.stack_size, child_wrapper) - } + let mut task = if opts.sched.mode != SingleThreaded { + if opts.watched { + Task::build_child(opts.stack_size, child_wrapper) } else { + Task::build_root(opts.stack_size, child_wrapper) + } + } else { + unsafe { // Creating a 1:1 task:thread ... let sched = Local::unsafe_borrow::(); let sched_handle = (*sched).make_handle(); diff --git a/src/libstd/unstable/intrinsics.rs b/src/libstd/unstable/intrinsics.rs index 92725fda70598..861b4f9a350dc 100644 --- a/src/libstd/unstable/intrinsics.rs +++ b/src/libstd/unstable/intrinsics.rs @@ -328,10 +328,6 @@ extern "rust-intrinsic" { /// Returns `true` if a type is managed (will be allocated on the local heap) pub fn contains_managed() -> bool; - #[cfg(stage0)] - pub fn visit_tydesc(td: *TyDesc, tv: @TyVisitor); - - #[cfg(not(stage0))] pub fn visit_tydesc(td: *TyDesc, tv: &TyVisitor); pub fn frame_address(f: &once fn(*u8)); @@ -351,7 +347,6 @@ extern "rust-intrinsic" { /// /// This intrinsic should be preferred over `offset` when the guarantee can /// be satisfied, to enable better optimization. - #[cfg(not(stage0))] pub fn offset_inbounds(dst: *T, offset: int) -> *T; /// Equivalent to the `llvm.memcpy.p0i8.0i8.i32` intrinsic, with a size of @@ -451,58 +446,34 @@ extern "rust-intrinsic" { pub fn bswap32(x: i32) -> i32; pub fn bswap64(x: i64) -> i64; - #[cfg(not(stage0))] pub fn i8_add_with_overflow(x: i8, y: i8) -> (i8, bool); - #[cfg(not(stage0))] pub fn i16_add_with_overflow(x: i16, y: i16) -> (i16, bool); - #[cfg(not(stage0))] pub fn i32_add_with_overflow(x: i32, y: i32) -> (i32, bool); - #[cfg(not(stage0))] pub fn i64_add_with_overflow(x: i64, y: i64) -> (i64, bool); - #[cfg(not(stage0))] pub fn u8_add_with_overflow(x: u8, y: u8) -> (u8, bool); - #[cfg(not(stage0))] pub fn u16_add_with_overflow(x: u16, y: u16) -> (u16, bool); - #[cfg(not(stage0))] pub fn u32_add_with_overflow(x: u32, y: u32) -> (u32, bool); - #[cfg(not(stage0))] pub fn u64_add_with_overflow(x: u64, y: u64) -> (u64, bool); - #[cfg(not(stage0))] pub fn i8_sub_with_overflow(x: i8, y: i8) -> (i8, bool); - #[cfg(not(stage0))] pub fn i16_sub_with_overflow(x: i16, y: i16) -> (i16, bool); - #[cfg(not(stage0))] pub fn i32_sub_with_overflow(x: i32, y: i32) -> (i32, bool); - #[cfg(not(stage0))] pub fn i64_sub_with_overflow(x: i64, y: i64) -> (i64, bool); - #[cfg(not(stage0))] pub fn u8_sub_with_overflow(x: u8, y: u8) -> (u8, bool); - #[cfg(not(stage0))] pub fn u16_sub_with_overflow(x: u16, y: u16) -> (u16, bool); - #[cfg(not(stage0))] pub fn u32_sub_with_overflow(x: u32, y: u32) -> (u32, bool); - #[cfg(not(stage0))] pub fn u64_sub_with_overflow(x: u64, y: u64) -> (u64, bool); - #[cfg(not(stage0))] pub fn i8_mul_with_overflow(x: i8, y: i8) -> (i8, bool); - #[cfg(not(stage0))] pub fn i16_mul_with_overflow(x: i16, y: i16) -> (i16, bool); - #[cfg(not(stage0))] pub fn i32_mul_with_overflow(x: i32, y: i32) -> (i32, bool); - #[cfg(not(stage0))] pub fn i64_mul_with_overflow(x: i64, y: i64) -> (i64, bool); - #[cfg(not(stage0))] pub fn u8_mul_with_overflow(x: u8, y: u8) -> (u8, bool); - #[cfg(not(stage0))] pub fn u16_mul_with_overflow(x: u16, y: u16) -> (u16, bool); - #[cfg(not(stage0))] pub fn u32_mul_with_overflow(x: u32, y: u32) -> (u32, bool); - #[cfg(not(stage0))] pub fn u64_mul_with_overflow(x: u64, y: u64) -> (u64, bool); } diff --git a/src/libstd/unstable/sync.rs b/src/libstd/unstable/sync.rs index a9dded41683a9..adbf9fc757819 100644 --- a/src/libstd/unstable/sync.rs +++ b/src/libstd/unstable/sync.rs @@ -229,20 +229,22 @@ impl Drop for UnsafeAtomicRcBox{ if self.data.is_null() { return; // Happens when destructing an unwrapper's handle. } - do task::unkillable { - let mut data: ~AtomicRcBoxData = cast::transmute(self.data); - // Must be acquire+release, not just release, to make sure this - // doesn't get reordered to after the unwrapper pointer load. - let old_count = data.count.fetch_sub(1, SeqCst); - assert!(old_count >= 1); - if old_count == 1 { - // Were we really last, or should we hand off to an - // unwrapper? It's safe to not xchg because the unwrapper - // will set the unwrap lock *before* dropping his/her - // reference. In effect, being here means we're the only - // *awake* task with the data. - match data.unwrapper.take(Acquire) { - Some(~(message,response)) => { + let mut data: ~AtomicRcBoxData = cast::transmute(self.data); + // Must be acquire+release, not just release, to make sure this + // doesn't get reordered to after the unwrapper pointer load. + let old_count = data.count.fetch_sub(1, SeqCst); + assert!(old_count >= 1); + if old_count == 1 { + // Were we really last, or should we hand off to an + // unwrapper? It's safe to not xchg because the unwrapper + // will set the unwrap lock *before* dropping his/her + // reference. In effect, being here means we're the only + // *awake* task with the data. + match data.unwrapper.take(Acquire) { + Some(~(message,response)) => { + let cell = Cell::new((message, response, data)); + do task::unkillable { + let (message, response, data) = cell.take(); // Send 'ready' and wait for a response. message.send(()); // Unkillable wait. Message guaranteed to come. @@ -253,13 +255,13 @@ impl Drop for UnsafeAtomicRcBox{ // Other task was killed. drop glue takes over. } } - None => { - // drop glue takes over. - } } - } else { - cast::forget(data); + None => { + // drop glue takes over. + } } + } else { + cast::forget(data); } } } diff --git a/src/libstd/vec.rs b/src/libstd/vec.rs index 2228922d9e4d9..27e09d8547989 100644 --- a/src/libstd/vec.rs +++ b/src/libstd/vec.rs @@ -313,18 +313,18 @@ pub fn connect_slices(v: &[&[T]], sep: &T) -> ~[T] { v.connect_vec(sep) pub trait VectorVector { // FIXME #5898: calling these .concat and .connect conflicts with // StrVector::con{cat,nect}, since they have generic contents. - pub fn concat_vec(&self) -> ~[T]; - pub fn connect_vec(&self, sep: &T) -> ~[T]; + fn concat_vec(&self) -> ~[T]; + fn connect_vec(&self, sep: &T) -> ~[T]; } impl<'self, T:Clone> VectorVector for &'self [~[T]] { /// Flattens a vector of slices of T into a single vector of T. - pub fn concat_vec(&self) -> ~[T] { + fn concat_vec(&self) -> ~[T] { self.flat_map(|inner| (*inner).clone()) } /// Concatenate a vector of vectors, placing a given separator between each. - pub fn connect_vec(&self, sep: &T) -> ~[T] { + fn connect_vec(&self, sep: &T) -> ~[T] { let mut r = ~[]; let mut first = true; for inner in self.iter() { @@ -337,12 +337,12 @@ impl<'self, T:Clone> VectorVector for &'self [~[T]] { impl<'self,T:Clone> VectorVector for &'self [&'self [T]] { /// Flattens a vector of slices of T into a single vector of T. - pub fn concat_vec(&self) -> ~[T] { + fn concat_vec(&self) -> ~[T] { self.flat_map(|&inner| inner.to_owned()) } /// Concatenate a vector of slices, placing a given separator between each. - pub fn connect_vec(&self, sep: &T) -> ~[T] { + fn connect_vec(&self, sep: &T) -> ~[T] { let mut r = ~[]; let mut first = true; for &inner in self.iter() { @@ -1649,7 +1649,7 @@ impl OwnedEqVector for ~[T] { * Remove consecutive repeated elements from a vector; if the vector is * sorted, this removes all duplicates. */ - pub fn dedup(&mut self) { + fn dedup(&mut self) { unsafe { // Although we have a mutable reference to `self`, we cannot make // *arbitrary* changes. There exists the possibility that this @@ -2079,7 +2079,7 @@ pub mod bytes { /// A trait for operations on mutable operations on `[u8]` pub trait MutableByteVector { /// Sets all bytes of the receiver to the given value. - pub fn set_memory(self, value: u8); + fn set_memory(self, value: u8); } impl<'self> MutableByteVector for &'self mut [u8] { diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index d99f8cab4937f..02eaf432b5402 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -672,7 +672,7 @@ pub fn walk_pat(pat: @pat, it: &fn(@pat) -> bool) -> bool { } pub trait EachViewItem { - pub fn each_view_item(&self, f: @fn(&ast::view_item) -> bool) -> bool; + fn each_view_item(&self, f: @fn(&ast::view_item) -> bool) -> bool; } struct EachViewItemData { diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index 47d8ebecca06a..51df08f52283f 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -82,7 +82,7 @@ impl AttrMetaMethods for MetaItem { } } - pub fn name_str_pair(&self) -> Option<(@str, @str)> { + fn name_str_pair(&self) -> Option<(@str, @str)> { self.value_str().map_move(|s| (self.name(), s)) } } @@ -105,14 +105,14 @@ pub trait AttributeMethods { impl AttributeMethods for Attribute { /// Extract the MetaItem from inside this Attribute. - pub fn meta(&self) -> @MetaItem { + fn meta(&self) -> @MetaItem { self.node.value } /// Convert self to a normal #[doc="foo"] comment, if it is a /// comment like `///` or `/** */`. (Returns self unchanged for /// non-sugared doc attributes.) - pub fn desugar_doc(&self) -> Attribute { + fn desugar_doc(&self) -> Attribute { if self.node.is_sugared_doc { let comment = self.value_str().unwrap(); let meta = mk_name_value_item_str(@"doc", diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index 8c70f128d9a09..d4337523cfb25 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -194,10 +194,10 @@ pub struct FileLines // represents the origin of a file: pub enum FileSubstr { // indicates that this is a normal standalone file: - pub FssNone, + FssNone, // indicates that this "file" is actually a substring // of another file that appears earlier in the codemap - pub FssInternal(span), + FssInternal(span), } /// Identifies an offset of a multi-byte character in a FileMap diff --git a/src/libsyntax/ext/deriving/generic.rs b/src/libsyntax/ext/deriving/generic.rs index a1abe47e0909d..6b028e25c0fff 100644 --- a/src/libsyntax/ext/deriving/generic.rs +++ b/src/libsyntax/ext/deriving/generic.rs @@ -542,7 +542,7 @@ impl<'self> MethodDef<'self> { id: cx.next_id(), span: span, self_id: cx.next_id(), - vis: ast::public + vis: ast::inherited, } } diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs index d218be5e47637..9d82bb9c4f8ab 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -40,11 +40,11 @@ pub mod rt { pub use codemap::{BytePos, span, dummy_spanned}; pub trait ToTokens { - pub fn to_tokens(&self, _cx: @ExtCtxt) -> ~[token_tree]; + fn to_tokens(&self, _cx: @ExtCtxt) -> ~[token_tree]; } impl ToTokens for ~[token_tree] { - pub fn to_tokens(&self, _cx: @ExtCtxt) -> ~[token_tree] { + fn to_tokens(&self, _cx: @ExtCtxt) -> ~[token_tree] { (*self).clone() } } @@ -65,7 +65,7 @@ pub mod rt { pub trait ToSource { // Takes a thing and generates a string containing rust code for it. - pub fn to_source(&self) -> @str; + fn to_source(&self) -> @str; } impl ToSource for ast::ident { diff --git a/src/libsyntax/opt_vec.rs b/src/libsyntax/opt_vec.rs index 3a10206b513f8..2d7801a22deda 100644 --- a/src/libsyntax/opt_vec.rs +++ b/src/libsyntax/opt_vec.rs @@ -124,7 +124,7 @@ impl OptVec { } impl Eq for OptVec { - pub fn eq(&self, other: &OptVec) -> bool { + fn eq(&self, other: &OptVec) -> bool { // Note: cannot use #[deriving(Eq)] here because // (Empty, Vec(~[])) ought to be equal. match (self, other) { @@ -135,7 +135,7 @@ impl Eq for OptVec { } } - pub fn ne(&self, other: &OptVec) -> bool { + fn ne(&self, other: &OptVec) -> bool { !self.eq(other) } } diff --git a/src/libsyntax/parse/obsolete.rs b/src/libsyntax/parse/obsolete.rs index dda5e990221ec..01c1af7464db6 100644 --- a/src/libsyntax/parse/obsolete.rs +++ b/src/libsyntax/parse/obsolete.rs @@ -65,6 +65,7 @@ pub enum ObsoleteSyntax { ObsoleteExternVisibility, ObsoleteUnsafeExternFn, ObsoletePrivVisibility, + ObsoleteTraitFuncVisibility, } impl to_bytes::IterBytes for ObsoleteSyntax { @@ -95,7 +96,7 @@ pub trait ParserObsoleteMethods { impl ParserObsoleteMethods for Parser { /// Reports an obsolete syntax non-fatal error. - pub fn obsolete(&self, sp: span, kind: ObsoleteSyntax) { + fn obsolete(&self, sp: span, kind: ObsoleteSyntax) { let (kind_str, desc) = match kind { ObsoleteLet => ( "`let` in field declaration", @@ -258,6 +259,10 @@ impl ParserObsoleteMethods for Parser { "`priv` not necessary", "an item without a visibility qualifier is private by default" ), + ObsoleteTraitFuncVisibility => ( + "visibility not necessary", + "trait functions inherit the visibility of the trait itself" + ), }; self.report(sp, kind, kind_str, desc); @@ -265,7 +270,7 @@ impl ParserObsoleteMethods for Parser { // Reports an obsolete syntax non-fatal error, and returns // a placeholder expression - pub fn obsolete_expr(&self, sp: span, kind: ObsoleteSyntax) -> @expr { + fn obsolete_expr(&self, sp: span, kind: ObsoleteSyntax) -> @expr { self.obsolete(sp, kind); self.mk_expr(sp.lo, sp.hi, expr_lit(@respan(sp, lit_nil))) } @@ -283,7 +288,7 @@ impl ParserObsoleteMethods for Parser { } } - pub fn token_is_obsolete_ident(&self, ident: &str, token: &Token) + fn token_is_obsolete_ident(&self, ident: &str, token: &Token) -> bool { match *token { token::IDENT(sid, _) => { @@ -293,11 +298,11 @@ impl ParserObsoleteMethods for Parser { } } - pub fn is_obsolete_ident(&self, ident: &str) -> bool { + fn is_obsolete_ident(&self, ident: &str) -> bool { self.token_is_obsolete_ident(ident, self.token) } - pub fn eat_obsolete_ident(&self, ident: &str) -> bool { + fn eat_obsolete_ident(&self, ident: &str) -> bool { if self.is_obsolete_ident(ident) { self.bump(); true @@ -306,7 +311,7 @@ impl ParserObsoleteMethods for Parser { } } - pub fn try_parse_obsolete_struct_ctor(&self) -> bool { + fn try_parse_obsolete_struct_ctor(&self) -> bool { if self.eat_obsolete_ident("new") { self.obsolete(*self.last_span, ObsoleteStructCtor); self.parse_fn_decl(); @@ -317,7 +322,7 @@ impl ParserObsoleteMethods for Parser { } } - pub fn try_parse_obsolete_with(&self) -> bool { + fn try_parse_obsolete_with(&self) -> bool { if *self.token == token::COMMA && self.look_ahead(1, |t| self.token_is_obsolete_ident("with", t)) { @@ -332,7 +337,7 @@ impl ParserObsoleteMethods for Parser { } } - pub fn try_parse_obsolete_priv_section(&self, attrs: &[Attribute]) + fn try_parse_obsolete_priv_section(&self, attrs: &[Attribute]) -> bool { if self.is_keyword(keywords::Priv) && self.look_ahead(1, |t| *t == token::LBRACE) { diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 7e18c440d816c..c09fdd8713e6e 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[macro_escape]; - use abi; use abi::AbiSet; use ast::{Sigil, BorrowedSigil, ManagedSigil, OwnedSigil}; @@ -87,7 +85,7 @@ use parse::obsolete::{ObsoleteConstItem, ObsoleteFixedLengthVectorType}; use parse::obsolete::{ObsoleteNamedExternModule, ObsoleteMultipleLocalDecl}; use parse::obsolete::{ObsoleteMutWithMultipleBindings}; use parse::obsolete::{ObsoleteExternVisibility, ObsoleteUnsafeExternFn}; -use parse::obsolete::{ParserObsoleteMethods, ObsoletePrivVisibility}; +use parse::obsolete::{ParserObsoleteMethods}; use parse::token::{can_begin_expr, get_ident_interner, ident_to_str, is_ident}; use parse::token::{is_ident_or_path}; use parse::token::{is_plain_ident, INTERPOLATED, keywords, special_idents}; @@ -146,7 +144,7 @@ macro_rules! maybe_whole_expr ( Some($p.mk_expr( ($p).span.lo, ($p).span.hi, - expr_path(/* bad */ (**pt).clone()))) + expr_path(/* bad */ (*pt).clone()))) } _ => None }; @@ -235,8 +233,8 @@ macro_rules! maybe_whole ( _ => None }; match __found__ { - Some(INTERPOLATED(token::$constructor(ref x))) => { - return (~[], (**x).clone()) + Some(INTERPOLATED(token::$constructor(x))) => { + return (~[], x.clone()) } _ => {} } @@ -265,7 +263,7 @@ struct ParsedItemsAndViewItems { pub fn Parser(sess: @mut ParseSess, cfg: ast::CrateConfig, - rdr: @mut reader) + rdr: @reader) -> Parser { let tok0 = rdr.next_token(); let interner = get_ident_interner(); @@ -283,7 +281,6 @@ pub fn Parser(sess: @mut ParseSess, token: @mut tok0.tok, span: @mut span, last_span: @mut span, - last_token: @mut None, buffer: @mut ([ placeholder.clone(), placeholder.clone(), @@ -310,15 +307,13 @@ pub struct Parser { span: @mut span, // the span of the prior token: last_span: @mut span, - // the previous token or None (only stashed sometimes). - last_token: @mut Option<~token::Token>, buffer: @mut [TokenAndSpan, ..4], buffer_start: @mut int, buffer_end: @mut int, tokens_consumed: @mut uint, restriction: @mut restriction, quote_depth: @mut uint, // not (yet) related to the quasiquoter - reader: @mut reader, + reader: @reader, interner: @token::ident_interner, /// The set of seen errors about obsolete syntax. Used to suppress /// extra detail when the same error is seen twice @@ -371,7 +366,7 @@ impl Parser { } else { self.fatal( fmt!( - "expected `%s` but found `%s`", + "expected `%s`, found `%s`", self.token_to_str(t), self.this_token_to_str() ) @@ -379,89 +374,6 @@ impl Parser { } } - // Expect next token to be edible or inedible token. If edible, - // then consume it; if inedible, then return without consuming - // anything. Signal a fatal error if next token is unexpected. - pub fn expect_one_of(&self, edible: &[token::Token], inedible: &[token::Token]) { - fn tokens_to_str(p:&Parser, tokens: &[token::Token]) -> ~str { - let mut i = tokens.iter(); - // This might be a sign we need a connect method on Iterator. - let b = i.next().map_default(~"", |t| p.token_to_str(*t)); - i.fold(b, |b,a| b + " " + p.token_to_str(a)) - } - if edible.contains(self.token) { - self.bump(); - } else if inedible.contains(self.token) { - // leave it in the input - } else { - let expected = vec::append(edible.to_owned(), inedible); - let expect = tokens_to_str(self, expected); - let actual = self.this_token_to_str(); - self.fatal( - if expected.len() != 1 { - fmt!("expected one of `%s` but found `%s`", expect, actual) - } else { - fmt!("expected `%s` but found `%s`", expect, actual) - } - ) - } - } - - // Check for erroneous `ident { }`; if matches, signal error and - // recover (without consuming any expected input token). Returns - // true if and only if input was consumed for recovery. - pub fn check_for_erroneous_unit_struct_expecting(&self, expected: &[token::Token]) -> bool { - if *self.token == token::LBRACE - && expected.iter().all(|t| *t != token::LBRACE) - && self.look_ahead(1, |t| *t == token::RBRACE) { - // matched; signal non-fatal error and recover. - self.span_err(*self.span, - "Unit-like struct construction is written with no trailing `{ }`"); - self.eat(&token::LBRACE); - self.eat(&token::RBRACE); - true - } else { - false - } - } - - // Commit to parsing a complete expression `e` expected to be - // followed by some token from the set edible + inedible. Recover - // from anticipated input errors, discarding erroneous characters. - pub fn commit_expr(&self, e: @expr, edible: &[token::Token], inedible: &[token::Token]) { - debug!("commit_expr %?", e); - match e.node { - expr_path(*) => { - // might be unit-struct construction; check for recoverableinput error. - let expected = vec::append(edible.to_owned(), inedible); - self.check_for_erroneous_unit_struct_expecting(expected); - } - _ => {} - } - self.expect_one_of(edible, inedible) - } - - pub fn commit_expr_expecting(&self, e: @expr, edible: token::Token) { - self.commit_expr(e, &[edible], &[]) - } - - // Commit to parsing a complete statement `s`, which expects to be - // followed by some token from the set edible + inedible. Check - // for recoverable input errors, discarding erroneous characters. - pub fn commit_stmt(&self, s: @stmt, edible: &[token::Token], inedible: &[token::Token]) { - debug!("commit_stmt %?", s); - let _s = s; // unused, but future checks might want to inspect `s`. - if self.last_token.map_default(false, |t|is_ident_or_path(*t)) { - let expected = vec::append(edible.to_owned(), inedible); - self.check_for_erroneous_unit_struct_expecting(expected); - } - self.expect_one_of(edible, inedible) - } - - pub fn commit_stmt_expecting(&self, s: @stmt, edible: token::Token) { - self.commit_stmt(s, &[edible], &[]) - } - pub fn parse_ident(&self) -> ast::ident { self.check_strict_keywords(); self.check_reserved_keywords(); @@ -664,12 +576,6 @@ impl Parser { // advance the parser by one token pub fn bump(&self) { *self.last_span = *self.span; - // Stash token for error recovery (sometimes; clone is not necessarily cheap). - *self.last_token = if is_ident_or_path(self.token) { - Some(~(*self.token).clone()) - } else { - None - }; let next = if *self.buffer_start == *self.buffer_end { self.reader.next_token() } else { @@ -908,7 +814,7 @@ impl Parser { let attrs = p.parse_outer_attributes(); let lo = p.span.lo; - let vis = p.parse_non_priv_visibility(); + let vis = p.parse_visibility(); let pur = p.parse_fn_purity(); // NB: at the moment, trait methods are public by default; this // could change. @@ -966,7 +872,7 @@ impl Parser { _ => { p.fatal( fmt!( - "expected `;` or `}` but found `%s`", + "expected `;` or `}`, found `%s`", self.this_token_to_str() ) ); @@ -1031,7 +937,7 @@ impl Parser { // Useless second parameter for compatibility with quasiquote macros. // Bleh! pub fn parse_ty(&self, _: bool) -> Ty { - maybe_whole!(deref self, nt_ty); + maybe_whole!(self, nt_ty); let lo = self.span.lo; @@ -1385,7 +1291,7 @@ impl Parser { // parse a path that doesn't have type parameters attached pub fn parse_path_without_tps(&self) -> ast::Path { - maybe_whole!(deref self, nt_path); + maybe_whole!(self, nt_path); let (ids,is_global,sp) = self.parse_path(); ast::Path { span: sp, global: is_global, @@ -1398,7 +1304,7 @@ impl Parser { before_tps: Option<&fn()>) -> ast::Path { debug!("parse_path_with_tps(colons=%b)", colons); - maybe_whole!(deref self, nt_path); + maybe_whole!(self, nt_path); let lo = self.span.lo; let path = self.parse_path_without_tps(); if colons && !self.eat(&token::MOD_SEP) { @@ -1687,19 +1593,17 @@ impl Parser { return self.mk_expr(lo, hi, expr_lit(lit)); } let mut es = ~[self.parse_expr()]; - self.commit_expr(*es.last(), &[], &[token::COMMA, token::RPAREN]); while *self.token == token::COMMA { self.bump(); if *self.token != token::RPAREN { es.push(self.parse_expr()); - self.commit_expr(*es.last(), &[], &[token::COMMA, token::RPAREN]); } else { trailing_comma = true; } } hi = self.span.hi; - self.commit_expr_expecting(*es.last(), token::RPAREN); + self.expect(&token::RPAREN); return if es.len() == 1 && !trailing_comma { self.mk_expr(lo, self.span.hi, expr_paren(es[0])) @@ -1839,7 +1743,7 @@ impl Parser { break; } - self.commit_expr(fields.last().expr, &[token::COMMA], &[token::RBRACE]); + self.expect(&token::COMMA); if self.eat(&token::DOTDOT) { base = Some(self.parse_expr()); @@ -1854,7 +1758,7 @@ impl Parser { } hi = pth.span.hi; - self.commit_expr_expecting(fields.last().expr, token::RBRACE); + self.expect(&token::RBRACE); ex = expr_struct(pth, fields, base); return self.mk_expr(lo, hi, ex); } @@ -1948,7 +1852,7 @@ impl Parser { self.bump(); let ix = self.parse_expr(); hi = ix.span.hi; - self.commit_expr_expecting(ix, token::RBRACKET); + self.expect(&token::RBRACKET); e = self.mk_expr(lo, hi, self.mk_index(e, ix)); } @@ -2557,7 +2461,7 @@ impl Parser { fn parse_match_expr(&self) -> @expr { let lo = self.last_span.lo; let discriminant = self.parse_expr(); - self.commit_expr_expecting(discriminant, token::LBRACE); + self.expect(&token::LBRACE); let mut arms: ~[arm] = ~[]; while *self.token != token::RBRACE { let pats = self.parse_pats(); @@ -2573,7 +2477,7 @@ impl Parser { && *self.token != token::RBRACE; if require_comma { - self.commit_expr(expr, &[token::COMMA], &[token::RBRACE]); + self.expect(&token::COMMA); } else { self.eat(&token::COMMA); } @@ -3194,7 +3098,7 @@ impl Parser { // parse a block. No inner attrs are allowed. pub fn parse_block(&self) -> Block { - maybe_whole!(deref self, nt_block); + maybe_whole!(self, nt_block); let lo = self.span.lo; if self.eat_keyword(keywords::Unsafe) { @@ -3273,26 +3177,37 @@ impl Parser { match stmt.node { stmt_expr(e, stmt_id) => { // expression without semicolon - if classify::stmt_ends_with_semi(stmt) { - // Just check for errors and recover; do not eat semicolon yet. - self.commit_stmt(stmt, &[], &[token::SEMI, token::RBRACE]); - } - + let has_semi; match *self.token { token::SEMI => { - self.bump(); - stmts.push(@codemap::spanned { - node: stmt_semi(e, stmt_id), - span: stmt.span, - }); + has_semi = true; } token::RBRACE => { + has_semi = false; expr = Some(e); } - _ => { + ref t => { + has_semi = false; + if classify::stmt_ends_with_semi(stmt) { + self.fatal( + fmt!( + "expected `;` or `}` after \ + expression, found `%s`", + self.token_to_str(t) + ) + ); + } stmts.push(stmt); } } + + if has_semi { + self.bump(); + stmts.push(@codemap::spanned { + node: stmt_semi(e, stmt_id), + span: stmt.span, + }); + } } stmt_mac(ref m, _) => { // statement macro; might be an expr @@ -3328,7 +3243,7 @@ impl Parser { stmts.push(stmt); if classify::stmt_ends_with_semi(stmt) { - self.commit_stmt_expecting(stmt, token::SEMI); + self.expect(&token::SEMI); } } } @@ -3476,7 +3391,7 @@ impl Parser { if !self.is_self_ident() { self.fatal( fmt!( - "expected `self` but found `%s`", + "expected `self`, found `%s`", self.this_token_to_str() ) ); @@ -3693,7 +3608,7 @@ impl Parser { let attrs = self.parse_outer_attributes(); let lo = self.span.lo; - let visa = self.parse_non_priv_visibility(); + let visa = self.parse_visibility(); let pur = self.parse_fn_purity(); let ident = self.parse_ident(); let generics = self.parse_generics(); @@ -3843,7 +3758,7 @@ impl Parser { } } if fields.len() == 0 { - self.fatal(fmt!("Unit-like struct definition should be written as `struct %s;`", + self.fatal(fmt!("Unit-like struct should be written as `struct %s;`", get_ident_interner().get(class_name.name))); } self.bump(); @@ -3874,7 +3789,7 @@ impl Parser { self.fatal( fmt!( "expected `{`, `(`, or `;` after struct name \ - but found `%s`", + , found `%s`", self.this_token_to_str() ) ); @@ -3918,7 +3833,7 @@ impl Parser { token::RBRACE => {} _ => { self.span_fatal(*self.span, - fmt!("expected `,`, or '}' but found `%s`", + fmt!("expected `,`, or '}', found `%s`", self.this_token_to_str())); } } @@ -3956,18 +3871,6 @@ impl Parser { else { inherited } } - // parse visibility, but emits an obsolete error if it's private - fn parse_non_priv_visibility(&self) -> visibility { - match self.parse_visibility() { - public => public, - inherited => inherited, - private => { - self.obsolete(*self.last_span, ObsoletePrivVisibility); - inherited - } - } - } - fn parse_staticness(&self) -> bool { if self.eat_keyword(keywords::Static) { self.obsolete(*self.last_span, ObsoleteStaticMethod); @@ -4014,7 +3917,7 @@ impl Parser { the module"); } _ => { - self.fatal(fmt!("expected item but found `%s`", + self.fatal(fmt!("expected item, found `%s`", self.this_token_to_str())); } } @@ -4035,7 +3938,7 @@ impl Parser { let ty = self.parse_ty(false); self.expect(&token::EQ); let e = self.parse_expr(); - self.commit_expr_expecting(e, token::SEMI); + self.expect(&token::SEMI); (id, item_static(ty, m, e), None) } @@ -4160,7 +4063,7 @@ impl Parser { // parse a function declaration from a foreign module fn parse_item_foreign_fn(&self, attrs: ~[Attribute]) -> @foreign_item { let lo = self.span.lo; - let vis = self.parse_non_priv_visibility(); + let vis = self.parse_visibility(); // Parse obsolete purity. let purity = self.parse_fn_purity(); @@ -4262,20 +4165,12 @@ impl Parser { self.expect_keyword(keywords::Mod); } else if *self.token != token::LBRACE { self.span_fatal(*self.span, - fmt!("expected `{` or `mod` but found `%s`", + fmt!("expected `{` or `mod`, found `%s`", self.this_token_to_str())); } - let (sort, maybe_path, ident) = match *self.token { - token::IDENT(*) => { - let the_ident = self.parse_ident(); - let path = if *self.token == token::EQ { - self.bump(); - Some(self.parse_str()) - } - else { None }; - (ast::named, path, the_ident) - } + let (sort, ident) = match *self.token { + token::IDENT(*) => (ast::named, self.parse_ident()), _ => { if must_be_named_mod { self.span_fatal(*self.span, @@ -4284,7 +4179,7 @@ impl Parser { self.this_token_to_str())); } - (ast::anonymous, None, + (ast::anonymous, special_idents::clownshoes_foreign_mod) } }; @@ -4323,7 +4218,7 @@ impl Parser { let metadata = self.parse_optional_meta(); self.expect(&token::SEMI); iovi_view_item(ast::view_item { - node: view_item_extern_mod(ident, maybe_path, metadata, self.get_id()), + node: view_item_extern_mod(ident, metadata, self.get_id()), attrs: attrs, vis: visibility, span: mk_sp(lo, self.last_span.hi) @@ -4395,7 +4290,7 @@ impl Parser { seq_sep_trailing_disallowed(token::COMMA), |p| p.parse_ty(false) ); - for ty in arg_tys.move_iter() { + for ty in arg_tys.consume_iter() { args.push(ast::variant_arg { ty: ty, id: self.get_id(), @@ -4545,20 +4440,10 @@ impl Parser { attrs: ~[Attribute], macros_allowed: bool) -> item_or_view_item { - match *self.token { - INTERPOLATED(token::nt_item(item)) => { - self.bump(); - let new_attrs = vec::append(attrs, item.attrs); - return iovi_item(@ast::item { - attrs: new_attrs, - ..(*item).clone()}); - } - _ => {} - } - + maybe_whole!(iovi self, nt_item); let lo = self.span.lo; - let visibility = self.parse_non_priv_visibility(); + let visibility = self.parse_visibility(); // must be a view item: if self.eat_keyword(keywords::Use) { @@ -4690,7 +4575,7 @@ impl Parser { maybe_whole!(iovi self, nt_item); let lo = self.span.lo; - let visibility = self.parse_non_priv_visibility(); + let visibility = self.parse_visibility(); if (self.is_keyword(keywords::Const) || self.is_keyword(keywords::Static)) { // FOREIGN CONST ITEM @@ -4915,13 +4800,8 @@ impl Parser { } else if self.eat_keyword(keywords::Extern) { self.expect_keyword(keywords::Mod); let ident = self.parse_ident(); - let path = if *self.token == token::EQ { - self.bump(); - Some(self.parse_str()) - } - else { None }; let metadata = self.parse_optional_meta(); - view_item_extern_mod(ident, path, metadata, self.get_id()) + view_item_extern_mod(ident, metadata, self.get_id()) } else { self.bug("expected view item"); }; diff --git a/src/snapshots.txt b/src/snapshots.txt index d5c27fb74eb95..987434b424e9c 100644 --- a/src/snapshots.txt +++ b/src/snapshots.txt @@ -1,3 +1,11 @@ +S 2013-08-12 ecfc9a8 + freebsd-x86_64 ae903580d6328b8517dc64b013c1b0740bfa4e83 + linux-i386 3076bf032ce980157a894a0a4446902ba8b1783d + linux-x86_64 241090d135e1ce95f0b17a198c194d29cd917bb1 + macos-i386 15a749ed891bfaad9515d01391fbcd1788d9adc6 + macos-x86_64 037e007d82dffdf3c8dfddaa6837ace821a1d3d5 + winnt-i386 d1272610ac2b7b938a5d992b61947aed7e4ebc3d + S 2013-08-03 18e3db7 freebsd-x86_64 addf91b20416bf21a7c53ea9508bc302ec957ce9 linux-i386 ce103c323c0a0b75d1307014f1d6f8ff4d03c873 diff --git a/src/test/auxiliary/private_variant_xc.rs b/src/test/auxiliary/private_variant_xc.rs index a3a604d9e784c..e1ecbf8c5432e 100644 --- a/src/test/auxiliary/private_variant_xc.rs +++ b/src/test/auxiliary/private_variant_xc.rs @@ -1,4 +1,4 @@ pub enum Foo { - pub Bar, + Bar, priv Baz, } diff --git a/src/test/auxiliary/reexported_static_methods.rs b/src/test/auxiliary/reexported_static_methods.rs index 811bf082ae891..bb20b04762d5a 100644 --- a/src/test/auxiliary/reexported_static_methods.rs +++ b/src/test/auxiliary/reexported_static_methods.rs @@ -14,20 +14,20 @@ pub use sub_foo::Boz; pub use sub_foo::Bort; pub trait Bar { - pub fn bar() -> Self; + fn bar() -> Self; } impl Bar for int { - pub fn bar() -> int { 84 } + fn bar() -> int { 84 } } pub mod sub_foo { pub trait Foo { - pub fn foo() -> Self; + fn foo() -> Self; } impl Foo for int { - pub fn foo() -> int { 42 } + fn foo() -> int { 42 } } pub struct Boz { diff --git a/src/test/compile-fail/bad-bang-ann-3.rs b/src/test/compile-fail/bad-bang-ann-3.rs index 9e73bbe1406bd..f7524787c7b96 100644 --- a/src/test/compile-fail/bad-bang-ann-3.rs +++ b/src/test/compile-fail/bad-bang-ann-3.rs @@ -13,7 +13,7 @@ fn bad_bang(i: uint) -> ! { return 7u; - //~^ ERROR expected `!` but found `uint` + //~^ ERROR expected `!`, found `uint` } fn main() { bad_bang(5u); } diff --git a/src/test/compile-fail/bad-bang-ann.rs b/src/test/compile-fail/bad-bang-ann.rs index 2ffb5dd29066f..a52c6f3a849a0 100644 --- a/src/test/compile-fail/bad-bang-ann.rs +++ b/src/test/compile-fail/bad-bang-ann.rs @@ -13,7 +13,7 @@ fn bad_bang(i: uint) -> ! { if i < 0u { } else { fail!(); } - //~^ ERROR expected `!` but found `()` + //~^ ERROR expected `!`, found `()` } fn main() { bad_bang(5u); } diff --git a/src/test/compile-fail/bad-const-type.rs b/src/test/compile-fail/bad-const-type.rs index 5045c87c2f3a8..21047716f303e 100644 --- a/src/test/compile-fail/bad-const-type.rs +++ b/src/test/compile-fail/bad-const-type.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern:expected `~str` but found `int` +// error-pattern:expected `~str`, found `int` static i: ~str = 10i; fn main() { info!(i); } diff --git a/src/test/compile-fail/bang-tailexpr.rs b/src/test/compile-fail/bang-tailexpr.rs index af78e19e8c2e2..ff95f05279eea 100644 --- a/src/test/compile-fail/bang-tailexpr.rs +++ b/src/test/compile-fail/bang-tailexpr.rs @@ -9,6 +9,6 @@ // except according to those terms. fn f() -> ! { - 3i //~ ERROR expected `!` but found `int` + 3i //~ ERROR expected `!`, found `int` } fn main() { } diff --git a/src/test/compile-fail/block-must-not-have-result-do.rs b/src/test/compile-fail/block-must-not-have-result-do.rs index abeefa4aac810..687171f8c1f9b 100644 --- a/src/test/compile-fail/block-must-not-have-result-do.rs +++ b/src/test/compile-fail/block-must-not-have-result-do.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern:mismatched types: expected `()` but found `bool` +// error-pattern:mismatched types: expected `()`, found `bool` fn main() { loop { diff --git a/src/test/compile-fail/block-must-not-have-result-res.rs b/src/test/compile-fail/block-must-not-have-result-res.rs index c9b627f55f803..a3bef505d0d4e 100644 --- a/src/test/compile-fail/block-must-not-have-result-res.rs +++ b/src/test/compile-fail/block-must-not-have-result-res.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern:mismatched types: expected `()` but found `bool` +// error-pattern:mismatched types: expected `()`, found `bool` struct r; diff --git a/src/test/compile-fail/block-must-not-have-result-while.rs b/src/test/compile-fail/block-must-not-have-result-while.rs index e4aceabf0c8fb..ed903f3fd6551 100644 --- a/src/test/compile-fail/block-must-not-have-result-while.rs +++ b/src/test/compile-fail/block-must-not-have-result-while.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern:mismatched types: expected `()` but found `bool` +// error-pattern:mismatched types: expected `()`, found `bool` fn main() { while true { diff --git a/src/test/compile-fail/borrowck-alias-mut-base-ptr.rs b/src/test/compile-fail/borrowck-alias-mut-base-ptr.rs index c51cf5b9538d9..1cde5cb94fd5e 100644 --- a/src/test/compile-fail/borrowck-alias-mut-base-ptr.rs +++ b/src/test/compile-fail/borrowck-alias-mut-base-ptr.rs @@ -12,4 +12,4 @@ fn foo(t0: &mut int) { } fn main() { -} \ No newline at end of file +} diff --git a/src/test/compile-fail/borrowck-anon-fields-struct.rs b/src/test/compile-fail/borrowck-anon-fields-struct.rs index 45a26068d8285..bcaa3b9086cf3 100644 --- a/src/test/compile-fail/borrowck-anon-fields-struct.rs +++ b/src/test/compile-fail/borrowck-anon-fields-struct.rs @@ -34,4 +34,4 @@ fn same_variant() { } fn main() { -} \ No newline at end of file +} diff --git a/src/test/compile-fail/borrowck-anon-fields-tuple.rs b/src/test/compile-fail/borrowck-anon-fields-tuple.rs index ae02245c97f52..de2a8d8326808 100644 --- a/src/test/compile-fail/borrowck-anon-fields-tuple.rs +++ b/src/test/compile-fail/borrowck-anon-fields-tuple.rs @@ -32,4 +32,4 @@ fn same_variant() { } fn main() { -} \ No newline at end of file +} diff --git a/src/test/compile-fail/borrowck-anon-fields-variant.rs b/src/test/compile-fail/borrowck-anon-fields-variant.rs index 3d9738df059ca..da0a9323d2c81 100644 --- a/src/test/compile-fail/borrowck-anon-fields-variant.rs +++ b/src/test/compile-fail/borrowck-anon-fields-variant.rs @@ -40,4 +40,4 @@ fn same_variant() { } fn main() { -} \ No newline at end of file +} diff --git a/src/test/compile-fail/borrowck-bad-nested-calls-free.rs b/src/test/compile-fail/borrowck-bad-nested-calls-free.rs index ff1ec38ad6406..c142876c5c2c5 100644 --- a/src/test/compile-fail/borrowck-bad-nested-calls-free.rs +++ b/src/test/compile-fail/borrowck-bad-nested-calls-free.rs @@ -40,4 +40,4 @@ fn explicit() { rewrite(&mut a)); //~ ERROR cannot borrow } -fn main() {} \ No newline at end of file +fn main() {} diff --git a/src/test/compile-fail/borrowck-bad-nested-calls-move.rs b/src/test/compile-fail/borrowck-bad-nested-calls-move.rs index 0adf486b8b3ab..622d2e78ee794 100644 --- a/src/test/compile-fail/borrowck-bad-nested-calls-move.rs +++ b/src/test/compile-fail/borrowck-bad-nested-calls-move.rs @@ -40,4 +40,4 @@ fn explicit() { a); //~ ERROR cannot move } -fn main() {} \ No newline at end of file +fn main() {} diff --git a/src/test/compile-fail/borrowck-borrow-mut-base-ptr-in-aliasable-loc.rs b/src/test/compile-fail/borrowck-borrow-mut-base-ptr-in-aliasable-loc.rs index 7e9c298ba4732..45238b36681b2 100644 --- a/src/test/compile-fail/borrowck-borrow-mut-base-ptr-in-aliasable-loc.rs +++ b/src/test/compile-fail/borrowck-borrow-mut-base-ptr-in-aliasable-loc.rs @@ -28,4 +28,4 @@ fn foo3(t0: &mut &mut int) { } fn main() { -} \ No newline at end of file +} diff --git a/src/test/compile-fail/borrowck-move-in-irrefut-pat.rs b/src/test/compile-fail/borrowck-move-in-irrefut-pat.rs index c99a1ee60d7fd..628ccd1a5d782 100644 --- a/src/test/compile-fail/borrowck-move-in-irrefut-pat.rs +++ b/src/test/compile-fail/borrowck-move-in-irrefut-pat.rs @@ -13,4 +13,4 @@ fn let_pat() { //~^ ERROR cannot move out of dereference of & pointer } -pub fn main() {} \ No newline at end of file +pub fn main() {} diff --git a/src/test/compile-fail/borrowck-move-mut-base-ptr.rs b/src/test/compile-fail/borrowck-move-mut-base-ptr.rs index 6a3832d2304cf..565629b1c306d 100644 --- a/src/test/compile-fail/borrowck-move-mut-base-ptr.rs +++ b/src/test/compile-fail/borrowck-move-mut-base-ptr.rs @@ -12,4 +12,4 @@ fn foo(t0: &mut int) { } fn main() { -} \ No newline at end of file +} diff --git a/src/test/compile-fail/borrowck-swap-mut-base-ptr.rs b/src/test/compile-fail/borrowck-swap-mut-base-ptr.rs index bea5f1f6ea765..ab6f70945be6c 100644 --- a/src/test/compile-fail/borrowck-swap-mut-base-ptr.rs +++ b/src/test/compile-fail/borrowck-swap-mut-base-ptr.rs @@ -13,4 +13,4 @@ fn foo<'a>(mut t0: &'a mut int, } fn main() { -} \ No newline at end of file +} diff --git a/src/test/compile-fail/cast-immutable-mutable-trait.rs b/src/test/compile-fail/cast-immutable-mutable-trait.rs index 1047a99577143..0a94d6c456081 100644 --- a/src/test/compile-fail/cast-immutable-mutable-trait.rs +++ b/src/test/compile-fail/cast-immutable-mutable-trait.rs @@ -25,4 +25,4 @@ fn main() { let s = @S { unused: 0 }; let _s2 = s as @mut T; //~ error: types differ in mutability let _s3 = &s as &mut T; //~ error: types differ in mutability -} \ No newline at end of file +} diff --git a/src/test/compile-fail/cast-vector-to-unsafe-nonstatic.rs b/src/test/compile-fail/cast-vector-to-unsafe-nonstatic.rs index a083757a0eb9a..ce58b260f6186 100644 --- a/src/test/compile-fail/cast-vector-to-unsafe-nonstatic.rs +++ b/src/test/compile-fail/cast-vector-to-unsafe-nonstatic.rs @@ -11,4 +11,4 @@ fn main() { let foo = ['h' as u8, 'i' as u8, 0 as u8]; let bar = &foo as *u8; //~ ERROR mismatched types -} \ No newline at end of file +} diff --git a/src/test/compile-fail/closure-bounds-cant-promote-superkind-in-struct.rs b/src/test/compile-fail/closure-bounds-cant-promote-superkind-in-struct.rs index b38cb89548807..2e7313b6afd54 100644 --- a/src/test/compile-fail/closure-bounds-cant-promote-superkind-in-struct.rs +++ b/src/test/compile-fail/closure-bounds-cant-promote-superkind-in-struct.rs @@ -13,7 +13,7 @@ struct X { } fn foo(blk: @fn:()) -> X { - return X { field: blk }; //~ ERROR expected bounds `Send` but found no bounds + return X { field: blk }; //~ ERROR expected bounds `Send`, found no bounds } fn main() { diff --git a/src/test/compile-fail/closure-bounds-not-builtin.rs b/src/test/compile-fail/closure-bounds-not-builtin.rs index a3484cb33dcae..fbf1acb60665b 100644 --- a/src/test/compile-fail/closure-bounds-not-builtin.rs +++ b/src/test/compile-fail/closure-bounds-not-builtin.rs @@ -5,4 +5,4 @@ fn take(f: &fn:Foo()) { //~^ ERROR only the builtin traits can be used as closure or object bounds } -fn main() {} \ No newline at end of file +fn main() {} diff --git a/src/test/compile-fail/closure-bounds-subtype.rs b/src/test/compile-fail/closure-bounds-subtype.rs index f04da0575b954..ba15d9a056544 100644 --- a/src/test/compile-fail/closure-bounds-subtype.rs +++ b/src/test/compile-fail/closure-bounds-subtype.rs @@ -11,7 +11,7 @@ fn give_any(f: &fn:()) { fn give_owned(f: &fn:Send()) { take_any(f); - take_const_owned(f); //~ ERROR expected bounds `Send+Freeze` but found bounds `Send` + take_const_owned(f); //~ ERROR expected bounds `Send+Freeze`, found bounds `Send` } fn main() {} diff --git a/src/test/compile-fail/coherence_inherent.rs b/src/test/compile-fail/coherence_inherent.rs index 590c12826e4fe..2c3fbc827aad6 100644 --- a/src/test/compile-fail/coherence_inherent.rs +++ b/src/test/compile-fail/coherence_inherent.rs @@ -42,4 +42,4 @@ mod NoImport { } } -fn main() {} \ No newline at end of file +fn main() {} diff --git a/src/test/compile-fail/coherence_inherent_cc.rs b/src/test/compile-fail/coherence_inherent_cc.rs index 72c6df57c4ff5..40d733f8bab5c 100644 --- a/src/test/compile-fail/coherence_inherent_cc.rs +++ b/src/test/compile-fail/coherence_inherent_cc.rs @@ -35,4 +35,4 @@ mod NoImport { } } -fn main() {} \ No newline at end of file +fn main() {} diff --git a/src/test/compile-fail/deprecated-auto-code.rs b/src/test/compile-fail/deprecated-auto-code.rs index 1f7cbfe980782..e4576e0f57c54 100644 --- a/src/test/compile-fail/deprecated-auto-code.rs +++ b/src/test/compile-fail/deprecated-auto-code.rs @@ -12,4 +12,4 @@ #[auto_decode] //~ ERROR: `#[auto_decode]` is deprecated struct A; -fn main() {} \ No newline at end of file +fn main() {} diff --git a/src/test/compile-fail/do-lambda-requires-braces.rs b/src/test/compile-fail/do-lambda-requires-braces.rs index a836556dff881..abe066182b924 100644 --- a/src/test/compile-fail/do-lambda-requires-braces.rs +++ b/src/test/compile-fail/do-lambda-requires-braces.rs @@ -10,6 +10,6 @@ fn main() { do something - |x| do somethingelse //~ ERROR: expected `{` but found `do` + |x| do somethingelse //~ ERROR: expected `{`, found `do` |y| say(x, y) } diff --git a/src/test/compile-fail/do1.rs b/src/test/compile-fail/do1.rs index d16fa4eadd566..2da57bda273e2 100644 --- a/src/test/compile-fail/do1.rs +++ b/src/test/compile-fail/do1.rs @@ -9,5 +9,5 @@ // except according to those terms. fn main() { - let x = do y; //~ ERROR: expected `{` but found + let x = do y; //~ ERROR: expected `{`, found } diff --git a/src/test/compile-fail/do2.rs b/src/test/compile-fail/do2.rs index 4466c07518fec..0d815363635f2 100644 --- a/src/test/compile-fail/do2.rs +++ b/src/test/compile-fail/do2.rs @@ -12,5 +12,5 @@ fn f(f: @fn(int) -> bool) -> bool { f(10i) } fn main() { assert!(do f() |i| { i == 10i } == 10i); - //~^ ERROR: expected `bool` but found `int` + //~^ ERROR: expected `bool`, found `int` } diff --git a/src/test/compile-fail/estr-subtyping.rs b/src/test/compile-fail/estr-subtyping.rs index d0d1b2013a95b..f8dcd9052b3ef 100644 --- a/src/test/compile-fail/estr-subtyping.rs +++ b/src/test/compile-fail/estr-subtyping.rs @@ -14,19 +14,19 @@ fn wants_slice(x: &str) { } fn has_box(x: @str) { wants_box(x); - wants_uniq(x); //~ ERROR str storage differs: expected ~ but found @ + wants_uniq(x); //~ ERROR str storage differs: expected ~, found @ wants_slice(x); } fn has_uniq(x: ~str) { - wants_box(x); //~ ERROR str storage differs: expected @ but found ~ + wants_box(x); //~ ERROR str storage differs: expected @, found ~ wants_uniq(x); wants_slice(x); } fn has_slice(x: &str) { - wants_box(x); //~ ERROR str storage differs: expected @ but found & - wants_uniq(x); //~ ERROR str storage differs: expected ~ but found & + wants_box(x); //~ ERROR str storage differs: expected @, found & + wants_uniq(x); //~ ERROR str storage differs: expected ~, found & wants_slice(x); } diff --git a/src/test/compile-fail/evec-subtyping.rs b/src/test/compile-fail/evec-subtyping.rs index f9c8ba01f1805..9301798bddb72 100644 --- a/src/test/compile-fail/evec-subtyping.rs +++ b/src/test/compile-fail/evec-subtyping.rs @@ -14,26 +14,26 @@ fn wants_three(x: [uint, ..3]) { } fn has_box(x: @[uint]) { wants_box(x); - wants_uniq(x); //~ ERROR [] storage differs: expected ~ but found @ - wants_three(x); //~ ERROR [] storage differs: expected 3 but found @ + wants_uniq(x); //~ ERROR [] storage differs: expected ~, found @ + wants_three(x); //~ ERROR [] storage differs: expected 3, found @ } fn has_uniq(x: ~[uint]) { - wants_box(x); //~ ERROR [] storage differs: expected @ but found ~ + wants_box(x); //~ ERROR [] storage differs: expected @, found ~ wants_uniq(x); - wants_three(x); //~ ERROR [] storage differs: expected 3 but found ~ + wants_three(x); //~ ERROR [] storage differs: expected 3, found ~ } fn has_three(x: [uint, ..3]) { - wants_box(x); //~ ERROR [] storage differs: expected @ but found 3 - wants_uniq(x); //~ ERROR [] storage differs: expected ~ but found 3 + wants_box(x); //~ ERROR [] storage differs: expected @, found 3 + wants_uniq(x); //~ ERROR [] storage differs: expected ~, found 3 wants_three(x); } fn has_four(x: [uint, ..4]) { - wants_box(x); //~ ERROR [] storage differs: expected @ but found 4 - wants_uniq(x); //~ ERROR [] storage differs: expected ~ but found 4 - wants_three(x); //~ ERROR [] storage differs: expected 3 but found 4 + wants_box(x); //~ ERROR [] storage differs: expected @, found 4 + wants_uniq(x); //~ ERROR [] storage differs: expected ~, found 4 + wants_three(x); //~ ERROR [] storage differs: expected 3, found 4 } fn main() { diff --git a/src/test/compile-fail/extern-no-call.rs b/src/test/compile-fail/extern-no-call.rs index 58649f3209bb1..343965a5c4a8c 100644 --- a/src/test/compile-fail/extern-no-call.rs +++ b/src/test/compile-fail/extern-no-call.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern:expected function but found `*u8` +// error-pattern:expected function, found `*u8` extern fn f() { } diff --git a/src/test/compile-fail/fully-qualified-type-name2.rs b/src/test/compile-fail/fully-qualified-type-name2.rs index 986d19669b91e..94af50dac0ea5 100644 --- a/src/test/compile-fail/fully-qualified-type-name2.rs +++ b/src/test/compile-fail/fully-qualified-type-name2.rs @@ -20,7 +20,7 @@ mod y { fn bar(x: x::foo) -> y::foo { return x; - //~^ ERROR mismatched types: expected `y::foo` but found `x::foo` + //~^ ERROR mismatched types: expected `y::foo`, found `x::foo` } fn main() { diff --git a/src/test/compile-fail/fully-qualified-type-name3.rs b/src/test/compile-fail/fully-qualified-type-name3.rs index 464f292b75899..a9fd68e4bf64a 100644 --- a/src/test/compile-fail/fully-qualified-type-name3.rs +++ b/src/test/compile-fail/fully-qualified-type-name3.rs @@ -16,7 +16,7 @@ type T2 = int; fn bar(x: T1) -> T2 { return x; - //~^ ERROR mismatched types: expected `T2` but found `T1` + //~^ ERROR mismatched types: expected `T2`, found `T1` } fn main() { diff --git a/src/test/compile-fail/if-branch-types.rs b/src/test/compile-fail/if-branch-types.rs index 1c6dd0ef9f657..4a8c72c3877c5 100644 --- a/src/test/compile-fail/if-branch-types.rs +++ b/src/test/compile-fail/if-branch-types.rs @@ -10,5 +10,5 @@ fn main() { let x = if true { 10i } else { 10u }; - //~^ ERROR if and else have incompatible types: expected `int` but found `uint` + //~^ ERROR if and else have incompatible types: expected `int`, found `uint` } diff --git a/src/test/compile-fail/if-without-else-result.rs b/src/test/compile-fail/if-without-else-result.rs index 8e3318f6945ac..d9307d9669ae7 100644 --- a/src/test/compile-fail/if-without-else-result.rs +++ b/src/test/compile-fail/if-without-else-result.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern:mismatched types: expected `()` but found `bool` +// error-pattern:mismatched types: expected `()`, found `bool` fn main() { let a = if true { true }; diff --git a/src/test/compile-fail/integer-literal-suffix-inference.rs b/src/test/compile-fail/integer-literal-suffix-inference.rs index 2f77497acc4a8..1e42a9447f67a 100644 --- a/src/test/compile-fail/integer-literal-suffix-inference.rs +++ b/src/test/compile-fail/integer-literal-suffix-inference.rs @@ -39,62 +39,62 @@ fn main() { fn id_u64(n: u64) -> u64 { n } id_i8(a8); // ok - id_i8(a16); //~ ERROR mismatched types: expected `i8` but found `i16` - id_i8(a32); //~ ERROR mismatched types: expected `i8` but found `i32` - id_i8(a64); //~ ERROR mismatched types: expected `i8` but found `i64` + id_i8(a16); //~ ERROR mismatched types: expected `i8`, found `i16` + id_i8(a32); //~ ERROR mismatched types: expected `i8`, found `i32` + id_i8(a64); //~ ERROR mismatched types: expected `i8`, found `i64` - id_i16(a8); //~ ERROR mismatched types: expected `i16` but found `i8` + id_i16(a8); //~ ERROR mismatched types: expected `i16`, found `i8` id_i16(a16); // ok - id_i16(a32); //~ ERROR mismatched types: expected `i16` but found `i32` - id_i16(a64); //~ ERROR mismatched types: expected `i16` but found `i64` + id_i16(a32); //~ ERROR mismatched types: expected `i16`, found `i32` + id_i16(a64); //~ ERROR mismatched types: expected `i16`, found `i64` - id_i32(a8); //~ ERROR mismatched types: expected `i32` but found `i8` - id_i32(a16); //~ ERROR mismatched types: expected `i32` but found `i16` + id_i32(a8); //~ ERROR mismatched types: expected `i32`, found `i8` + id_i32(a16); //~ ERROR mismatched types: expected `i32`, found `i16` id_i32(a32); // ok - id_i32(a64); //~ ERROR mismatched types: expected `i32` but found `i64` + id_i32(a64); //~ ERROR mismatched types: expected `i32`, found `i64` - id_i64(a8); //~ ERROR mismatched types: expected `i64` but found `i8` - id_i64(a16); //~ ERROR mismatched types: expected `i64` but found `i16` - id_i64(a32); //~ ERROR mismatched types: expected `i64` but found `i32` + id_i64(a8); //~ ERROR mismatched types: expected `i64`, found `i8` + id_i64(a16); //~ ERROR mismatched types: expected `i64`, found `i16` + id_i64(a32); //~ ERROR mismatched types: expected `i64`, found `i32` id_i64(a64); // ok id_i8(c8); // ok - id_i8(c16); //~ ERROR mismatched types: expected `i8` but found `i16` - id_i8(c32); //~ ERROR mismatched types: expected `i8` but found `i32` - id_i8(c64); //~ ERROR mismatched types: expected `i8` but found `i64` + id_i8(c16); //~ ERROR mismatched types: expected `i8`, found `i16` + id_i8(c32); //~ ERROR mismatched types: expected `i8`, found `i32` + id_i8(c64); //~ ERROR mismatched types: expected `i8`, found `i64` - id_i16(c8); //~ ERROR mismatched types: expected `i16` but found `i8` + id_i16(c8); //~ ERROR mismatched types: expected `i16`, found `i8` id_i16(c16); // ok - id_i16(c32); //~ ERROR mismatched types: expected `i16` but found `i32` - id_i16(c64); //~ ERROR mismatched types: expected `i16` but found `i64` + id_i16(c32); //~ ERROR mismatched types: expected `i16`, found `i32` + id_i16(c64); //~ ERROR mismatched types: expected `i16`, found `i64` - id_i32(c8); //~ ERROR mismatched types: expected `i32` but found `i8` - id_i32(c16); //~ ERROR mismatched types: expected `i32` but found `i16` + id_i32(c8); //~ ERROR mismatched types: expected `i32`, found `i8` + id_i32(c16); //~ ERROR mismatched types: expected `i32`, found `i16` id_i32(c32); // ok - id_i32(c64); //~ ERROR mismatched types: expected `i32` but found `i64` + id_i32(c64); //~ ERROR mismatched types: expected `i32`, found `i64` - id_i64(a8); //~ ERROR mismatched types: expected `i64` but found `i8` - id_i64(a16); //~ ERROR mismatched types: expected `i64` but found `i16` - id_i64(a32); //~ ERROR mismatched types: expected `i64` but found `i32` + id_i64(a8); //~ ERROR mismatched types: expected `i64`, found `i8` + id_i64(a16); //~ ERROR mismatched types: expected `i64`, found `i16` + id_i64(a32); //~ ERROR mismatched types: expected `i64`, found `i32` id_i64(a64); // ok id_u8(b8); // ok - id_u8(b16); //~ ERROR mismatched types: expected `u8` but found `u16` - id_u8(b32); //~ ERROR mismatched types: expected `u8` but found `u32` - id_u8(b64); //~ ERROR mismatched types: expected `u8` but found `u64` + id_u8(b16); //~ ERROR mismatched types: expected `u8`, found `u16` + id_u8(b32); //~ ERROR mismatched types: expected `u8`, found `u32` + id_u8(b64); //~ ERROR mismatched types: expected `u8`, found `u64` - id_u16(b8); //~ ERROR mismatched types: expected `u16` but found `u8` + id_u16(b8); //~ ERROR mismatched types: expected `u16`, found `u8` id_u16(b16); // ok - id_u16(b32); //~ ERROR mismatched types: expected `u16` but found `u32` - id_u16(b64); //~ ERROR mismatched types: expected `u16` but found `u64` + id_u16(b32); //~ ERROR mismatched types: expected `u16`, found `u32` + id_u16(b64); //~ ERROR mismatched types: expected `u16`, found `u64` - id_u32(b8); //~ ERROR mismatched types: expected `u32` but found `u8` - id_u32(b16); //~ ERROR mismatched types: expected `u32` but found `u16` + id_u32(b8); //~ ERROR mismatched types: expected `u32`, found `u8` + id_u32(b16); //~ ERROR mismatched types: expected `u32`, found `u16` id_u32(b32); // ok - id_u32(b64); //~ ERROR mismatched types: expected `u32` but found `u64` + id_u32(b64); //~ ERROR mismatched types: expected `u32`, found `u64` - id_u64(b8); //~ ERROR mismatched types: expected `u64` but found `u8` - id_u64(b16); //~ ERROR mismatched types: expected `u64` but found `u16` - id_u64(b32); //~ ERROR mismatched types: expected `u64` but found `u32` + id_u64(b8); //~ ERROR mismatched types: expected `u64`, found `u8` + id_u64(b16); //~ ERROR mismatched types: expected `u64`, found `u16` + id_u64(b32); //~ ERROR mismatched types: expected `u64`, found `u32` id_u64(b64); // ok } diff --git a/src/test/compile-fail/issue-2995.rs b/src/test/compile-fail/issue-2995.rs index 3e771eef970f7..ea8ee8699e482 100644 --- a/src/test/compile-fail/issue-2995.rs +++ b/src/test/compile-fail/issue-2995.rs @@ -12,4 +12,4 @@ fn bad (p: *int) { let _q: &int = p as ∫ //~ ERROR non-scalar cast } -fn main() { } \ No newline at end of file +fn main() { } diff --git a/src/test/compile-fail/issue-3036.rs b/src/test/compile-fail/issue-3036.rs index 45b4ab1871dc9..5f56f6b8b6b99 100644 --- a/src/test/compile-fail/issue-3036.rs +++ b/src/test/compile-fail/issue-3036.rs @@ -13,4 +13,4 @@ fn main() { let x = 3 -} //~ ERROR: expected `;` but found `}` +} //~ ERROR: expected `;`, found `}` diff --git a/src/test/compile-fail/issue-3477.rs b/src/test/compile-fail/issue-3477.rs index 23e680fd851c3..cb7809eef55b7 100644 --- a/src/test/compile-fail/issue-3477.rs +++ b/src/test/compile-fail/issue-3477.rs @@ -1,3 +1,3 @@ fn main() { - let _p: char = 100; //~ ERROR mismatched types: expected `char` but found + let _p: char = 100; //~ ERROR mismatched types: expected `char`, found } diff --git a/src/test/compile-fail/issue-3680.rs b/src/test/compile-fail/issue-3680.rs index b453384c0c890..7cb63d712664b 100644 --- a/src/test/compile-fail/issue-3680.rs +++ b/src/test/compile-fail/issue-3680.rs @@ -10,6 +10,6 @@ fn main() { match None { - Err(_) => () //~ ERROR mismatched types: expected `std::option::Option<>` but found `std::result::Result<,>` + Err(_) => () //~ ERROR mismatched types: expected `std::option::Option<>`, found `std::result::Result<,>` } } diff --git a/src/test/compile-fail/issue-4517.rs b/src/test/compile-fail/issue-4517.rs index 0fbc79b1bc7bd..02a245e0c97d0 100644 --- a/src/test/compile-fail/issue-4517.rs +++ b/src/test/compile-fail/issue-4517.rs @@ -2,5 +2,5 @@ fn bar(int_param: int) {} fn main() { let foo: [u8, ..4] = [1u8, ..4u8]; - bar(foo); //~ ERROR mismatched types: expected `int` but found `[u8, .. 4]` (expected int but found vector) + bar(foo); //~ ERROR mismatched types: expected `int`, found `[u8, .. 4]` (expected int, found vector) } diff --git a/src/test/compile-fail/issue-4736.rs b/src/test/compile-fail/issue-4736.rs index f7144b4c8fa91..6f410ea3c3739 100644 --- a/src/test/compile-fail/issue-4736.rs +++ b/src/test/compile-fail/issue-4736.rs @@ -12,4 +12,4 @@ struct NonCopyable(()); fn main() { let z = NonCopyable{ p: () }; //~ ERROR structure has no field named `p` -} \ No newline at end of file +} diff --git a/src/test/compile-fail/issue-4968.rs b/src/test/compile-fail/issue-4968.rs index 700d8a61c3a39..d94a8d69a8e95 100644 --- a/src/test/compile-fail/issue-4968.rs +++ b/src/test/compile-fail/issue-4968.rs @@ -12,5 +12,5 @@ static A: (int,int) = (4,2); fn main() { - match 42 { A => () } //~ ERROR mismatched types: expected `` but found `(int,int)` (expected integral variable but found tuple) + match 42 { A => () } //~ ERROR mismatched types: expected ``, found `(int,int)` (expected integral variable, found tuple) } diff --git a/src/test/compile-fail/issue-5100.rs b/src/test/compile-fail/issue-5100.rs index 1ef67f784e386..c6db366e79274 100644 --- a/src/test/compile-fail/issue-5100.rs +++ b/src/test/compile-fail/issue-5100.rs @@ -12,33 +12,33 @@ enum A { B, C } fn main() { match (true, false) { - B => (), //~ ERROR expected `(bool,bool)` but found an enum or structure pattern + B => (), //~ ERROR expected `(bool,bool)`, found an enum or structure pattern _ => () } match (true, false) { - (true, false, false) => () //~ ERROR mismatched types: expected `(bool,bool)` but found tuple (expected a tuple with 2 elements but found one with 3 elements) + (true, false, false) => () //~ ERROR mismatched types: expected `(bool,bool)`, found tuple (expected a tuple with 2 elements, found one with 3 elements) } match (true, false) { - @(true, false) => () //~ ERROR mismatched types: expected `(bool,bool)` but found an @-box pattern + @(true, false) => () //~ ERROR mismatched types: expected `(bool,bool)`, found an @-box pattern } match (true, false) { - ~(true, false) => () //~ ERROR mismatched types: expected `(bool,bool)` but found a ~-box pattern + ~(true, false) => () //~ ERROR mismatched types: expected `(bool,bool)`, found a ~-box pattern } match (true, false) { - &(true, false) => () //~ ERROR mismatched types: expected `(bool,bool)` but found an &-pointer pattern + &(true, false) => () //~ ERROR mismatched types: expected `(bool,bool)`, found an &-pointer pattern } - let v = [('a', 'b') //~ ERROR expected function but found `(char,char)` + let v = [('a', 'b') //~ ERROR expected function, found `(char,char)` ('c', 'd'), ('e', 'f')]; for &(x,y) in v.iter() {} // should be OK // Make sure none of the errors above were fatal - let x: char = true; //~ ERROR expected `char` but found `bool` + let x: char = true; //~ ERROR expected `char`, found `bool` } diff --git a/src/test/compile-fail/issue-5358-1.rs b/src/test/compile-fail/issue-5358-1.rs index a3d25e7d2adca..85e34cd6db3ee 100644 --- a/src/test/compile-fail/issue-5358-1.rs +++ b/src/test/compile-fail/issue-5358-1.rs @@ -12,7 +12,7 @@ struct S(Either); fn main() { match S(Left(5)) { - Right(_) => {} //~ ERROR mismatched types: expected `S` but found `std::either::Either + Right(_) => {} //~ ERROR mismatched types: expected `S`, found `std::either::Either _ => {} } } diff --git a/src/test/compile-fail/issue-5358.rs b/src/test/compile-fail/issue-5358.rs index 8d4f463346693..b0a74fb37abe2 100644 --- a/src/test/compile-fail/issue-5358.rs +++ b/src/test/compile-fail/issue-5358.rs @@ -12,6 +12,6 @@ struct S(Either); fn main() { match *S(Left(5)) { - S(_) => {} //~ ERROR mismatched types: expected `std::either::Either` but found a structure pattern + S(_) => {} //~ ERROR mismatched types: expected `std::either::Either`, found a structure pattern } } diff --git a/src/test/compile-fail/issue-6762.rs b/src/test/compile-fail/issue-6762.rs index 391c1019a9468..14dcc4ea8a3a8 100644 --- a/src/test/compile-fail/issue-6762.rs +++ b/src/test/compile-fail/issue-6762.rs @@ -21,4 +21,4 @@ fn main() twice(x); invoke(sq); -} \ No newline at end of file +} diff --git a/src/test/compile-fail/lint-missing-doc.rs b/src/test/compile-fail/lint-missing-doc.rs index 2350ca68b9747..75bc93c6d0b30 100644 --- a/src/test/compile-fail/lint-missing-doc.rs +++ b/src/test/compile-fail/lint-missing-doc.rs @@ -15,19 +15,17 @@ struct Foo { a: int, priv b: int, - pub c: int, // doesn't matter, Foo is private } pub struct PubFoo { //~ ERROR: missing documentation a: int, //~ ERROR: missing documentation priv b: int, - pub c: int, //~ ERROR: missing documentation } #[allow(missing_doc)] pub struct PubFoo2 { a: int, - pub c: int, + c: int, } /// dox @@ -44,9 +42,9 @@ pub trait C {} //~ ERROR: missing documentation trait Bar { /// dox - pub fn foo(); + fn foo(); fn foo2(); //~ ERROR: missing documentation - pub fn foo3(); //~ ERROR: missing documentation + fn foo3(); //~ ERROR: missing documentation } impl Foo { @@ -59,13 +57,13 @@ impl Foo { #[allow(missing_doc)] trait F { - pub fn a(); + fn a(); fn b(&self); } // should need to redefine documentation for implementations of traits impl F for Foo { - pub fn a() {} + fn a() {} fn b(&self) {} } diff --git a/src/test/compile-fail/loop-does-not-diverge.rs b/src/test/compile-fail/loop-does-not-diverge.rs index 0a9d9fb20ab0e..d0e5249305493 100644 --- a/src/test/compile-fail/loop-does-not-diverge.rs +++ b/src/test/compile-fail/loop-does-not-diverge.rs @@ -14,7 +14,7 @@ fn forever() -> ! { loop { break; } - return 42i; //~ ERROR expected `!` but found `int` + return 42i; //~ ERROR expected `!`, found `int` } fn main() { diff --git a/src/test/compile-fail/lub-if.rs b/src/test/compile-fail/lub-if.rs index 358c61921470f..6b5055cb1a2cd 100644 --- a/src/test/compile-fail/lub-if.rs +++ b/src/test/compile-fail/lub-if.rs @@ -49,4 +49,4 @@ pub fn opt_str3<'a>(maybestr: &'a Option<~str>) -> &'static str { } -fn main() {} \ No newline at end of file +fn main() {} diff --git a/src/test/compile-fail/lub-match.rs b/src/test/compile-fail/lub-match.rs index 2a61b72997d1f..37b9cc55dc822 100644 --- a/src/test/compile-fail/lub-match.rs +++ b/src/test/compile-fail/lub-match.rs @@ -52,4 +52,4 @@ pub fn opt_str3<'a>(maybestr: &'a Option<~str>) -> &'static str { } } -fn main() {} \ No newline at end of file +fn main() {} diff --git a/src/test/compile-fail/main-wrong-location.rs b/src/test/compile-fail/main-wrong-location.rs index 90ef7843d4bf9..ef3f8140c68a0 100644 --- a/src/test/compile-fail/main-wrong-location.rs +++ b/src/test/compile-fail/main-wrong-location.rs @@ -12,4 +12,4 @@ mod m { // An inferred main entry point (that doesn't use #[main]) // must appear at the top of the crate fn main() { } //~ NOTE here is a function named 'main' -} \ No newline at end of file +} diff --git a/src/test/compile-fail/map-types.rs b/src/test/compile-fail/map-types.rs index f6fd8e29a4f4d..8b29d165b603c 100644 --- a/src/test/compile-fail/map-types.rs +++ b/src/test/compile-fail/map-types.rs @@ -17,5 +17,5 @@ fn main() { let x: @Map<~str, ~str> = @HashMap::new::<~str, ~str>() as @Map<~str, ~str>; let y: @Map = @x; - //~^ ERROR expected trait std::container::Map but found @-ptr + //~^ ERROR expected trait std::container::Map, found @-ptr } diff --git a/src/test/compile-fail/match-struct.rs b/src/test/compile-fail/match-struct.rs index 6e9bf603aef9e..2b75fc6410e86 100644 --- a/src/test/compile-fail/match-struct.rs +++ b/src/test/compile-fail/match-struct.rs @@ -4,7 +4,7 @@ enum E { C(int) } fn main() { match S { a: 1 } { - C(_) => (), //~ ERROR mismatched types: expected `S` but found `E` + C(_) => (), //~ ERROR mismatched types: expected `S`, found `E` _ => () } } diff --git a/src/test/compile-fail/match-vec-mismatch-2.rs b/src/test/compile-fail/match-vec-mismatch-2.rs index 6ea0300cf1e7d..f2c61898b385b 100644 --- a/src/test/compile-fail/match-vec-mismatch-2.rs +++ b/src/test/compile-fail/match-vec-mismatch-2.rs @@ -1,5 +1,5 @@ fn main() { match () { - [()] => { } //~ ERROR mismatched types: expected `()` but found a vector pattern + [()] => { } //~ ERROR mismatched types: expected `()`, found a vector pattern } } diff --git a/src/test/compile-fail/match-vec-mismatch.rs b/src/test/compile-fail/match-vec-mismatch.rs index 85ed8761ee935..ffc2e0b31ee48 100644 --- a/src/test/compile-fail/match-vec-mismatch.rs +++ b/src/test/compile-fail/match-vec-mismatch.rs @@ -1,6 +1,6 @@ fn main() { match ~"foo" { - ['f', 'o', .._] => { } //~ ERROR mismatched types: expected `~str` but found a vector pattern + ['f', 'o', .._] => { } //~ ERROR mismatched types: expected `~str`, found a vector pattern _ => { } } } diff --git a/src/test/compile-fail/multitrait.rs b/src/test/compile-fail/multitrait.rs index b49ee5aab47e6..2ad07dcbb069c 100644 --- a/src/test/compile-fail/multitrait.rs +++ b/src/test/compile-fail/multitrait.rs @@ -12,7 +12,7 @@ struct S { y: int } -impl Cmp, ToStr for S { //~ ERROR: expected `{` but found `,` +impl Cmp, ToStr for S { //~ ERROR: expected `{`, found `,` fn eq(&&other: S) { false } fn to_str(&self) -> ~str { ~"hi" } } diff --git a/src/test/compile-fail/noexporttypeexe.rs b/src/test/compile-fail/noexporttypeexe.rs index 3add0134d002a..e622122306f82 100644 --- a/src/test/compile-fail/noexporttypeexe.rs +++ b/src/test/compile-fail/noexporttypeexe.rs @@ -18,5 +18,5 @@ fn main() { // because the def_id associated with the type was // not convertible to a path. let x: int = noexporttypelib::foo(); - //~^ ERROR expected `int` but found `std::option::Option` + //~^ ERROR expected `int`, found `std::option::Option` } diff --git a/src/test/compile-fail/non-constant-expr-for-vec-repeat.rs b/src/test/compile-fail/non-constant-expr-for-vec-repeat.rs index 2727db9d0422e..25d2bd2982fb3 100644 --- a/src/test/compile-fail/non-constant-expr-for-vec-repeat.rs +++ b/src/test/compile-fail/non-constant-expr-for-vec-repeat.rs @@ -12,6 +12,6 @@ fn main() { fn bar(n: int) { - let _x = [0, ..n]; //~ ERROR expected constant integer for repeat count but found variable + let _x = [0, ..n]; //~ ERROR expected constant integer for repeat count, found variable } } diff --git a/src/test/compile-fail/omitted-arg-in-item-fn.rs b/src/test/compile-fail/omitted-arg-in-item-fn.rs index fcbfb115af756..c5ff885997b72 100644 --- a/src/test/compile-fail/omitted-arg-in-item-fn.rs +++ b/src/test/compile-fail/omitted-arg-in-item-fn.rs @@ -8,5 +8,5 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn foo(x) { //~ ERROR expected `:` but found `)` +fn foo(x) { //~ ERROR expected `:`, found `)` } diff --git a/src/test/compile-fail/omitted-arg-wrong-types.rs b/src/test/compile-fail/omitted-arg-wrong-types.rs index a44c113269b98..92052aaff5781 100644 --- a/src/test/compile-fail/omitted-arg-wrong-types.rs +++ b/src/test/compile-fail/omitted-arg-wrong-types.rs @@ -13,8 +13,8 @@ fn let_in(x: T, f: &fn(T)) {} fn main() { let_in(3u, |i| { assert!(i == 3); }); - //~^ ERROR expected `uint` but found `int` + //~^ ERROR expected `uint`, found `int` let_in(3, |i| { assert!(i == 3u); }); - //~^ ERROR expected `int` but found `uint` + //~^ ERROR expected `int`, found `uint` } diff --git a/src/test/compile-fail/pattern-error-continue.rs b/src/test/compile-fail/pattern-error-continue.rs index 14d8b04ade4eb..79fcc8468166e 100644 --- a/src/test/compile-fail/pattern-error-continue.rs +++ b/src/test/compile-fail/pattern-error-continue.rs @@ -29,8 +29,8 @@ fn main() { _ => () } match 'c' { - S { _ } => (), //~ ERROR mismatched types: expected `char` but found struct + S { _ } => (), //~ ERROR mismatched types: expected `char`, found struct _ => () } - f(true); //~ ERROR mismatched types: expected `char` but found `bool` -} \ No newline at end of file + f(true); //~ ERROR mismatched types: expected `char`, found `bool` +} diff --git a/src/test/compile-fail/regions-bounds.rs b/src/test/compile-fail/regions-bounds.rs index ab2ac6cc0e5b9..ebc19c6eaf772 100644 --- a/src/test/compile-fail/regions-bounds.rs +++ b/src/test/compile-fail/regions-bounds.rs @@ -16,12 +16,12 @@ struct an_enum<'self>(&'self int); struct a_class<'self> { x:&'self int } fn a_fn1<'a,'b>(e: an_enum<'a>) -> an_enum<'b> { - return e; //~ ERROR mismatched types: expected `an_enum<'b>` but found `an_enum<'a>` + return e; //~ ERROR mismatched types: expected `an_enum<'b>`, found `an_enum<'a>` //~^ ERROR cannot infer an appropriate lifetime } fn a_fn3<'a,'b>(e: a_class<'a>) -> a_class<'b> { - return e; //~ ERROR mismatched types: expected `a_class<'b>` but found `a_class<'a>` + return e; //~ ERROR mismatched types: expected `a_class<'b>`, found `a_class<'a>` //~^ ERROR cannot infer an appropriate lifetime } diff --git a/src/test/compile-fail/regions-free-region-ordering-callee.rs b/src/test/compile-fail/regions-free-region-ordering-callee.rs index e5399fc7fa3b9..66ab4b7705433 100644 --- a/src/test/compile-fail/regions-free-region-ordering-callee.rs +++ b/src/test/compile-fail/regions-free-region-ordering-callee.rs @@ -34,4 +34,4 @@ fn ordering4<'a, 'b>(a: &'a uint, b: &'b uint, x: &fn(&'a &'b uint)) { let z: Option<&'a &'b uint> = None; } -fn main() {} \ No newline at end of file +fn main() {} diff --git a/src/test/compile-fail/regions-free-region-ordering-caller.rs b/src/test/compile-fail/regions-free-region-ordering-caller.rs index d06dcd8aa86b8..c9859899ea4f1 100644 --- a/src/test/compile-fail/regions-free-region-ordering-caller.rs +++ b/src/test/compile-fail/regions-free-region-ordering-caller.rs @@ -37,4 +37,4 @@ fn call4<'a, 'b>(a: &'a uint, b: &'b uint) { } -fn main() {} \ No newline at end of file +fn main() {} diff --git a/src/test/compile-fail/regions-infer-paramd-indirect.rs b/src/test/compile-fail/regions-infer-paramd-indirect.rs index 0b4aa44010bdc..97f551ca0c2ae 100644 --- a/src/test/compile-fail/regions-infer-paramd-indirect.rs +++ b/src/test/compile-fail/regions-infer-paramd-indirect.rs @@ -29,7 +29,7 @@ impl<'self> set_f<'self> for c<'self> { } fn set_f_bad(&self, b: @b) { - self.f = b; //~ ERROR mismatched types: expected `@@&'self int` but found `@@&int` + self.f = b; //~ ERROR mismatched types: expected `@@&'self int`, found `@@&int` //~^ ERROR cannot infer an appropriate lifetime } } diff --git a/src/test/compile-fail/regions-infer-paramd-method.rs b/src/test/compile-fail/regions-infer-paramd-method.rs index 8c3195f020a97..68bd2304b2ad0 100644 --- a/src/test/compile-fail/regions-infer-paramd-method.rs +++ b/src/test/compile-fail/regions-infer-paramd-method.rs @@ -30,7 +30,7 @@ trait set_foo_foo { impl<'self> set_foo_foo for with_foo<'self> { fn set_foo(&mut self, f: @foo) { - self.f = f; //~ ERROR mismatched types: expected `@foo/&self` but found `@foo/&` + self.f = f; //~ ERROR mismatched types: expected `@foo/&self`, found `@foo/&` } } diff --git a/src/test/compile-fail/regions-ref-in-fn-arg.rs b/src/test/compile-fail/regions-ref-in-fn-arg.rs index f90fe924587df..4848262750720 100644 --- a/src/test/compile-fail/regions-ref-in-fn-arg.rs +++ b/src/test/compile-fail/regions-ref-in-fn-arg.rs @@ -8,4 +8,4 @@ fn arg_closure() -> &'static int { with(|~ref x| x) //~ ERROR borrowed value does not live long enough } -fn main() {} \ No newline at end of file +fn main() {} diff --git a/src/test/compile-fail/regions-trait-3.rs b/src/test/compile-fail/regions-trait-3.rs index 072b0e83fdf58..a3f2a28d643f7 100644 --- a/src/test/compile-fail/regions-trait-3.rs +++ b/src/test/compile-fail/regions-trait-3.rs @@ -16,7 +16,7 @@ trait get_ctxt<'self> { } fn make_gc1(gc: @get_ctxt<'a>) -> @get_ctxt<'b> { - return gc; //~ ERROR mismatched types: expected `@get_ctxt/&b` but found `@get_ctxt/&a` + return gc; //~ ERROR mismatched types: expected `@get_ctxt/&b`, found `@get_ctxt/&a` } struct Foo { diff --git a/src/test/compile-fail/repeat_count.rs b/src/test/compile-fail/repeat_count.rs index 579575e2008f8..dd0fd7e221dc8 100644 --- a/src/test/compile-fail/repeat_count.rs +++ b/src/test/compile-fail/repeat_count.rs @@ -12,5 +12,5 @@ fn main() { let n = 1; - let a = ~[0, ..n]; //~ ERROR expected constant integer for repeat count but found variable + let a = ~[0, ..n]; //~ ERROR expected constant integer for repeat count, found variable } diff --git a/src/test/compile-fail/struct-base-wrong-type.rs b/src/test/compile-fail/struct-base-wrong-type.rs index adda356298d9f..af6fc64535149 100644 --- a/src/test/compile-fail/struct-base-wrong-type.rs +++ b/src/test/compile-fail/struct-base-wrong-type.rs @@ -12,11 +12,11 @@ struct Foo { a: int, b: int } struct Bar { x: int } static bar: Bar = Bar { x: 5 }; -static foo: Foo = Foo { a: 2, ..bar }; //~ ERROR mismatched types: expected `Foo` but found `Bar` +static foo: Foo = Foo { a: 2, ..bar }; //~ ERROR mismatched types: expected `Foo`, found `Bar` static foo_i: Foo = Foo { a: 2, ..4 }; //~ ERROR mismatched types: expected `Foo` fn main() { let b = Bar { x: 5 }; - let f = Foo { a: 2, ..b }; //~ ERROR mismatched types: expected `Foo` but found `Bar` + let f = Foo { a: 2, ..b }; //~ ERROR mismatched types: expected `Foo`, found `Bar` let f_i = Foo { a: 2, ..4 }; //~ ERROR mismatched types: expected `Foo` } diff --git a/src/test/compile-fail/suppressed-error.rs b/src/test/compile-fail/suppressed-error.rs index b4a72548cfc0d..f13aabe52594a 100644 --- a/src/test/compile-fail/suppressed-error.rs +++ b/src/test/compile-fail/suppressed-error.rs @@ -9,6 +9,6 @@ // except according to those terms. fn main() { - let (x, y) = (); //~ ERROR expected `()` but found tuple (types differ) + let (x, y) = (); //~ ERROR expected `()`, found tuple (types differ) return x; -} \ No newline at end of file +} diff --git a/src/test/compile-fail/tag-that-dare-not-speak-its-name.rs b/src/test/compile-fail/tag-that-dare-not-speak-its-name.rs index ebd3320d90126..478b4a4081ff6 100644 --- a/src/test/compile-fail/tag-that-dare-not-speak-its-name.rs +++ b/src/test/compile-fail/tag-that-dare-not-speak-its-name.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern:mismatched types: expected `char` but found +// error-pattern:mismatched types: expected `char`, found // Issue #876 #[no_std]; diff --git a/src/test/compile-fail/tag-variant-disr-dup.rs b/src/test/compile-fail/tag-variant-disr-dup.rs index 216779fac7c46..a5f85a685e695 100644 --- a/src/test/compile-fail/tag-variant-disr-dup.rs +++ b/src/test/compile-fail/tag-variant-disr-dup.rs @@ -20,4 +20,4 @@ enum color { white = 0x000000, } -fn main() { } \ No newline at end of file +fn main() { } diff --git a/src/test/compile-fail/terr-in-field.rs b/src/test/compile-fail/terr-in-field.rs index 6474a58c1cdb9..88da7bc854201 100644 --- a/src/test/compile-fail/terr-in-field.rs +++ b/src/test/compile-fail/terr-in-field.rs @@ -20,7 +20,7 @@ struct bar { fn want_foo(f: foo) {} fn have_bar(b: bar) { - want_foo(b); //~ ERROR (expected struct foo but found struct bar) + want_foo(b); //~ ERROR (expected struct foo, found struct bar) } fn main() {} diff --git a/src/test/compile-fail/terr-sorts.rs b/src/test/compile-fail/terr-sorts.rs index ad14688f08c62..462bb0a3962c7 100644 --- a/src/test/compile-fail/terr-sorts.rs +++ b/src/test/compile-fail/terr-sorts.rs @@ -17,7 +17,7 @@ type bar = @foo; fn want_foo(f: foo) {} fn have_bar(b: bar) { - want_foo(b); //~ ERROR (expected struct foo but found @-ptr) + want_foo(b); //~ ERROR (expected struct foo, found @-ptr) } fn main() {} diff --git a/src/test/compile-fail/trait-impl-method-mismatch.rs b/src/test/compile-fail/trait-impl-method-mismatch.rs index 54fa62f797766..e23c74880379c 100644 --- a/src/test/compile-fail/trait-impl-method-mismatch.rs +++ b/src/test/compile-fail/trait-impl-method-mismatch.rs @@ -15,7 +15,7 @@ trait Mumbo { impl Mumbo for uint { // Cannot have a larger effect than the trait: unsafe fn jumbo(&self, x: @uint) { *self + *x; } - //~^ ERROR expected impure fn but found unsafe fn + //~^ ERROR expected impure fn, found unsafe fn } fn main() {} diff --git a/src/test/compile-fail/tuple-arity-mismatch.rs b/src/test/compile-fail/tuple-arity-mismatch.rs index 517b3cb59232e..2ca8f3bcce261 100644 --- a/src/test/compile-fail/tuple-arity-mismatch.rs +++ b/src/test/compile-fail/tuple-arity-mismatch.rs @@ -13,5 +13,5 @@ fn first((value, _): (int, float)) -> int { value } fn main() { - let y = first ((1,2,3)); //~ ERROR expected a tuple with 2 elements but found one with 3 elements + let y = first ((1,2,3)); //~ ERROR expected a tuple with 2 elements, found one with 3 elements } diff --git a/src/test/compile-fail/tutorial-suffix-inference-test.rs b/src/test/compile-fail/tutorial-suffix-inference-test.rs index d92aa8d640ab5..c1be54b3f75e1 100644 --- a/src/test/compile-fail/tutorial-suffix-inference-test.rs +++ b/src/test/compile-fail/tutorial-suffix-inference-test.rs @@ -17,9 +17,9 @@ fn main() { identity_u8(x); // after this, `x` is assumed to have type `u8` identity_u16(x); - //~^ ERROR mismatched types: expected `u16` but found `u8` + //~^ ERROR mismatched types: expected `u16`, found `u8` identity_u16(y); - //~^ ERROR mismatched types: expected `u16` but found `i32` + //~^ ERROR mismatched types: expected `u16`, found `i32` let a = 3i; @@ -27,6 +27,6 @@ fn main() { identity_i(a); // ok identity_u16(a); - //~^ ERROR mismatched types: expected `u16` but found `int` + //~^ ERROR mismatched types: expected `u16`, found `int` } diff --git a/src/test/compile-fail/type-parameter-names.rs b/src/test/compile-fail/type-parameter-names.rs index 6af3166a2ff4e..c076e6b5c813f 100644 --- a/src/test/compile-fail/type-parameter-names.rs +++ b/src/test/compile-fail/type-parameter-names.rs @@ -1,6 +1,6 @@ // Test that we print out the names of type parameters correctly in // our error messages. -fn foo(x: Foo) -> Bar { x } //~ ERROR expected `Bar` but found `Foo` +fn foo(x: Foo) -> Bar { x } //~ ERROR expected `Bar`, found `Foo` -fn main() {} \ No newline at end of file +fn main() {} diff --git a/src/test/compile-fail/useless-priv.rs b/src/test/compile-fail/useless-priv.rs new file mode 100644 index 0000000000000..3d6841c919a4d --- /dev/null +++ b/src/test/compile-fail/useless-priv.rs @@ -0,0 +1,25 @@ +// Copyright 2013 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +struct A { pub i: int } //~ ERROR: unnecessary `pub` +struct B { priv i: int } // don't warn b/c B can still be returned +pub enum C { pub Variant } //~ ERROR: unnecessary `pub` +enum D { priv Variant2 } //~ ERROR: unnecessary `priv` + +pub trait E { + pub fn foo() {} //~ ERROR: unnecessary visibility +} +trait F { pub fn foo() {} } //~ ERROR: unnecessary visibility + +impl E for A { + pub fn foo() {} //~ ERROR: unnecessary visibility +} + +fn main() {} diff --git a/src/test/compile-fail/useless-priv2.rs b/src/test/compile-fail/useless-priv2.rs new file mode 100644 index 0000000000000..0d94300329c2d --- /dev/null +++ b/src/test/compile-fail/useless-priv2.rs @@ -0,0 +1,19 @@ +// Copyright 2013 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub trait E { + pub fn foo(); //~ ERROR: obsolete syntax +} +trait F { pub fn foo(); } //~ ERROR: obsolete syntax + +struct B; +impl E for B { + priv fn foo() {} //~ ERROR: obsolete syntax +} diff --git a/src/test/debug-info/borrowed-basic.rs b/src/test/debug-info/borrowed-basic.rs index 7610301f6f035..2ddf309b16916 100644 --- a/src/test/debug-info/borrowed-basic.rs +++ b/src/test/debug-info/borrowed-basic.rs @@ -110,4 +110,4 @@ fn main() { zzz(); } -fn zzz() {()} \ No newline at end of file +fn zzz() {()} diff --git a/src/test/debug-info/borrowed-c-style-enum.rs b/src/test/debug-info/borrowed-c-style-enum.rs index 70c85258c7921..14771396bd1ae 100644 --- a/src/test/debug-info/borrowed-c-style-enum.rs +++ b/src/test/debug-info/borrowed-c-style-enum.rs @@ -39,4 +39,4 @@ fn main() { zzz(); } -fn zzz() {()} \ No newline at end of file +fn zzz() {()} diff --git a/src/test/debug-info/borrowed-enum.rs b/src/test/debug-info/borrowed-enum.rs index 38aa9c3881000..7c8a6814dcb44 100644 --- a/src/test/debug-info/borrowed-enum.rs +++ b/src/test/debug-info/borrowed-enum.rs @@ -59,4 +59,4 @@ fn main() { zzz(); } -fn zzz() {()} \ No newline at end of file +fn zzz() {()} diff --git a/src/test/debug-info/borrowed-managed-basic.rs b/src/test/debug-info/borrowed-managed-basic.rs index 9087bb36fa5d6..7403ead3fcedd 100644 --- a/src/test/debug-info/borrowed-managed-basic.rs +++ b/src/test/debug-info/borrowed-managed-basic.rs @@ -111,4 +111,4 @@ fn main() { zzz(); } -fn zzz() {()} \ No newline at end of file +fn zzz() {()} diff --git a/src/test/debug-info/borrowed-struct.rs b/src/test/debug-info/borrowed-struct.rs index 8b6eca3e37f79..571333a8a3bc7 100644 --- a/src/test/debug-info/borrowed-struct.rs +++ b/src/test/debug-info/borrowed-struct.rs @@ -72,4 +72,4 @@ fn main() { zzz(); } -fn zzz() {()} \ No newline at end of file +fn zzz() {()} diff --git a/src/test/debug-info/borrowed-tuple.rs b/src/test/debug-info/borrowed-tuple.rs index da199941c8419..dbbf7d537aa54 100644 --- a/src/test/debug-info/borrowed-tuple.rs +++ b/src/test/debug-info/borrowed-tuple.rs @@ -41,4 +41,4 @@ fn main() { zzz(); } -fn zzz() {()} \ No newline at end of file +fn zzz() {()} diff --git a/src/test/debug-info/borrowed-unique-basic.rs b/src/test/debug-info/borrowed-unique-basic.rs index 52f5a2cba1ebe..893be617ac235 100644 --- a/src/test/debug-info/borrowed-unique-basic.rs +++ b/src/test/debug-info/borrowed-unique-basic.rs @@ -111,4 +111,4 @@ fn main() { zzz(); } -fn zzz() {()} \ No newline at end of file +fn zzz() {()} diff --git a/src/test/debug-info/boxed-struct.rs b/src/test/debug-info/boxed-struct.rs index 86162f0fa04cd..08f56154b62b8 100644 --- a/src/test/debug-info/boxed-struct.rs +++ b/src/test/debug-info/boxed-struct.rs @@ -56,4 +56,4 @@ fn main() { zzz(); } -fn zzz() {()} \ No newline at end of file +fn zzz() {()} diff --git a/src/test/debug-info/boxed-vec.rs b/src/test/debug-info/boxed-vec.rs index 8abead6519697..b6c6ce49ddaf4 100644 --- a/src/test/debug-info/boxed-vec.rs +++ b/src/test/debug-info/boxed-vec.rs @@ -33,4 +33,4 @@ fn main() { zzz(); } -fn zzz() {()} \ No newline at end of file +fn zzz() {()} diff --git a/src/test/debug-info/c-style-enum-in-composite.rs b/src/test/debug-info/c-style-enum-in-composite.rs index 47e433ea814ab..5a78666423a04 100644 --- a/src/test/debug-info/c-style-enum-in-composite.rs +++ b/src/test/debug-info/c-style-enum-in-composite.rs @@ -116,4 +116,4 @@ fn main() { zzz(); } -fn zzz() {()} \ No newline at end of file +fn zzz() {()} diff --git a/src/test/debug-info/c-style-enum.rs b/src/test/debug-info/c-style-enum.rs index d7cce4e6f3fb5..56c042f9e05fb 100644 --- a/src/test/debug-info/c-style-enum.rs +++ b/src/test/debug-info/c-style-enum.rs @@ -67,4 +67,4 @@ fn main() { zzz(); } -fn zzz() {()} \ No newline at end of file +fn zzz() {()} diff --git a/src/test/debug-info/destructured-fn-argument.rs b/src/test/debug-info/destructured-fn-argument.rs index 05718ab48909f..a3d53fb9efea2 100644 --- a/src/test/debug-info/destructured-fn-argument.rs +++ b/src/test/debug-info/destructured-fn-argument.rs @@ -315,4 +315,4 @@ fn main() { } -fn zzz() {()} \ No newline at end of file +fn zzz() {()} diff --git a/src/test/debug-info/destructured-local.rs b/src/test/debug-info/destructured-local.rs index f8db7981c941b..10d08ad66ba94 100644 --- a/src/test/debug-info/destructured-local.rs +++ b/src/test/debug-info/destructured-local.rs @@ -206,4 +206,4 @@ fn main() { zzz(); } -fn zzz() {()} \ No newline at end of file +fn zzz() {()} diff --git a/src/test/debug-info/evec-in-struct.rs b/src/test/debug-info/evec-in-struct.rs index 7e42690548e70..b23f3174705a9 100644 --- a/src/test/debug-info/evec-in-struct.rs +++ b/src/test/debug-info/evec-in-struct.rs @@ -85,4 +85,4 @@ fn main() { zzz(); } -fn zzz() {()} \ No newline at end of file +fn zzz() {()} diff --git a/src/test/debug-info/function-arguments.rs b/src/test/debug-info/function-arguments.rs index 1fe79b8e2a9e9..fba0a9b2dd2d1 100644 --- a/src/test/debug-info/function-arguments.rs +++ b/src/test/debug-info/function-arguments.rs @@ -45,4 +45,4 @@ fn fun(x: int, y: bool) -> (int, bool) { (x, y) } -fn zzz() {()} \ No newline at end of file +fn zzz() {()} diff --git a/src/test/debug-info/managed-enum.rs b/src/test/debug-info/managed-enum.rs index 1a3600a7d8cb3..ab77d7180bae1 100644 --- a/src/test/debug-info/managed-enum.rs +++ b/src/test/debug-info/managed-enum.rs @@ -60,4 +60,4 @@ fn main() { zzz(); } -fn zzz() {()} \ No newline at end of file +fn zzz() {()} diff --git a/src/test/debug-info/managed-pointer-within-unique-vec.rs b/src/test/debug-info/managed-pointer-within-unique-vec.rs index e42631599a9b9..facde86a305cc 100644 --- a/src/test/debug-info/managed-pointer-within-unique-vec.rs +++ b/src/test/debug-info/managed-pointer-within-unique-vec.rs @@ -34,4 +34,4 @@ fn main() { zzz(); } -fn zzz() {()} \ No newline at end of file +fn zzz() {()} diff --git a/src/test/debug-info/managed-pointer-within-unique.rs b/src/test/debug-info/managed-pointer-within-unique.rs index 3eb1c2ef01e55..9ea7b86f71141 100644 --- a/src/test/debug-info/managed-pointer-within-unique.rs +++ b/src/test/debug-info/managed-pointer-within-unique.rs @@ -44,4 +44,4 @@ fn main() { zzz(); } -fn zzz() {()} \ No newline at end of file +fn zzz() {()} diff --git a/src/test/debug-info/nil-enum.rs b/src/test/debug-info/nil-enum.rs index d3afd4b11f9cd..55ed84cd8f2ef 100644 --- a/src/test/debug-info/nil-enum.rs +++ b/src/test/debug-info/nil-enum.rs @@ -37,4 +37,4 @@ fn main() { } } -fn zzz() {()} \ No newline at end of file +fn zzz() {()} diff --git a/src/test/debug-info/option-like-enum.rs b/src/test/debug-info/option-like-enum.rs index 3bf3507faba77..3957d0b2a9873 100644 --- a/src/test/debug-info/option-like-enum.rs +++ b/src/test/debug-info/option-like-enum.rs @@ -69,4 +69,4 @@ fn main() { zzz(); } -fn zzz() {()} \ No newline at end of file +fn zzz() {()} diff --git a/src/test/debug-info/packed-struct-with-destructor.rs b/src/test/debug-info/packed-struct-with-destructor.rs index 9ff91aa00d1c9..cd2f9af26ca27 100644 --- a/src/test/debug-info/packed-struct-with-destructor.rs +++ b/src/test/debug-info/packed-struct-with-destructor.rs @@ -216,4 +216,4 @@ fn main() { zzz(); } -fn zzz() {()} \ No newline at end of file +fn zzz() {()} diff --git a/src/test/debug-info/packed-struct.rs b/src/test/debug-info/packed-struct.rs index 859166cb023a3..ef4d07fdb4322 100644 --- a/src/test/debug-info/packed-struct.rs +++ b/src/test/debug-info/packed-struct.rs @@ -101,4 +101,4 @@ fn main() { zzz(); } -fn zzz() {()} \ No newline at end of file +fn zzz() {()} diff --git a/src/test/debug-info/simple-struct.rs b/src/test/debug-info/simple-struct.rs index 49e7bc255c10f..7346c86fadb6e 100644 --- a/src/test/debug-info/simple-struct.rs +++ b/src/test/debug-info/simple-struct.rs @@ -81,4 +81,4 @@ fn main() { zzz(); } -fn zzz() {()} \ No newline at end of file +fn zzz() {()} diff --git a/src/test/debug-info/simple-tuple.rs b/src/test/debug-info/simple-tuple.rs index f45294221af16..f86959b7ca1eb 100644 --- a/src/test/debug-info/simple-tuple.rs +++ b/src/test/debug-info/simple-tuple.rs @@ -48,4 +48,4 @@ fn main() { zzz(); } -fn zzz() {()} \ No newline at end of file +fn zzz() {()} diff --git a/src/test/debug-info/struct-in-struct.rs b/src/test/debug-info/struct-in-struct.rs index 04c5eec610b73..60ac4bcea6087 100644 --- a/src/test/debug-info/struct-in-struct.rs +++ b/src/test/debug-info/struct-in-struct.rs @@ -142,4 +142,4 @@ fn main() { zzz(); } -fn zzz() {()} \ No newline at end of file +fn zzz() {()} diff --git a/src/test/debug-info/struct-style-enum.rs b/src/test/debug-info/struct-style-enum.rs index 61bbd2e215ff6..77d7746e2df86 100644 --- a/src/test/debug-info/struct-style-enum.rs +++ b/src/test/debug-info/struct-style-enum.rs @@ -70,4 +70,4 @@ fn main() { zzz(); } -fn zzz() {()} \ No newline at end of file +fn zzz() {()} diff --git a/src/test/debug-info/tuple-in-struct.rs b/src/test/debug-info/tuple-in-struct.rs index 369c9fd28ccdf..863cb57bd235a 100644 --- a/src/test/debug-info/tuple-in-struct.rs +++ b/src/test/debug-info/tuple-in-struct.rs @@ -148,4 +148,4 @@ fn main() { zzz(); } -fn zzz() {()} \ No newline at end of file +fn zzz() {()} diff --git a/src/test/debug-info/tuple-in-tuple.rs b/src/test/debug-info/tuple-in-tuple.rs index 9c6805dae67d3..ae77d4723f1ad 100644 --- a/src/test/debug-info/tuple-in-tuple.rs +++ b/src/test/debug-info/tuple-in-tuple.rs @@ -47,4 +47,4 @@ fn main() { zzz(); } -fn zzz() {()} \ No newline at end of file +fn zzz() {()} diff --git a/src/test/debug-info/tuple-style-enum.rs b/src/test/debug-info/tuple-style-enum.rs index ba1d02bb62a3c..dd52ee22766d4 100644 --- a/src/test/debug-info/tuple-style-enum.rs +++ b/src/test/debug-info/tuple-style-enum.rs @@ -70,4 +70,4 @@ fn main() { zzz(); } -fn zzz() {()} \ No newline at end of file +fn zzz() {()} diff --git a/src/test/debug-info/unique-enum.rs b/src/test/debug-info/unique-enum.rs index 443f641a85859..101b51632d9b6 100644 --- a/src/test/debug-info/unique-enum.rs +++ b/src/test/debug-info/unique-enum.rs @@ -60,4 +60,4 @@ fn main() { zzz(); } -fn zzz() {()} \ No newline at end of file +fn zzz() {()} diff --git a/src/test/run-pass/borrowck-scope-of-deref-issue-4666.rs b/src/test/run-pass/borrowck-scope-of-deref-issue-4666.rs index 59e82a038bc79..0e7572220a8b4 100644 --- a/src/test/run-pass/borrowck-scope-of-deref-issue-4666.rs +++ b/src/test/run-pass/borrowck-scope-of-deref-issue-4666.rs @@ -47,4 +47,4 @@ fn fun2() { pub fn main() { fun1(); fun2(); -} \ No newline at end of file +} diff --git a/src/test/run-pass/bug-7295.rs b/src/test/run-pass/bug-7295.rs index 2a1a0e35c56ed..ea711d78dd28e 100644 --- a/src/test/run-pass/bug-7295.rs +++ b/src/test/run-pass/bug-7295.rs @@ -9,9 +9,9 @@ // except according to those terms. pub trait Foo { - pub fn func1(&self, t: U); + fn func1(&self, t: U); - pub fn func2(&self, t: U) { + fn func2(&self, t: U) { self.func1(t); } } diff --git a/src/test/run-pass/cast-mutable-trait.rs b/src/test/run-pass/cast-mutable-trait.rs index 633188b9a623b..84827a7a82042 100644 --- a/src/test/run-pass/cast-mutable-trait.rs +++ b/src/test/run-pass/cast-mutable-trait.rs @@ -31,4 +31,4 @@ fn main() { s2.foo(); bar(s2); bar(s as @mut T); -} \ No newline at end of file +} diff --git a/src/test/run-pass/conditional-debug-macro-off.rs b/src/test/run-pass/conditional-debug-macro-off.rs index f40c8112e0bba..decd310c9a7e1 100644 --- a/src/test/run-pass/conditional-debug-macro-off.rs +++ b/src/test/run-pass/conditional-debug-macro-off.rs @@ -14,4 +14,4 @@ fn main() { // only fails if debug! evaluates its argument. debug!({ if true { fail!() } }); -} \ No newline at end of file +} diff --git a/src/test/run-pass/conditional-debug-macro-on.rs b/src/test/run-pass/conditional-debug-macro-on.rs index 65b751a58264d..a0da137369c1b 100644 --- a/src/test/run-pass/conditional-debug-macro-on.rs +++ b/src/test/run-pass/conditional-debug-macro-on.rs @@ -18,4 +18,4 @@ fn main() { debug!({ if true { return; } }); fail!(); -} \ No newline at end of file +} diff --git a/src/test/run-pass/deriving-cmp-generic-struct-enum.rs b/src/test/run-pass/deriving-cmp-generic-struct-enum.rs index 6f6e8d79d8b92..3d53ec97491a1 100644 --- a/src/test/run-pass/deriving-cmp-generic-struct-enum.rs +++ b/src/test/run-pass/deriving-cmp-generic-struct-enum.rs @@ -49,4 +49,4 @@ pub fn main() { assert_eq!(es1.cmp(es2), ord); } } -} \ No newline at end of file +} diff --git a/src/test/run-pass/deriving-via-extension-struct-empty.rs b/src/test/run-pass/deriving-via-extension-struct-empty.rs index 8f6a319798626..74698b9db28bc 100644 --- a/src/test/run-pass/deriving-via-extension-struct-empty.rs +++ b/src/test/run-pass/deriving-via-extension-struct-empty.rs @@ -14,4 +14,4 @@ struct Foo; pub fn main() { assert_eq!(Foo, Foo); assert!(!(Foo != Foo)); -} \ No newline at end of file +} diff --git a/src/test/run-pass/enum-vec-initializer.rs b/src/test/run-pass/enum-vec-initializer.rs index ae590ad7d1f71..11893bbf657ec 100644 --- a/src/test/run-pass/enum-vec-initializer.rs +++ b/src/test/run-pass/enum-vec-initializer.rs @@ -21,4 +21,4 @@ fn main() { let v = [0, .. BAR2]; static BAR3:uint = BAR2; let v = [0, .. BAR3]; -} \ No newline at end of file +} diff --git a/src/test/run-pass/foreach-external-iterators-hashmap-break-restart.rs b/src/test/run-pass/foreach-external-iterators-hashmap-break-restart.rs index 17c5bb5c0e253..cb438aa0b2085 100644 --- a/src/test/run-pass/foreach-external-iterators-hashmap-break-restart.rs +++ b/src/test/run-pass/foreach-external-iterators-hashmap-break-restart.rs @@ -38,4 +38,4 @@ fn main() { assert_eq!(x, 6); assert_eq!(y, 60); -} \ No newline at end of file +} diff --git a/src/test/run-pass/foreach-external-iterators-hashmap.rs b/src/test/run-pass/foreach-external-iterators-hashmap.rs index 908adc0d7620d..9a5c2fa86fadb 100644 --- a/src/test/run-pass/foreach-external-iterators-hashmap.rs +++ b/src/test/run-pass/foreach-external-iterators-hashmap.rs @@ -24,4 +24,4 @@ fn main() { } assert_eq!(x, 6); assert_eq!(y, 60); -} \ No newline at end of file +} diff --git a/src/test/run-pass/foreach-external-iterators.rs b/src/test/run-pass/foreach-external-iterators.rs index c6f903821dd0e..0933ac09243c9 100644 --- a/src/test/run-pass/foreach-external-iterators.rs +++ b/src/test/run-pass/foreach-external-iterators.rs @@ -15,4 +15,4 @@ fn main() { y += *i } assert!(y == 100); -} \ No newline at end of file +} diff --git a/src/test/run-pass/func-arg-incomplete-pattern.rs b/src/test/run-pass/func-arg-incomplete-pattern.rs index b08d3beae1bfa..6144e46593677 100644 --- a/src/test/run-pass/func-arg-incomplete-pattern.rs +++ b/src/test/run-pass/func-arg-incomplete-pattern.rs @@ -17,4 +17,4 @@ fn main() { let f = Foo {x: obj, y: ~2}; let xptr = foo(f); assert_eq!(objptr, xptr); -} \ No newline at end of file +} diff --git a/src/test/run-pass/issue-2804.rs b/src/test/run-pass/issue-2804.rs index aa9be2203c6b2..a2fc6392b75fd 100644 --- a/src/test/run-pass/issue-2804.rs +++ b/src/test/run-pass/issue-2804.rs @@ -47,7 +47,7 @@ fn add_interface(store: int, managed_ip: ~str, data: extra::json::Json) -> (~str (label, bool_value(false)) } _ => { - error!("Expected dict for %s interfaces but found %?", managed_ip, data); + error!("Expected dict for %s interfaces, found %?", managed_ip, data); (~"gnos:missing-interface", bool_value(true)) } } @@ -65,7 +65,7 @@ fn add_interfaces(store: int, managed_ip: ~str, device: HashMap<~str, extra::jso } _ => { - error!("Expected list for %s interfaces but found %?", managed_ip, + error!("Expected list for %s interfaces, found %?", managed_ip, device.get(&~"interfaces")); ~[] } diff --git a/src/test/run-pass/issue-4252.rs b/src/test/run-pass/issue-4252.rs index de1f630a245b8..ebbdf6cc230ac 100644 --- a/src/test/run-pass/issue-4252.rs +++ b/src/test/run-pass/issue-4252.rs @@ -34,4 +34,4 @@ impl Drop for Z { fn main() { let y = Y; let _z = Z{x: y}; -} \ No newline at end of file +} diff --git a/src/test/run-pass/issue-6141-leaking-owned-fn.rs b/src/test/run-pass/issue-6141-leaking-owned-fn.rs index fe11bb0a972ad..cd48eba0f2322 100644 --- a/src/test/run-pass/issue-6141-leaking-owned-fn.rs +++ b/src/test/run-pass/issue-6141-leaking-owned-fn.rs @@ -5,4 +5,4 @@ fn run(f: &fn()) { fn main() { let f: ~fn() = || (); run(f); -} \ No newline at end of file +} diff --git a/src/test/run-pass/issue-6341.rs b/src/test/run-pass/issue-6341.rs index 29fc074430584..dfead893392be 100644 --- a/src/test/run-pass/issue-6341.rs +++ b/src/test/run-pass/issue-6341.rs @@ -15,4 +15,4 @@ impl Drop for A { fn drop(&self) {} } -fn main() {} \ No newline at end of file +fn main() {} diff --git a/src/test/run-pass/issue-7712.rs b/src/test/run-pass/issue-7712.rs index 41c4af86bac95..1ea8312ddd927 100644 --- a/src/test/run-pass/issue-7712.rs +++ b/src/test/run-pass/issue-7712.rs @@ -11,7 +11,7 @@ // compile-flags:-Z debug-info pub trait TraitWithDefaultMethod { - pub fn method(self) { + fn method(self) { () } } diff --git a/src/test/run-pass/move-out-of-field.rs b/src/test/run-pass/move-out-of-field.rs index a3c2872803adc..04375052c3d6b 100644 --- a/src/test/run-pass/move-out-of-field.rs +++ b/src/test/run-pass/move-out-of-field.rs @@ -20,4 +20,4 @@ fn main() { sb.append("World!"); let str = to_str(sb); assert_eq!(str, ~"Hello, World!"); -} \ No newline at end of file +} diff --git a/src/test/run-pass/rt-start-main-thread.rs b/src/test/run-pass/rt-start-main-thread.rs index 8328e7416c579..2edf99e19430e 100644 --- a/src/test/run-pass/rt-start-main-thread.rs +++ b/src/test/run-pass/rt-start-main-thread.rs @@ -18,4 +18,4 @@ fn start(argc: int, argv: **u8, crate_map: *u8) -> int { info!("running on another thread"); } } -} \ No newline at end of file +} diff --git a/src/test/run-pass/static-methods-in-traits.rs b/src/test/run-pass/static-methods-in-traits.rs index 8cd7b78312bf2..180cd115c96e8 100644 --- a/src/test/run-pass/static-methods-in-traits.rs +++ b/src/test/run-pass/static-methods-in-traits.rs @@ -10,17 +10,17 @@ mod a { pub trait Foo { - pub fn foo() -> Self; + fn foo() -> Self; } impl Foo for int { - pub fn foo() -> int { + fn foo() -> int { 3 } } impl Foo for uint { - pub fn foo() -> uint { + fn foo() -> uint { 5u } } diff --git a/src/test/run-pass/unique-object-move.rs b/src/test/run-pass/unique-object-move.rs index 540de1652138b..e067fd49b1d13 100644 --- a/src/test/run-pass/unique-object-move.rs +++ b/src/test/run-pass/unique-object-move.rs @@ -21,4 +21,4 @@ impl EventLoop for UvEventLoop { } pub fn main() { let loop_: ~EventLoop = ~UvEventLoop { uvio: 0 } as ~EventLoop; let loop2_ = loop_; -} \ No newline at end of file +}