]> git.lizzy.rs Git - rust.git/log
rust.git
10 years agoauto merge of #15787 : treeman/rust/hashmap-doc, r=alexcrichton
bors [Fri, 25 Jul 2014 23:01:16 +0000 (23:01 +0000)]
auto merge of #15787 : treeman/rust/hashmap-doc, r=alexcrichton

Add an example showing how to use the map with a custom type. Fill in
examples for methods  without ones.

Also move `pop_equiv` next to related public methods, to not create a
duplicate trait in the docs.

10 years agoauto merge of #15979 : Randati/rust/patch-2, r=kballard
bors [Fri, 25 Jul 2014 20:36:10 +0000 (20:36 +0000)]
auto merge of #15979 : Randati/rust/patch-2, r=kballard

10 years agoauto merge of #15968 : nham/rust/keys_values_other_maps, r=alexcrichton
bors [Fri, 25 Jul 2014 18:51:09 +0000 (18:51 +0000)]
auto merge of #15968 : nham/rust/keys_values_other_maps, r=alexcrichton

Adds methods for obtaining iterators over the keys or values of a SmallIntMap/TreeMap/TrieMap.

Closes #14376

10 years agoauto merge of #15958 : hirschenberger/rust/borrock-stats-div-by-zero, r=alexcrichton
bors [Fri, 25 Jul 2014 15:41:08 +0000 (15:41 +0000)]
auto merge of #15958 : hirschenberger/rust/borrock-stats-div-by-zero, r=alexcrichton

`rustc -Z borrowck-stats` displays ugly `-NaN%` in the stats

```
paths requiring guarantees: 0
paths requiring loans     : 0 (-NaN%)
paths requiring imm loans : 0 (-NaN%)
stable paths              : 0 (-NaN%)
```

10 years agoFix assert message
Randati [Fri, 25 Jul 2014 15:12:21 +0000 (18:12 +0300)]
Fix assert message

10 years agoauto merge of #15971 : alexcrichton/rust/hurray-for-windows, r=pcwalton
bors [Fri, 25 Jul 2014 13:56:08 +0000 (13:56 +0000)]
auto merge of #15971 : alexcrichton/rust/hurray-for-windows, r=pcwalton

The right hand side of the comparison in these checks are values of type
Option<&Path> which are normalized versions of the left-hand side, so they're
not guaranteed to be byte-for-byte equivalent even though they're the same path.

For this reasons, the command line arguments are promoted to paths for
comparison of equality.

This fixes a bug on windows where if a library was specified with --extern it
would then be picked up twice because it was not considered to have been
previously registered.

10 years agoauto merge of #15970 : Zoxc/rust/noalias-ref, r=cmr
bors [Fri, 25 Jul 2014 12:11:08 +0000 (12:11 +0000)]
auto merge of #15970 : Zoxc/rust/noalias-ref, r=cmr

This add the LLVM noalias attribute to parameters of a
shared reference type (&) which have a safe interior.

10 years agoauto merge of #15957 : pcwalton/rust/builtin-bound-impl-checking, r=huonw,pnkfelix
bors [Fri, 25 Jul 2014 09:31:10 +0000 (09:31 +0000)]
auto merge of #15957 : pcwalton/rust/builtin-bound-impl-checking, r=huonw,pnkfelix

method calls are involved.

This breaks code like:

    impl<T:Copy> Foo for T { ... }

    fn take_param<T:Foo>(foo: &T) { ... }

    fn main() {
        let x = box 3i; // note no `Copy` bound
        take_param(&x);
    }

Change this code to not contain a type error. For example:

    impl<T:Copy> Foo for T { ... }

    fn take_param<T:Foo>(foo: &T) { ... }

    fn main() {
        let x = 3i; // satisfies `Copy` bound
        take_param(&x);
    }

Closes #15860.

[breaking-change]

r? @alexcrichton

10 years agolibrustc: Check built-in trait bounds on implementations when direct
Patrick Walton [Thu, 24 Jul 2014 20:52:47 +0000 (13:52 -0700)]
librustc: Check built-in trait bounds on implementations when direct
method calls are involved.

This breaks code like:

    impl<T:Copy> Foo for T { ... }

    fn take_param<T:Foo>(foo: &T) { ... }

    fn main() {
        let x = box 3i; // note no `Copy` bound
        take_param(&x);
    }

Change this code to not contain a type error. For example:

    impl<T:Copy> Foo for T { ... }

    fn take_param<T:Foo>(foo: &T) { ... }

    fn main() {
        let x = 3i; // satisfies `Copy` bound
        take_param(&x);
    }

Closes #15860.

[breaking-change]

10 years agoauto merge of #15961 : pcwalton/rust/fn-pointer-in-iterator, r=huonw
bors [Fri, 25 Jul 2014 07:46:12 +0000 (07:46 +0000)]
auto merge of #15961 : pcwalton/rust/fn-pointer-in-iterator, r=huonw

This breaks code like:

    struct A<'a> {
        func: &'a fn() -> Option<int>
    }

    fn foo() -> Option<int> { ... }

    fn create() -> A<'static> {
        A {
            func: &foo
        }
    }

Change this code to not take functions by reference. For example:

    struct A {
        func: extern "Rust" fn() -> Option<int>
    }

    fn foo() -> Option<int> { ... }

    fn create() -> A {
        A {
            func: foo
        }
    }

Closes #13595.

[breaking-change]

r? @huonw

10 years agoauto merge of #15959 : omasanori/rust/cleanup-ja, r=alexcrichton
bors [Fri, 25 Jul 2014 06:01:13 +0000 (06:01 +0000)]
auto merge of #15959 : omasanori/rust/cleanup-ja, r=alexcrichton

The translation is based on an early version of tutorial.md, thus most
of entries have been marked as fuzzy and actually they are incorrect.
Now tutorial.md is planed to be replaced with guide.md, so I'd suggest
removing translation files for a while.

/cc @gifnksm

10 years agorustc: Compare paths with --extern, not bytes
Alex Crichton [Fri, 25 Jul 2014 05:39:52 +0000 (22:39 -0700)]
rustc: Compare paths with --extern, not bytes

The right hand side of the comparison in these checks are values of type
Option<&Path> which are normalized versions of the left-hand side, so they're
not guaranteed to be byte-for-byte equivalent even though they're the same path.

For this reasons, the command line arguments are promoted to paths for
comparison of equality.

This fixes a bug on windows where if a library was specified with --extern it
would then be picked up twice because it was not considered to have been
previously registered.

10 years agoAdd noalias to safe shared reference parameters
John Kåre Alsaker [Fri, 25 Jul 2014 05:29:12 +0000 (07:29 +0200)]
Add noalias to safe shared reference parameters

This add the LLVM noalias attribute to parameters of a
shared reference type (&) which have a safe interior.

10 years agoAdd methods for obtaining iterators over the keys and values of a TrieMap
nham [Fri, 25 Jul 2014 05:14:49 +0000 (01:14 -0400)]
Add methods for obtaining iterators over the keys and values of a TrieMap

10 years agoAdd methods for obtaining iterators over the keys and values of a SmallIntMap
nham [Fri, 25 Jul 2014 04:48:05 +0000 (00:48 -0400)]
Add methods for obtaining iterators over the keys and values of a SmallIntMap

10 years agoAdd methods for obtaining iterators over the keys and values of a TreeMap
nham [Fri, 25 Jul 2014 04:32:42 +0000 (00:32 -0400)]
Add methods for obtaining iterators over the keys and values of a TreeMap

10 years agoauto merge of #15809 : pcwalton/rust/dedesugar-for, r=pnkfelix
bors [Fri, 25 Jul 2014 02:21:14 +0000 (02:21 +0000)]
auto merge of #15809 : pcwalton/rust/dedesugar-for, r=pnkfelix

librustc: Stop desugaring `for` expressions and translate them directly.

This makes edge cases in which the `Iterator` trait was not in scope
and/or `Option` or its variants were not in scope work properly.

This breaks code that looks like:

    struct MyStruct { ... }

    impl MyStruct {
        fn next(&mut self) -> Option<int> { ... }
    }

    for x in MyStruct { ... } { ... }

Change ad-hoc `next` methods like the above to implementations of the
`Iterator` trait. For example:

    impl Iterator<int> for MyStruct {
        fn next(&mut self) -> Option<int> { ... }
    }

Closes #15392.

[breaking-change]

10 years agolibrustc: Stop desugaring `for` expressions and translate them directly.
Patrick Walton [Tue, 22 Jul 2014 03:54:28 +0000 (20:54 -0700)]
librustc: Stop desugaring `for` expressions and translate them directly.

This makes edge cases in which the `Iterator` trait was not in scope
and/or `Option` or its variants were not in scope work properly.

This breaks code that looks like:

    struct MyStruct { ... }

    impl MyStruct {
        fn next(&mut self) -> Option<int> { ... }
    }

    for x in MyStruct { ... } { ... }

Change ad-hoc `next` methods like the above to implementations of the
`Iterator` trait. For example:

    impl Iterator<int> for MyStruct {
        fn next(&mut self) -> Option<int> { ... }
    }

Closes #15392.

[breaking-change]

10 years agoauto merge of #15951 : edwardw/rust/issue-15896, r=alexcrichton
bors [Fri, 25 Jul 2014 00:36:11 +0000 (00:36 +0000)]
auto merge of #15951 : edwardw/rust/issue-15896, r=alexcrichton

Fix ICE when there's an incorrect enum variant constructor in match arm.

Closes #15896.

10 years agoauto merge of #15945 : treeman/rust/doc-smallint-update, r=alexcrichton
bors [Thu, 24 Jul 2014 22:51:10 +0000 (22:51 +0000)]
auto merge of #15945 : treeman/rust/doc-smallint-update, r=alexcrichton

Forgot two methods, but @alexcrichton was a bit too quick to accept  #15943, so I made a new PR.

10 years agolibrustc: Make references to functions not have static lifetime.
Patrick Walton [Thu, 24 Jul 2014 22:27:01 +0000 (15:27 -0700)]
librustc: Make references to functions not have static lifetime.

This breaks code like:

    struct A<'a> {
        func: &'a fn() -> Option<int>
    }

    fn foo() -> Option<int> { ... }

    fn create() -> A<'static> {
        A {
            func: &foo
        }
    }

Change this code to not take functions by reference. For example:

    struct A {
        func: extern "Rust" fn() -> Option<int>
    }

    fn foo() -> Option<int> { ... }

    fn create() -> A {
        A {
            func: foo
        }
    }

Closes #13595.

[breaking-change]

10 years agoRemove obsolete Japanese translation for a while.
OGINO Masanori [Thu, 24 Jul 2014 21:29:17 +0000 (06:29 +0900)]
Remove obsolete Japanese translation for a while.

The translation is based on an early version of tutorial.md, thus most
of entries have been marked as fuzzy and actually they are incorrect.
Now tutorial.md is planed to be replaced with guide.md, so I'd suggest
removing translation files for a while.

Signed-off-by: OGINO Masanori <masanori.ogino@gmail.com>
10 years agoFix display of `-NaN%` in borrock stats caused by div by zero
Falco Hirschenberger [Thu, 24 Jul 2014 21:49:30 +0000 (23:49 +0200)]
Fix display of `-NaN%` in borrock stats caused by div by zero

10 years agoauto merge of #15779 : alexcrichton/rust/no-nul-terminator, r=pcwalton
bors [Thu, 24 Jul 2014 19:56:06 +0000 (19:56 +0000)]
auto merge of #15779 : alexcrichton/rust/no-nul-terminator, r=pcwalton

Apparently the default getFile implementation for a memory buffer in LLVM ends
up requiring a null terminator at the end of the file. This isn't true a good
bit of the time apparently on OSX. There have been a number of failed
nightly/snapshot builds recently with this strange assertion.

This modifies the calls to MemoryBuffer::getFile to explicitly not ask for a
null terminator.

10 years agorustllvm: Don't require null terminators in files
Alex Crichton [Fri, 18 Jul 2014 14:07:15 +0000 (07:07 -0700)]
rustllvm: Don't require null terminators in files

Apparently the default getFile implementation for a memory buffer in LLVM ends
up requiring a null terminator at the end of the file. This isn't true a good
bit of the time apparently on OSX. There have been a number of failed
nightly/snapshot builds recently with this strange assertion.

This modifies the calls to MemoryBuffer::getFile to explicitly not ask for a
null terminator.

10 years agoauto merge of #15424 : TeXitoi/rust/relicense-shootout-threadring, r=brson
bors [Thu, 24 Jul 2014 18:11:03 +0000 (18:11 +0000)]
auto merge of #15424 : TeXitoi/rust/relicense-shootout-threadring, r=brson

Everyone agreed.

Related to #14248, close #15328

@brson OK?

10 years agoFix #15896
Edward Wang [Thu, 24 Jul 2014 16:44:35 +0000 (00:44 +0800)]
Fix #15896

Fix ICE when there's an incorrect enum variant constructor in match arm.

Closes #15896.

10 years agoauto merge of #15949 : alexcrichton/rust/rollup, r=alexcrichton
bors [Thu, 24 Jul 2014 16:11:23 +0000 (16:11 +0000)]
auto merge of #15949 : alexcrichton/rust/rollup, r=alexcrichton

10 years agoTest fixes from the rollup
Alex Crichton [Thu, 24 Jul 2014 15:48:38 +0000 (08:48 -0700)]
Test fixes from the rollup

Closes #15807 (Deprecate some unsafe functions in `str::raw` and remove `OwnedStr` trait)
Closes #15859 (Implement `Show` for `CString` and fix warning compiling tests for libcollections)
Closes #15911 (Updated LLVM for iOS)
Closes #15925 (libsyntax: Remove `~self` and `mut ~self` from the language.)
Closes #15930 (Add examples for Checked[Add|Sub|Mul|Div])
Closes #15933 (rustdoc: make table of contents optional)
Closes #15937 (librustc: Make bare functions implement the `FnMut` trait.)
Closes #15938 (librustc: Check structure constructors against their types.)
Closes #15939 (rustdoc: Add a --crate-name option)
Closes #15942 (Document trie collections)
Closes #15943 (Document SmallIntMap)

10 years agoDocument update and update_with_key in SmallIntMap.
Jonas Hietala [Thu, 24 Jul 2014 14:28:34 +0000 (16:28 +0200)]
Document update and update_with_key in SmallIntMap.

Move update above for better docs progression.

10 years agoDocument SmallIntMap with examples.
Jonas Hietala [Thu, 24 Jul 2014 13:46:55 +0000 (15:46 +0200)]
Document SmallIntMap with examples.

10 years agoFormat documentation for SmallIntMap.
Jonas Hietala [Thu, 24 Jul 2014 13:22:24 +0000 (15:22 +0200)]
Format documentation for SmallIntMap.

10 years agoMain examples for TrieSet and TrieMap.
Jonas Hietala [Thu, 24 Jul 2014 12:30:03 +0000 (14:30 +0200)]
Main examples for TrieSet and TrieMap.

10 years agoDocument TrieSet and TrieMap methods.
Jonas Hietala [Thu, 24 Jul 2014 12:08:14 +0000 (14:08 +0200)]
Document TrieSet and TrieMap methods.

10 years agorustdoc: Add a --crate-name option
Alex Crichton [Thu, 24 Jul 2014 04:46:49 +0000 (21:46 -0700)]
rustdoc: Add a --crate-name option

Like rustc, this is required by cargo to build documentation.

10 years agolibrustc: Check structure constructors against their types.
Patrick Walton [Thu, 24 Jul 2014 04:33:33 +0000 (21:33 -0700)]
librustc: Check structure constructors against their types.

This breaks code like:

    struct Point<T> {
        x: T,
        y: T,
    }

    let pt = Point::<bool> {
        x: 1,
        y: 2,
    };

Change this code to not contain a type error. For example:

    let pt = Point::<int> {
        x: 1,
        y: 2,
    };

Closes #9620.
Closes #15875.

[breaking-change]

10 years agolibrustc: Make bare functions implement the `FnMut` trait.
Patrick Walton [Thu, 24 Jul 2014 02:57:30 +0000 (19:57 -0700)]
librustc: Make bare functions implement the `FnMut` trait.

This is done entirely in the libraries for functions up to 16 arguments.
A macro is used so that more arguments can be easily added if we need.
Note that I had to adjust the overloaded call algorithm to not try
calling the overloaded call operator if the callee is a built-in
function type, to prevent loops.

Closes #15448.

10 years agorustdoc: make table of contents optional
Aaron Turon [Wed, 23 Jul 2014 22:43:03 +0000 (15:43 -0700)]
rustdoc: make table of contents optional

rustdoc currently determines whether to produce a table of
contents (along with numbered sections) from the input type: yes for
markdown input, no for Rust input. This commit adds a flag to disable
the table of contents for markdown input, which is useful for embedding
the output in a larger context.

10 years agoAdd examples for Checked[Add|Sub|Mul|Div]
nham [Wed, 23 Jul 2014 19:57:30 +0000 (15:57 -0400)]
Add examples for Checked[Add|Sub|Mul|Div]

10 years agolibsyntax: Remove `~self` and `mut ~self` from the language.
Patrick Walton [Wed, 23 Jul 2014 17:21:50 +0000 (10:21 -0700)]
libsyntax: Remove `~self` and `mut ~self` from the language.

This eliminates the last vestige of the `~` syntax.

Instead of `~self`, write `self: Box<TypeOfSelf>`; instead of `mut
~self`, write `mut self: Box<TypeOfSelf>`, replacing `TypeOfSelf` with
the self-type parameter as specified in the implementation.

Closes #13885.

[breaking-change]

10 years agoUpdated LLVM for iOS
Valerii Hiora [Wed, 23 Jul 2014 06:14:58 +0000 (09:14 +0300)]
Updated LLVM for iOS

There should be no more problems during SjLj pass

10 years agoAdd a null pointer check to CString::new
Adolfo Ochagavía [Tue, 22 Jul 2014 16:24:33 +0000 (18:24 +0200)]
Add a null pointer check to CString::new

This also removes checks in other methods of `CString`

Breaking changes:
* `CString::new` now fails if `buf` is null. To avoid this add a check
before creatng a new `CString` .
* The `is_null` and `is_not_null` methods are deprecated, because a
`CString` cannot be null.
* Other methods which used to fail if the `CString` was null do not fail anymore

[breaking-change]

10 years agoImplement Show for CString
Adolfo Ochagavía [Mon, 21 Jul 2014 16:06:24 +0000 (18:06 +0200)]
Implement Show for CString

We use use `from_utf8_lossy` to convert it to a MaybeOwned string, to
avoid failing in case the CString contains invalid UTF-8

10 years agoFix deprecation warning in deque.rs
Adolfo Ochagavía [Mon, 21 Jul 2014 14:04:24 +0000 (16:04 +0200)]
Fix deprecation warning in deque.rs

10 years agoAdd `string::raw::from_buf`
Adolfo Ochagavía [Tue, 22 Jul 2014 15:55:12 +0000 (17:55 +0200)]
Add `string::raw::from_buf`

10 years agoFix travis errors
Adolfo Ochagavía [Tue, 22 Jul 2014 14:02:54 +0000 (16:02 +0200)]
Fix travis errors

10 years agoDeprecated `String::from_raw_parts`
Adolfo Ochagavía [Mon, 21 Jul 2014 18:44:56 +0000 (20:44 +0200)]
Deprecated `String::from_raw_parts`

Replaced by `string::raw::from_parts`

[breaking-change]

10 years agoDeprecated `str::raw::from_buf_len`
Adolfo Ochagavía [Sun, 20 Jul 2014 10:08:40 +0000 (12:08 +0200)]
Deprecated `str::raw::from_buf_len`

Replaced by `string::raw::from_buf_len`

[breaking-change]

10 years agoDeprecated `str::raw::from_byte`
Adolfo Ochagavía [Sat, 19 Jul 2014 10:30:35 +0000 (12:30 +0200)]
Deprecated `str::raw::from_byte`

Use `string:raw::from_utf8` instead

[breaking-change]

10 years agoDeprecated `str::raw::from_utf8_owned`
Adolfo Ochagavía [Sat, 19 Jul 2014 10:23:47 +0000 (12:23 +0200)]
Deprecated `str::raw::from_utf8_owned`

Replaced by `string::raw::from_utf8`

[breaking-change]

10 years agoDeprecated `str::raw::from_c_str`
Adolfo Ochagavía [Sat, 19 Jul 2014 10:08:34 +0000 (12:08 +0200)]
Deprecated `str::raw::from_c_str`

Use `string::raw::from_buf` instead

[breaking-change]

10 years agoRemove OwnedStr trait
Adolfo Ochagavía [Sat, 19 Jul 2014 09:34:51 +0000 (11:34 +0200)]
Remove OwnedStr trait

This trait was only implemented by `String`. It provided the methods
`into_bytes` and `append`, both of which **are already implemented as normal
methods** of `String` (not as trait methods). This change improves the
consistency of strings.

This shouldn't break any code, except if somebody has implemented
`OwnedStr` for a user-defined type.

10 years agoCleanup HashMap documentation.
Jonas Hietala [Thu, 24 Jul 2014 13:03:01 +0000 (15:03 +0200)]
Cleanup HashMap documentation.

Link to mentioned methods. Use `# Failure` tags to describe failure.
Make `pop_equiv`, `find_equiv` and `get_copy` standalone.

10 years agoauto merge of #15922 : poiru/rust/remove-whitespace-mk-backslash, r=brson
bors [Thu, 24 Jul 2014 13:51:17 +0000 (13:51 +0000)]
auto merge of #15922 : poiru/rust/remove-whitespace-mk-backslash, r=brson

The alignment of the line continuation backslashes is rather inconsistent. These commits solve that by removing the extra whitespace and adding a space where there previously was none. An alternative solution would be to fix the alignment.

10 years agoauto merge of #15856 : treeman/rust/doc-priorityqueue, r=huonw
bors [Thu, 24 Jul 2014 11:46:15 +0000 (11:46 +0000)]
auto merge of #15856 : treeman/rust/doc-priorityqueue, r=huonw

Add examples to methods.

10 years agoauto merge of #15921 : dotdash/rust/match_lifetimes, r=pcwalton
bors [Thu, 24 Jul 2014 09:51:16 +0000 (09:51 +0000)]
auto merge of #15921 : dotdash/rust/match_lifetimes, r=pcwalton

The allocas used in match expression currently don't get good lifetime
markers, in fact they only get lifetime start markers, because their
lifetimes don't match to cleanup scopes.

While the bindings themselves are bog standard and just need a matching
pair of start and end markers, they might need them twice, once for a
guard clause and once for the match body.

The __llmatch alloca OTOH needs a single lifetime start marker, but
when there's a guard clause, it needs two end markers, because its
lifetime ends either when the guard doesn't match or after the match
body.

With these intrinsics in place, LLVM can now, for example, optimize
code like this:

````rust
enum E {
  A1(int),
  A2(int),
  A3(int),
  A4(int),
}

pub fn variants(x: E) {
  match x {
    A1(m) => bar(&m),
    A2(m) => bar(&m),
    A3(m) => bar(&m),
    A4(m) => bar(&m),
  }
}
````

To a single call to bar, using only a single stack slot. It still fails
to eliminate some of checks.

````gas
.Ltmp5:
.cfi_def_cfa_offset 16
movb (%rdi), %al
testb %al, %al
je .LBB3_5
movzbl %al, %eax
cmpl $1, %eax
je .LBB3_5
cmpl $2, %eax
.LBB3_5:
movq 8(%rdi), %rax
movq %rax, (%rsp)
leaq (%rsp), %rdi
callq _ZN3bar20hcb7a0d8be8e17e37daaE@PLT
popq %rax
retq
````

Refs #15665

10 years agoDocument PriorityQueue.
Jonas Hietala [Mon, 21 Jul 2014 12:39:28 +0000 (14:39 +0200)]
Document PriorityQueue.

10 years agoMove contructors to the top of PriorityQueue.
Jonas Hietala [Mon, 21 Jul 2014 09:35:49 +0000 (11:35 +0200)]
Move contructors to the top of PriorityQueue.

10 years agoRemove explicit rust code specifier. Unhide use HashMap.
Jonas Hietala [Sat, 19 Jul 2014 03:24:56 +0000 (05:24 +0200)]
Remove explicit rust code specifier. Unhide use HashMap.

10 years agoFill in example code for HashMap.
Jonas Hietala [Fri, 18 Jul 2014 14:19:38 +0000 (16:19 +0200)]
Fill in example code for HashMap.

Add an example showing how to use the map with a custom type. Fill in
examples for methods in the hashmap file without ones.

Also move pop_equiv next to related public methods, to not create a
duplicate trait implementation in the docs.

10 years agoauto merge of #15909 : colemickens/rust/patch-3, r=alexcrichton
bors [Thu, 24 Jul 2014 07:51:18 +0000 (07:51 +0000)]
auto merge of #15909 : colemickens/rust/patch-3, r=alexcrichton

Tested this on the playground, the range specifies range(0u, 3), so it should be okay to remove this cast.

10 years agoauto merge of #15862 : jakub-/rust/issue-15774, r=alexcrichton
bors [Thu, 24 Jul 2014 05:01:22 +0000 (05:01 +0000)]
auto merge of #15862 : jakub-/rust/issue-15774, r=alexcrichton

Fixed #15774.

10 years agoauto merge of #15781 : alexcrichton/rust/issue-15758, r=bblum
bors [Thu, 24 Jul 2014 02:16:13 +0000 (02:16 +0000)]
auto merge of #15781 : alexcrichton/rust/issue-15758, r=bblum

Semaphores are not currently designed to handle this case correctly, leading to
very strange behavior. Semaphores as written are intended to count *resources*
and it's not possible to have a negative number of resources.

This alters the behavior and documentation to note that the task will be failed
if the initial count is 0.

Closes #15758

10 years agoauto merge of #15407 : sneves/rust/master, r=aturon
bors [Thu, 24 Jul 2014 00:26:14 +0000 (00:26 +0000)]
auto merge of #15407 : sneves/rust/master, r=aturon

At the moment, writing generic functions for integer types that involve shifting is rather verbose. For example, a function at shifts an integer left by 1 currently requires

    use std::num::One;
    fn f<T: Int>(x : T) -> T {
        x << One::one()
    }

If the shift amount is not 1, it's even worse:

    use std::num::FromPrimitive;
    fn f<T: Int + FromPrimitive>(x: T) -> T {
        x << FromPrimitive::from_int(2).unwrap()
    }

This patch allows the much simpler implementation

    fn f<T: Int>(x: T) -> T {
        x << 2
    }

It accomplishes this by changing the built-in integer types (and the `Int` trait) to implement `Shl<uint, T>` instead of `Shl<T, T>` as it currently is defined. Note that the internal implementations of `shl` already cast the right-hand side to `uint`. `BigInt` also implements `Shl<uint, BigInt>`, so this increases consistency.

All of the above applies similarly to right shifts, i.e., `Shr<uint, T>`.

10 years agoauto merge of #15611 : brson/rust/pushpop, r=alexcrichton
bors [Wed, 23 Jul 2014 21:41:14 +0000 (21:41 +0000)]
auto merge of #15611 : brson/rust/pushpop, r=alexcrichton

This fixes naming conventions for `push`/`pop` from either end of a structure by partially implementing @erickt's suggestion from https://github.com/rust-lang/rust/issues/10852#issuecomment-30823343, namely:

* push/pop from the 'back' are called `push` and `pop`.
* push/pop from the 'front' are called `push_front` and `pop_front`.
* `push`/`pop` are declared on the `MutableSeq` trait.
* Implement `MutableSeq` for `Vec`, `DList`, and `RingBuf`.
* Add `MutableSeq` to the prelude.

I did not make any further refactorings because there is some more extensive thought that needs to be put into the collections traits. This is an easy first step that should close https://github.com/rust-lang/rust/issues/10852.

I left the `push_back` and `pop_back` methods on `DList` and `RingBuf` deprecated. Because `MutableSeq` is in the prelude it shouldn't break many, but it is a breaking change.

10 years agoJust land already
Brian Anderson [Mon, 21 Jul 2014 00:57:29 +0000 (17:57 -0700)]
Just land already

10 years agoRemove stray llvmdeps.rs
Brian Anderson [Mon, 14 Jul 2014 22:03:15 +0000 (15:03 -0700)]
Remove stray llvmdeps.rs

10 years agocollections: Tweak docs for push
Brian Anderson [Mon, 14 Jul 2014 21:51:54 +0000 (14:51 -0700)]
collections: Tweak docs for push

10 years agoRemove kludgy imports from vec! macro
Brian Anderson [Mon, 14 Jul 2014 21:45:10 +0000 (14:45 -0700)]
Remove kludgy imports from vec! macro

10 years agocollections: Deprecate shift/unshift
Brian Anderson [Mon, 14 Jul 2014 20:54:10 +0000 (13:54 -0700)]
collections: Deprecate shift/unshift

Use insert/remove instead.

10 years agocollections: Make push_back/pop_back default methods
Brian Anderson [Sat, 12 Jul 2014 01:08:46 +0000 (18:08 -0700)]
collections: Make push_back/pop_back default methods

10 years agovim: Add MutableSeq
Brian Anderson [Sat, 12 Jul 2014 01:00:43 +0000 (18:00 -0700)]
vim: Add MutableSeq

10 years agocollections: Move push/pop docs to MutableSeq
Brian Anderson [Fri, 11 Jul 2014 19:01:06 +0000 (12:01 -0700)]
collections: Move push/pop docs to MutableSeq

10 years agoConvert some push_back users to push
Brian Anderson [Fri, 11 Jul 2014 18:29:38 +0000 (11:29 -0700)]
Convert some push_back users to push

10 years agocollections: Deprecate push_back/pop_back
Brian Anderson [Fri, 11 Jul 2014 17:19:27 +0000 (10:19 -0700)]
collections: Deprecate push_back/pop_back

10 years agocollections: Move push/pop to MutableSeq
Brian Anderson [Fri, 11 Jul 2014 17:12:38 +0000 (10:12 -0700)]
collections: Move push/pop to MutableSeq

Implement for Vec, DList, RingBuf. Add MutableSeq to the prelude.

Since the collections traits are in the prelude most consumers of
these methods will continue to work without change.

[breaking-change]

10 years agoParser: Global single-segment paths should be represented as PatEnum
Jakub Wieczorek [Mon, 21 Jul 2014 16:47:24 +0000 (18:47 +0200)]
Parser: Global single-segment paths should be represented as PatEnum

Fixed #15774.

10 years agoauto merge of #15928 : brson/rust/dist, r=alexcrichton,alexcrichton
bors [Wed, 23 Jul 2014 19:56:15 +0000 (19:56 +0000)]
auto merge of #15928 : brson/rust/dist, r=alexcrichton,alexcrichton

The first commit reverts a similar fix that only solves the `make install` case. This adds the `--enable-dist-host-only` flag to configure to preserve the old behavior, which the nightly bots rely on. The bots will need to be updated soon after this lands (or they will ~double in size).

Closes https://github.com/rust-lang/rust/issues/15711

10 years agomk: Have the various flavors of 'dist' install all targets by default
Brian Anderson [Wed, 23 Jul 2014 19:04:13 +0000 (12:04 -0700)]
mk: Have the various flavors of 'dist' install all targets by default

Closes #15711

10 years agoconfigure: Add --enable-dist-host-only flag
Brian Anderson [Wed, 23 Jul 2014 00:20:15 +0000 (17:20 -0700)]
configure: Add --enable-dist-host-only flag

This preserves the current behavior of `make dist` where we only
distribute bins for the host architecture. The bots need this.

10 years agoauto merge of #15902 : nham/rust/hash_triemap, r=alexcrichton
bors [Wed, 23 Jul 2014 18:11:15 +0000 (18:11 +0000)]
auto merge of #15902 : nham/rust/hash_triemap, r=alexcrichton

cc #15294

10 years agomk: Add space before line continuation backslash
Birunthan Mohanathas [Wed, 23 Jul 2014 04:45:08 +0000 (21:45 -0700)]
mk: Add space before line continuation backslash

10 years agomk: Remove extra whitespace before line continuation backslashes
Birunthan Mohanathas [Wed, 23 Jul 2014 04:37:05 +0000 (21:37 -0700)]
mk: Remove extra whitespace before line continuation backslashes

10 years agoImprove usage of lifetime intrinsics in match expressions
Björn Steinbrink [Wed, 23 Jul 2014 15:39:13 +0000 (17:39 +0200)]
Improve usage of lifetime intrinsics in match expressions

The allocas used in match expression currently don't get good lifetime
markers, in fact they only get lifetime start markers, because their
lifetimes don't match to cleanup scopes.

While the bindings themselves are bog standard and just need a matching
pair of start and end markers, they might need them twice, once for a
guard clause and once for the match body.

The __llmatch alloca OTOH needs a single lifetime start marker, but
when there's a guard clause, it needs two end markers, because its
lifetime ends either when the guard doesn't match or after the match
body.

With these intrinsics in place, LLVM can now, for example, optimize
code like this:

````rust
enum E {
  A1(int),
  A2(int),
  A3(int),
  A4(int),
}

pub fn variants(x: E) {
  match x {
    A1(m) => bar(&m),
    A2(m) => bar(&m),
    A3(m) => bar(&m),
    A4(m) => bar(&m),
  }
}
````

To a single call to bar, using only a single stack slot. It still fails
to eliminate some of checks.

````gas
.Ltmp5:
.cfi_def_cfa_offset 16
movb (%rdi), %al
testb %al, %al
je .LBB3_5
movzbl %al, %eax
cmpl $1, %eax
je .LBB3_5
cmpl $2, %eax
.LBB3_5:
movq 8(%rdi), %rax
movq %rax, (%rsp)
leaq (%rsp), %rdi
callq _ZN3bar20hcb7a0d8be8e17e37daaE@PLT
popq %rax
retq
````

10 years agoauto merge of #15749 : vhbit/rust/treemap-doc-fixes, r=alexcrichton
bors [Wed, 23 Jul 2014 14:06:08 +0000 (14:06 +0000)]
auto merge of #15749 : vhbit/rust/treemap-doc-fixes, r=alexcrichton

1. Removed obsolete comment regarding recursive/iteration implementations of tree_find_with/tree_find_mut_with
2. Replaced easy breakable find_with example with simpler one (which only removes redundant allocation during search)

10 years agoauto merge of #15910 : sfackler/rust/nogc, r=cmr
bors [Wed, 23 Jul 2014 10:06:09 +0000 (10:06 +0000)]
auto merge of #15910 : sfackler/rust/nogc, r=cmr

10 years agoauto merge of #15900 : tbu-/rust/pr_numcleanup, r=kballard
bors [Wed, 23 Jul 2014 08:16:10 +0000 (08:16 +0000)]
auto merge of #15900 : tbu-/rust/pr_numcleanup, r=kballard

This removes the special casing for `float`s where it was not necessary, as
`-0.0 == 0.0`.

10 years agoTreeMap examples fixes
Valerii Hiora [Thu, 17 Jul 2014 19:06:13 +0000 (22:06 +0300)]
TreeMap examples fixes

1. Removed obsolete comment regarding recursive/iteration implementations of tree_find_with/tree_find_mut_with
2. Replaced easy breakable find_with example with simpler one (which only removes redundant allocation during search)

10 years agoauto merge of #15899 : aochagavia/rust/guide, r=kballard
bors [Wed, 23 Jul 2014 06:31:11 +0000 (06:31 +0000)]
auto merge of #15899 : aochagavia/rust/guide, r=kballard

The removed code caused confusion because it is not clear that the type of `y` is actually `()`

10 years agoRemove ancient GC cfg flags
Steven Fackler [Wed, 23 Jul 2014 06:19:08 +0000 (23:19 -0700)]
Remove ancient GC cfg flags

10 years agoRemove unnecessary cast from intro
Cole Mickens [Wed, 23 Jul 2014 06:10:18 +0000 (23:10 -0700)]
Remove unnecessary cast from intro

10 years agoauto merge of #15897 : Gankro/rust/it-docs, r=kballard
bors [Wed, 23 Jul 2014 04:46:09 +0000 (04:46 +0000)]
auto merge of #15897 : Gankro/rust/it-docs, r=kballard

I found these things to be ambiguous, or at least worth stating explicitly to reduce the amount a user/developer needs to think about the API.

10 years agoRevert "Made 'make install' include libs for additional targets"
Brian Anderson [Wed, 23 Jul 2014 00:17:57 +0000 (17:17 -0700)]
Revert "Made 'make install' include libs for additional targets"

This reverts commit 87334fb05ff2a665419241d877c13d6c4770a3f4.

Conflicts:
mk/install.mk

10 years agoauto merge of #15272 : jakub-/rust/issue-13041, r=pcwalton
bors [Tue, 22 Jul 2014 23:11:12 +0000 (23:11 +0000)]
auto merge of #15272 : jakub-/rust/issue-13041, r=pcwalton

Fixes #13041.

10 years agoAdd Drop support for enums
Jakub Wieczorek [Sat, 14 Jun 2014 13:55:55 +0000 (15:55 +0200)]
Add Drop support for enums

Fixes #13041.

10 years agoauto merge of #15894 : treeman/rust/vec-doc, r=alexcrichton
bors [Tue, 22 Jul 2014 21:26:14 +0000 (21:26 +0000)]
auto merge of #15894 : treeman/rust/vec-doc, r=alexcrichton

Fill in examples for missing methods. Opt for `vec![]` instead of `vec!()`.

10 years agoImplement PartialEq, Eq for TrieMap, TrieSet
nham [Tue, 22 Jul 2014 21:04:16 +0000 (17:04 -0400)]
Implement PartialEq, Eq for TrieMap, TrieSet

10 years agoDerive Hash for TrieMap and TrieSet
nham [Tue, 22 Jul 2014 20:36:09 +0000 (16:36 -0400)]
Derive Hash for TrieMap and TrieSet

10 years agoauto merge of #15869 : alexcrichton/rust/issue-15828, r=kballard
bors [Tue, 22 Jul 2014 19:41:13 +0000 (19:41 +0000)]
auto merge of #15869 : alexcrichton/rust/issue-15828, r=kballard

Closes #15828

10 years agoClean up some trait impls in core::num.
Tobias Bucher [Sun, 13 Jul 2014 14:55:55 +0000 (16:55 +0200)]
Clean up some trait impls in core::num.

This removes the special casing for `float`s where it was not necessary, as
`-0.0 == 0.0`.