Commit graph

34990 commits

Author SHA1 Message Date
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
bors
ce05ff5d4b auto merge of #19695 : arthurtw/rust/master, r=steveklabnik 2014-12-13 15:22:16 +00: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
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
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
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
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
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
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
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
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
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
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
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
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
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
bors
c38e73fef5 auto merge of #19705 : brson/rust/fix-install, r=alexcrichton 2014-12-10 20:11:27 +00:00
Brian Anderson
65bca024a7 Don't try to dist src/README.md which does not exist 2014-12-10 09:47:36 -08: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
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