]> git.lizzy.rs Git - rust.git/log
rust.git
9 years agoauto merge of #19514 : jbranchaud/rust/add-btree-set-bitor, r=Gankro
bors [Fri, 12 Dec 2014 02:56:53 +0000 (02:56 +0000)]
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`.

9 years agoAdd an implementation of the BitOps for BTreeSets.
jbranchaud [Thu, 4 Dec 2014 04:10:06 +0000 (22:10 -0600)]
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.

9 years agoauto merge of #19672 : alexcrichton/rust/snapshots, r=brson
bors [Thu, 11 Dec 2014 22:56:54 +0000 (22:56 +0000)]
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

9 years agoRegister new snapshots
Alex Crichton [Tue, 9 Dec 2014 22:08:10 +0000 (14:08 -0800)]
Register new snapshots

9 years agoauto merge of #19377 : tbu-/rust/pr_mapinplace_fixzerosized_test, r=sfackler
bors [Thu, 11 Dec 2014 18:12:11 +0000 (18:12 +0000)]
auto merge of #19377 : tbu-/rust/pr_mapinplace_fixzerosized_test, r=sfackler

9 years agoauto merge of #19294 : huonw/rust/transmute-inplace, r=nikomatsakis
bors [Thu, 11 Dec 2014 00:11:23 +0000 (00:11 +0000)]
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

9 years agoauto merge of #19705 : brson/rust/fix-install, r=alexcrichton
bors [Wed, 10 Dec 2014 20:11:27 +0000 (20:11 +0000)]
auto merge of #19705 : brson/rust/fix-install, r=alexcrichton

9 years agoDon't try to dist src/README.md which does not exist
Brian Anderson [Wed, 10 Dec 2014 17:47:36 +0000 (09:47 -0800)]
Don't try to dist src/README.md which does not exist

9 years agorustc: Fix `make install`
Alex Crichton [Wed, 10 Dec 2014 16:50:50 +0000 (08:50 -0800)]
rustc: Fix `make install`

Move a few docblocks from 'ignore' to something that's not rust (e.g. 'text').

Closes #19678

9 years agoauto merge of #19663 : tbu-/rust/pr_fix_vecmap, r=Gankro
bors [Wed, 10 Dec 2014 15:22:18 +0000 (15:22 +0000)]
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.

9 years agoauto merge of #19655 : jbranchaud/rust/change-example-to-examples, r=steveklabnik
bors [Wed, 10 Dec 2014 12:46:11 +0000 (12:46 +0000)]
auto merge of #19655 : jbranchaud/rust/change-example-to-examples, r=steveklabnik

@steveklabnik I got a start on this.

9 years agoauto merge of #19638 : barosl/rust/typeck-tupled-arguments-ice, r=jakub
bors [Wed, 10 Dec 2014 09:56:14 +0000 (09:56 +0000)]
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.

9 years agoauto merge of #19628 : jbranchaud/rust/add-string-as-string-doctest, r=steveklabnik
bors [Wed, 10 Dec 2014 06:46:16 +0000 (06:46 +0000)]
auto merge of #19628 : jbranchaud/rust/add-string-as-string-doctest, r=steveklabnik

9 years agoauto merge of #19648 : mquandalle/rust/patch-1, r=alexcrichton
bors [Wed, 10 Dec 2014 03:41:14 +0000 (03:41 +0000)]
auto merge of #19648 : mquandalle/rust/patch-1, r=alexcrichton

9 years agotypeck: Make the supplied parameters to be a tuple
Barosl Lee [Mon, 8 Dec 2014 07:28:14 +0000 (16:28 +0900)]
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.

9 years agoauto merge of #19573 : apasel422/rust/sized_fn_once, r=alexcrichton
bors [Wed, 10 Dec 2014 00:31:13 +0000 (00:31 +0000)]
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?`.

9 years agoauto merge of #19563 : alexcrichton/rust/issue-19501, r=pnkfelix
bors [Tue, 9 Dec 2014 21:56:13 +0000 (21:56 +0000)]
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

9 years agoauto merge of #19665 : alexcrichton/rust/rollup, r=alexcrichton
bors [Tue, 9 Dec 2014 19:12:02 +0000 (19:12 +0000)]
auto merge of #19665 : alexcrichton/rust/rollup, r=alexcrichton

9 years agoAdd a proper `Hash` implementation for `VecMap`
Tobias Bucher [Tue, 9 Dec 2014 19:05:51 +0000 (20:05 +0100)]
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.

9 years agoTest fixes and rebase conflicts from the rollup
Alex Crichton [Tue, 9 Dec 2014 18:26:04 +0000 (10:26 -0800)]
Test fixes and rebase conflicts from the rollup

9 years agorollup merge of #19653: frewsxcv/rm-reexports
Alex Crichton [Tue, 9 Dec 2014 17:25:14 +0000 (09:25 -0800)]
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]

9 years agorollup merge of #19642: aaronweiss74/master
Alex Crichton [Tue, 9 Dec 2014 17:25:12 +0000 (09:25 -0800)]
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.

9 years agorollup merge of #19626: bluss/string-extend-str
Alex Crichton [Tue, 9 Dec 2014 17:25:10 +0000 (09:25 -0800)]
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.

9 years agorollup merge of #19623: rustyrazorblade/patch-1
Alex Crichton [Tue, 9 Dec 2014 17:25:09 +0000 (09:25 -0800)]
rollup merge of #19623: rustyrazorblade/patch-1

Docs said from_utf8 accepts a vector when it actually accepts an array of bytes.

9 years agorollup merge of #19622: steveklabnik/fix_ringbuf_doc
Alex Crichton [Tue, 9 Dec 2014 17:25:08 +0000 (09:25 -0800)]
rollup merge of #19622: steveklabnik/fix_ringbuf_doc

  https://botbot.me/mozilla/rust/2014-12-07/?msg=27003846&page=20

9 years agorollup merge of #19620: retep998/memorymap
Alex Crichton [Tue, 9 Dec 2014 17:25:07 +0000 (09:25 -0800)]
rollup merge of #19620: retep998/memorymap

9 years agorollup merge of #19616: steveklabnik/gh19556
Alex Crichton [Tue, 9 Dec 2014 17:25:06 +0000 (09:25 -0800)]
rollup merge of #19616: steveklabnik/gh19556

Closes #19556.

9 years agorollup merge of #19615: steveklabnik/gh19595
Alex Crichton [Tue, 9 Dec 2014 17:25:05 +0000 (09:25 -0800)]
rollup merge of #19615: steveklabnik/gh19595

Fixes #19595.

9 years agorollup merge of #19614: steveklabnik/gh19599
Alex Crichton [Tue, 9 Dec 2014 17:25:04 +0000 (09:25 -0800)]
rollup merge of #19614: steveklabnik/gh19599

Fixes #19599

9 years agorollup merge of #19608: jbranchaud/add-missing-semicolon-in-intro
Alex Crichton [Tue, 9 Dec 2014 17:24:53 +0000 (09:24 -0800)]
rollup merge of #19608: jbranchaud/add-missing-semicolon-in-intro

9 years agorollup merge of #19604: vadimcn/gcc-less
Alex Crichton [Tue, 9 Dec 2014 17:24:52 +0000 (09:24 -0800)]
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

9 years agorollup merge of #19598: japaric/ord
Alex Crichton [Tue, 9 Dec 2014 17:24:51 +0000 (09:24 -0800)]
rollup merge of #19598: japaric/ord

cc #18755

r? @alexcrichton
cc @bjz

9 years agorollup merge of #19594: Arcterus/master
Alex Crichton [Tue, 9 Dec 2014 17:24:50 +0000 (09:24 -0800)]
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]

9 years agorollup merge of #19592: jbranchaud/add-btreemap-iter-doctest
Alex Crichton [Tue, 9 Dec 2014 17:24:48 +0000 (09:24 -0800)]
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.

9 years agorollup merge of #19589: huonw/unboxed-closure-elision
Alex Crichton [Tue, 9 Dec 2014 17:24:47 +0000 (09:24 -0800)]
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.

9 years agorollup merge of #19588: nodakai/libstd-fix-zombie-children-finder
Alex Crichton [Tue, 9 Dec 2014 17:24:46 +0000 (09:24 -0800)]
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@74fb798a200dc82cf5b4a18065e3ea565229adc3 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.

9 years agorollup merge of #19587: huonw/closure-feature-gate
Alex Crichton [Tue, 9 Dec 2014 17:24:44 +0000 (09:24 -0800)]
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.

9 years agorollup merge of #19585: mdinger/guide_typo
Alex Crichton [Tue, 9 Dec 2014 17:24:43 +0000 (09:24 -0800)]
rollup merge of #19585: mdinger/guide_typo

@steveklabnik r?

9 years agorollup merge of #19584: CaptainHayashi/patch-1
Alex Crichton [Tue, 9 Dec 2014 17:24:42 +0000 (09:24 -0800)]
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 :grinning:

9 years agorollup merge of #19581: luqmana/duc
Alex Crichton [Tue, 9 Dec 2014 17:24:41 +0000 (09:24 -0800)]
rollup merge of #19581: luqmana/duc

Fixes #19575.

9 years agorollup merge of #19577: aidancully/master
Alex Crichton [Tue, 9 Dec 2014 17:24:39 +0000 (09:24 -0800)]
rollup merge of #19577: aidancully/master

pthread_key_create can be 0.
addresses issue #19567.

9 years agorollup merge of #19576: nhoss2/master
Alex Crichton [Tue, 9 Dec 2014 17:24:38 +0000 (09:24 -0800)]
rollup merge of #19576: nhoss2/master

There was a link to a non existing guide

9 years agoClean up `libcollections::VecMap`
Tobias Bucher [Tue, 9 Dec 2014 17:17:18 +0000 (18:17 +0100)]
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.

9 years agoAdd a doctest for the std::string::as_string method.
jbranchaud [Sun, 7 Dec 2014 23:47:00 +0000 (17:47 -0600)]
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.

9 years agoDelete the outdated source layout README
Maxime Quandalle [Tue, 9 Dec 2014 00:54:26 +0000 (01:54 +0100)]
Delete the outdated source layout README

9 years agoserialize: base64: remove some .as_bytes() from the tests
Arcterus [Tue, 9 Dec 2014 08:21:43 +0000 (00:21 -0800)]
serialize: base64: remove some .as_bytes() from the tests

9 years agoserialize: base64: improve newline handling speed
Arcterus [Sat, 6 Dec 2014 18:58:18 +0000 (10:58 -0800)]
serialize: base64: improve newline handling speed

9 years agoserialize: base64: allow LF in addition to CRLF and optimize slightly
Arcterus [Sat, 6 Dec 2014 10:35:26 +0000 (02:35 -0800)]
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]

9 years agoauto merge of #19466 : nikomatsakis/rust/recursion-limit, r=eddyb
bors [Tue, 9 Dec 2014 14:02:45 +0000 (14:02 +0000)]
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

9 years agoauto merge of #19249 : barosl/rust/json-type-safety, r=alexcrichton
bors [Tue, 9 Dec 2014 10:51:49 +0000 (10:51 +0000)]
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.

9 years agoauto merge of #19644 : pcwalton/rust/oibit3, r=nikomatsakis
bors [Tue, 9 Dec 2014 07:51:52 +0000 (07:51 +0000)]
auto merge of #19644 : pcwalton/rust/oibit3, r=nikomatsakis

9 years agoAdd some missing Copy implementations
Patrick Walton [Mon, 8 Dec 2014 22:07:33 +0000 (14:07 -0800)]
Add some missing Copy implementations

9 years agoChange 'Example' to 'Examples' throughout collections' rustdocs.
jbranchaud [Tue, 9 Dec 2014 05:28:07 +0000 (23:28 -0600)]
Change 'Example' to 'Examples' throughout collections' rustdocs.

9 years agoauto merge of #19645 : alexcrichton/rust/old-snap, r=brson
bors [Tue, 9 Dec 2014 05:01:53 +0000 (05:01 +0000)]
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

9 years agoRemove Result and Option reexports
Corey Farwell [Mon, 8 Dec 2014 17:58:01 +0000 (12:58 -0500)]
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]

9 years agoRevert "Register new snapshots"
Alex Crichton [Mon, 8 Dec 2014 22:30:13 +0000 (14:30 -0800)]
Revert "Register new snapshots"

This reverts commit 9b443289cf32cbcff16768614340f0c844675340.

9 years agorustc: Prepend a length to all metadata
Alex Crichton [Fri, 5 Dec 2014 05:32:34 +0000 (21:32 -0800)]
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

9 years agoImplemented BorrowFrom<Rc<T>> for T.
Aaron Weiss [Mon, 8 Dec 2014 20:56:10 +0000 (15:56 -0500)]
Implemented BorrowFrom<Rc<T>> for T.

9 years agoauto merge of #19456 : nikomatsakis/rust/reborrow-closure-arg, r=pnkfelix
bors [Mon, 8 Dec 2014 21:31:51 +0000 (21:31 +0000)]
auto merge of #19456 : nikomatsakis/rust/reborrow-closure-arg, r=pnkfelix

Otherwise region inference can fail when closure arguments include `ref` bindings. Test case included in the PR.

9 years agoLink regions in `ref` bindings from fn arguments.
Niko Matsakis [Tue, 2 Dec 2014 07:42:11 +0000 (02:42 -0500)]
Link regions in `ref` bindings from fn arguments.

9 years agoStop masking overflow and propagate it out more aggressively; also improve error...
Niko Matsakis [Tue, 2 Dec 2014 19:04:10 +0000 (14:04 -0500)]
Stop masking overflow and propagate it out more aggressively; also improve error reporting to suggest to user how to fix.

9 years agoKill dead code
Niko Matsakis [Tue, 2 Dec 2014 18:28:59 +0000 (13:28 -0500)]
Kill dead code

9 years agoAdd ability to configure recursion limit.
Niko Matsakis [Tue, 2 Dec 2014 17:57:38 +0000 (12:57 -0500)]
Add ability to configure recursion limit.

Fixes #19318.

9 years agoAdd a feature opt `opt_out_copy` that allows people to revert to the older
Niko Matsakis [Mon, 8 Dec 2014 18:21:35 +0000 (13:21 -0500)]
Add a feature opt `opt_out_copy` that allows people to revert to the older
behavior temporarily. This feature will eventually transition to REJECTED.

9 years agolibrustc: Make `Copy` opt-in.
Niko Matsakis [Sat, 6 Dec 2014 01:01:33 +0000 (17:01 -0800)]
librustc: Make `Copy` opt-in.

This change makes the compiler no longer infer whether types (structures
and enumerations) implement the `Copy` trait (and thus are implicitly
copyable). Rather, you must implement `Copy` yourself via `impl Copy for
MyType {}`.

A new warning has been added, `missing_copy_implementations`, to warn
you if a non-generic public type has been added that could have
implemented `Copy` but didn't.

For convenience, you may *temporarily* opt out of this behavior by using
`#![feature(opt_out_copy)]`. Note though that this feature gate will never be
accepted and will be removed by the time that 1.0 is released, so you should
transition your code away from using it.

This breaks code like:

    #[deriving(Show)]
    struct Point2D {
        x: int,
        y: int,
    }

    fn main() {
        let mypoint = Point2D {
            x: 1,
            y: 1,
        };
        let otherpoint = mypoint;
        println!("{}{}", mypoint, otherpoint);
    }

Change this code to:

    #[deriving(Show)]
    struct Point2D {
        x: int,
        y: int,
    }

    impl Copy for Point2D {}

    fn main() {
        let mypoint = Point2D {
            x: 1,
            y: 1,
        };
        let otherpoint = mypoint;
        println!("{}{}", mypoint, otherpoint);
    }

This is the backwards-incompatible part of #13231.

Part of RFC #3.

[breaking-change]

9 years agoauto merge of #19574 : erickt/rust/vec-reserve, r=alexcrichton
bors [Mon, 8 Dec 2014 18:42:21 +0000 (18:42 +0000)]
auto merge of #19574 : erickt/rust/vec-reserve, r=alexcrichton

(I don't understand why this works, and so I don't quite trust this yet. I'm pushing it up to see if anyone else can replicate this performance increase)

Somehow llvm is able to optimize this version of Vec::reserve into dramatically faster than the old version. In micro-benchmarks this was 2-10 times faster. It also reduce my Rust compile time from 41 minutes to 27 minutes.

Closes #19281.

9 years agoauto merge of #19306 : steveklabnik/rust/gh19269, r=nikomatsakis,brson
bors [Mon, 8 Dec 2014 16:22:43 +0000 (16:22 +0000)]
auto merge of #19306 : steveklabnik/rust/gh19269, r=nikomatsakis,brson

Fixes #19269.

/cc @thestinger @mahkoh @mitsuhiko

9 years agoauto merge of #19560 : sfackler/rust/should-fail-reason, r=alexcrichton
bors [Mon, 8 Dec 2014 12:12:23 +0000 (12:12 +0000)]
auto merge of #19560 : sfackler/rust/should-fail-reason, r=alexcrichton

The test harness will make sure that the panic message contains the
specified string. This is useful to help make `#[should_fail]` tests a
bit less brittle by decreasing the chance that the test isn't
"accidentally" passing due to a panic occurring earlier than expected.
The behavior is in some ways similar to JUnit's `expected` feature:
`@Test(expected=NullPointerException.class)`.

Without the message assertion, this test would pass even though it's not
actually reaching the intended part of the code:
```rust
#[test]
#[should_fail(message = "out of bounds")]
fn test_oob_array_access() {
    let idx: uint = from_str("13o").unwrap(); // oops, this will panic
    [1i32, 2, 3][idx];
}
```

9 years agolibserialize: Prefer into_string() to to_string() wherever possible
Barosl Lee [Mon, 8 Dec 2014 09:16:09 +0000 (18:16 +0900)]
libserialize: Prefer into_string() to to_string() wherever possible

Except for the example code!

9 years agolibserialize: Code cleanup
Barosl Lee [Sun, 23 Nov 2014 18:32:31 +0000 (03:32 +0900)]
libserialize: Code cleanup

9 years agolibserialize: Always use a decimal point when emitting a float value
Barosl Lee [Sun, 23 Nov 2014 18:14:02 +0000 (03:14 +0900)]
libserialize: 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.

[breaking-change]

9 years agoauto merge of #19506 : eddyb/rust/fmt-polish, r=alexcrichton
bors [Mon, 8 Dec 2014 09:02:33 +0000 (09:02 +0000)]
auto merge of #19506 : eddyb/rust/fmt-polish, r=alexcrichton

9 years agolibserialize: Do not coerce to integer when decoding a float value
Barosl Lee [Sun, 23 Nov 2014 18:00:10 +0000 (03:00 +0900)]
libserialize: 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.

[breaking-change]

9 years agolibserialize: Remove float preprocessing in serialize::json::Encoder
Barosl Lee [Sun, 23 Nov 2014 17:22:30 +0000 (02:22 +0900)]
libserialize: 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 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

[breaking-change]

9 years agotest: adjust pretty/issue-4264 for formatting changes.
Eduard Burtescu [Mon, 8 Dec 2014 07:14:00 +0000 (09:14 +0200)]
test: adjust pretty/issue-4264 for formatting changes.

9 years agocore: make the public fmt API completely safe.
Eduard Burtescu [Wed, 3 Dec 2014 20:56:39 +0000 (22:56 +0200)]
core: make the public fmt API completely safe.

9 years agocore: remove the dead function fmt::argumentstr.
Eduard Burtescu [Wed, 3 Dec 2014 20:46:09 +0000 (22:46 +0200)]
core: remove the dead function fmt::argumentstr.

9 years agodocumentation incorrectly described from_utf8
Jon Haddad [Sun, 7 Dec 2014 19:35:06 +0000 (11:35 -0800)]
documentation incorrectly described from_utf8

Docs said from_utf8 accepts a vector when it actually accepts a slice of bytes.

9 years agoauto merge of #19555 : jbranchaud/rust/add-doctests-for-key-values-of-btreemap, r...
bors [Mon, 8 Dec 2014 05:52:28 +0000 (05:52 +0000)]
auto merge of #19555 : jbranchaud/rust/add-doctests-for-key-values-of-btreemap, r=Gankro

9 years agoauto merge of #19378 : japaric/rust/no-as-slice, r=alexcrichton
bors [Mon, 8 Dec 2014 02:32:31 +0000 (02:32 +0000)]
auto merge of #19378 : japaric/rust/no-as-slice, r=alexcrichton

Now that we have an overloaded comparison (`==`) operator, and that `Vec`/`String` deref to `[T]`/`str` on method calls, many `as_slice()`/`as_mut_slice()`/`to_string()` calls have become redundant. This patch removes them. These were the most common patterns:

- `assert_eq(test_output.as_slice(), "ground truth")` -> `assert_eq(test_output, "ground truth")`
- `assert_eq(test_output, "ground truth".to_string())` -> `assert_eq(test_output, "ground truth")`
- `vec.as_mut_slice().sort()` -> `vec.sort()`
- `vec.as_slice().slice(from, to)` -> `vec.slice(from_to)`

---

Note that e.g. `a_string.push_str(b_string.as_slice())` has been left untouched in this PR, since we first need to settle down whether we want to favor the `&*b_string` or the `b_string[]` notation.

This is rebased on top of #19167

cc @alexcrichton @aturon

9 years agoauto merge of #19561 : csouth3/rust/treeset-bitops, r=Gankro
bors [Mon, 8 Dec 2014 00:12:30 +0000 (00:12 +0000)]
auto merge of #19561 : csouth3/rust/treeset-bitops, r=Gankro

Implement the `BitOr`, `BitAnd`, `BitXor`, and `Sub` traits from `std::ops` for TreeSet.  The behavior of these operator overloads is consistent with [RFC 235](https://github.com/rust-lang/rfcs/blob/master/text/0235-collections-conventions.md#combinations).

r? @Gankro

9 years agoMention expected in testing docs
Steven Fackler [Sat, 6 Dec 2014 23:33:33 +0000 (15:33 -0800)]
Mention expected in testing docs

9 years agostring: Add test for FromIterator<&str> and Extend<&str>
bluss [Sun, 7 Dec 2014 20:45:47 +0000 (21:45 +0100)]
string: Add test for FromIterator<&str> and Extend<&str>

9 years agostring: Add test for FromIterator<char> and Extend<char>
bluss [Sun, 7 Dec 2014 20:43:11 +0000 (21:43 +0100)]
string: Add test for FromIterator<char> and Extend<char>

9 years agosyntax: use UFCS in the expansion of `#[deriving(Ord)]`
Jorge Aparicio [Sat, 6 Dec 2014 16:56:55 +0000 (11:56 -0500)]
syntax: use UFCS in the expansion of `#[deriving(Ord)]`

cc #18755

9 years agostring: Implement FromIterator<&str> and Extend<&str> for String
bluss [Sun, 7 Dec 2014 20:32:00 +0000 (21:32 +0100)]
string: Implement FromIterator<&str> and Extend<&str> for String

&str is a "particle" of a string already, see the graphemes iterator,
so it seems natural that we should be able to use it with Extend.

9 years agostring: Use the iterator size_hint() in .extend()
bluss [Sun, 7 Dec 2014 20:31:24 +0000 (21:31 +0100)]
string: Use the iterator size_hint() in .extend()

9 years agoRemove mention of Dequeue in collections docs.
Steve Klabnik [Sun, 7 Dec 2014 19:12:01 +0000 (14:12 -0500)]
Remove mention of Dequeue in collections docs.

  https://botbot.me/mozilla/rust/2014-12-07/?msg=27003846&page=20

9 years agoauto merge of #19548 : luqmana/rust/mfb, r=nikomatsakis
bors [Sun, 7 Dec 2014 19:02:18 +0000 (19:02 +0000)]
auto merge of #19548 : luqmana/rust/mfb, r=nikomatsakis

Fixes #19367.

9 years agoMake MemoryMap use HANDLE on Windows.
Peter Atashian [Sun, 7 Dec 2014 18:25:51 +0000 (13:25 -0500)]
Make MemoryMap use HANDLE on Windows.
Also fixes some conflicting module names.

Signed-off-by: Peter Atashian <retep998@gmail.com>
9 years agoauto merge of #19539 : cmr/rust/18959, r=nikomatsakis
bors [Sun, 7 Dec 2014 16:12:22 +0000 (16:12 +0000)]
auto merge of #19539 : cmr/rust/18959, r=nikomatsakis

Closes #18959

Technically, this causes code that once compiled to no longer compile, but
that code probably never ran.

[breaking-change]

------------

Not quite sure the error message is good enough, I feel like it ought to tell you "because it inherits from non-object-safe trait Foo", so I've opened up a follow-up issue #19538

9 years agoFix syntax error on android tests
Jorge Aparicio [Sun, 7 Dec 2014 13:49:17 +0000 (08:49 -0500)]
Fix syntax error on android tests

9 years agoauto merge of #19522 : mukilan/rust/import-conflicts-item, r=cmr
bors [Sun, 7 Dec 2014 13:42:18 +0000 (13:42 +0000)]
auto merge of #19522 : mukilan/rust/import-conflicts-item, r=cmr

Fixes #19498

9 years agoAdd enum namespacing to the Guide.
Steve Klabnik [Sun, 7 Dec 2014 12:55:30 +0000 (07:55 -0500)]
Add enum namespacing to the Guide.

Closes #19556.

9 years agoCorrect the reference with regards to floats
Steve Klabnik [Sun, 7 Dec 2014 12:30:15 +0000 (07:30 -0500)]
Correct the reference with regards to floats

Fixes #19595.

9 years agoremove usage of notrust from the docs
Steve Klabnik [Sun, 7 Dec 2014 09:18:56 +0000 (04:18 -0500)]
remove usage of notrust from the docs

Fixes #19599

9 years agoauto merge of #19488 : jbranchaud/rust/add-btree-set-doctests, r=alexcrichton
bors [Sun, 7 Dec 2014 07:12:16 +0000 (07:12 +0000)]
auto merge of #19488 : jbranchaud/rust/add-btree-set-doctests, r=alexcrichton

There is already a test for `union` in the test namespace, but this commit adds a doctest that will appear in the rustdocs.

Someone on IRC said, *Write doctests!*, so here I am.

I am not sure this is the best way to demonstrate the behavior of the union function, so I am open to suggestions for improving this. If I am on the right track I'd be glad to include similar doctests for `intersection`, `difference`, etc.

9 years agolibtime: remove unnecessary `to_string()` calls
Jorge Aparicio [Fri, 28 Nov 2014 00:58:14 +0000 (19:58 -0500)]
libtime: remove unnecessary `to_string()` calls

9 years agolibtest: remove unnecessary `to_string()` calls
Jorge Aparicio [Fri, 28 Nov 2014 00:55:37 +0000 (19:55 -0500)]
libtest: remove unnecessary `to_string()` calls

9 years agolibterm: remove unnecessary `to_string()` calls
Jorge Aparicio [Fri, 28 Nov 2014 00:53:58 +0000 (19:53 -0500)]
libterm: remove unnecessary `to_string()` calls