Commit Graph

35460 Commits

Author SHA1 Message Date
Alexis Beingessner
20d7a5fc3c Make bitv's APIs match RFC + fixup 2014-12-22 14:11:43 -05:00
Tobias Bucher
24329d7293 Change Extend and FromIterator functionality of BitvSet
Also fix up some tests from last commit.
2014-12-20 09:10:06 -05:00
Tobias Bucher
e84a383307 Add a new invariant to Bitv
The length of the underlying vector must now be exactly as long as it needs to
be.
2014-12-20 09:10:05 -05:00
Josh Stone
3deb97f5d0 bitv: Fix all() for nbits that are multiples of u32::BITS
The old logic would be ok with *either* 0 or all 1s in the last word,
because it didn't compute a proper mask for the case where nbits is an
exact multiple of u32::BITS.

Add mask_for_bits() to compute this properly, and use it in all().  Add
all/none assertions to most of the tests.  Note in particular, the all-zero
bitv in test_32_elements() was incorrectly all()==true before this patch.
2014-12-20 09:10:04 -05:00
Josh Stone
8f194de95d bitv: correct build failures
- Fix typos on Blocks and MutBlocks.
- Use slice_to_mut() for creating blocks_mut().
- Deref the block parameter in get().
- Access nbits separately from mutating set in pop().
2014-12-20 09:10:03 -05:00
Alexis Beingessner
9c5101542d Conventions and cleanup for Bitv and BitvSet
Part of #18424

This commit changes the semantics of `reserve` and `capacity` for Bitv and BitvSet to match conventions. It also introduces the notion of `reserve_index` and `reserve_index_exact` for collections with maximum-index-based capacity semantics.

Deprecates free function constructors in favour of functions on Bitv itself.

Changes `Bitv::pop` to return an Option rather than panicking.

Deprecates and renames several methods in favour of conventions.

Marks several blessed methods as unstable.

This commit also substantially refactors Bitv and BitvSet's implementations. The new implementation is simpler, cleaner, better documented, and more robust against overflows. It also reduces coupling between Bitv and BitvSet. Tests have been seperated into seperate submodules.

Fixes #16958

[breaking-change]
2014-12-20 09:10:02 -05:00
bors
8f51ad2420 auto merge of #19511 : eddyb/rust/no-shadow, r=alexcrichton
r? @erickt
2014-12-20 08:10:23 +00:00
bors
8443b09e36 auto merge of #19995 : eddyb/rust/split-resolve, r=nikomatsakis
r? @nikomatsakis
2014-12-20 05:52:18 +00:00
Eduard Burtescu
b45d30da34 Fix fallout of removing import_shadowing in tests. 2014-12-20 07:49:37 +02:00
Eduard Burtescu
f95e0c21aa Fix more import_shadowing fallout in collections. 2014-12-20 07:49:37 +02:00
Eduard Burtescu
5193d542f6 Fix the fallout of removing feature(import_shadowing). 2014-12-20 07:49:37 +02:00
Eduard Burtescu
948cc666de rustc_resolve: move export recording into its own module. 2014-12-20 07:28:47 +02:00
Eduard Burtescu
1614d92f51 rustc_resolve: move unused import checking into its own module. 2014-12-20 07:28:47 +02:00
Eduard Burtescu
c54fc980f3 Split resolve from rustc::middle into rustc_resolve. 2014-12-20 07:28:47 +02:00
Eduard Burtescu
a74a050c44 rustc: middle: move some types from resolve to privacy. 2014-12-20 07:28:47 +02:00
Eduard Burtescu
5d1257a760 rustc: middle: move TraitItemKind from resolve to def. 2014-12-20 07:28:46 +02:00
Eduard Burtescu
d9504d4a47 rustc: middle: move Export and ExportMap from resolve to def. 2014-12-20 07:28:46 +02:00
Eduard Burtescu
10a862d4f4 rustc: middle: use cheaper Name in resolve::Export instead of String. 2014-12-20 07:25:42 +02:00
Eduard Burtescu
f0276072a3 rustc: middle: move TraitMap from resolve to ty. 2014-12-20 07:25:41 +02:00
Eduard Burtescu
d8f57c3804 rustc: middle: move DefMap from resolve to def. 2014-12-20 07:25:37 +02:00
Eduard Burtescu
fb1d6f24fc middle: resolve: fix inconsistencies around ExportMap and remove the 2 suffix. 2014-12-20 07:11:03 +02:00
Eduard Burtescu
533822207f rustc: don't allow(non_camel_case_types) in resolve. 2014-12-20 07:11:03 +02:00
Eduard Burtescu
d5267d5845 Remove feature(import_shadowing) from all crates. 2014-12-20 06:37:14 +02:00
bors
1c2df5cc3c auto merge of #19640 : aliblong/rust/power_of_two_reform, r=Gankro
The `is_power_of_two()` method of the `UnsignedInt` trait currently returns `true` for `self == 0`. Zero is not a power of two, assuming an integral exponent `k >= 0`. I've therefore moved this functionality to the new method `is_power_of_two_or_zero()` and reformed `is_power_of_two()` to return false for `self == 0`.

To illustrate the usefulness of the existence of both functions, consider `HashMap`. Its capacity must be zero or a power of two; conversely, it also requires a (non-zero) power of two for key and val alignment.

Also, added a small amount of documentation regarding #18604.
2014-12-20 01:12:19 +00:00
Aaron Liblong
f6328b60da Reform power_of_two methods for perf increase & semantic change to consider 0 not a power of 2.
Vec panics when attempting to reserve capacity > int::MAX (uint::MAX / 2).
2014-12-19 18:21:24 -05:00
bors
cbe9fb45bc auto merge of #19463 : kali/rust/master, r=alexcrichton
parse_ty() no longer takes a boolean parameter. quote_ty! implementation has not yet been modified accordingly. 

As a matter of fact, quote_ty! was not covered by tests. One test (called qquotes) references it, but it has been ignored for nearly one year and now need heavy refactoring.

quote_token.rs seemed like a good place to test quote_ty!, many other quote_*! macros were asserted there.
2014-12-19 20:22:17 +00:00
bors
95c2ed31ae auto merge of #19867 : japaric/rust/deriving-copy, r=acrichto
r? @alexcrichton
2014-12-19 16:02:31 +00:00
Jorge Aparicio
f975b10310 windows: remove unused import 2014-12-19 10:51:01 -05:00
Jorge Aparicio
4c6e76b7c8 libtime: use #[deriving(Copy)] 2014-12-19 10:51:01 -05:00
Jorge Aparicio
ce92437769 libtest: use #[deriving(Copy)] 2014-12-19 10:51:01 -05:00
Jorge Aparicio
64234b3541 libterm: use #[deriving(Copy)] 2014-12-19 10:51:01 -05:00
Jorge Aparicio
86f8c127dd libsyntax: use #[deriving(Copy)] 2014-12-19 10:51:00 -05:00
Jorge Aparicio
a77e8a63d5 libstd: use #[deriving(Copy)] 2014-12-19 10:51:00 -05:00
Jorge Aparicio
2df30a47e2 libserialize: use #[deriving(Copy)] 2014-12-19 10:51:00 -05:00
Jorge Aparicio
1d25271e05 librustrt: use #[deriving(Copy)] 2014-12-19 10:51:00 -05:00
Jorge Aparicio
4c007568bf librustdoc: use #[deriving(Copy)] 2014-12-19 10:51:00 -05:00
Jorge Aparicio
fa0383f38d librustc_typeck: use #[deriving(Copy)] 2014-12-19 10:51:00 -05:00
Jorge Aparicio
5e2bca9e86 librustc_trans: use #[deriving(Copy)] 2014-12-19 10:51:00 -05:00
Jorge Aparicio
463475b7fa librustc_llvm: use #[deriving(Copy)] 2014-12-19 10:51:00 -05:00
Jorge Aparicio
db45be2616 librustc_driver: use #[deriving(Copy)] 2014-12-19 10:51:00 -05:00
Jorge Aparicio
392ea799b8 librustc_borrowck: use #[deriving(Copy)] 2014-12-19 10:51:00 -05:00
Jorge Aparicio
e64a0072d6 librustc: use #[deriving(Copy)] 2014-12-19 10:51:00 -05:00
Jorge Aparicio
f2ef2cda52 libregex: use #[deriving(Copy)] 2014-12-19 10:43:24 -05:00
Jorge Aparicio
fd4a5d9ef1 librbml: use #[deriving(Copy)] 2014-12-19 10:43:24 -05:00
Jorge Aparicio
a18d090c3c librand: use #[deriving(Copy)] 2014-12-19 10:43:24 -05:00
Jorge Aparicio
e0a88a78da liblog: use #[deriving(Copy)] 2014-12-19 10:43:24 -05:00
Jorge Aparicio
c407785ac0 libgetopts: use #[deriving(Copy)] 2014-12-19 10:43:24 -05:00
Jorge Aparicio
4c62c76ef9 libfmt_macros: use #[deriving(Copy)] 2014-12-19 10:43:24 -05:00
Jorge Aparicio
30cefcbdfd libcore: use #[deriving(Copy)] 2014-12-19 10:43:23 -05:00
Jorge Aparicio
c32a48293a libcollections: use #[deriving(Copy)] 2014-12-19 10:43:23 -05:00