Commit Graph

31890 Commits

Author SHA1 Message Date
Jorge Aparicio
b5537fa838 libtime: convert Timespec binops to by value 2014-12-13 20:15:39 -05:00
Jorge Aparicio
9126a24e42 libstd: convert Duration binops to by value 2014-12-13 20:15:39 -05:00
Jorge Aparicio
32168faf9f libstd: convert BitFlags binops to by value 2014-12-13 20:15:39 -05:00
Jorge Aparicio
baf79d4a11 libcollections: make EnumSet binops by value 2014-12-13 20:15:39 -05:00
Jorge Aparicio
076e932fd5 libcollections: String + &str 2014-12-13 20:15:39 -05:00
Jorge Aparicio
dbc7e17cce libcollections: Vec<T> + &[T] 2014-12-13 20:15:39 -05:00
Jorge Aparicio
65d3a40c07 libcore: fix move semantics fallout 2014-12-13 20:15:38 -05:00
Jorge Aparicio
c73259a269 libcore: convert binop traits to by value 2014-12-13 20:15:38 -05:00
Jorge Aparicio
227435a11e Tell regionck which binops are by value 2014-12-13 20:15:38 -05:00
Jorge Aparicio
5038f5a70c Tell expr_use_visitor which binops are by value 2014-12-13 20:15:38 -05:00
Jorge Aparicio
f64e52a7f7 Tell trans which binops are by value 2014-12-13 20:15:38 -05:00
Jorge Aparicio
c3a6d2860c Tell typeck which binops are by value 2014-12-13 20:15:38 -05:00
Jorge Aparicio
14c0a708cc syntax/ast_util: add is_by_value_binop() 2014-12-13 20:11:13 -05:00
bors
f07526a999 auto merge of #19669 : alfie/rust/master, r=sanxiyn 2014-12-14 01:07:31 +00:00
Jorge Aparicio
029789b98c Get rid of all the remaining uses of refN/valN/mutN/TupleN 2014-12-13 20:04:41 -05:00
Jorge Aparicio
17a9c2764f libcore: allow deprecated valN methods on doc tests 2014-12-13 20:04:41 -05:00
Jorge Aparicio
8720174bf2 libgraphviz: use tuple indexing 2014-12-13 20:04:41 -05:00
Jorge Aparicio
778be74cbb libcoretest: use tuple indexing 2014-12-13 20:04:41 -05:00
Jorge Aparicio
e792338318 librustdoc: use tuple indexing 2014-12-13 20:04:41 -05:00
Jorge Aparicio
0c5d22c9cd librustc_trans: use tuple indexing 2014-12-13 20:04:41 -05:00
Jorge Aparicio
821b836634 librustc: use tuple indexing 2014-12-13 20:04:41 -05:00
Jorge Aparicio
c434954b27 libsyntax: use tuple indexing 2014-12-13 20:04:40 -05:00
Jorge Aparicio
4fd6a99851 libregex: use tuple indexing 2014-12-13 20:04:40 -05:00
Jorge Aparicio
fe48a65aaa libstd: use tuple indexing 2014-12-13 20:04:40 -05:00
Jorge Aparicio
4deb27e67a libcollections: use tuple indexing 2014-12-13 20:04:40 -05:00
Jorge Aparicio
2e8963debc libunicode: use tuple indexing 2014-12-13 20:04:40 -05:00
Jorge Aparicio
0c9b6ae6a8 Deprecate the TupleN traits 2014-12-13 20:04:40 -05:00
Jorge Aparicio
b8e0b81dd5 librustc_borrowck: add #![feature(unboxed_closures)] 2014-12-13 17:40:34 -05:00
Alex Crichton
8abe7846d6 Deprecate more in-tree libs for crates.io
This commit deprecates a few more in-tree libs for their crates.io counterparts.
Note that this commit does not make use of the #[deprecated] tag to prevent
warnings from being generated for in-tree usage. Once #[unstable] warnings are
turned on then all external users will be warned to move.

These crates have all been duplicated in rust-lang/$crate repositories so
development can happen independently of the in-tree copies. We can explore at a
later date replacing the in-tree copies with the external copies, but at this
time the libraries have changed very little over the past few months so it's
unlikely for changes to be sent to both repos.

cc #19260
2014-12-13 14:18:44 -08:00
Vadim Chugunov
317d91261b Windows dbghelp strips leading underscores from symbols, so let's accept "ZN...E" form too.
Also, print PC displacement from symbols.
2014-12-13 14:16:53 -08:00
Jorge Aparicio
db8300ce06 libstd: add missing imports 2014-12-13 17:03:48 -05:00
Jorge Aparicio
6f28816f87 Remove some unnecessary move keywords 2014-12-13 17:03:48 -05:00
Jorge Aparicio
745225d905 libtest: use unboxed closures 2014-12-13 17:03:48 -05:00
Jorge Aparicio
015c0fcee5 librustc_driver: use unboxed closures 2014-12-13 17:03:48 -05:00
Jorge Aparicio
521a6e62b1 librustc_typeck: use unboxed closures 2014-12-13 17:03:48 -05:00
Jorge Aparicio
888f24969f librustdoc: use unboxed closures 2014-12-13 17:03:48 -05:00
Jorge Aparicio
0676c3bf03 librustc_trans: use unboxed closures 2014-12-13 17:03:48 -05:00
Jorge Aparicio
0d4d8b9b78 librustc_trans: fix fallout 2014-12-13 17:03:47 -05:00
Jorge Aparicio
46272c18a2 librustc_typeck: fix fallout 2014-12-13 17:03:47 -05:00
Jorge Aparicio
1195708f64 librustc: use unboxed closures 2014-12-13 17:03:47 -05:00
Jorge Aparicio
933e7b4a3e librustc_llvm: use unboxed closures 2014-12-13 17:03:47 -05:00
Jorge Aparicio
3739a2427b librustc_trans: fix fallout 2014-12-13 17:03:47 -05:00
Jorge Aparicio
451eef5c40 librustc_back: use unboxed closures 2014-12-13 17:03:47 -05:00
Jorge Aparicio
d3d707c883 librustc: fix fallout 2014-12-13 17:03:47 -05:00
Jorge Aparicio
0dac05dd62 libsyntax: use unboxed closures 2014-12-13 17:03:47 -05:00
Jorge Aparicio
2160427900 Fix benches 2014-12-13 17:03:47 -05:00
Jorge Aparicio
cdbb3ca9b7 libstd: use unboxed closures 2014-12-13 17:03:47 -05:00
Jorge Aparicio
be53d619f8 librustrt: use unboxed closures 2014-12-13 17:03:47 -05:00
Jorge Aparicio
b44b5da8c2 libregex_macros: use unboxed closures 2014-12-13 17:03:47 -05:00
Jorge Aparicio
879ebce6a4 libcollections: use unboxed closures 2014-12-13 17:03:47 -05:00
Jorge Aparicio
9b075bcf3f libserialize: use unboxed closures 2014-12-13 17:03:47 -05:00
Jorge Aparicio
95d0763707 libregex: use unboxed closures 2014-12-13 17:03:46 -05:00
Jorge Aparicio
1c5aac2b30 libarena: use unboxed closures 2014-12-13 17:03:46 -05:00
Jorge Aparicio
341e7bc08b libregex: fix fallout in doc tests 2014-12-13 17:03:46 -05:00
Jorge Aparicio
61ba334452 libregex: impl Replacer for FnMut(&Captures) -> String implementors 2014-12-13 17:03:46 -05:00
Jorge Aparicio
01d2e46a2d librustc: fix fallout 2014-12-13 17:03:46 -05:00
Jorge Aparicio
594ff51b23 librbml: use unboxed closures in free functions 2014-12-13 17:03:46 -05:00
Jorge Aparicio
807c5e8c8d librbml: fix fallout 2014-12-13 17:03:46 -05:00
Jorge Aparicio
a8aff7e95c libserialize: use unboxed closures 2014-12-13 17:03:46 -05:00
Jorge Aparicio
533a47bd9b librand: use unboxed closures in distributions module 2014-12-13 17:03:46 -05:00
Jorge Aparicio
5d7543b6ba libgraphviz: use unboxed closures in LabelText methods 2014-12-13 17:03:46 -05:00
Jorge Aparicio
04652b57e5 libgetopts: use unboxed closures in each_split_within 2014-12-13 17:03:46 -05:00
Jorge Aparicio
f56f9728e6 libcore: use unboxed closures in slice::raw free functions 2014-12-13 17:03:46 -05:00
Jorge Aparicio
c7b6eb38ff libcore: use unboxed closures in float_to_str_bytes_common 2014-12-13 17:03:46 -05:00
Jorge Aparicio
5579692ce7 libcollections: use unboxed closures in VecMap methods 2014-12-13 17:03:46 -05:00
Jorge Aparicio
683342c3f0 libgraphviz: fix fallout 2014-12-13 17:03:46 -05:00
Jorge Aparicio
a7a065bd98 libcollections: use unboxed closures in [Clone]SliceAllocPrelude methods 2014-12-13 17:03:46 -05:00
Jorge Aparicio
6f19f8d430 libcollections: use unboxed closures in DList methods 2014-12-13 17:03:46 -05:00
Jorge Aparicio
d5c332688c libcollections: use unboxed closures in Vec methods 2014-12-13 17:03:46 -05:00
Jorge Aparicio
0055678f7a libcollections: use unboxed closures in Bitv methods 2014-12-13 17:03:46 -05:00
Jorge Aparicio
0d39fc01bf libcollections: use unboxed closures in TreeMap methods 2014-12-13 17:03:46 -05:00
Jorge Aparicio
02e7389c5d libcore: use unboxed closures in the char module 2014-12-13 17:03:46 -05:00
Jorge Aparicio
1a87fc7c9f libcore: use unboxed closures in Formatter methods 2014-12-13 17:03:46 -05:00
Jorge Aparicio
0b0c3e1d96 libcore: fix fallout in doc tests 2014-12-13 17:03:46 -05:00
Jorge Aparicio
950fbf4e10 librustrt: fix fallout 2014-12-13 17:03:46 -05:00
Jorge Aparicio
8df27d26bd libcoretest: fix fallout 2014-12-13 17:03:45 -05:00
Jorge Aparicio
45860b53e0 Fix run pass test 2014-12-13 17:03:45 -05:00
Jorge Aparicio
40b3617035 libstd: fix fallout 2014-12-13 17:03:45 -05:00
Jorge Aparicio
f18b255bce libcore: use unboxed closures in the finally module 2014-12-13 17:03:45 -05:00
Jorge Aparicio
e2a362f9bb libcore: use unboxed closures in SlicePrelude methods 2014-12-13 17:03:45 -05:00
Jorge Aparicio
6ae9b9e54a libcore: use unboxed closures in the fields of MutSplits 2014-12-13 17:03:45 -05:00
Jorge Aparicio
43cf7b4e45 libstd: fix fallout 2014-12-13 17:03:45 -05:00
Jorge Aparicio
9c7046573b libcore: use unboxed closures in the fields of Splits 2014-12-13 17:03:45 -05:00
Jorge Aparicio
30ea64ea77 libcore: fix fallout in doctests 2014-12-13 17:03:45 -05:00
Jorge Aparicio
47acce498a libcoretest: fix fallout in unit tests 2014-12-13 17:03:45 -05:00
Jorge Aparicio
646083510a libcollections: fix fallout in unit tests 2014-12-13 17:03:45 -05:00
Jorge Aparicio
4d4915aa28 librustdoc: fix fallout 2014-12-13 17:03:45 -05:00
Jorge Aparicio
cc242bcf47 libstd: fix fallout 2014-12-13 17:03:45 -05:00
Jorge Aparicio
50ef207253 libunicode: fix fallout 2014-12-13 17:03:45 -05:00
Jorge Aparicio
d3f5c1397c libcore: impl CharEq for FnMut(char) -> bool implementors 2014-12-13 17:03:45 -05:00
Jorge Aparicio
aa921b6162 libcore: use unboxed closures in ExactSizeIterator methods 2014-12-13 17:03:45 -05:00
Jorge Aparicio
b3cd05642c libcollections: fix unit tests 2014-12-13 17:03:45 -05:00
Jorge Aparicio
10a14d5f04 Fix run-pass tests 2014-12-13 17:03:45 -05:00
Jorge Aparicio
5a9047b9b3 librustc: fix fallout 2014-12-13 17:03:45 -05:00
Jorge Aparicio
fee500d312 libregex: fix fallout 2014-12-13 17:03:45 -05:00
Jorge Aparicio
5e9ca5b255 libcore: use unboxed closures in IteratorExt methods 2014-12-13 17:03:45 -05:00
Jorge Aparicio
216bcfd66b libcore: use unboxed closures in the fields of Unfold 2014-12-13 17:03:45 -05:00
Jorge Aparicio
a50c587242 libcoretest: fix fallout 2014-12-13 17:03:45 -05:00
Jorge Aparicio
7e3493e5e3 libcore: use unboxed closures in the fields of Inspect 2014-12-13 17:03:45 -05:00
Jorge Aparicio
a051ba1dff libcore: use unboxed closures in the fields of FlatMap 2014-12-13 17:03:45 -05:00
Jorge Aparicio
ba480cbf75 libcore: use unboxed closures in the fields of Scan 2014-12-13 17:03:44 -05:00
Jorge Aparicio
e2724cb1d5 libcore: use unboxed closures in the fields of TakeWhile 2014-12-13 17:03:44 -05:00
Jorge Aparicio
0cfdc99c71 libcore: use unboxed closures in the fields of SkipWhile 2014-12-13 17:03:44 -05:00
Jorge Aparicio
ca001e1bd0 librustdoc: fix fallout 2014-12-13 17:03:44 -05:00
Jorge Aparicio
c3fe7105ba libstd: fix fallout 2014-12-13 17:03:44 -05:00
Jorge Aparicio
4f6f6af281 libcollections: fix fallout 2014-12-13 17:03:44 -05:00
Jorge Aparicio
eede5d2bce libcore: use unboxed closures in the fields of FilterMap 2014-12-13 17:03:44 -05:00
Jorge Aparicio
80a04b1aed librustc_trans: fix fallout 2014-12-13 17:03:44 -05:00
Jorge Aparicio
e66ba15764 libunicode: fix fallout 2014-12-13 17:03:44 -05:00
Jorge Aparicio
801ae1333c libcore: use unboxed closures in the fields of Filter 2014-12-13 17:03:44 -05:00
Jorge Aparicio
44b419b820 librustc_trans: fix fallout 2014-12-13 17:03:44 -05:00
Jorge Aparicio
fd06ef24bb librustc: fix fallout 2014-12-13 17:03:44 -05:00
Jorge Aparicio
5e7469cfe1 libsyntax: fix fallout 2014-12-13 17:03:44 -05:00
Jorge Aparicio
d22acb77b2 libstd: fix fallout 2014-12-13 17:03:44 -05:00
Jorge Aparicio
0fcd730373 librustrt: fix fallout 2014-12-13 17:03:44 -05:00
Jorge Aparicio
f91d87e6a0 libcollections: fix fallout 2014-12-13 17:03:44 -05:00
Jorge Aparicio
1646d10edc libcore: use unboxed closures in the fields of Map 2014-12-13 17:03:44 -05:00
Jorge Aparicio
19524f1ed1 libcore: use unboxed closures in Result methods 2014-12-13 17:03:44 -05:00
Jorge Aparicio
135c4ab5fe Fix compile fail tests 2014-12-13 17:03:44 -05:00
Jorge Aparicio
60b0dd533b librustc_trans: fix fallout 2014-12-13 17:03:44 -05:00
Jorge Aparicio
56ecb51ba6 libcore: use unboxed closures in Option methods 2014-12-13 17:03:44 -05:00
bors
567b90ff09 auto merge of #19582 : nikomatsakis/rust/crateification, r=alexcrichton
r? @alexcrichton
2014-12-13 20:02:15 +00:00
bors
2bfb64e525 auto merge of #19627 : steveklabnik/rust/testing_guide, r=cmr 2014-12-13 17:27:15 +00:00
Steve Klabnik
d4ea71dbc1 Revamped testing guide 2014-12-13 12:19:43 -05:00
jbranchaud
1567c94361 Fix a typo in ownership guide, aquire to acquire. 2014-12-13 10:56:19 -06:00
bors
ce05ff5d4b auto merge of #19695 : arthurtw/rust/master, r=steveklabnik 2014-12-13 15:22:16 +00:00
Corey Farwell
3fc6dc95b4 Expansion should explicitly include enum
In preparation for removing the std::cmp::Ordering reexport, this needs
to be done to prevent errors like:

```
note: in expansion of #[deriving]
note: expansion site
error: unresolved name `std::cmp::Equal`
\#[deriving(Clone, PartialEq, PartialOrd, Eq, Ord, Show)]
                                              ^~~
```
2014-12-13 09:57:46 -05:00
bors
1eccb54bd6 auto merge of #19685 : jbranchaud/rust/add-btreemap-iter-doctests, r=Gankro 2014-12-13 11:02:17 +00:00
Niko Matsakis
2854d1bfc2 Separate borrowck into its own crate and remove dead code as well. 2014-12-13 06:01:19 -05:00
bors
de64f85c6e auto merge of #19671 : tbu-/rust/pr_doc_removetraitrefs, r=Gankro
This specifically means:
- `Deque`
- `Map`
- `Set`
2014-12-13 08:22:16 +00:00
Valerii Hiora
319c379bac Add Copy to bitflags-generated structures 2014-12-13 07:52:00 +02:00
Jonathan S
808eeffee6 Make BTree's Handle system more generic and more powerful, removing some runtine checks in favor of newly gained static safety 2014-12-12 23:26:57 -06:00
Kevin Ballard
d333a91009 vim: Support the new \u{1234} unicode escapes 2014-12-12 21:26:22 -08:00
jbranchaud
58125e5433 Add a doctest for BTreeSet::new. 2014-12-12 22:09:40 -06:00
bors
2d90b91b5d auto merge of #19683 : nikomatsakis/rust/generalized-where-clauses, r=nrc
This patch does not itself enable generalized where clauses, but it lays the groundwork. Rather than storing a list of bounds per type parameter, the trait selection and other logic is now driven by a unified list of predicates. All predicate handling is now driven through a common interface. This also fixes a number of bugs where region predicates were being dropped on the floor. As a drive-by, this patch also fixes some bugs in the opt-out-copy feature flag.

That said, this patch does not change the parser or AST in any way, so we still *generate* the list of predicates by walking a list of bounds (and we still *store* the bounds on the `TypeParameterDef` and so on). Those will get patched in a follow-up.

The commits in this case are standalone; the first few are simple refactorings.

r? @nick29581 
cc @aturon
2014-12-13 03:07:17 +00:00
Alex Crichton
9a47d65e3b rustc: Don't panic on corrupt metadata
Fix a panic where the compiler was looking at stale or old metadata.

See #19798, #19772, #19757, #19744, #19718, #19691.
2014-12-12 18:02:01 -08:00
Niko Matsakis
124e1e18cc Improve comments and address nits. 2014-12-12 20:25:21 -05:00
Niko Matsakis
5f43899db4 Implement the astencode rules for predicates. These don't actually get
used by trans, but it's easy to do.
2014-12-12 20:25:21 -05:00
Niko Matsakis
97cf91aa30 Fix the opt-out-copy behavior so that values with dtor etc are considered affine 2014-12-12 20:25:21 -05:00
Niko Matsakis
07eebf6910 Remove diagnostic errors that were yielding warnings. 2014-12-12 20:25:21 -05:00
Niko Matsakis
9f492fefef Switch to using predicates to drive checking. Correct various tests --
in most cases, just the error message changed, but in some cases we
are reporting new errors that OUGHT to have been reported before but
we're overlooked (mostly involving the `'static` bound on `Send`).
2014-12-12 20:25:21 -05:00
Niko Matsakis
2be6c4f1ca Write code for registering region obligations (but don't use it yet). 2014-12-12 20:24:34 -05:00
Niko Matsakis
9409bd9ff8 Introduce predicates but don't use them. 2014-12-12 20:24:34 -05:00
Niko Matsakis
70be49d2c7 Move the list of region obligations into the fulfillment context. 2014-12-12 20:24:34 -05:00
Niko Matsakis
9bdd7f0040 Thread a id to Obligation 2014-12-12 20:24:34 -05:00
Niko Matsakis
4efaddf7c9 Start restructuring to support generalized where clauses etc. 2014-12-12 20:24:34 -05:00
Tom Jakubowski
31f75ac5c5 metadata: Encode attributes for const items
Fix #19773

Together with #19774 (which this is rebased on):

Fix #18156, fix #19722, fix #19185
2014-12-12 16:57:59 -08:00
bors
8c66927242 auto merge of #19664 : tbu-/rust/pr_oibit2_fix, r=Gankro
These probably happened during the merge of the commit that made `Copy` opt-in.

Also, convert the last occurence of `/**` to `///` in `src/libstd/num/strconv.rs`
2014-12-13 00:27:15 +00:00
Akos Kiss
a28d16a751 libc::c_char is not necessarily i8 2014-12-12 22:41:14 +00:00
Chase Southwood
0a015f287b Update vim syntax highlighting for ExactSizeIterator 2014-12-12 15:09:26 -06:00
bors
ffc111889e auto merge of #19569 : murphm8/rust/ring_buf_insert, r=Gankro
This is a first pass at insert on RingBuf. I tried to keep it as simple as possible. I'm not sure of the performance implications of doing one copy vs. copying multiple times but moving a smaller amount of memory. I chose to stick with one copy, even if the amount of memory I have to move is larger.

I believe this is part of #18424 

@Gankro mentioned this was missing.
2014-12-12 21:07:19 +00:00
Chase Southwood
cd3bdeb91a Remove feature gate directives for if_let, while_let, and tuple_indexing. 2014-12-12 13:23:54 -06:00
bors
9146a919b6 auto merge of #19391 : nick29581/rust/assoc-eq, r=nikomatsakis
r? @nikomatsakis 

cc @aturon (I think you were interested in this for some library stuff)

closes #18432
2014-12-12 18:57:15 +00:00
Mike Pedersen
3cc730e1e1 Add Ord impl to raw pointers 2014-12-12 18:44:22 +01:00
Adolfo Ochagavía
8788cb05c2 Add test for issue #19734 2014-12-12 17:40:49 +01:00
Adolfo Ochagavía
b99fb55f0f Fix #19734 (ICE) 2014-12-12 17:34:28 +01:00
bors
a5921241a3 auto merge of #18028 : gereeter/rust/slimmer-btree-node, r=Gankro
...ated buffer.

Before:

    test btree::map::bench::find_rand_100                      ... bench:        29 ns/iter (+/- 2)
    test btree::map::bench::find_rand_10_000                   ... bench:        83 ns/iter (+/- 6)
    test btree::map::bench::find_seq_100                       ... bench:        30 ns/iter (+/- 1)
    test btree::map::bench::find_seq_10_000                    ... bench:        50 ns/iter (+/- 3)
    test btree::map::bench::insert_rand_100                    ... bench:       186 ns/iter (+/- 30)
    test btree::map::bench::insert_rand_10_000                 ... bench:       377 ns/iter (+/- 8)
    test btree::map::bench::insert_seq_100                     ... bench:       299 ns/iter (+/- 10)
    test btree::map::bench::insert_seq_10_000                  ... bench:       368 ns/iter (+/- 12)
    test btree::map::bench::iter_1000                          ... bench:     20956 ns/iter (+/- 479)
    test btree::map::bench::iter_100000                        ... bench:   2060899 ns/iter (+/- 44325)
    test btree::map::bench::iter_20                            ... bench:       560 ns/iter (+/- 63)

After:

    test btree::map::bench::find_rand_100                      ... bench:        28 ns/iter (+/- 2)
    test btree::map::bench::find_rand_10_000                   ... bench:        74 ns/iter (+/- 3)
    test btree::map::bench::find_seq_100                       ... bench:        31 ns/iter (+/- 0)
    test btree::map::bench::find_seq_10_000                    ... bench:        46 ns/iter (+/- 0)
    test btree::map::bench::insert_rand_100                    ... bench:       141 ns/iter (+/- 1)
    test btree::map::bench::insert_rand_10_000                 ... bench:       273 ns/iter (+/- 12)
    test btree::map::bench::insert_seq_100                     ... bench:       255 ns/iter (+/- 17)
    test btree::map::bench::insert_seq_10_000                  ... bench:       340 ns/iter (+/- 3)
    test btree::map::bench::iter_1000                          ... bench:     21193 ns/iter (+/- 1958)
    test btree::map::bench::iter_100000                        ... bench:   2203599 ns/iter (+/- 100491)
    test btree::map::bench::iter_20                            ... bench:       614 ns/iter (+/- 110)

This code could probably be a fair bit cleaner, but it works.

Part of #18009.
2014-12-12 15:22:06 +00:00
Simon Sapin
0c601153d4 gedit language spec: add new-style Unicode escapes 2014-12-12 14:03:30 +00:00
Tom Jakubowski
25223c8ef8 rustdoc: Properly inline const items
Build `clean::ConstantItem` values in the `inline` module and
pretty-print the AST for inlined const items.

Doc strings are still missing from inlined constants (see #19773).

Partially address #18156, #19722, #19185

Fix #15821
2014-12-12 05:37:08 -08:00
bors
2ea38750e9 auto merge of #19617 : nikomatsakis/rust/issue-19261-2, r=nrc
**First commit.** Patch up debruijn indices. Fixes #19537. 

**Second commit.** Stop reborrowing so much. Fixes #19147. Fixes #19261.

r? @nick29581
2014-12-12 13:21:58 +00:00
Jonathan S
130fb08210 Slimmify BTree by replacing its internal Node type, which previously…held three separately allocated Vecs, with a manually allocated buffer. Additionally, restructure the node and stack interfaces to be safer and require fewer bounds checks.
Before:
test btree::map::bench::find_rand_100                      ... bench:        35 ns/iter (+/- 2)
test btree::map::bench::find_rand_10_000                   ... bench:        88 ns/iter (+/- 3)
test btree::map::bench::find_seq_100                       ... bench:        36 ns/iter (+/- 1)
test btree::map::bench::find_seq_10_000                    ... bench:        62 ns/iter (+/- 0)
test btree::map::bench::insert_rand_100                    ... bench:       157 ns/iter (+/- 8)
test btree::map::bench::insert_rand_10_000                 ... bench:       413 ns/iter (+/- 8)
test btree::map::bench::insert_seq_100                     ... bench:       272 ns/iter (+/- 10)
test btree::map::bench::insert_seq_10_000                  ... bench:       369 ns/iter (+/- 19)
test btree::map::bench::iter_1000                          ... bench:     19049 ns/iter (+/- 740)
test btree::map::bench::iter_100000                        ... bench:   1916737 ns/iter (+/- 102250)
test btree::map::bench::iter_20                            ... bench:       424 ns/iter (+/- 40)

After:
test btree::map::bench::find_rand_100                      ... bench:         9 ns/iter (+/- 1)
test btree::map::bench::find_rand_10_000                   ... bench:         8 ns/iter (+/- 0)
test btree::map::bench::find_seq_100                       ... bench:         7 ns/iter (+/- 0)
test btree::map::bench::find_seq_10_000                    ... bench:         8 ns/iter (+/- 0)
test btree::map::bench::insert_rand_100                    ... bench:       136 ns/iter (+/- 5)
test btree::map::bench::insert_rand_10_000                 ... bench:       380 ns/iter (+/- 34)
test btree::map::bench::insert_seq_100                     ... bench:       255 ns/iter (+/- 8)
test btree::map::bench::insert_seq_10_000                  ... bench:       364 ns/iter (+/- 10)
test btree::map::bench::iter_1000                          ... bench:     19112 ns/iter (+/- 837)
test btree::map::bench::iter_100000                        ... bench:   1911961 ns/iter (+/- 33069)
test btree::map::bench::iter_20                            ... bench:       453 ns/iter (+/- 37)
2014-12-12 06:58:18 -06:00
bors
d2e2bd1b44 auto merge of #19568 : barosl/rust/enum-struct-variants-ice, r=alexcrichton
This pull request tries to fix #19340, which states two ICE cases related to enum struct variants.

It is my first attempt to fix the compiler. I found this solution by trial and error, so the method used to fix the issue looks very hacky. Please review it, and direct me to find a better solution.

I'm also to add test cases. Where should I put them? Maybe `src/test/run-pass/issue-19340.rs`?
2014-12-12 09:12:08 +00:00
jbranchaud
47b071af27 Add doctests for iter and into_iter for BTreeSet. 2014-12-12 01:18:10 -06:00
Nick Cameron
ce4318ad86 Reviewer comments 2014-12-12 19:29:17 +13:00
Nick Cameron
ae8ba88424 Mostly non-behaviour-changing changes (style, etc.) 2014-12-12 19:11:59 +13:00
Nick Cameron
397dda8aa0 Add support for equality constraints on associated types 2014-12-12 19:11:59 +13:00
Nick Cameron
19eb4bf0b2 Add coercions from *mut to *const and from &mut to *const. 2014-12-12 16:54:57 +13:00
Matt Murphy
40f28c70d6 Implement insert for RingBuf 2014-12-11 21:14:59 -06:00
bors
da83ad8e2c auto merge of #19514 : jbranchaud/rust/add-btree-set-bitor, r=Gankro
I am trying to add an implementation of `bitor` for `BTreeSet`. I think I am most of the way there, but I am going to need some guidance to take it all the way.

When I run `make check`, I get:

```
error: cannot move out of dereference of `&`-pointer
self.union(_rhs).map(|&i| i).collect::<BTreeSet<T>>()
                      ^~
```

I'd appreciate any nudges in the right direction. If I can figure this one out, I am sure I will be able to implement `bitand`, `bitxor`, and `sub` as well.

/cc @Gankro 

---

**Update**

I have added implementations for `BitOr`, `BitAnd`, `BitXor`, and `Sub` for `BTreeSet`.
2014-12-12 02:56:53 +00:00
Kang Seonghoon
577f742d7a serialize: Avoid stray nul characters when auto-serializing char.
Fixes #19719.
2014-12-12 11:51:00 +09:00
jbranchaud
cd008c4127 Add an implementation of the BitOps for BTreeSets.
Add initial attempt at implementing BitOr for BTreeSet.

Update the implementation of the bitor operator for BTreeSets.

`make check` ran fine through this.

Add implementations for BitAnd, BitXor, and Sub as well.

Remove the FIXME comment and add unstable flags.

Add doctests for the bitop functions.
2014-12-11 19:42:06 -06:00
Brian Anderson
e92e8ac365 Use rust-installer for installation
This is just a refactoring of the current installer so that Rust and Cargo
use the same codebase.

cc #16456
2014-12-11 17:14:17 -08:00
bors
193390d0e4 auto merge of #19672 : alexcrichton/rust/snapshots, r=brson
These snapshots were generated on the 10.7 bot which should be the first step in fixing #19643
2014-12-11 22:56:54 +00:00
Murarth
04b4b500b9 Perform compiler state reset in phase_1 2014-12-11 15:33:27 -07:00
Murarth
2c028452b5 Add LLVM ExecutionEngine API 2014-12-11 15:33:27 -07:00
Steve Klabnik
31b240d6bc Add comments with type annotations.
This will hopefully help people with their first steps in Rust.

Fixes #16143.
2014-12-11 15:45:47 -05:00
Alex Crichton
52edb2ecc9 Register new snapshots 2014-12-11 11:30:38 -08:00
Barosl Lee
086c9493c8 Fix ICE when a struct variant enum contains multiple fields
Fixes the second case of #19340.
2014-12-12 03:38:11 +09:00
Barosl Lee
418d1bfc9a Fix ICE when a struct variant enum is imported from an external crate
Fixes the first case of #19340.
2014-12-12 03:38:11 +09:00
bors
dea7143204 auto merge of #19377 : tbu-/rust/pr_mapinplace_fixzerosized_test, r=sfackler 2014-12-11 18:12:11 +00:00
Steve Klabnik
38d29092f9 reference: type definition -> type alias
Fixes #9266
2014-12-11 12:35:03 -05:00
Steve Klabnik
f473aee893 gdb < RUST_BACKTRACE
Fixes #19717
2014-12-11 11:47:16 -05:00
Seth Pollack
7676d0164f Update intro.md 2014-12-11 11:21:48 -05:00
Niko Matsakis
061a87e519 Fix an incorrect type annotation (shadowed lifetime parameter) that was masked by
these bugs.
2014-12-11 04:16:11 -05:00
Niko Matsakis
31e46ac0a9 During method resolution, only reborrow if we are not doing an auto-ref.
The current behavior leads to adjustments like `&&*` being applied
instead of just `&` (when the unmodified receiver is a `&T` or an `&mut
T`). This causes both safety errors and unexpected behavior. The safety
errors result from regionck not being prepared for auto-ref-ref-like
adjustments; this is worth fixing on its own, but I think the best way
to do it is to modify regionck to use expr-use-visitor (and fix
expr-use-visitor as well, which I don't think properly invokes `borrow`
for each level of auto-ref), and for now it's simpler to just not
produce the adjustment in question. (I have a separate patch porting
regionck to use exprusevisitor for a different bug, so that is coming.)
2014-12-10 19:45:19 -05:00
Niko Matsakis
ca98fefd04 Fix two bugs in HRTB: 1. Categorize early-vs-late bindings on impls when constructing generics, so that we don't add unnecessary region parameters. 2. Correct the DeBruijn indices when substituting the self type into the method signature.
Previously, the DeBruijn index for the self type was not being
adjusted to account for the fn binder. This mean that when late-bound
regions were instantiated, you sometimes wind up with two distinct
lifetimes.

Fixes #19537.
2014-12-10 19:45:19 -05:00
bors
872ba2ccd3 auto merge of #19294 : huonw/rust/transmute-inplace, r=nikomatsakis
This detects (a subset of) the cases when `transmute::<T, U>(x)` can be
lowered to a direct `bitcast T x to U` in LLVM. This assists with
efficiently handling a SIMD vector as multiple different types,
e.g. swapping bytes/words/double words around inside some larger vector
type.

C compilers like GCC and Clang handle integer vector types as `__m128i`
for all widths, and implicitly insert bitcasts as required. This patch
allows Rust to express this, even if it takes a bit of `unsafe`, whereas
previously it was impossible to do at all without inline assembly.

Example:

    pub fn reverse_u32s(u: u64x2) -> u64x2 {
        unsafe {
            let tmp = mem::transmute::<_, u32x4>(u);
            let swapped = u32x4(tmp.3, tmp.2, tmp.1, tmp.0);
            mem::transmute::<_, u64x2>(swapped)
        }
    }

Compiling with `--opt-level=3` gives:

Before

    define <2 x i64> @_ZN12reverse_u32s20hbdb206aba18a03d8tbaE(<2 x i64>) unnamed_addr #0 {
    entry-block:
      %1 = bitcast <2 x i64> %0 to i128
      %u.0.extract.trunc = trunc i128 %1 to i32
      %u.4.extract.shift = lshr i128 %1, 32
      %u.4.extract.trunc = trunc i128 %u.4.extract.shift to i32
      %u.8.extract.shift = lshr i128 %1, 64
      %u.8.extract.trunc = trunc i128 %u.8.extract.shift to i32
      %u.12.extract.shift = lshr i128 %1, 96
      %u.12.extract.trunc = trunc i128 %u.12.extract.shift to i32
      %2 = insertelement <4 x i32> undef, i32 %u.12.extract.trunc, i64 0
      %3 = insertelement <4 x i32> %2, i32 %u.8.extract.trunc, i64 1
      %4 = insertelement <4 x i32> %3, i32 %u.4.extract.trunc, i64 2
      %5 = insertelement <4 x i32> %4, i32 %u.0.extract.trunc, i64 3
      %6 = bitcast <4 x i32> %5 to <2 x i64>
      ret <2 x i64> %6
    }

    _ZN12reverse_u32s20hbdb206aba18a03d8tbaE:
    	.cfi_startproc
    	movd	%xmm0, %rax
    	punpckhqdq	%xmm0, %xmm0
    	movd	%xmm0, %rcx
    	movq	%rcx, %rdx
    	shrq	$32, %rdx
    	movq	%rax, %rsi
    	shrq	$32, %rsi
    	movd	%eax, %xmm0
    	movd	%ecx, %xmm1
    	punpckldq	%xmm0, %xmm1
    	movd	%esi, %xmm2
    	movd	%edx, %xmm0
    	punpckldq	%xmm2, %xmm0
    	punpckldq	%xmm1, %xmm0
    	retq

After

    define <2 x i64> @_ZN12reverse_u32s20hbdb206aba18a03d8tbaE(<2 x i64>) unnamed_addr #0 {
    entry-block:
      %1 = bitcast <2 x i64> %0 to <4 x i32>
      %2 = shufflevector <4 x i32> %1, <4 x i32> undef, <4 x i32> <i32 3, i32 2, i32 1, i32 0>
      %3 = bitcast <4 x i32> %2 to <2 x i64>
      ret <2 x i64> %3
    }

    _ZN12reverse_u32s20hbdb206aba18a03d8tbaE:
    	.cfi_startproc
    	pshufd	$27, %xmm0, %xmm0
    	retq
2014-12-11 00:11:23 +00:00
Vadim Chugunov
3eda3cde18 Change default installation directory to %SYSTEMDRIVE%\Rust.
Modify user PATH, rather than system PATH.
2014-12-10 15:14:14 -08:00
Steve Klabnik
3c9d8983be Fix up some {ignore} and {notrust}s
These should be properly annotated instead.

Fixes #16219.
2014-12-10 15:14:18 -05:00
Steve Klabnik
6780031540 Fix inappropriate ## headings
Fixes #15499.
2014-12-10 13:54:56 -05:00
Steve Klabnik
a9fdd1618b Fix po4a conf file
This line was declared twice, which causes the build of i10n docs to
fail.
2014-12-10 13:33:27 -05:00
Alex Crichton
e8bc621f48 rustc: Fix make install
Move a few docblocks from 'ignore' to something that's not rust (e.g. 'text').

Closes #19678
2014-12-10 09:46:30 -08:00
bors
bc486dc233 auto merge of #19663 : tbu-/rust/pr_fix_vecmap, r=Gankro
- Introduce a named type for the return type of `VecMap::move_iter`
- Rename all type parameters to `V` for "Value".
- Remove unnecessary call to an `Option::unwrap`, use pattern matching instead.
- Remove incorrect `Hash` implementation which took the `VecMap`'s capacity
  into account.

This is a [breaking-change], however whoever used the `Hash` implementation
relied on an incorrect implementation.
2014-12-10 15:22:18 +00:00
Barosl Lee
cfee5b7e88 Fix an ICE when trying to resolve a struct variant
Unlike a tuple variant constructor which can be called as a function, a
struct variant constructor is not a function, so cannot be called.

If the user tries to assign the constructor to a variable, an ICE
occurs, because there is no way to use it later. So we should stop the
constructor from being used like that.

A similar mechanism already exists for a normal struct, as it prohibits
a struct from being resolved. This commit does the same for a struct
variant.

This commit also includes some changes to the existing tests.

Fixes #19452.
2014-12-10 22:45:28 +09:00
Arthur Liao
2f5e170bab Update sample code to use getopts::usage in print_usage 2014-12-10 20:46:33 +08:00
bors
daa2bde2ba auto merge of #19655 : jbranchaud/rust/change-example-to-examples, r=steveklabnik
@steveklabnik I got a start on this.
2014-12-10 12:46:11 +00:00
Tobias Bucher
4a46f5ebde Remove references to traits that no longer exist
This specifically means:
- `Deque`
- `Map`
- `Set`
2014-12-10 12:31:47 +01:00
bors
fddec2d88a auto merge of #19638 : barosl/rust/typeck-tupled-arguments-ice, r=jakub
When a type error occurs, `check_method_argument_types()` tries to provide arguments filled with `ty::mk_err()`. However, if a function takes the parameters as a tuple, the arguments should be converted to a tuple before passing it to `check_argument_types()`.

Fixes #19521.
2014-12-10 09:56:14 +00:00
bors
444a759b84 auto merge of #19628 : jbranchaud/rust/add-string-as-string-doctest, r=steveklabnik 2014-12-10 06:46:16 +00:00
jbranchaud
d946426699 Add doctests for iter_mut and into_iter of BTreeMap.
Add spacing as dictated by standard rust code style.
2014-12-09 22:19:23 -06:00
bors
ab1b1ae719 auto merge of #19648 : mquandalle/rust/patch-1, r=alexcrichton 2014-12-10 03:41:14 +00:00
Barosl Lee
21d12c0297 typeck: Make the supplied parameters to be a tuple
When a type error occurs, check_method_argument_types() tries to provide
arguments filled with ty::mk_err(). However, if a function takes the
parameters as a tuple, the arguments should be converted to a tuple
before being passed to check_argument_types().

Fixes #19521.
2014-12-10 12:33:20 +09:00
bors
4c692d3a35 auto merge of #19573 : apasel422/rust/sized_fn_once, r=alexcrichton
- Remove the `for Sized?` bound on `core::ops::FnOnce`, as it takes `self` by value and can never be implemented by an unsized type.
- Add a missing `Sized?` bound to the blanket `core::ops::FnMut` impl, as both `Fn` and `FnMut` are `for Sized?`.
2014-12-10 00:31:13 +00:00
bors
8fbfa66b45 auto merge of #19563 : alexcrichton/rust/issue-19501, r=pnkfelix
One of the causes of #19501 was that the metadata on OSX was getting corrupted.
For any one particular invocation of the compiler the metadata file inside of an
rlib archive would have extra bytes appended to the end of it. These extra bytes
end up confusing rbml and have it run off the end of the array (resulting in the
out of bounds detected).

This commit prepends the length of metadata to the start of the metadata to
ensure that we always slice the precise amount that we want, and it also
un-ignores the test from #19502.

Closes #19501
2014-12-09 21:56:13 +00:00
Alfie John
b9c3b5693a doc: grammar fix 2014-12-09 20:17:40 +00:00
Tobias Bucher
20eaf168c5 Add a proper Hash implementation for VecMap
Also re-add the previously deleted test with an additional test that would have
failed before, when the hash function depended on the capacity.
2014-12-09 20:05:51 +01:00
Alex Crichton
1a61fe4280 Test fixes and rebase conflicts from the rollup 2014-12-09 10:26:04 -08:00
Tobias Bucher
deabeb0276 Rollback accidental documentation changes
These probably happened during the merge of the commit that made `Copy` opt-in.

Also, convert the last occurence of `/**` to `///` in `src/libstd/num/strconv.rs`
2014-12-09 18:50:31 +01:00
Alex Crichton
2457375534 rollup merge of #19653: frewsxcv/rm-reexports
Brief note: This does *not* affect anything in the prelude

Part of #19253

All this does is remove the reexporting of Result and Option from their
respective modules. More core reexports might be removed, but these ones
are the safest to remove since these enums (and their variants) are included in
the prelude.

Depends on https://github.com/rust-lang/rust/pull/19407 which is merged, but might need a new snapshot

[breaking-change]
2014-12-09 09:25:14 -08:00
Alex Crichton
b4b1bb0a4e rollup merge of #19642: aaronweiss74/master
This was discussed in [#rust-internals](
https://botbot.me/mozilla/rust-internals/2014-12-08/?msg=27077624&page=5). It's a small change.
2014-12-09 09:25:12 -08:00
Alex Crichton
4b34f3c3ad rollup merge of #19626: bluss/string-extend-str
Strings iterate to both char and &str, so it is natural it can also be extended or collected from an iterator of &str.

Apart from the trait implementations, `Extend<char>` is updated to use the iterator size hint, and the test added tests both the char and the &str versions of Extend and FromIterator.
2014-12-09 09:25:10 -08:00
Alex Crichton
1cbb07507e rollup merge of #19623: rustyrazorblade/patch-1
Docs said from_utf8 accepts a vector when it actually accepts an array of bytes.
2014-12-09 09:25:09 -08:00
Alex Crichton
21e5efb43c rollup merge of #19622: steveklabnik/fix_ringbuf_doc
https://botbot.me/mozilla/rust/2014-12-07/?msg=27003846&page=20
2014-12-09 09:25:08 -08:00
Alex Crichton
4a49912cfe rollup merge of #19620: retep998/memorymap 2014-12-09 09:25:07 -08:00
Alex Crichton
a2e9c99a66 rollup merge of #19616: steveklabnik/gh19556
Closes #19556.
2014-12-09 09:25:06 -08:00
Alex Crichton
e6d8190b0c rollup merge of #19615: steveklabnik/gh19595
Fixes #19595.
2014-12-09 09:25:05 -08:00
Alex Crichton
fb587f1f9b rollup merge of #19614: steveklabnik/gh19599
Fixes #19599
2014-12-09 09:25:04 -08:00
Alex Crichton
ae805da487 rollup merge of #19608: jbranchaud/add-missing-semicolon-in-intro 2014-12-09 09:24:53 -08:00
Alex Crichton
c56344ba31 rollup merge of #19604: vadimcn/gcc-less
- Support gcc-less installation on Windows.  To do so in unattended mode run:`<intaller>.exe /TYPE=compact /SILENT`.
- Do not require admin privileges to install.

cc #19519
2014-12-09 09:24:52 -08:00
Alex Crichton
2a244ce7f4 rollup merge of #19598: japaric/ord
cc #18755

r? @alexcrichton
cc @bjz
2014-12-09 09:24:51 -08:00
Alex Crichton
d0ad3c7f93 rollup merge of #19594: Arcterus/master
It is useful to have configurable newlines in base64 as the standard
leaves that for the implementation to decide.  GNU `base64` apparently
uses LF, which meant in `uutils` we had to manually convert the CRLF to
LF.  This made the program very slow for large inputs.

[breaking-change]
2014-12-09 09:24:50 -08:00
Alex Crichton
ae60f9c592 rollup merge of #19592: jbranchaud/add-btreemap-iter-doctest
I'm interested in including doctests for `BTreeMap`'s `iter_mut` and `into_iter` methods in this PR as well, but I am not sure of the best way to demonstrate/test what they do for the doctests.
2014-12-09 09:24:48 -08:00
Alex Crichton
63ef9e980f rollup merge of #19589: huonw/unboxed-closure-elision
This means that `Fn(&A) -> (&B, &C)` is equivalent to `for<'a> Fn(&'a A)
-> (&'a B, &'a C)` similar to the lifetime elision of lower-case `fn` in
types and declarations.

Closes #18992.
2014-12-09 09:24:47 -08:00
Alex Crichton
356193be0e rollup merge of #19588: nodakai/libstd-fix-zombie-children-finder
Reported as a part of rust-lang/rust#19120

The logic of rust-lang/rust@74fb798a20 was
flawed because when a CI tool run the test parallely with other tasks,
they all belong to a single session family and the test may pick up
irrelevant zombie processes before they are reaped by the CI tool
depending on timing.
2014-12-09 09:24:46 -08:00
Alex Crichton
26c24221e4 rollup merge of #19587: huonw/closure-feature-gate
detect UFCS drop and allow UFCS methods to have explicit type parameters.

Work towards #18875.

Since code could previously call the methods & implement the traits
manually, this is a

[breaking-change]

Closes #19586. Closes #19375.
2014-12-09 09:24:44 -08:00
Alex Crichton
60f97fc44a rollup merge of #19585: mdinger/guide_typo
@steveklabnik r?
2014-12-09 09:24:43 -08:00
Alex Crichton
6a652cfd1d rollup merge of #19584: CaptainHayashi/patch-1
Substitutes 'lifetime' for 'liftime' in a few places.

Apologies if this has already been noticed/PRQed!  I did try to do due diligence, though 😀
2014-12-09 09:24:42 -08:00
Alex Crichton
2593070d57 rollup merge of #19581: luqmana/duc
Fixes #19575.
2014-12-09 09:24:41 -08:00
Alex Crichton
39b57115fb rollup merge of #19577: aidancully/master
pthread_key_create can be 0.
addresses issue #19567.
2014-12-09 09:24:39 -08:00
Alex Crichton
a09632f7cb rollup merge of #19576: nhoss2/master
There was a link to a non existing guide
2014-12-09 09:24:38 -08:00
Tobias Bucher
67ae3a49e4 Clean up libcollections::VecMap
- Introduce a named type for the return type of `VecMap::move_iter`
- Rename all type parameters to `V` for "Value".
- Remove unnecessary call to an `Option::unwrap`, use pattern matching instead.
- Remove incorrect `Hash` implementation which took the `VecMap`'s capacity
  into account.

This is a [breaking-change], however whoever used the `Hash` implementation
relied on an incorrect implementation.
2014-12-09 18:20:20 +01:00
jbranchaud
de3fcee2dc Add a doctest for the std::string::as_string method.
Change Example to Examples.

Add a doctest that better demonstrates the utility of as_string.

Update the doctest example to use String instead of &String.
2014-12-09 11:11:50 -06:00
Maxime Quandalle
c93d47d395 Delete the outdated source layout README 2014-12-09 16:53:22 +01:00
Arcterus
a119ad83c7 serialize: base64: remove some .as_bytes() from the tests 2014-12-09 07:40:21 -08:00
Arcterus
a943a7a4e5 serialize: base64: improve newline handling speed 2014-12-09 07:40:21 -08:00
Arcterus
553ab271a3 serialize: base64: allow LF in addition to CRLF and optimize slightly
It is useful to have configurable newlines in base64 as the standard
leaves that for the implementation to decide.  GNU `base64` apparently
uses LF, which meant in `uutils` we had to manually convert the CRLF to
LF.  This made the program very slow for large inputs.

[breaking-change]
2014-12-09 07:40:21 -08:00
bors
ef4982f0f8 auto merge of #19466 : nikomatsakis/rust/recursion-limit, r=eddyb
This is particularly important for deeply nested types, which generate deeply nested impls. This is a fix for #19318. It's possible we could also improve this particular case not to increment the recursion count, but it's worth being able to adjust the recursion limit anyhow.

cc @jdm 
r? @pcwalton
2014-12-09 14:02:45 +00:00
bors
cafe296677 auto merge of #19249 : barosl/rust/json-type-safety, r=alexcrichton
This pull request tries to improve type safety of `serialize::json::Encoder`.

Looking at #18319, I decided to test some JSON implementations in other languages. The results are as follows:

* Encoding to JSON

| Language | 111111111111111111 | 1.0 |
| --- | --- | --- |
| JavaScript™ | "111111111111111100" | "1" |
| Python | "111111111111111111" | **"1.0"** |
| Go | "111111111111111111" | "1" |
| Haskell | "111111111111111111" | "1" |
| Rust | **"111111111111111104"** | "1" |

* Decoding from JSON

| Language | "1" | "1.0" | "1.6" |
| --- | --- | --- | --- |
| JavaScript™ | 1 (Number) | 1 (Number) | 1.6 (Number) |
| Python | 1 (int) | 1.0 (float) | 1.6 (float) |
| Go | **1 (float64)** | 1 (float64) | 1.6 (float64) |
| Go (expecting `int`) | 1 (int) | **error** | error |
| Haskell (with `:: Int`) | 1 (Int) | 1 (Int) | **2 (Int)** |
| Haskell (with `:: Double`) | 1.0 (Double) | 1.0 (Double) | 1.6 (Double) |
| Rust (with `::<int>`) | 1 (int) | 1 (Int) | **1 (Int)** |
| Rust (with `::<f64>`) | 1 (f64) | 1 (f64) | 1.6 (f64) |

* The tests on Haskell were done using the [json](http://hackage.haskell.org/package/json) package.
* The error message printed by Go was: `cannot unmarshal number 1.0 into Go value of type int`

As you see, there is no uniform behavior. Every implementation follows its own principle. So I think it is reasonable to find a desirable set of behaviors for Rust.

Firstly, every implementation except the one for JavaScript is capable of handling `i64` values. It is even practical, because [Twitter API uses an i64 number to represent a tweet ID](https://dev.twitter.com/overview/api/twitter-ids-json-and-snowflake), although it is recommended to use the string version of the ID.

Secondly, looking into the Go's behavior, implicit type conversion is not allowed in their decoder. If the user expects an integer value to follow, decoding a float value will raise an error. This behavior is desirable in Rust, because we are pleased to follow the principles of strong typing.

Thirdly, Python's JSON module forces a decimal point to be printed even if the fractional part does not exist. This eases the distinction of a float value from an integer value in JSON, because by the spec there is only one type to represent numbers, `Number`.

So, I suggest the following three breaking changes:

1. Remove float preprocessing in serialize::json::Encoder

 `serialize::json::Encoder` currently uses `f64` to emit any integral type. This is possibly due to the behavior of JavaScript, which uses `f64` to represent any numeric value.

 This leads to a problem that only the integers in the range of [-2^53+1, 2^53-1] can be encoded. Therefore, `i64` and `u64` cannot be used reliably in the current implementation.

 [RFC 7159](http://tools.ietf.org/html/rfc7159) suggests that good interoperability can be achieved if the range is respected by implementations. However, it also says that implementations are allowed to set the range of number accepted. And it seems that the JSON encoders outside of the JavaScript world usually make use of `i64` values.

 This commit removes the float preprocessing done in the `emit_*` methods. It also increases performance, because transforming `f64` into String costs more than that of an integral type.

 Fixes #18319

2. Do not coerce to integer when decoding a float value

 When an integral value is expected by the user but a fractional value is found, the current implementation uses `std::num::cast()` to coerce to an integer type, losing the fractional part. This behavior is not desirable because the number loses precision without notice.

 This commit makes it raise `ExpectedError` when such a situation arises.

3. Always use a decimal point when emitting a float value

 JSON doesn't distinguish between integer and float. They are just numbers. Also, in the current implementation, a fractional number without the fractional part is encoded without a decimal point.

 Thereforce, when the value is decoded, it is first rendered as `Json`, either `I64` or `U64`. This reduces type safety, because while the original intention was to cast the value to float, it can also be casted to integer.

 As a workaround of this problem, this commit makes the encoder always emit a decimal point even if it is not necessary. If the fractional part of a float number is zero, ".0" is padded to the end of the result.
2014-12-09 10:51:49 +00:00
bors
c56e59c722 auto merge of #19644 : pcwalton/rust/oibit3, r=nikomatsakis 2014-12-09 07:51:52 +00:00
Patrick Walton
fcd1f53e43 Add some missing Copy implementations 2014-12-08 21:44:04 -08:00
jbranchaud
c09defa070 Change 'Example' to 'Examples' throughout collections' rustdocs. 2014-12-08 23:28:07 -06:00
bors
50b6d01e1c auto merge of #19645 : alexcrichton/rust/old-snap, r=brson
The most recent snapshot was produced on OSX 10.8, but this segfaults on OSX
10.7 so we need to roll back one snapshot so we can start bootstrapping on 10.7
systems again.

cc #19643
2014-12-09 05:01:53 +00:00
Corey Farwell
9af324a673 Remove Result and Option reexports
Brief note: This does *not* affect anything in the prelude

Part of #19253

All this does is remove the reexporting of Result and Option from their
respective modules. More core reexports might be removed, but these ones
are the safest to remove since these enums (and their variants) are included in
the prelude.

[breaking-change]
2014-12-08 21:40:16 -05:00
Niels Egberts
2dc338dfdb Rename assert_eq arguments to left and right.
The names expected and actual are not used anymore in the output. It also
removes the confusion that the argument order is the opposite of junit.
2014-12-09 00:09:42 +00:00
Alex Crichton
456ffcdc56 Revert "Register new snapshots"
This reverts commit 9b443289cf.
2014-12-08 14:30:13 -08:00
Alex Crichton
daafff508c rustc: Prepend a length to all metadata
One of the causes of #19501 was that the metadata on OSX was getting corrupted.
For any one particular invocation of the compiler the metadata file inside of an
rlib archive would have extra bytes appended to the end of it. These extra bytes
end up confusing rbml and have it run off the end of the array (resulting in the
out of bounds detected).

This commit prepends the length of metadata to the start of the metadata to
ensure that we always slice the precise amount that we want, and it also
un-ignores the test from #19502.

Closes #19501
2014-12-08 14:29:24 -08:00
Aaron Weiss
ad7dacd9eb Implemented BorrowFrom<Rc<T>> for T. 2014-12-08 16:32:08 -05:00
Niko Matsakis
9c65a5b150 Link regions in ref bindings from fn arguments. 2014-12-08 15:53:03 -05:00
Niko Matsakis
34812b891d Stop masking overflow and propagate it out more aggressively; also improve error reporting to suggest to user how to fix. 2014-12-08 15:51:38 -05:00
Niko Matsakis
3ee85d828e Kill dead code 2014-12-08 15:51:38 -05:00