From 026c1ae3113a6333bace9058d2d38cb7bc1c9cc8 Mon Sep 17 00:00:00 2001 From: blake2-ppc Date: Wed, 7 Aug 2013 16:59:17 +0200 Subject: [PATCH 01/29] extra: Remove all .each methods in smallintmap --- src/libextra/smallintmap.rs | 43 ------------------------------------- 1 file changed, 43 deletions(-) diff --git a/src/libextra/smallintmap.rs b/src/libextra/smallintmap.rs index e5116f19afa..8103ed7a478 100644 --- a/src/libextra/smallintmap.rs +++ b/src/libextra/smallintmap.rs @@ -16,7 +16,6 @@ #[allow(missing_doc)]; use std::iterator::{Iterator, IteratorUtil, Enumerate, FilterMap, Invert}; -use std::uint; use std::util::replace; use std::vec::{VecIterator, VecMutIterator}; use std::vec; @@ -116,48 +115,6 @@ impl SmallIntMap { /// Create an empty SmallIntMap pub fn new() -> SmallIntMap { SmallIntMap{v: ~[]} } - /// Visit all key-value pairs in order - pub fn each<'a>(&'a self, it: &fn(&uint, &'a V) -> bool) -> bool { - for i in range(0u, self.v.len()) { - match self.v[i] { - Some(ref elt) => if !it(&i, elt) { return false; }, - None => () - } - } - true - } - - /// Visit all keys in order - pub fn each_key(&self, blk: &fn(key: &uint) -> bool) -> bool { - self.each(|k, _| blk(k)) - } - - /// Visit all values in order - pub fn each_value<'a>(&'a self, blk: &fn(value: &'a V) -> bool) -> bool { - self.each(|_, v| blk(v)) - } - - /// Iterate over the map and mutate the contained values - pub fn mutate_values(&mut self, it: &fn(&uint, &mut V) -> bool) -> bool { - for i in range(0, self.v.len()) { - match self.v[i] { - Some(ref mut elt) => if !it(&i, elt) { return false; }, - None => () - } - } - true - } - - /// Visit all key-value pairs in reverse order - pub fn each_reverse<'a>(&'a self, it: &fn(uint, &'a V) -> bool) -> bool { - do uint::range_rev(self.v.len(), 0) |i| { - match self.v[i] { - Some(ref elt) => it(i, elt), - None => true - } - } - } - pub fn get<'a>(&'a self, key: &uint) -> &'a V { self.find(key).expect("key not present") } From 40bdbf0f5d1e997891918a2bf8bec5fc61432f05 Mon Sep 17 00:00:00 2001 From: blake2-ppc Date: Wed, 7 Aug 2013 16:58:56 +0200 Subject: [PATCH 02/29] std: Fix for-range loops that can use iterators Fix inappropriate for-range loops to use for-iterator constructs (or other appropriate solution) instead. --- src/libextra/arc.rs | 14 ++++---------- src/libextra/bitv.rs | 17 +++++++++-------- src/libextra/smallintmap.rs | 14 ++++++-------- src/libextra/sort.rs | 10 ++-------- src/libstd/at_vec.rs | 6 +++--- src/libstd/hashmap.rs | 6 +++--- src/libstd/trie.rs | 4 ++-- src/libstd/vec.rs | 4 ++-- 8 files changed, 31 insertions(+), 44 deletions(-) diff --git a/src/libextra/arc.rs b/src/libextra/arc.rs index cb4468f48ec..ad950f198ce 100644 --- a/src/libextra/arc.rs +++ b/src/libextra/arc.rs @@ -846,22 +846,16 @@ mod tests { } assert_eq!(*state, 42); *state = 31337; - // FIXME: #7372: hits type inference bug with iterators // send to other readers - for i in range(0u, reader_convos.len()) { - match reader_convos[i] { - (ref rc, _) => rc.send(()), - } + for &(ref rc, _) in reader_convos.iter() { + rc.send(()) } } let read_mode = arc.downgrade(write_mode); do (&read_mode).read |state| { - // FIXME: #7372: hits type inference bug with iterators // complete handshake with other readers - for i in range(0u, reader_convos.len()) { - match reader_convos[i] { - (_, ref rp) => rp.recv(), - } + for &(_, ref rp) in reader_convos.iter() { + rp.recv() } wc1.send(()); // tell writer to try again assert_eq!(*state, 31337); diff --git a/src/libextra/bitv.rs b/src/libextra/bitv.rs index 6dedd9ee4dd..20a3add3e7b 100644 --- a/src/libextra/bitv.rs +++ b/src/libextra/bitv.rs @@ -145,14 +145,16 @@ impl BigBitv { let len = b.storage.len(); assert_eq!(self.storage.len(), len); let mut changed = false; - for i in range(0, len) { + for (i, (a, b)) in self.storage.mut_iter() + .zip(b.storage.iter()) + .enumerate() { let mask = big_mask(nbits, i); - let w0 = self.storage[i] & mask; - let w1 = b.storage[i] & mask; + let w0 = *a & mask; + let w1 = *b & mask; let w = op(w0, w1) & mask; if w0 != w { changed = true; - self.storage[i] = w; + *a = w; } } changed @@ -160,7 +162,7 @@ impl BigBitv { #[inline] pub fn each_storage(&mut self, op: &fn(v: &mut uint) -> bool) -> bool { - range(0u, self.storage.len()).advance(|i| op(&mut self.storage[i])) + self.storage.mut_iter().advance(|elt| op(elt)) } #[inline] @@ -205,10 +207,9 @@ impl BigBitv { #[inline] pub fn equals(&self, b: &BigBitv, nbits: uint) -> bool { - let len = b.storage.len(); - for i in range(0, len) { + for (i, elt) in b.storage.iter().enumerate() { let mask = big_mask(nbits, i); - if mask & self.storage[i] != mask & b.storage[i] { + if mask & self.storage[i] != mask & *elt { return false; } } diff --git a/src/libextra/smallintmap.rs b/src/libextra/smallintmap.rs index 8103ed7a478..a601270e8ec 100644 --- a/src/libextra/smallintmap.rs +++ b/src/libextra/smallintmap.rs @@ -28,14 +28,12 @@ pub struct SmallIntMap { impl Container for SmallIntMap { /// Return the number of elements in the map fn len(&self) -> uint { - let mut sz = 0; - for i in range(0u, self.v.len()) { - match self.v[i] { - Some(_) => sz += 1, - None => {} - } - } - sz + self.v.iter().count(|elt| elt.is_some()) + } + + /// Return true if there are no elements in the map + fn is_empty(&self) -> bool { + self.v.iter().all(|elt| elt.is_none()) } } diff --git a/src/libextra/sort.rs b/src/libextra/sort.rs index 8090dd26ef2..daafdbc3718 100644 --- a/src/libextra/sort.rs +++ b/src/libextra/sort.rs @@ -469,10 +469,7 @@ impl MergeState { base2: uint, len2: uint) { assert!(len1 != 0 && len2 != 0 && base1+len1 == base2); - let mut tmp = ~[]; - for i in range(base1, base1+len1) { - tmp.push(array[i].clone()); - } + let mut tmp = array.slice(base1, base1 + len1).to_owned(); let mut c1 = 0; let mut c2 = base2; @@ -579,10 +576,7 @@ impl MergeState { base2: uint, len2: uint) { assert!(len1 != 1 && len2 != 0 && base1 + len1 == base2); - let mut tmp = ~[]; - for i in range(base2, base2+len2) { - tmp.push(array[i].clone()); - } + let mut tmp = array.slice(base2, base2 + len2).to_owned(); let mut c1 = base1 + len1 - 1; let mut c2 = len2 - 1; diff --git a/src/libstd/at_vec.rs b/src/libstd/at_vec.rs index a84f3137bbd..f2470bed732 100644 --- a/src/libstd/at_vec.rs +++ b/src/libstd/at_vec.rs @@ -12,7 +12,7 @@ use clone::Clone; use container::Container; -use iterator::{Iterator, range}; +use iterator::Iterator; use option::{Option, Some, None}; use sys; use unstable::raw::Repr; @@ -92,8 +92,8 @@ pub fn append(lhs: @[T], rhs: &[T]) -> @[T] { for x in lhs.iter() { push((*x).clone()); } - for i in range(0u, rhs.len()) { - push(rhs[i].clone()); + for elt in rhs.iter() { + push(elt.clone()); } } } diff --git a/src/libstd/hashmap.rs b/src/libstd/hashmap.rs index 3484a5e7d6e..84cba254dcf 100644 --- a/src/libstd/hashmap.rs +++ b/src/libstd/hashmap.rs @@ -19,7 +19,7 @@ use container::{Container, Mutable, Map, MutableMap, Set, MutableSet}; use clone::Clone; use cmp::{Eq, Equiv}; use hash::Hash; -use iterator::{Iterator, IteratorUtil, FromIterator, Extendable, range}; +use iterator::{Iterator, IteratorUtil, FromIterator, Extendable}; use iterator::{FilterMap, Chain, Repeat, Zip}; use num; use option::{None, Option, Some}; @@ -265,8 +265,8 @@ impl Container for HashMap { impl Mutable for HashMap { /// Clear the map, removing all key-value pairs. fn clear(&mut self) { - for idx in range(0u, self.buckets.len()) { - self.buckets[idx] = None; + for bkt in self.buckets.mut_iter() { + *bkt = None; } self.size = 0; } diff --git a/src/libstd/trie.rs b/src/libstd/trie.rs index 6f61d29780f..a5efae542a1 100644 --- a/src/libstd/trie.rs +++ b/src/libstd/trie.rs @@ -271,8 +271,8 @@ impl TrieNode { impl TrieNode { fn each<'a>(&'a self, f: &fn(&uint, &'a T) -> bool) -> bool { - for idx in range(0u, self.children.len()) { - match self.children[idx] { + for elt in self.children.iter() { + match *elt { Internal(ref x) => if !x.each(|i,t| f(i,t)) { return false }, External(k, ref v) => if !f(&k, v) { return false }, Nothing => () diff --git a/src/libstd/vec.rs b/src/libstd/vec.rs index 36201dc5e82..0f6d94bb771 100644 --- a/src/libstd/vec.rs +++ b/src/libstd/vec.rs @@ -1602,8 +1602,8 @@ impl OwnedCopyableVector for ~[T] { let new_len = self.len() + rhs.len(); self.reserve(new_len); - for i in range(0u, rhs.len()) { - self.push(unsafe { raw::get(rhs, i) }) + for elt in rhs.iter() { + self.push((*elt).clone()) } } From e7d4a9c7f248a87a1aa6b5008c7229da2b69a20f Mon Sep 17 00:00:00 2001 From: blake2-ppc Date: Wed, 7 Aug 2013 19:29:19 +0200 Subject: [PATCH 03/29] Bugfix .each_edge in middle/graph.rs Edge iterator used the length of the nodes vector, must be a mistake. --- src/librustc/middle/graph.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/librustc/middle/graph.rs b/src/librustc/middle/graph.rs index 28d24b169ca..46394454d00 100644 --- a/src/librustc/middle/graph.rs +++ b/src/librustc/middle/graph.rs @@ -187,12 +187,12 @@ impl Graph { pub fn each_node(&self, f: &fn(NodeIndex, &Node) -> bool) -> bool { //! Iterates over all edges defined in the graph. - range(0u, self.nodes.len()).advance(|i| f(NodeIndex(i), &self.nodes[i])) + self.nodes.iter().enumerate().advance(|(i, node)| f(NodeIndex(i), node)) } pub fn each_edge(&self, f: &fn(EdgeIndex, &Edge) -> bool) -> bool { - //! Iterates over all edges defined in the graph. - range(0u, self.nodes.len()).advance(|i| f(EdgeIndex(i), &self.edges[i])) + //! Iterates over all edges defined in the graph + self.edges.iter().enumerate().advance(|(i, edge)| f(EdgeIndex(i), edge)) } pub fn each_outgoing_edge(&self, From 8523f6d64355f53bb9453c2c9d32e835bec790ae Mon Sep 17 00:00:00 2001 From: blake2-ppc Date: Wed, 7 Aug 2013 20:19:15 +0200 Subject: [PATCH 04/29] rustc: Fix for-range loops that can use iterators Transform range loops that can be regular iterator loops. --- src/compiletest/runtest.rs | 4 ++-- src/librustc/middle/borrowck/check_loans.rs | 8 ++++---- src/librustc/middle/dataflow.rs | 8 ++++---- src/librustc/middle/trans/base.rs | 3 +-- src/librustc/middle/trans/cabi_x86_64.rs | 4 ++-- src/librustc/middle/trans/type_use.rs | 11 ++--------- src/librustc/middle/typeck/check/method.rs | 4 ++-- src/librustc/middle/typeck/coherence.rs | 4 ++-- .../middle/typeck/infer/region_inference/mod.rs | 4 ++-- 9 files changed, 21 insertions(+), 29 deletions(-) diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs index 0d1c5c8eb43..9c176b504b2 100644 --- a/src/compiletest/runtest.rs +++ b/src/compiletest/runtest.rs @@ -412,8 +412,8 @@ fn check_expected_errors(expected_errors: ~[errors::ExpectedError], } } - for i in range(0u, found_flags.len()) { - if !found_flags[i] { + for (i, &flag) in found_flags.iter().enumerate() { + if !flag { let ee = &expected_errors[i]; fatal_ProcRes(fmt!("expected %s on line %u not found: %s", ee.kind, ee.line, ee.msg), ProcRes); diff --git a/src/librustc/middle/borrowck/check_loans.rs b/src/librustc/middle/borrowck/check_loans.rs index c3bb2000447..88e168db558 100644 --- a/src/librustc/middle/borrowck/check_loans.rs +++ b/src/librustc/middle/borrowck/check_loans.rs @@ -159,10 +159,10 @@ impl<'self> CheckLoanCtxt<'self> { true }; - for i in range(0u, new_loan_indices.len()) { - let old_loan = &self.all_loans[new_loan_indices[i]]; - for j in range(i+1, new_loan_indices.len()) { - let new_loan = &self.all_loans[new_loan_indices[j]]; + for (i, &x) in new_loan_indices.iter().enumerate() { + let old_loan = &self.all_loans[x]; + for &y in new_loan_indices.slice_from(i+1).iter() { + let new_loan = &self.all_loans[y]; self.report_error_if_loans_conflict(old_loan, new_loan); } } diff --git a/src/librustc/middle/dataflow.rs b/src/librustc/middle/dataflow.rs index 008add975d4..46b6d2214ae 100644 --- a/src/librustc/middle/dataflow.rs +++ b/src/librustc/middle/dataflow.rs @@ -983,10 +983,10 @@ fn bitwise(out_vec: &mut [uint], op: &fn(uint, uint) -> uint) -> bool { assert_eq!(out_vec.len(), in_vec.len()); let mut changed = false; - for i in range(0u, out_vec.len()) { - let old_val = out_vec[i]; - let new_val = op(old_val, in_vec[i]); - out_vec[i] = new_val; + for (out_elt, in_elt) in out_vec.mut_iter().zip(in_vec.iter()) { + let old_val = *out_elt; + let new_val = op(old_val, *in_elt); + *out_elt = new_val; changed |= (old_val != new_val); } changed diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index dcaa141cbc2..db8a86fe948 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -1742,8 +1742,7 @@ pub fn copy_args_to_allocas(fcx: @mut FunctionContext, _ => {} } - for arg_n in range(0u, arg_tys.len()) { - let arg_ty = arg_tys[arg_n]; + for (arg_n, &arg_ty) in arg_tys.iter().enumerate() { let raw_llarg = raw_llargs[arg_n]; // For certain mode/type combinations, the raw llarg values are passed diff --git a/src/librustc/middle/trans/cabi_x86_64.rs b/src/librustc/middle/trans/cabi_x86_64.rs index 530e1ff8e5b..dd24ec3ff1a 100644 --- a/src/librustc/middle/trans/cabi_x86_64.rs +++ b/src/librustc/middle/trans/cabi_x86_64.rs @@ -145,8 +145,8 @@ fn classify_ty(ty: Type) -> ~[RegClass] { } fn all_mem(cls: &mut [RegClass]) { - for i in range(0u, cls.len()) { - cls[i] = Memory; + for elt in cls.mut_iter() { + *elt = Memory; } } diff --git a/src/librustc/middle/trans/type_use.rs b/src/librustc/middle/trans/type_use.rs index ad83286c8c1..f25bf011f5d 100644 --- a/src/librustc/middle/trans/type_use.rs +++ b/src/librustc/middle/trans/type_use.rs @@ -206,15 +206,8 @@ pub fn type_uses_for(ccx: @mut CrateContext, fn_id: def_id, n_tps: uint) pub fn type_needs(cx: &Context, use_: uint, ty: ty::t) { // Optimization -- don't descend type if all params already have this use - let len = { - let uses = &*cx.uses; - uses.len() - }; - for i in range(0u, len) { - if cx.uses[i] & use_ != use_ { - type_needs_inner(cx, use_, ty, @Nil); - return; - } + if cx.uses.iter().any(|&elt| elt & use_ != use_) { + type_needs_inner(cx, use_, ty, @Nil); } } diff --git a/src/librustc/middle/typeck/check/method.rs b/src/librustc/middle/typeck/check/method.rs index e1e7d10db0a..ae0a95688ed 100644 --- a/src/librustc/middle/typeck/check/method.rs +++ b/src/librustc/middle/typeck/check/method.rs @@ -772,8 +772,8 @@ impl<'self> LookupContext<'self> { self.tcx().sess.span_err( self.expr.span, "multiple applicable methods in scope"); - for idx in range(0u, relevant_candidates.len()) { - self.report_candidate(idx, &relevant_candidates[idx].origin); + for (idx, candidate) in relevant_candidates.iter().enumerate() { + self.report_candidate(idx, &candidate.origin); } } diff --git a/src/librustc/middle/typeck/coherence.rs b/src/librustc/middle/typeck/coherence.rs index bc8de29b78b..c3df0d06f83 100644 --- a/src/librustc/middle/typeck/coherence.rs +++ b/src/librustc/middle/typeck/coherence.rs @@ -554,8 +554,8 @@ impl CoherenceChecker { let mut provided_names = HashSet::new(); // Implemented methods - for i in range(0u, all_methods.len()) { - provided_names.insert(all_methods[i].ident); + for elt in all_methods.iter() { + provided_names.insert(elt.ident); } let r = ty::trait_methods(tcx, trait_did); diff --git a/src/librustc/middle/typeck/infer/region_inference/mod.rs b/src/librustc/middle/typeck/infer/region_inference/mod.rs index 63503f3e6b6..91b6a4ce3bc 100644 --- a/src/librustc/middle/typeck/infer/region_inference/mod.rs +++ b/src/librustc/middle/typeck/infer/region_inference/mod.rs @@ -374,8 +374,8 @@ impl RegionVarBindings { pub fn vars_created_since_snapshot(&mut self, snapshot: uint) -> ~[RegionVid] { do vec::build |push| { - for i in range(snapshot, self.undo_log.len()) { - match self.undo_log[i] { + for &elt in self.undo_log.slice_from(snapshot).iter() { + match elt { AddVar(vid) => push(vid), _ => () } From 8964fcc5ac9cefcc55ea071142c3c81d623a52be Mon Sep 17 00:00:00 2001 From: Kevin Ballard Date: Tue, 6 Aug 2013 22:34:22 -0700 Subject: [PATCH 05/29] Implement DoubleEndedIterator on Range Range is now invertable as long as its element type conforms to Integer. Remove int::range_rev() et al in favor of range().invert(). --- src/libstd/iterator.rs | 35 ++++++++++++++++++++++--- src/libstd/num/int_macros.rs | 18 +------------ src/libstd/num/uint_macros.rs | 17 +----------- src/libstd/run.rs | 6 ++--- src/libstd/trie.rs | 26 +++++++++--------- src/test/bench/core-map.rs | 15 +++++------ src/test/run-fail/assert-eq-macro-fail | Bin 0 -> 104051 bytes src/test/run-pass/num-range-rev.rs | 4 +-- 8 files changed, 56 insertions(+), 65 deletions(-) create mode 100755 src/test/run-fail/assert-eq-macro-fail diff --git a/src/libstd/iterator.rs b/src/libstd/iterator.rs index 29f54bd10fb..d10a5541e41 100644 --- a/src/libstd/iterator.rs +++ b/src/libstd/iterator.rs @@ -18,9 +18,9 @@ implementing the `Iterator` trait. */ use cmp; -use num::{Zero, One, Saturating}; +use num::{Zero, One, Integer, Saturating}; use option::{Option, Some, None}; -use ops::{Add, Mul}; +use ops::{Add, Mul, Sub}; use cmp::Ord; use clone::Clone; use uint; @@ -1531,7 +1531,7 @@ pub fn range + Ord + Clone + One>(start: A, stop: A) -> Range { Range{state: start, stop: stop, one: One::one()} } -impl + Ord + Clone + One> Iterator for Range { +impl + Ord + Clone> Iterator for Range { #[inline] fn next(&mut self) -> Option { if self.state < self.stop { @@ -1544,6 +1544,22 @@ impl + Ord + Clone + One> Iterator for Range { } } +impl + Integer + Ord + Clone> DoubleEndedIterator for Range { + #[inline] + fn next_back(&mut self) -> Option { + if self.stop > self.state { + // Integer doesn't technically define this rule, but we're going to assume that every + // Integer is reachable from every other one by adding or subtracting enough Ones. This + // seems like a reasonable-enough rule that every Integer should conform to, even if it + // can't be statically checked. + self.stop = self.stop - self.one; + Some(self.stop.clone()) + } else { + None + } + } +} + impl + Clone> Iterator for Counter { #[inline] fn next(&mut self) -> Option { @@ -2121,4 +2137,17 @@ mod tests { check_randacc_iter(xs.iter().cycle().take_(27), 27); check_randacc_iter(empty.iter().cycle(), 0); } + + #[test] + fn test_double_ended_range() { + assert_eq!(range(11i, 14).invert().collect::<~[int]>(), ~[13i, 12, 11]); + for _ in range(10i, 0).invert() { + fail!("unreachable"); + } + + assert_eq!(range(11u, 14).invert().collect::<~[uint]>(), ~[13u, 12, 11]); + for _ in range(10u, 0).invert() { + fail!("unreachable"); + } + } } diff --git a/src/libstd/num/int_macros.rs b/src/libstd/num/int_macros.rs index 9842a570d7e..b692bedebfd 100644 --- a/src/libstd/num/int_macros.rs +++ b/src/libstd/num/int_macros.rs @@ -124,14 +124,6 @@ pub fn range_step_inclusive(start: $T, last: $T, step: $T, it: &fn($T) -> bool) range_step_core(start, last, step, Closed, it) } - -#[inline] -/// Iterate over the range (`hi`..`lo`] -pub fn range_rev(hi: $T, lo: $T, it: &fn($T) -> bool) -> bool { - if hi == min_value { return true; } - range_step_inclusive(hi-1, lo, -1 as $T, it) -} - impl Num for $T {} #[cfg(not(test))] @@ -889,10 +881,6 @@ mod tests { fn test_ranges() { let mut l = ~[]; - do range_rev(14,11) |i| { - l.push(i); - true - }; do range_step(20,26,2) |i| { l.push(i); true @@ -917,8 +905,7 @@ mod tests { l.push(i); true }; - assert_eq!(l, ~[13,12,11, - 20,22,24, + assert_eq!(l, ~[20,22,24, 36,34,32, max_value-2, max_value-3,max_value-1, @@ -926,9 +913,6 @@ mod tests { min_value+3,min_value+1]); // None of the `fail`s should execute. - do range_rev(0,10) |_i| { - fail!(~"unreachable"); - }; do range_step(10,0,1) |_i| { fail!(~"unreachable"); }; diff --git a/src/libstd/num/uint_macros.rs b/src/libstd/num/uint_macros.rs index a2874c96703..29b8f29d87d 100644 --- a/src/libstd/num/uint_macros.rs +++ b/src/libstd/num/uint_macros.rs @@ -125,13 +125,6 @@ pub fn range_step_inclusive(start: $T, last: $T, step: $T_SIGNED, it: &fn($T) -> range_step_core(start, last, step, Closed, it) } -#[inline] -/// Iterate over the range (`hi`..`lo`] -pub fn range_rev(hi: $T, lo: $T, it: &fn($T) -> bool) -> bool { - if hi == min_value { return true; } - range_step_inclusive(hi-1, lo, -1 as $T_SIGNED, it) -} - impl Num for $T {} #[cfg(not(test))] @@ -654,10 +647,6 @@ mod tests { pub fn test_ranges() { let mut l = ~[]; - do range_rev(14,11) |i| { - l.push(i); - true - }; do range_step(20,26,2) |i| { l.push(i); true @@ -683,8 +672,7 @@ mod tests { true }; - assert_eq!(l, ~[13,12,11, - 20,22,24, + assert_eq!(l, ~[20,22,24, 36,34,32, max_value-2, max_value-3,max_value-1, @@ -692,9 +680,6 @@ mod tests { min_value+3,min_value+1]); // None of the `fail`s should execute. - do range_rev(0,0) |_i| { - fail!("unreachable"); - }; do range_step(10,0,1) |_i| { fail!("unreachable"); }; diff --git a/src/libstd/run.rs b/src/libstd/run.rs index ef3d881c5fe..694aa672af7 100644 --- a/src/libstd/run.rs +++ b/src/libstd/run.rs @@ -632,7 +632,6 @@ fn spawn_process_os(prog: &str, args: &[~str], use libc::funcs::posix88::unistd::{fork, dup2, close, chdir, execvp}; use libc::funcs::bsd44::getdtablesize; - use int; mod rustrt { use libc::c_void; @@ -665,10 +664,9 @@ fn spawn_process_os(prog: &str, args: &[~str], fail!("failure in dup3(err_fd, 2): %s", os::last_os_error()); } // close all other fds - do int::range_rev(getdtablesize() as int, 3) |fd| { + for fd in range(3, getdtablesize()).invert() { close(fd as c_int); - true - }; + } do with_dirp(dir) |dirp| { if !dirp.is_null() && chdir(dirp) == -1 { diff --git a/src/libstd/trie.rs b/src/libstd/trie.rs index a5efae542a1..5ef5526e516 100644 --- a/src/libstd/trie.rs +++ b/src/libstd/trie.rs @@ -282,13 +282,14 @@ impl TrieNode { } fn each_reverse<'a>(&'a self, f: &fn(&uint, &'a T) -> bool) -> bool { - do uint::range_rev(self.children.len(), 0) |idx| { - match self.children[idx] { - Internal(ref x) => x.each_reverse(|i,t| f(i,t)), - External(k, ref v) => f(&k, v), - Nothing => true + for elt in self.children.rev_iter() { + match *elt { + Internal(ref x) => if !x.each_reverse(|i,t| f(i,t)) { return false }, + External(k, ref v) => if !f(&k, v) { return false }, + Nothing => () } } + true } fn mutate_values<'a>(&'a mut self, f: &fn(&uint, &mut T) -> bool) -> bool { @@ -539,10 +540,9 @@ mod test_map { fn test_each_break() { let mut m = TrieMap::new(); - do uint::range_rev(uint::max_value, uint::max_value - 10000) |x| { + for x in range(uint::max_value - 10000, uint::max_value).invert() { m.insert(x, x / 2); - true - }; + } let mut n = uint::max_value - 10000; do m.each |k, v| { @@ -580,10 +580,9 @@ mod test_map { fn test_each_reverse_break() { let mut m = TrieMap::new(); - do uint::range_rev(uint::max_value, uint::max_value - 10000) |x| { + for x in range(uint::max_value - 10000, uint::max_value).invert() { m.insert(x, x / 2); - true - }; + } let mut n = uint::max_value - 1; do m.each_reverse |k, v| { @@ -634,10 +633,9 @@ mod test_map { let last = uint::max_value; let mut map = TrieMap::new(); - do uint::range_rev(last, first) |x| { + for x in range(first, last).invert() { map.insert(x, x / 2); - true - }; + } let mut i = 0; for (k, &v) in map.iter() { diff --git a/src/test/bench/core-map.rs b/src/test/bench/core-map.rs index cf160ca31c6..6475012e009 100644 --- a/src/test/bench/core-map.rs +++ b/src/test/bench/core-map.rs @@ -53,24 +53,21 @@ fn descending>(map: &mut M, n_keys: uint) { io::println(" Descending integers:"); do timed("insert") { - do uint::range_rev(n_keys, 0) |i| { + for i in range(0, n_keys).invert() { map.insert(i, i + 1); - true - }; + } } do timed("search") { - do uint::range_rev(n_keys, 0) |i| { + for i in range(0, n_keys).invert() { assert_eq!(map.find(&i).unwrap(), &(i + 1)); - true - }; + } } do timed("remove") { - do uint::range_rev(n_keys, 0) |i| { + for i in range(0, n_keys) { assert!(map.remove(&i)); - true - }; + } } } diff --git a/src/test/run-fail/assert-eq-macro-fail b/src/test/run-fail/assert-eq-macro-fail new file mode 100755 index 0000000000000000000000000000000000000000..2841756d4a0e10e1d852b1e651e62f7903f954ac GIT binary patch literal 104051 zcmd444PaYU`3HQrb)$o^1q7@xB|yP~`$)f27?QDeWY|LZ7*t>;X_Kynt_^KE3U1P| zZZ>4a2n+@etuV3pM~EU=a6q@!Z32G{C|DJ>e;k<5DdEFWaFX};oR8$*^xiZr^L^h7 z%X81~InQ&R^PJ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s-HdF=Wu`5(P63&GC)+!%BT3L0~1u0))0P2AzzvuA=L+URv9F%)|# z1YJ6!r-io)lS;5$!TrZ~W5k8eAr>e~?rVt^;!?9r*UfbUM8(eTcXMFn=pKJUtcyB~ x!BTPVGQ>4k(xDV5y$LnG@e?ZQ?Y<~>7^<1#=lt| bool) -> bool { } fn uint_range_rev(hi: uint, lo: uint, it: &fn(uint) -> bool) -> bool { - uint::range_rev(hi, lo, it) + range(lo, hi).invert().advance(it) } fn int_range_rev(hi: int, lo: int, it: &fn(int) -> bool) -> bool { - int::range_rev(hi, lo, it) + range(lo, hi).invert().advance(it) } fn int_range_step(a: int, b: int, step: int, it: &fn(int) -> bool) -> bool { From e99eff172a11816f335153147dd0800fc4877bee Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 6 Aug 2013 23:03:31 -0700 Subject: [PATCH 06/29] Forbid `priv` where it has no effect This is everywhere except struct fields and enum variants. --- src/libextra/fileinput.rs | 14 +++++------ src/libextra/future.rs | 2 +- src/libextra/getopts.rs | 8 +++---- src/libextra/num/bigint.rs | 20 ++++++++-------- src/libextra/stats.rs | 2 +- src/libextra/term.rs | 4 ++-- src/libextra/terminfo/parm.rs | 12 +++++----- src/libextra/time.rs | 4 ++-- src/librustc/middle/typeck/rscope.rs | 2 +- src/libstd/comm.rs | 8 +++---- src/libstd/num/strconv.rs | 6 ++--- src/libstd/run.rs | 6 ++--- src/libstd/str.rs | 20 ++++++++-------- src/libstd/str/ascii.rs | 6 ++--- src/libsyntax/parse/obsolete.rs | 5 ++++ src/libsyntax/parse/parser.rs | 24 ++++++++++++++----- .../class-cast-to-trait-multiple-types.rs | 2 +- 17 files changed, 81 insertions(+), 64 deletions(-) diff --git a/src/libextra/fileinput.rs b/src/libextra/fileinput.rs index 7a36b25eac5..14b02688cff 100644 --- a/src/libextra/fileinput.rs +++ b/src/libextra/fileinput.rs @@ -129,27 +129,27 @@ struct FileInput_ { `Some(path)` is the file represented by `path`, `None` is `stdin`. Consumed as the files are read. */ - priv files: ~[Option], + files: ~[Option], /** The current file: `Some(r)` for an open file, `None` before starting and after reading everything. */ - priv current_reader: Option<@io::Reader>, - priv state: FileInputState, + current_reader: Option<@io::Reader>, + state: FileInputState, /** Used to keep track of whether we need to insert the newline at the end of a file that is missing it, which is needed to separate the last and first lines. */ - priv previous_was_newline: bool + previous_was_newline: bool } // XXX: remove this when Reader has &mut self. Should be removable via // "self.fi." -> "self." and renaming FileInput_. Documentation above // will likely have to be updated to use `let mut in = ...`. pub struct FileInput { - priv fi: @mut FileInput_ + fi: @mut FileInput_ } impl FileInput { @@ -198,7 +198,7 @@ impl FileInput { FileInput::from_vec(pathed) } - priv fn current_file_eof(&self) -> bool { + fn current_file_eof(&self) -> bool { match self.fi.current_reader { None => false, Some(r) => r.eof() @@ -240,7 +240,7 @@ impl FileInput { Returns `true` if it had to move to the next file and did so successfully. */ - priv fn next_file_if_eof(&self) -> bool { + fn next_file_if_eof(&self) -> bool { match self.fi.current_reader { None => self.next_file(), Some(r) => { diff --git a/src/libextra/future.rs b/src/libextra/future.rs index 7d2a0658969..cc65c49d73a 100644 --- a/src/libextra/future.rs +++ b/src/libextra/future.rs @@ -46,7 +46,7 @@ impl Drop for Future { fn drop(&self) {} } -priv enum FutureState { +enum FutureState { Pending(~fn() -> A), Evaluating, Forced(A) diff --git a/src/libextra/getopts.rs b/src/libextra/getopts.rs index 15aac8ef47c..8bd9d857d69 100644 --- a/src/libextra/getopts.rs +++ b/src/libextra/getopts.rs @@ -708,9 +708,9 @@ pub mod groups { * Fails during iteration if the string contains a non-whitespace * sequence longer than the limit. */ - priv fn each_split_within<'a>(ss: &'a str, - lim: uint, - it: &fn(&'a str) -> bool) -> bool { + fn each_split_within<'a>(ss: &'a str, + lim: uint, + it: &fn(&'a str) -> bool) -> bool { // Just for fun, let's write this as an state machine: enum SplitWithinState { @@ -778,7 +778,7 @@ pub mod groups { } #[test] - priv fn test_split_within() { + fn test_split_within() { fn t(s: &str, i: uint, u: &[~str]) { let mut v = ~[]; do each_split_within(s, i) |s| { v.push(s.to_owned()); true }; diff --git a/src/libextra/num/bigint.rs b/src/libextra/num/bigint.rs index c3737d44e38..0c8701bd0b5 100644 --- a/src/libextra/num/bigint.rs +++ b/src/libextra/num/bigint.rs @@ -59,13 +59,13 @@ pub mod BigDigit { pub static bits: uint = 32; pub static base: uint = 1 << bits; - priv static hi_mask: uint = (-1 as uint) << bits; - priv static lo_mask: uint = (-1 as uint) >> bits; + static hi_mask: uint = (-1 as uint) << bits; + static lo_mask: uint = (-1 as uint) >> bits; - priv fn get_hi(n: uint) -> BigDigit { (n >> bits) as BigDigit } + fn get_hi(n: uint) -> BigDigit { (n >> bits) as BigDigit } - priv fn get_lo(n: uint) -> BigDigit { (n & lo_mask) as BigDigit } + fn get_lo(n: uint) -> BigDigit { (n & lo_mask) as BigDigit } /// Split one machine sized unsigned integer into two BigDigits. @@ -613,7 +613,7 @@ impl BigUint { } - priv fn shl_unit(&self, n_unit: uint) -> BigUint { + fn shl_unit(&self, n_unit: uint) -> BigUint { if n_unit == 0 || self.is_zero() { return (*self).clone(); } return BigUint::new(vec::from_elem(n_unit, ZERO_BIG_DIGIT) @@ -621,7 +621,7 @@ impl BigUint { } - priv fn shl_bits(&self, n_bits: uint) -> BigUint { + fn shl_bits(&self, n_bits: uint) -> BigUint { if n_bits == 0 || self.is_zero() { return (*self).clone(); } let mut carry = 0; @@ -637,7 +637,7 @@ impl BigUint { } - priv fn shr_unit(&self, n_unit: uint) -> BigUint { + fn shr_unit(&self, n_unit: uint) -> BigUint { if n_unit == 0 { return (*self).clone(); } if self.data.len() < n_unit { return Zero::zero(); } return BigUint::from_slice( @@ -646,7 +646,7 @@ impl BigUint { } - priv fn shr_bits(&self, n_bits: uint) -> BigUint { + fn shr_bits(&self, n_bits: uint) -> BigUint { if n_bits == 0 || self.data.is_empty() { return (*self).clone(); } let mut borrow = 0; @@ -661,7 +661,7 @@ impl BigUint { #[cfg(target_arch = "x86_64")] -priv fn get_radix_base(radix: uint) -> (uint, uint) { +fn get_radix_base(radix: uint) -> (uint, uint) { assert!(1 < radix && radix <= 16); match radix { 2 => (4294967296, 32), @@ -687,7 +687,7 @@ priv fn get_radix_base(radix: uint) -> (uint, uint) { #[cfg(target_arch = "x86")] #[cfg(target_arch = "mips")] -priv fn get_radix_base(radix: uint) -> (uint, uint) { +fn get_radix_base(radix: uint) -> (uint, uint) { assert!(1 < radix && radix <= 16); match radix { 2 => (65536, 16), diff --git a/src/libextra/stats.rs b/src/libextra/stats.rs index 9238034cba3..881d931fe0a 100644 --- a/src/libextra/stats.rs +++ b/src/libextra/stats.rs @@ -223,7 +223,7 @@ impl<'self> Stats for &'self [f64] { // Helper function: extract a value representing the `pct` percentile of a sorted sample-set, using // linear interpolation. If samples are not sorted, return nonsensical value. -priv fn percentile_of_sorted(sorted_samples: &[f64], +fn percentile_of_sorted(sorted_samples: &[f64], pct: f64) -> f64 { assert!(sorted_samples.len() != 0); if sorted_samples.len() == 1 { diff --git a/src/libextra/term.rs b/src/libextra/term.rs index 2173eb838e5..d0412b8954d 100644 --- a/src/libextra/term.rs +++ b/src/libextra/term.rs @@ -75,7 +75,7 @@ pub mod attr { } #[cfg(not(target_os = "win32"))] -priv fn cap_for_attr(attr: attr::Attr) -> &'static str { +fn cap_for_attr(attr: attr::Attr) -> &'static str { match attr { attr::Bold => "bold", attr::Dim => "dim", @@ -234,7 +234,7 @@ impl Terminal { } } - priv fn dim_if_necessary(&self, color: color::Color) -> color::Color { + fn dim_if_necessary(&self, color: color::Color) -> color::Color { if color >= self.num_colors && color >= 8 && color < 16 { color-8 } else { color } diff --git a/src/libextra/terminfo/parm.rs b/src/libextra/terminfo/parm.rs index b619e0f33b6..0929575ee9e 100644 --- a/src/libextra/terminfo/parm.rs +++ b/src/libextra/terminfo/parm.rs @@ -430,7 +430,7 @@ pub fn expand(cap: &[u8], params: &[Param], vars: &mut Variables) } #[deriving(Eq)] -priv struct Flags { +struct Flags { width: uint, precision: uint, alternate: bool, @@ -440,13 +440,13 @@ priv struct Flags { } impl Flags { - priv fn new() -> Flags { + fn new() -> Flags { Flags{ width: 0, precision: 0, alternate: false, left: false, sign: false, space: false } } } -priv enum FormatOp { +enum FormatOp { FormatDigit, FormatOctal, FormatHex, @@ -455,7 +455,7 @@ priv enum FormatOp { } impl FormatOp { - priv fn from_char(c: char) -> FormatOp { + fn from_char(c: char) -> FormatOp { match c { 'd' => FormatDigit, 'o' => FormatOctal, @@ -465,7 +465,7 @@ impl FormatOp { _ => fail!("bad FormatOp char") } } - priv fn to_char(self) -> char { + fn to_char(self) -> char { match self { FormatDigit => 'd', FormatOctal => 'o', @@ -476,7 +476,7 @@ impl FormatOp { } } -priv fn format(val: Param, op: FormatOp, flags: Flags) -> Result<~[u8],~str> { +fn format(val: Param, op: FormatOp, flags: Flags) -> Result<~[u8],~str> { let mut s = match val { Number(d) => { match op { diff --git a/src/libextra/time.rs b/src/libextra/time.rs index efc3dc87adc..f6a5fd98234 100644 --- a/src/libextra/time.rs +++ b/src/libextra/time.rs @@ -254,7 +254,7 @@ impl Tm { } } -priv fn do_strptime(s: &str, format: &str) -> Result { +fn do_strptime(s: &str, format: &str) -> Result { fn match_str(s: &str, pos: uint, needle: &str) -> bool { let mut i = pos; for ch in needle.byte_iter() { @@ -687,7 +687,7 @@ priv fn do_strptime(s: &str, format: &str) -> Result { } } -priv fn do_strftime(format: &str, tm: &Tm) -> ~str { +fn do_strftime(format: &str, tm: &Tm) -> ~str { fn parse_type(ch: char, tm: &Tm) -> ~str { //FIXME (#2350): Implement missing types. let die = || fmt!("strftime: can't understand this format %c ", ch); diff --git a/src/librustc/middle/typeck/rscope.rs b/src/librustc/middle/typeck/rscope.rs index bbcf42b1c5d..c9e2b8dd37b 100644 --- a/src/librustc/middle/typeck/rscope.rs +++ b/src/librustc/middle/typeck/rscope.rs @@ -215,7 +215,7 @@ impl region_scope for MethodRscope { pub struct type_rscope(Option); impl type_rscope { - priv fn replacement(&self) -> ty::Region { + fn replacement(&self) -> ty::Region { if self.is_some() { ty::re_bound(ty::br_self) } else { diff --git a/src/libstd/comm.rs b/src/libstd/comm.rs index 4356f1143da..a4de10f8c77 100644 --- a/src/libstd/comm.rs +++ b/src/libstd/comm.rs @@ -314,7 +314,7 @@ mod pipesy { #[allow(non_camel_case_types)] pub mod oneshot { - priv use std::kinds::Send; + use std::kinds::Send; use ptr::to_mut_unsafe_ptr; pub fn init() -> (server::Oneshot, client::Oneshot) { @@ -341,7 +341,7 @@ mod pipesy { #[allow(non_camel_case_types)] pub mod client { - priv use std::kinds::Send; + use std::kinds::Send; #[allow(non_camel_case_types)] pub fn try_send(pipe: Oneshot, x_0: T) -> @@ -489,7 +489,7 @@ mod pipesy { #[allow(non_camel_case_types)] pub mod streamp { - priv use std::kinds::Send; + use std::kinds::Send; pub fn init() -> (server::Open, client::Open) { pub use std::pipes::HasBuffer; @@ -501,7 +501,7 @@ mod pipesy { #[allow(non_camel_case_types)] pub mod client { - priv use std::kinds::Send; + use std::kinds::Send; #[allow(non_camel_case_types)] pub fn try_data(pipe: Open, x_0: T) -> diff --git a/src/libstd/num/strconv.rs b/src/libstd/num/strconv.rs index 7ab3c81b61f..1f22343ad9c 100644 --- a/src/libstd/num/strconv.rs +++ b/src/libstd/num/strconv.rs @@ -422,9 +422,9 @@ pub fn float_to_str_common(d: Option<&Path>, } #[cfg(windows)] -priv fn free_handle(handle: *()) { +fn free_handle(handle: *()) { unsafe { libc::funcs::extra::kernel32::CloseHandle(cast::transmute(handle)); } } #[cfg(unix)] -priv fn free_handle(_handle: *()) { +fn free_handle(_handle: *()) { // unix has no process handle object, just a pid } @@ -823,7 +823,7 @@ pub fn process_output(prog: &str, args: &[~str]) -> ProcessOutput { * operate on a none-existant process or, even worse, on a newer process * with the same id. */ -priv fn waitpid(pid: pid_t) -> int { +fn waitpid(pid: pid_t) -> int { return waitpid_os(pid); #[cfg(windows)] diff --git a/src/libstd/str.rs b/src/libstd/str.rs index c4bd2c5435a..fa75916fb86 100644 --- a/src/libstd/str.rs +++ b/src/libstd/str.rs @@ -738,7 +738,7 @@ pub fn count_bytes<'b>(s: &'b str, start: uint, n: uint) -> uint { } // https://tools.ietf.org/html/rfc3629 -priv static UTF8_CHAR_WIDTH: [u8, ..256] = [ +static UTF8_CHAR_WIDTH: [u8, ..256] = [ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // 0x1F 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, @@ -781,15 +781,15 @@ macro_rules! utf8_acc_cont_byte( ) // UTF-8 tags and ranges -priv static TAG_CONT_U8: u8 = 128u8; -priv static TAG_CONT: uint = 128u; -priv static MAX_ONE_B: uint = 128u; -priv static TAG_TWO_B: uint = 192u; -priv static MAX_TWO_B: uint = 2048u; -priv static TAG_THREE_B: uint = 224u; -priv static MAX_THREE_B: uint = 65536u; -priv static TAG_FOUR_B: uint = 240u; -priv static MAX_UNICODE: uint = 1114112u; +static TAG_CONT_U8: u8 = 128u8; +static TAG_CONT: uint = 128u; +static MAX_ONE_B: uint = 128u; +static TAG_TWO_B: uint = 192u; +static MAX_TWO_B: uint = 2048u; +static TAG_THREE_B: uint = 224u; +static MAX_THREE_B: uint = 65536u; +static TAG_FOUR_B: uint = 240u; +static MAX_UNICODE: uint = 1114112u; /// Unsafe operations pub mod raw { diff --git a/src/libstd/str/ascii.rs b/src/libstd/str/ascii.rs index 1be4d07dfa4..6ededb02107 100644 --- a/src/libstd/str/ascii.rs +++ b/src/libstd/str/ascii.rs @@ -274,7 +274,7 @@ pub fn to_ascii_lower(string: &str) -> ~str { } #[inline] -priv fn map_bytes(string: &str, map: &'static [u8]) -> ~str { +fn map_bytes(string: &str, map: &'static [u8]) -> ~str { let len = string.len(); let mut result = str::with_capacity(len); unsafe { @@ -298,7 +298,7 @@ pub fn eq_ignore_ascii_case(a: &str, b: &str) -> bool { |(byte_a, byte_b)| ASCII_LOWER_MAP[*byte_a] == ASCII_LOWER_MAP[*byte_b]) } -priv static ASCII_LOWER_MAP: &'static [u8] = &[ +static ASCII_LOWER_MAP: &'static [u8] = &[ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, @@ -333,7 +333,7 @@ priv static ASCII_LOWER_MAP: &'static [u8] = &[ 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, ]; -priv static ASCII_UPPER_MAP: &'static [u8] = &[ +static ASCII_UPPER_MAP: &'static [u8] = &[ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, diff --git a/src/libsyntax/parse/obsolete.rs b/src/libsyntax/parse/obsolete.rs index ec956f61863..dda5e990221 100644 --- a/src/libsyntax/parse/obsolete.rs +++ b/src/libsyntax/parse/obsolete.rs @@ -64,6 +64,7 @@ pub enum ObsoleteSyntax { ObsoleteMutWithMultipleBindings, ObsoleteExternVisibility, ObsoleteUnsafeExternFn, + ObsoletePrivVisibility, } impl to_bytes::IterBytes for ObsoleteSyntax { @@ -253,6 +254,10 @@ impl ParserObsoleteMethods for Parser { "external functions are always unsafe; remove the `unsafe` \ keyword" ), + ObsoletePrivVisibility => ( + "`priv` not necessary", + "an item without a visibility qualifier is private by default" + ), }; self.report(sp, kind, kind_str, desc); diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 4902c4587ac..7d6dce22fb7 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -85,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}; +use parse::obsolete::{ParserObsoleteMethods, ObsoletePrivVisibility}; 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}; @@ -814,7 +814,7 @@ impl Parser { let attrs = p.parse_outer_attributes(); let lo = p.span.lo; - let vis = p.parse_visibility(); + let vis = p.parse_non_priv_visibility(); let pur = p.parse_fn_purity(); // NB: at the moment, trait methods are public by default; this // could change. @@ -3608,7 +3608,7 @@ impl Parser { let attrs = self.parse_outer_attributes(); let lo = self.span.lo; - let visa = self.parse_visibility(); + let visa = self.parse_non_priv_visibility(); let pur = self.parse_fn_purity(); let ident = self.parse_ident(); let generics = self.parse_generics(); @@ -3871,6 +3871,18 @@ 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); @@ -4063,7 +4075,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_visibility(); + let vis = self.parse_non_priv_visibility(); // Parse obsolete purity. let purity = self.parse_fn_purity(); @@ -4443,7 +4455,7 @@ impl Parser { maybe_whole!(iovi self, nt_item); let lo = self.span.lo; - let visibility = self.parse_visibility(); + let visibility = self.parse_non_priv_visibility(); // must be a view item: if self.eat_keyword(keywords::Use) { @@ -4575,7 +4587,7 @@ impl Parser { maybe_whole!(iovi self, nt_item); let lo = self.span.lo; - let visibility = self.parse_visibility(); + let visibility = self.parse_non_priv_visibility(); if (self.is_keyword(keywords::Const) || self.is_keyword(keywords::Static)) { // FOREIGN CONST ITEM diff --git a/src/test/run-pass/class-cast-to-trait-multiple-types.rs b/src/test/run-pass/class-cast-to-trait-multiple-types.rs index a5d7ba2c1aa..a134ffe49fd 100644 --- a/src/test/run-pass/class-cast-to-trait-multiple-types.rs +++ b/src/test/run-pass/class-cast-to-trait-multiple-types.rs @@ -21,7 +21,7 @@ struct dog { } impl dog { - priv fn bark(&self) -> int { + fn bark(&self) -> int { info!("Woof %u %d", *self.barks, *self.volume); *self.barks += 1u; if *self.barks % 3u == 0u { From a7f008bc3954223d3c6693389d82880a88dc407c Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Mon, 5 Aug 2013 14:34:58 +0200 Subject: [PATCH 07/29] Add missing getopts::groups::optflagmulti function --- src/libextra/getopts.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/libextra/getopts.rs b/src/libextra/getopts.rs index 8bd9d857d69..5ec6713509e 100644 --- a/src/libextra/getopts.rs +++ b/src/libextra/getopts.rs @@ -542,6 +542,20 @@ pub mod groups { occur: Optional}; } + /// Create a long option that can occur more than once and does not + /// take an argument + pub fn optflagmulti(short_name: &str, long_name: &str, + desc: &str) -> OptGroup { + let len = short_name.len(); + assert!(len == 1 || len == 0); + return OptGroup {short_name: short_name.to_owned(), + long_name: long_name.to_owned(), + hint: ~"", + desc: desc.to_owned(), + hasarg: No, + occur: Multi}; + } + /// Create a long option that is optional and takes an optional argument pub fn optflagopt(short_name: &str, long_name: &str, desc: &str, hint: &str) -> OptGroup { From a8f3f038c03eb1393110dfdb1e6bdf1be6a3fb62 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Mon, 5 Aug 2013 14:37:54 +0200 Subject: [PATCH 08/29] Turn OptGroups into a main opt and a main and an aliased opts This way opt_present("apple") will match no matter if the user passed -a or --apple --- src/libextra/getopts.rs | 99 ++++++++++++++++++++++++++++------------- 1 file changed, 68 insertions(+), 31 deletions(-) diff --git a/src/libextra/getopts.rs b/src/libextra/getopts.rs index 5ec6713509e..1b65528923a 100644 --- a/src/libextra/getopts.rs +++ b/src/libextra/getopts.rs @@ -114,7 +114,8 @@ pub enum Occur { pub struct Opt { name: Name, hasarg: HasArg, - occur: Occur + occur: Occur, + aliases: ~[Opt], } fn mkname(nm: &str) -> Name { @@ -127,29 +128,29 @@ fn mkname(nm: &str) -> Name { /// Create an option that is required and takes an argument pub fn reqopt(name: &str) -> Opt { - return Opt {name: mkname(name), hasarg: Yes, occur: Req}; + return Opt {name: mkname(name), hasarg: Yes, occur: Req, aliases: ~[]}; } /// Create an option that is optional and takes an argument pub fn optopt(name: &str) -> Opt { - return Opt {name: mkname(name), hasarg: Yes, occur: Optional}; + return Opt {name: mkname(name), hasarg: Yes, occur: Optional, aliases: ~[]}; } /// Create an option that is optional and does not take an argument pub fn optflag(name: &str) -> Opt { - return Opt {name: mkname(name), hasarg: No, occur: Optional}; + return Opt {name: mkname(name), hasarg: No, occur: Optional, aliases: ~[]}; } /** Create an option that is optional, does not take an argument, * and may occur multiple times. */ pub fn optflagmulti(name: &str) -> Opt { - return Opt {name: mkname(name), hasarg: No, occur: Multi}; + return Opt {name: mkname(name), hasarg: No, occur: Multi, aliases: ~[]}; } /// Create an option that is optional and takes an optional argument pub fn optflagopt(name: &str) -> Opt { - return Opt {name: mkname(name), hasarg: Maybe, occur: Optional}; + return Opt {name: mkname(name), hasarg: Maybe, occur: Optional, aliases: ~[]}; } /** @@ -157,7 +158,7 @@ pub fn optflagopt(name: &str) -> Opt { * multiple times */ pub fn optmulti(name: &str) -> Opt { - return Opt {name: mkname(name), hasarg: Yes, occur: Multi}; + return Opt {name: mkname(name), hasarg: Yes, occur: Multi, aliases: ~[]}; } #[deriving(Clone, Eq)] @@ -189,7 +190,20 @@ fn name_str(nm: &Name) -> ~str { } fn find_opt(opts: &[Opt], nm: Name) -> Option { - opts.iter().position(|opt| opt.name == nm) + // search main options + let pos = opts.iter().position(|opt| opt.name == nm); + if pos.is_some() { + return pos + } + + // search in aliases + for candidate in opts.iter() { + if candidate.aliases.iter().position(|opt| opt.name == nm).is_some() { + return opts.iter().position(|opt| opt.name == candidate.name); + } + } + + None } /** @@ -488,8 +502,6 @@ pub mod groups { use getopts::{HasArg, Long, Maybe, Multi, No, Occur, Opt, Optional, Req}; use getopts::{Short, Yes}; - use std::vec; - /** one group of options, e.g., both -h and --help, along with * their shared description and properties */ @@ -587,7 +599,7 @@ pub mod groups { // translate OptGroup into Opt // (both short and long names correspond to different Opts) - pub fn long_to_short(lopt: &OptGroup) -> ~[Opt] { + pub fn long_to_short(lopt: &OptGroup) -> Opt { let OptGroup{short_name: short_name, long_name: long_name, hasarg: hasarg, @@ -595,24 +607,29 @@ pub mod groups { _} = (*lopt).clone(); match (short_name.len(), long_name.len()) { - (0,0) => fail!("this long-format option was given no name"), + (0,0) => fail!("this long-format option was given no name"), - (0,_) => ~[Opt {name: Long((long_name)), - hasarg: hasarg, - occur: occur}], + (0,_) => Opt {name: Long((long_name)), + hasarg: hasarg, + occur: occur, + aliases: ~[]}, - (1,0) => ~[Opt {name: Short(short_name.char_at(0)), - hasarg: hasarg, - occur: occur}], + (1,0) => Opt {name: Short(short_name.char_at(0)), + hasarg: hasarg, + occur: occur, + aliases: ~[]}, - (1,_) => ~[Opt {name: Short(short_name.char_at(0)), - hasarg: hasarg, - occur: occur}, - Opt {name: Long((long_name)), - hasarg: hasarg, - occur: occur}], + (1,_) => Opt {name: Long((long_name)), + hasarg: hasarg, + occur: occur, + aliases: ~[Opt { + name: Short(short_name.char_at(0)), + hasarg: hasarg, + occur: occur, + aliases: ~[] + }]}, - (_,_) => fail!("something is wrong with the long-form opt") + (_,_) => fail!("something is wrong with the long-form opt") } } @@ -620,7 +637,7 @@ pub mod groups { * Parse command line args with the provided long format options */ pub fn getopts(args: &[~str], opts: &[OptGroup]) -> ::getopts::Result { - ::getopts::getopts(args, vec::flat_map(opts, long_to_short)) + ::getopts::getopts(args, opts.map(long_to_short)) } /** @@ -1454,7 +1471,8 @@ mod tests { #[test] fn test_groups_long_to_short() { - let short = ~[reqopt("b"), reqopt("banana")]; + let mut short = reqopt("banana"); + short.aliases = ~[reqopt("b")]; let verbose = groups::reqopt("b", "banana", "some bananas", "VAL"); assert_eq!(groups::long_to_short(&verbose), short); @@ -1462,10 +1480,16 @@ mod tests { #[test] fn test_groups_getopts() { + let mut banana = reqopt("banana"); + banana.aliases = ~[reqopt("b")]; + let mut apple = optopt("apple"); + apple.aliases = ~[optopt("a")]; + let mut kiwi = optflag("kiwi"); + kiwi.aliases = ~[optflag("k")]; let short = ~[ - reqopt("b"), reqopt("banana"), - optopt("a"), optopt("apple"), - optflag("k"), optflagopt("kiwi"), + banana, + apple, + kiwi, optflagopt("p"), optmulti("l") ]; @@ -1478,7 +1502,7 @@ mod tests { groups::optmulti("l", "", "Desc", "VAL"), ]; - let sample_args = ~[~"-k", ~"15", ~"--apple", ~"1", ~"k", + let sample_args = ~[~"--kiwi", ~"15", ~"--apple", ~"1", ~"k", ~"-p", ~"16", ~"l", ~"35"]; // FIXME #4681: sort options here? @@ -1486,6 +1510,19 @@ mod tests { == groups::getopts(sample_args, verbose)); } + #[test] + fn test_groups_aliases_long_and_short() { + let opts = ~[ + groups::optflagmulti("a", "apple", "Desc"), + ]; + + let args = ~[~"-a", ~"--apple", ~"-a"]; + + let matches = groups::getopts(args, opts).unwrap(); + assert_eq!(3, opt_count(&matches, "a")); + assert_eq!(3, opt_count(&matches, "apple")); + } + #[test] fn test_groups_usage() { let optgroups = ~[ From 9b221f56f1d9f923fad48b7e30f886acaeb3f741 Mon Sep 17 00:00:00 2001 From: darkf Date: Sun, 4 Aug 2013 22:28:53 -0700 Subject: [PATCH 09/29] add inflate_bytes_zlib to exra::flate --- src/libextra/flate.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/libextra/flate.rs b/src/libextra/flate.rs index 8024b9aa159..5d5180c152b 100644 --- a/src/libextra/flate.rs +++ b/src/libextra/flate.rs @@ -43,6 +43,7 @@ static LZ_NONE : c_int = 0x0; // Huffman-coding only. static LZ_FAST : c_int = 0x1; // LZ with only one probe static LZ_NORM : c_int = 0x80; // LZ with 128 probes, "normal" static LZ_BEST : c_int = 0xfff; // LZ with 4095 probes, "best" +static TINFL_FLAG_PARSE_ZLIB_HEADER : c_int = 0x1; // parse zlib header and adler32 checksum pub fn deflate_bytes(bytes: &[u8]) -> ~[u8] { do bytes.as_imm_buf |b, len| { @@ -62,7 +63,7 @@ pub fn deflate_bytes(bytes: &[u8]) -> ~[u8] { } } -pub fn inflate_bytes(bytes: &[u8]) -> ~[u8] { +fn inflate_bytes_(bytes: &[u8], flags: c_int) -> ~[u8] { do bytes.as_imm_buf |b, len| { unsafe { let mut outsz : size_t = 0; @@ -70,7 +71,7 @@ pub fn inflate_bytes(bytes: &[u8]) -> ~[u8] { rustrt::tinfl_decompress_mem_to_heap(b as *c_void, len as size_t, &mut outsz, - 0); + flags); assert!(res as int != 0); let out = vec::raw::from_buf_raw(res as *u8, outsz as uint); @@ -80,6 +81,14 @@ pub fn inflate_bytes(bytes: &[u8]) -> ~[u8] { } } +pub fn inflate_bytes(bytes: &[u8]) -> ~[u8] { + inflate_bytes_(bytes, 0) +} + +pub fn inflate_bytes_zlib(bytes: &[u8]) -> ~[u8] { + inflate_bytes_(bytes, TINFL_FLAG_PARSE_ZLIB_HEADER) +} + #[cfg(test)] mod tests { use super::*; From dd5e8b218fb7a6f45beca1cddb0c19949307ea3d Mon Sep 17 00:00:00 2001 From: darkf Date: Sun, 4 Aug 2013 22:37:09 -0700 Subject: [PATCH 10/29] add extra::flate::deflate_bytes_zlib and a test --- src/libextra/flate.rs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/libextra/flate.rs b/src/libextra/flate.rs index 5d5180c152b..c974148ee12 100644 --- a/src/libextra/flate.rs +++ b/src/libextra/flate.rs @@ -44,8 +44,9 @@ static LZ_FAST : c_int = 0x1; // LZ with only one probe static LZ_NORM : c_int = 0x80; // LZ with 128 probes, "normal" static LZ_BEST : c_int = 0xfff; // LZ with 4095 probes, "best" static TINFL_FLAG_PARSE_ZLIB_HEADER : c_int = 0x1; // parse zlib header and adler32 checksum +static TDEFL_WRITE_ZLIB_HEADER : c_int = 0x01000; // write zlib header and adler32 checksum -pub fn deflate_bytes(bytes: &[u8]) -> ~[u8] { +fn deflate_bytes_(bytes: &[u8], flags: c_int) -> ~[u8] { do bytes.as_imm_buf |b, len| { unsafe { let mut outsz : size_t = 0; @@ -53,7 +54,7 @@ pub fn deflate_bytes(bytes: &[u8]) -> ~[u8] { rustrt::tdefl_compress_mem_to_heap(b as *c_void, len as size_t, &mut outsz, - LZ_NORM); + flags); assert!(res as int != 0); let out = vec::raw::from_buf_raw(res as *u8, outsz as uint); @@ -63,6 +64,14 @@ pub fn deflate_bytes(bytes: &[u8]) -> ~[u8] { } } +pub fn deflate_bytes(bytes: &[u8]) -> ~[u8] { + deflate_bytes_(bytes, LZ_NORM) +} + +pub fn deflate_bytes_zlib(bytes: &[u8]) -> ~[u8] { + deflate_bytes_(bytes, LZ_NORM | TDEFL_WRITE_ZLIB_HEADER) +} + fn inflate_bytes_(bytes: &[u8], flags: c_int) -> ~[u8] { do bytes.as_imm_buf |b, len| { unsafe { @@ -118,4 +127,12 @@ mod tests { assert_eq!(input, out); } } + + #[test] + fn test_zlib_flate() { + let bytes = ~[1, 2, 3, 4, 5]; + let deflated = deflate_bytes(bytes); + let inflated = inflate_bytes(deflated); + assert_eq!(inflated, bytes); + } } From cc160a00285b2856610b31004eee7704ca0806d1 Mon Sep 17 00:00:00 2001 From: darkf Date: Mon, 5 Aug 2013 06:06:43 -0700 Subject: [PATCH 11/29] extra: add `internal` to {de,in}flate_bytes_ naming to address nit --- src/libextra/flate.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/libextra/flate.rs b/src/libextra/flate.rs index c974148ee12..ed8cbcd0663 100644 --- a/src/libextra/flate.rs +++ b/src/libextra/flate.rs @@ -46,7 +46,7 @@ static LZ_BEST : c_int = 0xfff; // LZ with 4095 probes, "best" static TINFL_FLAG_PARSE_ZLIB_HEADER : c_int = 0x1; // parse zlib header and adler32 checksum static TDEFL_WRITE_ZLIB_HEADER : c_int = 0x01000; // write zlib header and adler32 checksum -fn deflate_bytes_(bytes: &[u8], flags: c_int) -> ~[u8] { +fn deflate_bytes_internal(bytes: &[u8], flags: c_int) -> ~[u8] { do bytes.as_imm_buf |b, len| { unsafe { let mut outsz : size_t = 0; @@ -65,14 +65,14 @@ fn deflate_bytes_(bytes: &[u8], flags: c_int) -> ~[u8] { } pub fn deflate_bytes(bytes: &[u8]) -> ~[u8] { - deflate_bytes_(bytes, LZ_NORM) + deflate_bytes_internal(bytes, LZ_NORM) } pub fn deflate_bytes_zlib(bytes: &[u8]) -> ~[u8] { - deflate_bytes_(bytes, LZ_NORM | TDEFL_WRITE_ZLIB_HEADER) + deflate_bytes_internal(bytes, LZ_NORM | TDEFL_WRITE_ZLIB_HEADER) } -fn inflate_bytes_(bytes: &[u8], flags: c_int) -> ~[u8] { +fn inflate_bytes_internal(bytes: &[u8], flags: c_int) -> ~[u8] { do bytes.as_imm_buf |b, len| { unsafe { let mut outsz : size_t = 0; @@ -91,11 +91,11 @@ fn inflate_bytes_(bytes: &[u8], flags: c_int) -> ~[u8] { } pub fn inflate_bytes(bytes: &[u8]) -> ~[u8] { - inflate_bytes_(bytes, 0) + inflate_bytes_internal(bytes, 0) } pub fn inflate_bytes_zlib(bytes: &[u8]) -> ~[u8] { - inflate_bytes_(bytes, TINFL_FLAG_PARSE_ZLIB_HEADER) + inflate_bytes_internal(bytes, TINFL_FLAG_PARSE_ZLIB_HEADER) } #[cfg(test)] From ffd80aa276224c8343d3f8b0942c7497b16df10f Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 7 Aug 2013 11:52:33 -0700 Subject: [PATCH 12/29] Fix unit structs in cross-crate situtations --- src/librustc/middle/resolve.rs | 7 +++-- src/test/auxiliary/xcrate_unit_struct.rs | 31 ++++++++++++++++++ src/test/compile-fail/xcrate-unit-struct.rs | 21 +++++++++++++ src/test/run-pass/xcrate-unit-struct.rs | 35 +++++++++++++++++++++ 4 files changed, 92 insertions(+), 2 deletions(-) create mode 100644 src/test/auxiliary/xcrate_unit_struct.rs create mode 100644 src/test/compile-fail/xcrate-unit-struct.rs create mode 100644 src/test/run-pass/xcrate-unit-struct.rs diff --git a/src/librustc/middle/resolve.rs b/src/librustc/middle/resolve.rs index da0ba1558c9..f55fdd22c9a 100644 --- a/src/librustc/middle/resolve.rs +++ b/src/librustc/middle/resolve.rs @@ -13,7 +13,7 @@ use driver::session::Session; use metadata::csearch::{each_path, get_trait_method_def_ids}; use metadata::csearch::get_method_name_and_explicit_self; use metadata::csearch::get_static_methods_if_impl; -use metadata::csearch::get_type_name_if_impl; +use metadata::csearch::{get_type_name_if_impl, get_struct_fields}; use metadata::cstore::find_extern_mod_stmt_cnum; use metadata::decoder::{def_like, dl_def, dl_field, dl_impl}; use middle::lang_items::LanguageItems; @@ -1700,9 +1700,12 @@ impl Resolver { } def_struct(def_id) => { debug!("(building reduced graph for external \ - crate) building type %s", + crate) building type and value for %s", final_ident); child_name_bindings.define_type(privacy, def, dummy_sp()); + if get_struct_fields(self.session.cstore, def_id).len() == 0 { + child_name_bindings.define_value(privacy, def, dummy_sp()); + } self.structs.insert(def_id); } def_method(*) => { diff --git a/src/test/auxiliary/xcrate_unit_struct.rs b/src/test/auxiliary/xcrate_unit_struct.rs new file mode 100644 index 00000000000..a72bf307e5d --- /dev/null +++ b/src/test/auxiliary/xcrate_unit_struct.rs @@ -0,0 +1,31 @@ +// 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. + +#[crate_type = "lib"]; + +// used by the rpass test + +pub struct Struct; + +pub enum Unit { + Unit, + Argument(Struct) +} + +// used by the cfail test + +pub struct StructWithFields { + foo: int, +} + +pub enum EnumWithVariants { + EnumVariant, + EnumVariantArg(int) +} diff --git a/src/test/compile-fail/xcrate-unit-struct.rs b/src/test/compile-fail/xcrate-unit-struct.rs new file mode 100644 index 00000000000..e71a0f05dff --- /dev/null +++ b/src/test/compile-fail/xcrate-unit-struct.rs @@ -0,0 +1,21 @@ +// 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. + +// aux-build:xcrate_unit_struct.rs + +// Make sure that when we have cross-crate unit structs we don't accidentally +// make values out of cross-crate structs that aren't unit. + +extern mod xcrate_unit_struct; + +fn main() { + let _ = xcrate_unit_struct::StructWithFields; //~ ERROR: unresolved name + let _ = xcrate_unit_struct::Struct; +} diff --git a/src/test/run-pass/xcrate-unit-struct.rs b/src/test/run-pass/xcrate-unit-struct.rs new file mode 100644 index 00000000000..58676f7cd70 --- /dev/null +++ b/src/test/run-pass/xcrate-unit-struct.rs @@ -0,0 +1,35 @@ +// 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. + +// aux-build:xcrate_unit_struct.rs + +extern mod xcrate_unit_struct; + +use std::util; + +static s1: xcrate_unit_struct::Struct = xcrate_unit_struct::Struct; +static s2: xcrate_unit_struct::Unit = xcrate_unit_struct::Unit; +static s3: xcrate_unit_struct::Unit = + xcrate_unit_struct::Argument(xcrate_unit_struct::Struct); +static s4: xcrate_unit_struct::Unit = xcrate_unit_struct::Argument(s1); + +fn f1(_: xcrate_unit_struct::Struct) {} +fn f2(_: xcrate_unit_struct::Unit) {} + +fn main() { + f1(xcrate_unit_struct::Struct); + f2(xcrate_unit_struct::Unit); + f2(xcrate_unit_struct::Argument(xcrate_unit_struct::Struct)); + + f1(s1); + f2(s2); + f2(s3); + f2(s4); +} From 19d0eb90600f1b643025b99b8a2ea204e4d08034 Mon Sep 17 00:00:00 2001 From: Sangeun Kim Date: Wed, 7 Aug 2013 16:44:42 +0900 Subject: [PATCH 13/29] Change Freeze to Static --- src/librustdoc/markdown_pass.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/librustdoc/markdown_pass.rs b/src/librustdoc/markdown_pass.rs index f05c59083f4..beebe71faae 100644 --- a/src/librustdoc/markdown_pass.rs +++ b/src/librustdoc/markdown_pass.rs @@ -150,8 +150,8 @@ pub fn header_kind(doc: doc::ItemTag) -> ~str { doc::FnTag(_) => { ~"Function" } - doc::ConstTag(_) => { - ~"Freeze" + doc::StaticTag(_) => { + ~"Static" } doc::EnumTag(_) => { ~"Enum" @@ -777,7 +777,7 @@ mod test { #[test] fn should_write_const_header() { let markdown = render(~"static a: bool = true;"); - assert!(markdown.contains("## Freeze `a`\n\n")); + assert!(markdown.contains("## Static `a`\n\n")); } #[test] From a9b7bec2e7f005431c7424a59095ccda33484bb1 Mon Sep 17 00:00:00 2001 From: Sangeun Kim Date: Wed, 7 Aug 2013 16:47:21 +0900 Subject: [PATCH 14/29] Change const to static --- src/librustdoc/doc.rs | 16 +++++++-------- src/librustdoc/extract.rs | 12 ++++++------ src/librustdoc/fold.rs | 28 +++++++++++++-------------- src/librustdoc/markdown_pass.rs | 10 +++++----- src/librustdoc/sort_item_type_pass.rs | 6 +++--- src/librustdoc/tystr_pass.rs | 14 +++++++------- 6 files changed, 43 insertions(+), 43 deletions(-) diff --git a/src/librustdoc/doc.rs b/src/librustdoc/doc.rs index d24fd1f5bfe..aba7ea1f0d7 100644 --- a/src/librustdoc/doc.rs +++ b/src/librustdoc/doc.rs @@ -54,7 +54,7 @@ pub struct CrateDoc { pub enum ItemTag { ModTag(ModDoc), NmodTag(NmodDoc), - ConstTag(ConstDoc), + StaticTag(StaticDoc), FnTag(FnDoc), EnumTag(EnumDoc), TraitTag(TraitDoc), @@ -95,7 +95,7 @@ pub struct NmodDoc { index: Option } -pub type ConstDoc = SimpleItemDoc; +pub type StaticDoc = SimpleItemDoc; pub type FnDoc = SimpleItemDoc; @@ -214,8 +214,8 @@ impl ModDoc { md!(FnTag) } - pub fn consts(&self) -> ~[ConstDoc] { - md!(ConstTag) + pub fn statics(&self) -> ~[StaticDoc] { + md!(StaticTag) } pub fn enums(&self) -> ~[EnumDoc] { @@ -249,7 +249,7 @@ pub trait PageUtils { fn mods(&self) -> ~[ModDoc]; fn nmods(&self) -> ~[NmodDoc]; fn fns(&self) -> ~[FnDoc]; - fn consts(&self) -> ~[ConstDoc]; + fn statics(&self) -> ~[StaticDoc]; fn enums(&self) -> ~[EnumDoc]; fn traits(&self) -> ~[TraitDoc]; fn impls(&self) -> ~[ImplDoc]; @@ -270,8 +270,8 @@ impl PageUtils for ~[Page] { pu!(FnTag) } - fn consts(&self) -> ~[ConstDoc] { - pu!(ConstTag) + fn statics(&self) -> ~[StaticDoc] { + pu!(StaticTag) } fn enums(&self) -> ~[EnumDoc] { @@ -301,7 +301,7 @@ impl Item for ItemTag { &doc::ModTag(ref doc) => doc.item.clone(), &doc::NmodTag(ref doc) => doc.item.clone(), &doc::FnTag(ref doc) => doc.item.clone(), - &doc::ConstTag(ref doc) => doc.item.clone(), + &doc::StaticTag(ref doc) => doc.item.clone(), &doc::EnumTag(ref doc) => doc.item.clone(), &doc::TraitTag(ref doc) => doc.item.clone(), &doc::ImplTag(ref doc) => doc.item.clone(), diff --git a/src/librustdoc/extract.rs b/src/librustdoc/extract.rs index f849cfade9b..2cab62296a4 100644 --- a/src/librustdoc/extract.rs +++ b/src/librustdoc/extract.rs @@ -101,8 +101,8 @@ fn moddoc_from_mod( )) } ast::item_static(*) => { - Some(doc::ConstTag( - constdoc_from_const(ItemDoc) + Some(doc::StaticTag( + staticdoc_from_static(ItemDoc) )) } ast::item_enum(enum_definition, _) => { @@ -165,7 +165,7 @@ fn fndoc_from_fn(itemdoc: doc::ItemDoc) -> doc::FnDoc { } } -fn constdoc_from_const(itemdoc: doc::ItemDoc) -> doc::ConstDoc { +fn staticdoc_from_static(itemdoc: doc::ItemDoc) -> doc::StaticDoc { doc::SimpleItemDoc { item: itemdoc, sig: None @@ -356,10 +356,10 @@ mod test { } #[test] - fn should_extract_const_name_and_id() { + fn should_extract_static_name_and_id() { let doc = mk_doc(@"static a: int = 0;"); - assert!(doc.cratemod().consts()[0].id() != 0); - assert!(doc.cratemod().consts()[0].name_() == ~"a"); + assert!(doc.cratemod().statics()[0].id() != 0); + assert!(doc.cratemod().statics()[0].name_() == ~"a"); } #[test] diff --git a/src/librustdoc/fold.rs b/src/librustdoc/fold.rs index ad0dabdc3a4..589232f6e2f 100644 --- a/src/librustdoc/fold.rs +++ b/src/librustdoc/fold.rs @@ -21,7 +21,7 @@ pub struct Fold { fold_mod: FoldMod, fold_nmod: FoldNmod, fold_fn: FoldFn, - fold_const: FoldConst, + fold_static: FoldStatic, fold_enum: FoldEnum, fold_trait: FoldTrait, fold_impl: FoldImpl, @@ -39,7 +39,7 @@ impl Clone for Fold { fold_mod: self.fold_mod, fold_nmod: self.fold_nmod, fold_fn: self.fold_fn, - fold_const: self.fold_const, + fold_static: self.fold_static, fold_enum: self.fold_enum, fold_trait: self.fold_trait, fold_impl: self.fold_impl, @@ -55,7 +55,7 @@ type FoldItem = @fn(fold: &Fold, doc: doc::ItemDoc) -> doc::ItemDoc; type FoldMod = @fn(fold: &Fold, doc: doc::ModDoc) -> doc::ModDoc; type FoldNmod = @fn(fold: &Fold, doc: doc::NmodDoc) -> doc::NmodDoc; type FoldFn = @fn(fold: &Fold, doc: doc::FnDoc) -> doc::FnDoc; -type FoldConst = @fn(fold: &Fold, doc: doc::ConstDoc) -> doc::ConstDoc; +type FoldStatic = @fn(fold: &Fold, doc: doc::StaticDoc) -> doc::StaticDoc; type FoldEnum = @fn(fold: &Fold, doc: doc::EnumDoc) -> doc::EnumDoc; type FoldTrait = @fn(fold: &Fold, doc: doc::TraitDoc) -> doc::TraitDoc; type FoldImpl = @fn(fold: &Fold, doc: doc::ImplDoc) -> doc::ImplDoc; @@ -73,7 +73,7 @@ fn mk_fold( fold_mod: FoldMod, fold_nmod: FoldNmod, fold_fn: FoldFn, - fold_const: FoldConst, + fold_static: FoldStatic, fold_enum: FoldEnum, fold_trait: FoldTrait, fold_impl: FoldImpl, @@ -88,7 +88,7 @@ fn mk_fold( fold_mod: fold_mod, fold_nmod: fold_nmod, fold_fn: fold_fn, - fold_const: fold_const, + fold_static: fold_static, fold_enum: fold_enum, fold_trait: fold_trait, fold_impl: fold_impl, @@ -106,7 +106,7 @@ pub fn default_any_fold(ctxt: T) -> Fold { |f, d| default_any_fold_mod(f, d), |f, d| default_any_fold_nmod(f, d), |f, d| default_seq_fold_fn(f, d), - |f, d| default_seq_fold_const(f, d), + |f, d| default_seq_fold_static(f, d), |f, d| default_seq_fold_enum(f, d), |f, d| default_seq_fold_trait(f, d), |f, d| default_seq_fold_impl(f, d), @@ -124,7 +124,7 @@ pub fn default_seq_fold(ctxt: T) -> Fold { |f, d| default_seq_fold_mod(f, d), |f, d| default_seq_fold_nmod(f, d), |f, d| default_seq_fold_fn(f, d), - |f, d| default_seq_fold_const(f, d), + |f, d| default_seq_fold_static(f, d), |f, d| default_seq_fold_enum(f, d), |f, d| default_seq_fold_trait(f, d), |f, d| default_seq_fold_impl(f, d), @@ -142,7 +142,7 @@ pub fn default_par_fold(ctxt: T) -> Fold { |f, d| default_par_fold_mod(f, d), |f, d| default_par_fold_nmod(f, d), |f, d| default_seq_fold_fn(f, d), - |f, d| default_seq_fold_const(f, d), + |f, d| default_seq_fold_static(f, d), |f, d| default_seq_fold_enum(f, d), |f, d| default_seq_fold_trait(f, d), |f, d| default_seq_fold_impl(f, d), @@ -272,8 +272,8 @@ pub fn fold_ItemTag(fold: &Fold, doc: doc::ItemTag) -> doc::ItemTag { doc::FnTag(FnDoc) => { doc::FnTag((fold.fold_fn)(fold, FnDoc)) } - doc::ConstTag(ConstDoc) => { - doc::ConstTag((fold.fold_const)(fold, ConstDoc)) + doc::StaticTag(StaticDoc) => { + doc::StaticTag((fold.fold_static)(fold, StaticDoc)) } doc::EnumTag(EnumDoc) => { doc::EnumTag((fold.fold_enum)(fold, EnumDoc)) @@ -303,10 +303,10 @@ pub fn default_seq_fold_fn( } } -pub fn default_seq_fold_const( +pub fn default_seq_fold_static( fold: &Fold, - doc: doc::ConstDoc -) -> doc::ConstDoc { + doc: doc::StaticDoc +) -> doc::StaticDoc { doc::SimpleItemDoc { item: (fold.fold_item)(fold, doc.item.clone()), .. doc @@ -374,7 +374,7 @@ fn default_fold_should_produce_same_doc() { } #[test] -fn default_fold_should_produce_same_consts() { +fn default_fold_should_produce_same_statics() { let source = @"static a: int = 0;"; let ast = parse::from_str(source); let doc = extract::extract(ast, ~""); diff --git a/src/librustdoc/markdown_pass.rs b/src/librustdoc/markdown_pass.rs index beebe71faae..7d07b4864f5 100644 --- a/src/librustdoc/markdown_pass.rs +++ b/src/librustdoc/markdown_pass.rs @@ -321,7 +321,7 @@ fn write_item_(ctxt: &Ctxt, doc: doc::ItemTag, write_header: bool) { doc::ModTag(ModDoc) => write_mod(ctxt, ModDoc), doc::NmodTag(nModDoc) => write_nmod(ctxt, nModDoc), doc::FnTag(FnDoc) => write_fn(ctxt, FnDoc), - doc::ConstTag(ConstDoc) => write_const(ctxt, ConstDoc), + doc::StaticTag(StaticDoc) => write_static(ctxt, StaticDoc), doc::EnumTag(EnumDoc) => write_enum(ctxt, EnumDoc), doc::TraitTag(TraitDoc) => write_trait(ctxt, TraitDoc), doc::ImplTag(ImplDoc) => write_impl(ctxt, ImplDoc), @@ -409,9 +409,9 @@ fn code_block(s: ~str) -> ~str { ~~~", s) } -fn write_const( +fn write_static( ctxt: &Ctxt, - doc: doc::ConstDoc + doc: doc::StaticDoc ) { write_sig(ctxt, doc.sig.clone()); write_common(ctxt, doc.desc(), doc.sections()); @@ -775,13 +775,13 @@ mod test { } #[test] - fn should_write_const_header() { + fn should_write_static_header() { let markdown = render(~"static a: bool = true;"); assert!(markdown.contains("## Static `a`\n\n")); } #[test] - fn should_write_const_description() { + fn should_write_static_description() { let markdown = render( ~"#[doc = \"b\"]\ static a: bool = true;"); diff --git a/src/librustdoc/sort_item_type_pass.rs b/src/librustdoc/sort_item_type_pass.rs index 366cc83df27..ba8f37601fd 100644 --- a/src/librustdoc/sort_item_type_pass.rs +++ b/src/librustdoc/sort_item_type_pass.rs @@ -18,7 +18,7 @@ pub fn mk_pass() -> Pass { fn by_score(item1: &doc::ItemTag, item2: &doc::ItemTag) -> bool { fn score(item: &doc::ItemTag) -> int { match *item { - doc::ConstTag(_) => 0, + doc::StaticTag(_) => 0, doc::TyTag(_) => 1, doc::EnumTag(_) => 2, doc::StructTag(_) => 3, @@ -43,7 +43,7 @@ fn test() { let source = ~"mod imod { } \ - static iconst: int = 0; \ + static istatic: int = 0; \ fn ifn() { } \ enum ienum { ivar } \ trait itrait { fn a(); } \ @@ -54,7 +54,7 @@ fn test() { let doc = extract::from_srv(srv.clone(), ~""); let doc = (mk_pass().f)(srv.clone(), doc); // hidden __std_macros module at the start. - assert_eq!(doc.cratemod().items[0].name_(), ~"iconst"); + assert_eq!(doc.cratemod().items[0].name_(), ~"istatic"); assert_eq!(doc.cratemod().items[1].name_(), ~"itype"); assert_eq!(doc.cratemod().items[2].name_(), ~"ienum"); assert_eq!(doc.cratemod().items[3].name_(), ~"istruct"); diff --git a/src/librustdoc/tystr_pass.rs b/src/librustdoc/tystr_pass.rs index 0d7ec34243d..196c7e892a8 100644 --- a/src/librustdoc/tystr_pass.rs +++ b/src/librustdoc/tystr_pass.rs @@ -39,7 +39,7 @@ pub fn run( let fold = Fold { ctxt: srv.clone(), fold_fn: fold_fn, - fold_const: fold_const, + fold_static: fold_static, fold_enum: fold_enum, fold_trait: fold_trait, fold_impl: fold_impl, @@ -93,10 +93,10 @@ fn get_fn_sig(srv: astsrv::Srv, fn_id: doc::AstId) -> Option<~str> { } } -fn fold_const( +fn fold_static( fold: &fold::Fold, - doc: doc::ConstDoc -) -> doc::ConstDoc { + doc: doc::StaticDoc +) -> doc::StaticDoc { let srv = fold.ctxt.clone(); doc::SimpleItemDoc { @@ -109,7 +109,7 @@ fn fold_const( }, _) => { pprust::ty_to_str(ty, extract::interner()) } - _ => fail!("fold_const: id not bound to a const item") + _ => fail!("fold_static: id not bound to a static item") } }}), .. doc @@ -384,9 +384,9 @@ mod test { } #[test] - fn should_add_const_types() { + fn should_add_static_types() { let doc = mk_doc(~"static a: bool = true;"); - assert!(doc.cratemod().consts()[0].sig == Some(~"bool")); + assert!(doc.cratemod().statics()[0].sig == Some(~"bool")); } #[test] From 3db9dc1dfd8038862b06b712ece75fd7d17339af Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Tue, 6 Aug 2013 22:13:26 +0200 Subject: [PATCH 15/29] Document rand module with more emphasis on cryptographic security --- src/libstd/rand.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/libstd/rand.rs b/src/libstd/rand.rs index 4ef524d7715..4408e5e1f27 100644 --- a/src/libstd/rand.rs +++ b/src/libstd/rand.rs @@ -610,6 +610,11 @@ impl RngUtil for R { } /// Create a random number generator with a default algorithm and seed. +/// +/// It returns the cryptographically-safest `Rng` algorithm currently +/// available in Rust. If you require a specifically seeded `Rng` for +/// consistency over time you should pick one algorithm and create the +/// `Rng` yourself. pub fn rng() -> IsaacRng { IsaacRng::new() } @@ -619,6 +624,8 @@ static RAND_SIZE: u32 = 1 << RAND_SIZE_LEN; /// A random number generator that uses the [ISAAC /// algorithm](http://en.wikipedia.org/wiki/ISAAC_%28cipher%29). +/// +/// The ISAAC algorithm is suitable for cryptographic purposes. pub struct IsaacRng { priv cnt: u32, priv rsl: [u32, .. RAND_SIZE], @@ -794,8 +801,11 @@ impl Rng for IsaacRng { } /// An [Xorshift random number -/// generator](http://en.wikipedia.org/wiki/Xorshift). Not suitable for -/// cryptographic purposes. +/// generator](http://en.wikipedia.org/wiki/Xorshift). +/// +/// The Xorshift algorithm is not suitable for cryptographic purposes +/// but is very fast. If you do not know for sure that it fits your +/// requirements, use a more secure one such as `IsaacRng`. pub struct XorShiftRng { priv x: u32, priv y: u32, From 403c52d2ae1a59dea1a3b04ad794a66bd687d067 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Tue, 6 Aug 2013 22:14:32 +0200 Subject: [PATCH 16/29] Add weak_rng to get a random algo that puts more emphasis on speed than security --- src/libstd/rand.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/libstd/rand.rs b/src/libstd/rand.rs index 4408e5e1f27..5f8fa9fddbc 100644 --- a/src/libstd/rand.rs +++ b/src/libstd/rand.rs @@ -619,6 +619,16 @@ pub fn rng() -> IsaacRng { IsaacRng::new() } +/// Create a weak random number generator with a default algorithm and seed. +/// +/// It returns the fatest `Rng` algorithm currently available in Rust without +/// consideration for cryptography or security. If you require a specifically +/// seeded `Rng` for consistency over time you should pick one algorithm and +/// create the `Rng` yourself. +pub fn weak_rng() -> XorShiftRng { + XorShiftRng::new() +} + static RAND_SIZE_LEN: u32 = 8; static RAND_SIZE: u32 = 1 << RAND_SIZE_LEN; From 1b103912eaacef82dfee940a3c3e8ecb693417bc Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 5 Aug 2013 19:16:29 -0700 Subject: [PATCH 17/29] Add some documentation about globals in ffi docs --- doc/tutorial-ffi.md | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/doc/tutorial-ffi.md b/doc/tutorial-ffi.md index 047b57e56a6..d1aa793e5fc 100644 --- a/doc/tutorial-ffi.md +++ b/doc/tutorial-ffi.md @@ -228,6 +228,48 @@ unsafe fn kaboom(ptr: *int) -> int { *ptr } This function can only be called from an `unsafe` block or another `unsafe` function. +# Accessing foreign globals + +Foreign APIs often export a global variable which could do something like track +global state. In order to access these variables, you declare them in `extern` +blocks with the `static` keyword: + +~~~{.xfail-test} +use std::libc; + +#[link_args = "-lreadline"] +extern { + static rl_readline_version: libc::c_int; +} + +fn main() { + println(fmt!("You have readline version %d installed.", + rl_readline_version as int)); +} +~~~ + +Alternatively, you may need to alter global state provided by a foreign +interface. To do this, statics can be declared with `mut` so rust can mutate +them. + +~~~{.xfail-test} +use std::libc; +use std::ptr; + +#[link_args = "-lreadline"] +extern { + static mut rl_prompt: *libc::c_char; +} + +fn main() { + do "[my-awesome-shell] $".as_c_str |buf| { + unsafe { rl_prompt = buf; } + // get a line, process it + unsafe { rl_prompt = ptr::null(); } + } +} +~~~ + # Foreign calling conventions Most foreign code exposes a C ABI, and Rust uses the platform's C calling convention by default when From a185343fc42646b84db32391096e096cb1acba46 Mon Sep 17 00:00:00 2001 From: Do Nhat Minh Date: Tue, 6 Aug 2013 11:04:58 +0800 Subject: [PATCH 18/29] misc help message fix --- src/librustc/rustc.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/librustc/rustc.rs b/src/librustc/rustc.rs index 222433787f0..bf9808c1ae4 100644 --- a/src/librustc/rustc.rs +++ b/src/librustc/rustc.rs @@ -136,7 +136,7 @@ Additional help: pub fn describe_warnings() { use extra::sort::Sort; - printfln!(" + println(" Available lint options: -W Warn about -A Allow @@ -157,7 +157,7 @@ Available lint options: fn padded(max: uint, s: &str) -> ~str { str::from_bytes(vec::from_elem(max - s.len(), ' ' as u8)) + s } - printfln!("\nAvailable lint checks:\n"); + println("\nAvailable lint checks:\n"); printfln!(" %s %7.7s %s", padded(max_key, "name"), "default", "meaning"); printfln!(" %s %7.7s %s\n", @@ -173,7 +173,7 @@ Available lint options: } pub fn describe_debug_flags() { - printfln!("\nAvailable debug options:\n"); + println("\nAvailable debug options:\n"); let r = session::debugging_opts_map(); for tuple in r.iter() { match *tuple { From 8460dac909fc10b6bf0216d0123735c283cc1391 Mon Sep 17 00:00:00 2001 From: Huon Wilson Date: Tue, 6 Aug 2013 22:19:33 +1000 Subject: [PATCH 19/29] std: add missing #[inline] annotation to the f64 arithmetic trait impls. --- src/libstd/num/f64.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/libstd/num/f64.rs b/src/libstd/num/f64.rs index c7db60e6fd2..60527905779 100644 --- a/src/libstd/num/f64.rs +++ b/src/libstd/num/f64.rs @@ -278,18 +278,22 @@ impl One for f64 { #[cfg(not(test))] impl Add for f64 { + #[inline] fn add(&self, other: &f64) -> f64 { *self + *other } } #[cfg(not(test))] impl Sub for f64 { + #[inline] fn sub(&self, other: &f64) -> f64 { *self - *other } } #[cfg(not(test))] impl Mul for f64 { + #[inline] fn mul(&self, other: &f64) -> f64 { *self * *other } } #[cfg(not(test))] impl Div for f64 { + #[inline] fn div(&self, other: &f64) -> f64 { *self / *other } } #[cfg(not(test))] From 240f8f03c9da7e574fd0fce0eb72e6ade97628ff Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Tue, 6 Aug 2013 20:31:35 +0100 Subject: [PATCH 20/29] Gedit/gtksourceview language spec: add 'in' keyword --- src/etc/gedit/share/gtksourceview-3.0/language-specs/rust.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/src/etc/gedit/share/gtksourceview-3.0/language-specs/rust.lang b/src/etc/gedit/share/gtksourceview-3.0/language-specs/rust.lang index a6415beab36..b1180098bd2 100644 --- a/src/etc/gedit/share/gtksourceview-3.0/language-specs/rust.lang +++ b/src/etc/gedit/share/gtksourceview-3.0/language-specs/rust.lang @@ -50,6 +50,7 @@ for if impl + in let log loop From 4ab05f91f49b1248aab7d21630cfb38d6dafacfa Mon Sep 17 00:00:00 2001 From: blake2-ppc Date: Tue, 6 Aug 2013 17:27:39 +0200 Subject: [PATCH 21/29] extra: Simplify Eq/Ord in treemap Write the Eq and Ord impls for TreeMap in a more straightforward way using iterator::Zip --- src/libextra/treemap.rs | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/src/libextra/treemap.rs b/src/libextra/treemap.rs index ab7d47255da..2e20752754a 100644 --- a/src/libextra/treemap.rs +++ b/src/libextra/treemap.rs @@ -42,39 +42,23 @@ pub struct TreeMap { impl Eq for TreeMap { fn eq(&self, other: &TreeMap) -> bool { - if self.len() != other.len() { - false - } else { - let mut x = self.iter(); - let mut y = other.iter(); - for _ in range(0u, self.len()) { - if x.next().unwrap() != y.next().unwrap() { - return false - } - } - true - } + self.len() == other.len() && + self.iter().zip(other.iter()).all(|(a, b)| a == b) } - fn ne(&self, other: &TreeMap) -> bool { !self.eq(other) } } // Lexicographical comparison fn lt(a: &TreeMap, b: &TreeMap) -> bool { - let mut x = a.iter(); - let mut y = b.iter(); - - let (a_len, b_len) = (a.len(), b.len()); - for _ in range(0u, num::min(a_len, b_len)) { - let (key_a, value_a) = x.next().unwrap(); - let (key_b, value_b) = y.next().unwrap(); + // the Zip iterator is as long as the shortest of a and b. + for ((key_a, value_a), (key_b, value_b)) in a.iter().zip(b.iter()) { if *key_a < *key_b { return true; } if *key_a > *key_b { return false; } if *value_a < *value_b { return true; } if *value_a > *value_b { return false; } } - a_len < b_len + a.len() < b.len() } impl Ord for TreeMap { From 52b01c50cbf001e383fb20bde313f6e58ee6f601 Mon Sep 17 00:00:00 2001 From: blake2-ppc Date: Tue, 6 Aug 2013 20:17:06 +0200 Subject: [PATCH 22/29] extra: External iterators for TreeSet set operations Write external iterators for Difference, Sym. Difference, Intersection and Union set operations. These iterators are generic insofar that they could work on any ordered sequence iterators, even though they are type specialized to the TreeSetIterator in this case. Looking at the `check` function in the treeset tests, rustc seems unwilling to compile a function resembling:: fn check<'a, T: Iterator<&'a int>>(... ) so the tests for these iterators are still running the legacy loop protocol. --- src/libextra/treemap.rs | 274 +++++++++++++++++++++------------------- 1 file changed, 147 insertions(+), 127 deletions(-) diff --git a/src/libextra/treemap.rs b/src/libextra/treemap.rs index 2e20752754a..051587a74f9 100644 --- a/src/libextra/treemap.rs +++ b/src/libextra/treemap.rs @@ -433,20 +433,7 @@ impl Set for TreeSet { /// Return true if the set has no elements in common with `other`. /// This is equivalent to checking for an empty intersection. fn is_disjoint(&self, other: &TreeSet) -> bool { - let mut x = self.iter(); - let mut y = other.iter(); - let mut a = x.next(); - let mut b = y.next(); - while a.is_some() && b.is_some() { - let a1 = a.unwrap(); - let b1 = b.unwrap(); - match a1.cmp(b1) { - Less => a = x.next(), - Greater => b = y.next(), - Equal => return false - } - } - true + self.intersection(other).next().is_none() } /// Return true if the set is a subset of another @@ -526,124 +513,25 @@ impl TreeSet { } /// Visit the values (in-order) representing the difference - pub fn difference(&self, other: &TreeSet, f: &fn(&T) -> bool) -> bool { - let mut x = self.iter(); - let mut y = other.iter(); - - let mut a = x.next(); - let mut b = y.next(); - - while a.is_some() { - if b.is_none() { - return f(a.unwrap()) && x.advance(f); - } - - let a1 = a.unwrap(); - let b1 = b.unwrap(); - - let cmp = a1.cmp(b1); - - if cmp == Less { - if !f(a1) { return false; } - a = x.next(); - } else { - if cmp == Equal { a = x.next() } - b = y.next(); - } - } - return true; + pub fn difference<'a>(&'a self, other: &'a TreeSet) -> Difference<'a, T> { + Difference{a: Focus::new(self.iter()), b: Focus::new(other.iter())} } /// Visit the values (in-order) representing the symmetric difference - pub fn symmetric_difference(&self, other: &TreeSet, - f: &fn(&T) -> bool) -> bool { - let mut x = self.iter(); - let mut y = other.iter(); - - let mut a = x.next(); - let mut b = y.next(); - - while a.is_some() { - if b.is_none() { - return f(a.unwrap()) && x.advance(f); - } - - let a1 = a.unwrap(); - let b1 = b.unwrap(); - - let cmp = a1.cmp(b1); - - if cmp == Less { - if !f(a1) { return false; } - a = x.next(); - } else { - if cmp == Greater { - if !f(b1) { return false; } - } else { - a = x.next(); - } - b = y.next(); - } - } - b.iter().advance(|&x| f(x)) && y.advance(f) + pub fn symmetric_difference<'a>(&'a self, other: &'a TreeSet) + -> SymDifference<'a, T> { + SymDifference{a: Focus::new(self.iter()), b: Focus::new(other.iter())} } /// Visit the values (in-order) representing the intersection - pub fn intersection(&self, other: &TreeSet, f: &fn(&T) -> bool) -> bool { - let mut x = self.iter(); - let mut y = other.iter(); - - let mut a = x.next(); - let mut b = y.next(); - - while a.is_some() && b.is_some() { - let a1 = a.unwrap(); - let b1 = b.unwrap(); - - let cmp = a1.cmp(b1); - - if cmp == Less { - a = x.next(); - } else { - if cmp == Equal { - if !f(a1) { return false } - } - b = y.next(); - } - } - return true; + pub fn intersection<'a>(&'a self, other: &'a TreeSet) + -> Intersection<'a, T> { + Intersection{a: Focus::new(self.iter()), b: Focus::new(other.iter())} } /// Visit the values (in-order) representing the union - pub fn union(&self, other: &TreeSet, f: &fn(&T) -> bool) -> bool { - let mut x = self.iter(); - let mut y = other.iter(); - - let mut a = x.next(); - let mut b = y.next(); - - while a.is_some() { - if b.is_none() { - return f(a.unwrap()) && x.advance(f); - } - - let a1 = a.unwrap(); - let b1 = b.unwrap(); - - let cmp = a1.cmp(b1); - - if cmp == Greater { - if !f(b1) { return false; } - b = y.next(); - } else { - if !f(a1) { return false; } - if cmp == Equal { - b = y.next(); - } - a = x.next(); - } - } - b.iter().advance(|&x| f(x)) && y.advance(f) + pub fn union<'a>(&'a self, other: &'a TreeSet) -> Union<'a, T> { + Union{a: Focus::new(self.iter()), b: Focus::new(other.iter())} } } @@ -652,6 +540,138 @@ pub struct TreeSetIterator<'self, T> { priv iter: TreeMapIterator<'self, T, ()> } +// Encapsulate an iterator and hold its latest value until stepped forward +struct Focus { + priv iter: T, + priv focus: Option, +} + +impl> Focus { + fn new(mut it: T) -> Focus { + Focus{focus: it.next(), iter: it} + } + fn step(&mut self) { + self.focus = self.iter.next() + } +} + +/// Lazy iterator producing elements in the set difference (in-order) +pub struct Difference<'self, T> { + priv a: Focus<&'self T, TreeSetIterator<'self, T>>, + priv b: Focus<&'self T, TreeSetIterator<'self, T>>, +} + +/// Lazy iterator producing elements in the set symmetric difference (in-order) +pub struct SymDifference<'self, T> { + priv a: Focus<&'self T, TreeSetIterator<'self, T>>, + priv b: Focus<&'self T, TreeSetIterator<'self, T>>, +} + +/// Lazy iterator producing elements in the set intersection (in-order) +pub struct Intersection<'self, T> { + priv a: Focus<&'self T, TreeSetIterator<'self, T>>, + priv b: Focus<&'self T, TreeSetIterator<'self, T>>, +} + +/// Lazy iterator producing elements in the set intersection (in-order) +pub struct Union<'self, T> { + priv a: Focus<&'self T, TreeSetIterator<'self, T>>, + priv b: Focus<&'self T, TreeSetIterator<'self, T>>, +} + +impl<'self, T: TotalOrd> Iterator<&'self T> for Difference<'self, T> { + fn next(&mut self) -> Option<&'self T> { + loop { + match (self.a.focus, self.b.focus) { + (None , _ ) => return None, + (ret , None ) => { self.a.step(); return ret }, + (Some(a1), Some(b1)) => { + let cmp = a1.cmp(b1); + if cmp == Less { + self.a.step(); + return Some(a1); + } else { + if cmp == Equal { self.a.step() } + self.b.step(); + } + } + } + } + } +} + +impl<'self, T: TotalOrd> Iterator<&'self T> for SymDifference<'self, T> { + fn next(&mut self) -> Option<&'self T> { + loop { + match (self.a.focus, self.b.focus) { + (ret , None ) => { self.a.step(); return ret }, + (None , ret ) => { self.b.step(); return ret }, + (Some(a1), Some(b1)) => { + let cmp = a1.cmp(b1); + if cmp == Less { + self.a.step(); + return Some(a1); + } else { + self.b.step(); + if cmp == Greater { + return Some(b1); + } else { + self.a.step(); + } + } + } + } + } + } +} + +impl<'self, T: TotalOrd> Iterator<&'self T> for Intersection<'self, T> { + fn next(&mut self) -> Option<&'self T> { + loop { + match (self.a.focus, self.b.focus) { + (None , _ ) => return None, + (_ , None ) => return None, + (Some(a1), Some(b1)) => { + let cmp = a1.cmp(b1); + if cmp == Less { + self.a.step(); + } else { + self.b.step(); + if cmp == Equal { + return Some(a1); + } + } + }, + } + } + } +} + +impl<'self, T: TotalOrd> Iterator<&'self T> for Union<'self, T> { + fn next(&mut self) -> Option<&'self T> { + loop { + match (self.a.focus, self.b.focus) { + (ret , None) => { self.a.step(); return ret }, + (None , ret ) => { self.b.step(); return ret }, + (Some(a1), Some(b1)) => { + let cmp = a1.cmp(b1); + if cmp == Greater { + self.b.step(); + return Some(b1); + } else { + self.a.step(); + if cmp == Equal { + self.b.step(); + } + return Some(a1); + } + } + } + } + } +} + + // Nodes keep track of their level in the tree, starting at 1 in the // leaves and with a red child sharing the level of the parent. #[deriving(Clone)] @@ -1426,7 +1446,7 @@ mod test_set { #[test] fn test_intersection() { fn check_intersection(a: &[int], b: &[int], expected: &[int]) { - check(a, b, expected, |x, y, z| x.intersection(y, z)) + check(a, b, expected, |x, y, f| x.intersection(y).advance(f)) } check_intersection([], [], []); @@ -1442,7 +1462,7 @@ mod test_set { #[test] fn test_difference() { fn check_difference(a: &[int], b: &[int], expected: &[int]) { - check(a, b, expected, |x, y, z| x.difference(y, z)) + check(a, b, expected, |x, y, f| x.difference(y).advance(f)) } check_difference([], [], []); @@ -1460,7 +1480,7 @@ mod test_set { fn test_symmetric_difference() { fn check_symmetric_difference(a: &[int], b: &[int], expected: &[int]) { - check(a, b, expected, |x, y, z| x.symmetric_difference(y, z)) + check(a, b, expected, |x, y, f| x.symmetric_difference(y).advance(f)) } check_symmetric_difference([], [], []); @@ -1475,7 +1495,7 @@ mod test_set { fn test_union() { fn check_union(a: &[int], b: &[int], expected: &[int]) { - check(a, b, expected, |x, y, z| x.union(y, z)) + check(a, b, expected, |x, y, f| x.union(y).advance(f)) } check_union([], [], []); From 7afface3fffc09e8872569199ba902cf8a3170cb Mon Sep 17 00:00:00 2001 From: blake2-ppc Date: Tue, 6 Aug 2013 21:57:46 +0200 Subject: [PATCH 23/29] extra: Implement .rev_iter() in treemap Implement reverse iterators for TreeMap and TreeSet, that produce the keys in backward order. --- src/libextra/treemap.rs | 81 ++++++++++++++++++++++++++++++----------- 1 file changed, 60 insertions(+), 21 deletions(-) diff --git a/src/libextra/treemap.rs b/src/libextra/treemap.rs index 051587a74f9..989f7a419bb 100644 --- a/src/libextra/treemap.rs +++ b/src/libextra/treemap.rs @@ -13,7 +13,6 @@ //! `TotalOrd`. -use std::num; use std::util::{swap, replace}; use std::iterator::{FromIterator, Extendable}; @@ -152,7 +151,7 @@ impl TreeMap { /// Visit all key-value pairs in reverse order pub fn each_reverse<'a>(&'a self, f: &fn(&'a K, &'a V) -> bool) -> bool { - each_reverse(&self.root, f) + self.rev_iter().advance(|(k,v)| f(k, v)) } /// Visit all keys in reverse order @@ -176,6 +175,12 @@ impl TreeMap { } } + /// Get a lazy reverse iterator over the key-value pairs in the map. + /// Requires that it be frozen (immutable). + pub fn rev_iter<'a>(&'a self) -> TreeMapRevIterator<'a, K, V> { + TreeMapRevIterator{iter: self.iter()} + } + /// Get a lazy iterator that should be initialized using /// `iter_traverse_left`/`iter_traverse_right`/`iter_traverse_complete`. fn iter_for_traversal<'a>(&'a self) -> TreeMapIterator<'a, K, V> { @@ -254,20 +259,18 @@ pub struct TreeMapIterator<'self, K, V> { priv remaining_max: uint } -impl<'self, K, V> Iterator<(&'self K, &'self V)> for TreeMapIterator<'self, K, V> { - /// Advance the iterator to the next node (in order) and return a - /// tuple with a reference to the key and value. If there are no - /// more nodes, return `None`. - fn next(&mut self) -> Option<(&'self K, &'self V)> { +impl<'self, K, V> TreeMapIterator<'self, K, V> { + #[inline(always)] + fn next_(&mut self, forward: bool) -> Option<(&'self K, &'self V)> { while !self.stack.is_empty() || self.node.is_some() { match *self.node { Some(ref x) => { self.stack.push(x); - self.node = &x.left; + self.node = if forward { &x.left } else { &x.right }; } None => { let res = self.stack.pop(); - self.node = &res.right; + self.node = if forward { &res.right } else { &res.left }; self.remaining_max -= 1; if self.remaining_min > 0 { self.remaining_min -= 1; @@ -278,6 +281,15 @@ impl<'self, K, V> Iterator<(&'self K, &'self V)> for TreeMapIterator<'self, K, V } None } +} + +impl<'self, K, V> Iterator<(&'self K, &'self V)> for TreeMapIterator<'self, K, V> { + /// Advance the iterator to the next node (in order) and return a + /// tuple with a reference to the key and value. If there are no + /// more nodes, return `None`. + fn next(&mut self) -> Option<(&'self K, &'self V)> { + self.next_(true) + } #[inline] fn size_hint(&self) -> (uint, Option) { @@ -285,6 +297,25 @@ impl<'self, K, V> Iterator<(&'self K, &'self V)> for TreeMapIterator<'self, K, V } } +/// Lazy backward iterator over a map +pub struct TreeMapRevIterator<'self, K, V> { + priv iter: TreeMapIterator<'self, K, V>, +} + +impl<'self, K, V> Iterator<(&'self K, &'self V)> for TreeMapRevIterator<'self, K, V> { + /// Advance the iterator to the next node (in order) and return a + /// tuple with a reference to the key and value. If there are no + /// more nodes, return `None`. + fn next(&mut self) -> Option<(&'self K, &'self V)> { + self.iter.next_(false) + } + + #[inline] + fn size_hint(&self) -> (uint, Option) { + self.iter.size_hint() + } +} + /// iter_traverse_left, iter_traverse_right and iter_traverse_complete are used to /// initialize TreeMapIterator pointing to element inside tree structure. /// @@ -382,6 +413,14 @@ impl<'self, T> Iterator<&'self T> for TreeSetIterator<'self, T> { } } +impl<'self, T> Iterator<&'self T> for TreeSetRevIterator<'self, T> { + /// Advance the iterator to the next node (in order). If there are no more nodes, return `None`. + #[inline] + fn next(&mut self) -> Option<&'self T> { + do self.iter.next().map |&(value, _)| { value } + } +} + /// A implementation of the `Set` trait on top of the `TreeMap` container. The /// only requirement is that the type of the elements contained ascribes to the /// `TotalOrd` trait. @@ -492,6 +531,13 @@ impl TreeSet { TreeSetIterator{iter: self.map.iter()} } + /// Get a lazy iterator over the values in the set. + /// Requires that it be frozen (immutable). + #[inline] + pub fn rev_iter<'a>(&'a self) -> TreeSetRevIterator<'a, T> { + TreeSetRevIterator{iter: self.map.rev_iter()} + } + /// Get a lazy iterator pointing to the first value not less than `v` (greater or equal). /// If all elements in the set are less than `v` empty iterator is returned. #[inline] @@ -540,6 +586,11 @@ pub struct TreeSetIterator<'self, T> { priv iter: TreeMapIterator<'self, T, ()> } +/// Lazy backward iterator over a set +pub struct TreeSetRevIterator<'self, T> { + priv iter: TreeMapRevIterator<'self, T, ()> +} + // Encapsulate an iterator and hold its latest value until stepped forward struct Focus { priv iter: T, @@ -691,18 +742,6 @@ impl TreeNode { } } -fn each<'r, K: TotalOrd, V>(node: &'r Option<~TreeNode>, - f: &fn(&'r K, &'r V) -> bool) -> bool { - node.iter().advance(|x| each(&x.left, |k,v| f(k,v)) && f(&x.key, &x.value) && - each(&x.right, |k,v| f(k,v))) -} - -fn each_reverse<'r, K: TotalOrd, V>(node: &'r Option<~TreeNode>, - f: &fn(&'r K, &'r V) -> bool) -> bool { - node.iter().advance(|x| each_reverse(&x.right, |k,v| f(k,v)) && f(&x.key, &x.value) && - each_reverse(&x.left, |k,v| f(k,v))) -} - fn mutate_values<'r, K: TotalOrd, V>(node: &'r mut Option<~TreeNode>, f: &fn(&'r K, &'r mut V) -> bool) -> bool { From 898226f39a5fcc4479899e9b90f616eb77d387b7 Mon Sep 17 00:00:00 2001 From: blake2-ppc Date: Tue, 6 Aug 2013 22:53:51 +0200 Subject: [PATCH 24/29] extra: Remove all each_* methods in treemap .each_key(), .each_value() and the other methods are replaced by .iter() and .rev_iter(), and restrictions of those iterators. --- src/libextra/treemap.rs | 45 ++++++----------------------------------- 1 file changed, 6 insertions(+), 39 deletions(-) diff --git a/src/libextra/treemap.rs b/src/libextra/treemap.rs index 989f7a419bb..4d898dfb2b4 100644 --- a/src/libextra/treemap.rs +++ b/src/libextra/treemap.rs @@ -134,36 +134,11 @@ impl TreeMap { /// Create an empty TreeMap pub fn new() -> TreeMap { TreeMap{root: None, length: 0} } - /// Visit all keys in order - pub fn each_key(&self, f: &fn(&K) -> bool) -> bool { - self.iter().advance(|(k, _)| f(k)) - } - - /// Visit all values in order - pub fn each_value<'a>(&'a self, f: &fn(&'a V) -> bool) -> bool { - self.iter().advance(|(_, v)| f(v)) - } - /// Iterate over the map and mutate the contained values pub fn mutate_values(&mut self, f: &fn(&K, &mut V) -> bool) -> bool { mutate_values(&mut self.root, f) } - /// Visit all key-value pairs in reverse order - pub fn each_reverse<'a>(&'a self, f: &fn(&'a K, &'a V) -> bool) -> bool { - self.rev_iter().advance(|(k,v)| f(k, v)) - } - - /// Visit all keys in reverse order - pub fn each_key_reverse(&self, f: &fn(&K) -> bool) -> bool { - self.each_reverse(|k, _| f(k)) - } - - /// Visit all values in reverse order - pub fn each_value_reverse(&self, f: &fn(&V) -> bool) -> bool { - self.each_reverse(|_, v| f(v)) - } - /// Get a lazy iterator over the key-value pairs in the map. /// Requires that it be frozen (immutable). pub fn iter<'a>(&'a self) -> TreeMapIterator<'a, K, V> { @@ -552,12 +527,6 @@ impl TreeSet { TreeSetIterator{iter: self.map.upper_bound_iter(v)} } - /// Visit all values in reverse order - #[inline] - pub fn each_reverse(&self, f: &fn(&T) -> bool) -> bool { - self.map.each_key_reverse(f) - } - /// Visit the values (in-order) representing the difference pub fn difference<'a>(&'a self, other: &'a TreeSet) -> Difference<'a, T> { Difference{a: Focus::new(self.iter()), b: Focus::new(other.iter())} @@ -1172,7 +1141,7 @@ mod test_treemap { } #[test] - fn test_each_reverse() { + fn test_rev_iter() { let mut m = TreeMap::new(); assert!(m.insert(3, 6)); @@ -1182,12 +1151,11 @@ mod test_treemap { assert!(m.insert(1, 2)); let mut n = 4; - do m.each_reverse |k, v| { + for (k, v) in m.rev_iter() { assert_eq!(*k, n); assert_eq!(*v, n * 2); n -= 1; - true - }; + } } #[test] @@ -1448,7 +1416,7 @@ mod test_set { } #[test] - fn test_each_reverse() { + fn test_rev_iter() { let mut m = TreeSet::new(); assert!(m.insert(3)); @@ -1458,11 +1426,10 @@ mod test_set { assert!(m.insert(1)); let mut n = 4; - do m.each_reverse |x| { + for x in m.rev_iter() { assert_eq!(*x, n); n -= 1; - true - }; + } } fn check(a: &[int], b: &[int], expected: &[int], From 8ebdb37fd24435d08451625656cc53ebc814c3fa Mon Sep 17 00:00:00 2001 From: Ben Blum Date: Mon, 5 Aug 2013 19:58:10 -0400 Subject: [PATCH 25/29] fix recv_ready for Port to take &self and not need to return a tuple. Close #8192. --- src/libstd/rt/comm.rs | 29 +++++++++++++++++++++++++---- src/libstd/rt/select.rs | 4 +--- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/src/libstd/rt/comm.rs b/src/libstd/rt/comm.rs index 0cf223f3029..6dc44dd1193 100644 --- a/src/libstd/rt/comm.rs +++ b/src/libstd/rt/comm.rs @@ -508,7 +508,11 @@ impl Peekable for Port { } } -impl Select for Port { +// XXX: Kind of gross. A Port should be selectable so you can make an array +// 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 { #[inline] fn optimistic_check(&mut self) -> bool { do self.next.with_mut_ref |pone| { pone.optimistic_check() } @@ -526,12 +530,29 @@ impl Select for Port { } } -impl SelectPort<(T, Port)> for Port { - fn recv_ready(self) -> Option<(T, Port)> { +impl Select for Port { + #[inline] + fn optimistic_check(&mut self) -> bool { + (&*self).optimistic_check() + } + + #[inline] + fn block_on(&mut self, sched: &mut Scheduler, task: BlockedTask) -> bool { + (&*self).block_on(sched, task) + } + + #[inline] + fn unblock_from(&mut self) -> bool { + (&*self).unblock_from() + } +} + +impl<'self, T> SelectPort for &'self Port { + fn recv_ready(self) -> Option { match self.next.take().recv_ready() { Some(StreamPayload { val, next }) => { self.next.put_back(next); - Some((val, self)) + Some(val) } None => None } diff --git a/src/libstd/rt/select.rs b/src/libstd/rt/select.rs index 006b777b71b..84ce36c3e6b 100644 --- a/src/libstd/rt/select.rs +++ b/src/libstd/rt/select.rs @@ -199,9 +199,7 @@ mod test { // get it back out util::swap(port.get_mut_ref(), &mut ports[index]); // NB. Not recv(), because optimistic_check randomly fails. - let (data, new_port) = port.take_unwrap().recv_ready().unwrap(); - assert!(data == 31337); - port = Some(new_port); + assert!(port.get_ref().recv_ready().unwrap() == 31337); } } } From fb1575bcc4fdcae1be5654d630d2b3ac9ebc9712 Mon Sep 17 00:00:00 2001 From: Ben Blum Date: Mon, 5 Aug 2013 20:14:20 -0400 Subject: [PATCH 26/29] (cleanup) Improve rtabort message for atomic-sleep. --- src/libstd/rt/kill.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libstd/rt/kill.rs b/src/libstd/rt/kill.rs index 789c7531eca..b3e81d4b7b2 100644 --- a/src/libstd/rt/kill.rs +++ b/src/libstd/rt/kill.rs @@ -590,7 +590,8 @@ impl Death { #[inline] pub fn assert_may_sleep(&self) { if self.wont_sleep != 0 { - rtabort!("illegal atomic-sleep: can't deschedule inside atomically()"); + rtabort!("illegal atomic-sleep: attempt to reschedule while \ + using an Exclusive or LittleLock"); } } } From 0627089bba7e1cc8040f41800fff2a5d80896958 Mon Sep 17 00:00:00 2001 From: Corey Richardson Date: Wed, 7 Aug 2013 23:20:06 -0400 Subject: [PATCH 27/29] Fix fallout --- src/test/auxiliary/cci_class_5.rs | 2 +- src/test/compile-fail/issue-3763.rs | 2 +- src/test/compile-fail/issue-3993-3.rs | 4 ++-- src/test/compile-fail/issue-3993.rs | 2 +- src/test/compile-fail/private-impl-method.rs | 2 +- src/test/compile-fail/private-item-simple.rs | 2 +- src/test/compile-fail/private-method.rs | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/test/auxiliary/cci_class_5.rs b/src/test/auxiliary/cci_class_5.rs index 7cdfcf64bb9..5b8bebda924 100644 --- a/src/test/auxiliary/cci_class_5.rs +++ b/src/test/auxiliary/cci_class_5.rs @@ -17,7 +17,7 @@ pub mod kitties { } impl cat { - priv fn nap(&self) {} + fn nap(&self) {} } pub fn cat(in_x : uint, in_y : int) -> cat { diff --git a/src/test/compile-fail/issue-3763.rs b/src/test/compile-fail/issue-3763.rs index 9647d412d2c..7097615b87e 100644 --- a/src/test/compile-fail/issue-3763.rs +++ b/src/test/compile-fail/issue-3763.rs @@ -16,7 +16,7 @@ mod my_mod { MyStruct {priv_field: 4} } impl MyStruct { - priv fn happyfun(&self) {} + fn happyfun(&self) {} } } diff --git a/src/test/compile-fail/issue-3993-3.rs b/src/test/compile-fail/issue-3993-3.rs index ccda6f158ed..cab999f621d 100644 --- a/src/test/compile-fail/issue-3993-3.rs +++ b/src/test/compile-fail/issue-3993-3.rs @@ -12,8 +12,8 @@ use zoo::fly; //~ ERROR failed to resolve import //~^ ERROR unresolved import: found `fly` in `zoo` but it is private mod zoo { - priv type fly = (); - priv fn fly() {} + type fly = (); + fn fly() {} } diff --git a/src/test/compile-fail/issue-3993.rs b/src/test/compile-fail/issue-3993.rs index 450ea023bcb..53a56ad2774 100644 --- a/src/test/compile-fail/issue-3993.rs +++ b/src/test/compile-fail/issue-3993.rs @@ -12,7 +12,7 @@ use zoo::fly; //~ ERROR failed to resolve import //~^ ERROR unresolved import: found `fly` in `zoo` but it is private mod zoo { - priv fn fly() {} + fn fly() {} } diff --git a/src/test/compile-fail/private-impl-method.rs b/src/test/compile-fail/private-impl-method.rs index 26b7d73ab2a..42da53e9890 100644 --- a/src/test/compile-fail/private-impl-method.rs +++ b/src/test/compile-fail/private-impl-method.rs @@ -14,7 +14,7 @@ mod a { } impl Foo { - priv fn foo(&self) {} + fn foo(&self) {} } } diff --git a/src/test/compile-fail/private-item-simple.rs b/src/test/compile-fail/private-item-simple.rs index 8776739db2d..a31d0030f67 100644 --- a/src/test/compile-fail/private-item-simple.rs +++ b/src/test/compile-fail/private-item-simple.rs @@ -9,7 +9,7 @@ // except according to those terms. mod a { - priv fn f() {} + fn f() {} } fn main() { diff --git a/src/test/compile-fail/private-method.rs b/src/test/compile-fail/private-method.rs index 1cde50cc15e..85822765595 100644 --- a/src/test/compile-fail/private-method.rs +++ b/src/test/compile-fail/private-method.rs @@ -18,7 +18,7 @@ mod kitties { } impl cat { - priv fn nap(&self) {} + fn nap(&self) {} } pub fn cat(in_x : uint, in_y : int) -> cat { From 86d581f83bc4a1d788de0c7bf35565665870ca0a Mon Sep 17 00:00:00 2001 From: Corey Richardson Date: Thu, 8 Aug 2013 15:34:59 -0400 Subject: [PATCH 28/29] xfail-fast an aux test --- src/test/run-pass/xcrate-unit-struct.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/run-pass/xcrate-unit-struct.rs b/src/test/run-pass/xcrate-unit-struct.rs index 58676f7cd70..d6522231f65 100644 --- a/src/test/run-pass/xcrate-unit-struct.rs +++ b/src/test/run-pass/xcrate-unit-struct.rs @@ -9,7 +9,7 @@ // except according to those terms. // aux-build:xcrate_unit_struct.rs - +// xfail-fast extern mod xcrate_unit_struct; use std::util; From 878e74e1cedd80a909e06073f8fb677d6ffd895f Mon Sep 17 00:00:00 2001 From: Corey Richardson Date: Thu, 8 Aug 2013 17:02:03 -0400 Subject: [PATCH 29/29] Fix more priv fallout --- doc/tutorial.md | 4 ++-- src/librustdoc/prune_private_pass.rs | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/tutorial.md b/doc/tutorial.md index 6e6b804aa9d..40e276ae04a 100644 --- a/doc/tutorial.md +++ b/doc/tutorial.md @@ -2288,8 +2288,8 @@ pub mod farm { } impl Farm { - priv fn feed_chickens(&self) { ... } - priv fn feed_cows(&self) { ... } + fn feed_chickens(&self) { ... } + fn feed_cows(&self) { ... } pub fn add_chicken(&self, c: Chicken) { ... } } diff --git a/src/librustdoc/prune_private_pass.rs b/src/librustdoc/prune_private_pass.rs index 6f3f91f3c65..3e380732d0f 100644 --- a/src/librustdoc/prune_private_pass.rs +++ b/src/librustdoc/prune_private_pass.rs @@ -202,7 +202,7 @@ mod test { let doc = mk_doc( ~"impl Foo {\ pub fn bar() { }\ - priv fn baz() { }\ + fn baz() { }\ }"); assert_eq!(doc.cratemod().impls()[0].methods.len(), 1); } @@ -212,7 +212,7 @@ mod test { let doc = mk_doc( ~"impl Foo {\ pub fn bar() { }\ - priv fn baz() { }\ + fn baz() { }\ }"); assert_eq!(doc.cratemod().impls()[0].methods.len(), 1); } @@ -232,7 +232,7 @@ mod test { let doc = mk_doc( ~"impl Foo {\ pub fn bar() { }\ - priv fn baz() { }\ + fn baz() { }\ }"); assert_eq!(doc.cratemod().impls()[0].methods.len(), 1); }