Commit Graph

35132 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
bors
b25e100173 auto merge of #19665 : alexcrichton/rust/rollup, r=alexcrichton 2014-12-09 19:12:02 +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