]> git.lizzy.rs Git - rust.git/log
rust.git
10 years agoauto merge of #15991 : pcwalton/rust/resolve-regions-in-trait-matching, r=alexcrichton
bors [Sat, 26 Jul 2014 12:16:21 +0000 (12:16 +0000)]
auto merge of #15991 : pcwalton/rust/resolve-regions-in-trait-matching, r=alexcrichton

matching.

This breaks code like:

    struct Foo<'a,'b> {
        x: &'a int,
        y: &'b int,
    }

    trait Tr {
        fn foo(x: Self) {}
    }

    impl<'a,'b> Tr for Foo<'a,'b> {
        fn foo(x: Foo<'b,'a>) {} // <-- bad
    }

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

    struct Foo<'a,'b> {
        x: &'a int,
        y: &'b int,
    }

    trait Tr {
        fn foo(x: Self) {}
    }

    impl<'a,'b> Tr for Foo<'a,'b> {
        fn foo(x: Foo<'a,'b>) {} // OK
    }

Closes #15517.

[breaking-change]

r? @alexcrichton

10 years agoauto merge of #15988 : brson/rust/antlrprep, r=cmr
bors [Sat, 26 Jul 2014 10:31:23 +0000 (10:31 +0000)]
auto merge of #15988 : brson/rust/antlrprep, r=cmr

Add `check-secondary`, which runs the pretty and lexer tests so we can run them on a dedicated bot. Leaves the pretty tests running under `check` until the bots are switched over. Also fixes some issues.

r? @cmr

10 years agoauto merge of #15987 : brson/rust/hidestdrt, r=alexcrichton
bors [Sat, 26 Jul 2014 08:46:21 +0000 (08:46 +0000)]
auto merge of #15987 : brson/rust/hidestdrt, r=alexcrichton

Rename and gensym the runtime on import, so that users
can't refer to the `native` crate.

This is unlikely to break code, but users should import the "native" crate directly.

[breaking-change]

cc @alexcrichton

10 years agoauto merge of #15982 : alexcrichton/rust/rustdoc-fixes, r=brson
bors [Sat, 26 Jul 2014 06:56:23 +0000 (06:56 +0000)]
auto merge of #15982 : alexcrichton/rust/rustdoc-fixes, r=brson

Sadly there's still a lot of open issues, but this tackles some of the more pressing ones. Each commit has its own description along with the issues it closes.

10 years agoauto merge of #15975 : dotdash/rust/unwind_lifetimes, r=pcwalton
bors [Sat, 26 Jul 2014 03:31:22 +0000 (03:31 +0000)]
auto merge of #15975 : dotdash/rust/unwind_lifetimes, r=pcwalton

Currently we don't emit lifetime end markers when translating the
unwinding code. I omitted that when I added the support for lifetime
intrinsics, because I initially made the mistake of just returning true
in clean_on_unwind(). That caused almost all calls to be translated as
invokes, leading to quite awful results.

To correctly emit the lifetime end markers, we must differentiate
between cleanup that requires unwinding and such cleanup that just wants
to emit code during unwinding.

10 years agoauto merge of #15789 : steveklabnik/rust/guide_pointers, r=cmr
bors [Sat, 26 Jul 2014 00:46:16 +0000 (00:46 +0000)]
auto merge of #15789 : steveklabnik/rust/guide_pointers, r=cmr

This is super, super WIP, but I'm going to go get lunch for a while, and figured I'd toss my work up here in case anyone wants to see my work as I do it.

This contains a new introductory section explaining the basics of pointers, and some pitfalls that Rust attempts to solve. I'd be interested in hearing how my explanation is, as well as if this belongs here. Pointers are such a crucial concept, I don't mind having a beginners' section on them in the main docs, even though our main audience is supposed to understand them already. Reasonable people may disagree, however.

10 years agoAdd tests that the injected runtime is inaccessible
Brian Anderson [Fri, 25 Jul 2014 22:26:51 +0000 (15:26 -0700)]
Add tests that the injected runtime is inaccessible

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 agolibrustc: Resolve regions and report errors in trait/impl method
Patrick Walton [Fri, 25 Jul 2014 22:56:42 +0000 (15:56 -0700)]
librustc: Resolve regions and report errors in trait/impl method
matching.

This breaks code like:

    struct Foo<'a,'b> {
        x: &'a int,
        y: &'b int,
    }

    trait Tr {
        fn foo(x: Self) {}
    }

    impl<'a,'b> Tr for Foo<'a,'b> {
        fn foo(x: Foo<'b,'a>) {} // <-- bad
    }

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

    struct Foo<'a,'b> {
        x: &'a int,
        y: &'b int,
    }

    trait Tr {
        fn foo(x: Self) {}
    }

    impl<'a,'b> Tr for Foo<'a,'b> {
        fn foo(x: Foo<'a,'b>) {} // OK
    }

Closes #15517.

[breaking-change]

10 years agomk: Print grammar info message like others
Brian Anderson [Fri, 25 Jul 2014 21:32:34 +0000 (14:32 -0700)]
mk: Print grammar info message like others

10 years agomk: Remove check-syntax target
Brian Anderson [Fri, 25 Jul 2014 21:28:55 +0000 (14:28 -0700)]
mk: Remove check-syntax target

This appears to be redundantly named with a shortcut target for
testing the syntax crate.

10 years agorustc: Future proof runtime injection
Brian Anderson [Fri, 25 Jul 2014 04:35:42 +0000 (21:35 -0700)]
rustc: Future proof runtime injection

Rename and gensym the runtime on import, so that users
can't refer to the `native` crate.

This is unlikely to break code, but users should import the "native" crate directly.

[breaking-change]

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 agorustdoc: Inline items from foreign mods
Alex Crichton [Fri, 25 Jul 2014 17:37:23 +0000 (10:37 -0700)]
rustdoc: Inline items from foreign mods

These were all just previously skipped.

Closes #15648

10 years agorustdoc: Correctly handle local renamings
Alex Crichton [Fri, 25 Jul 2014 17:16:41 +0000 (10:16 -0700)]
rustdoc: Correctly handle local renamings

Previously a `pub use` would not rename the destination in rustdoc, it would
always use the destination ident instead of the renamed ident.

10 years agorustdoc: Fix links to Box/Gc
Alex Crichton [Fri, 25 Jul 2014 16:31:20 +0000 (09:31 -0700)]
rustdoc: Fix links to Box/Gc

These are lang items now, so the internal representations need to be
re-translated back to the original structures manually.

Closes #15185
Closes #15800

10 years agorustdoc: Fix inlining type parameters
Alex Crichton [Fri, 25 Jul 2014 16:07:20 +0000 (09:07 -0700)]
rustdoc: Fix inlining type parameters

I'm not entirely sure if the correct space can be inferred when cleaning
Generics, so the impl has been switched to take the space explicitly.

Closes #15099

10 years agorustdoc: Bind keydown instead of keypress for nav
Alex Crichton [Fri, 25 Jul 2014 15:54:38 +0000 (08:54 -0700)]
rustdoc: Bind keydown instead of keypress for nav

Apparently keypress doesn't quite work in all browsers due to some not invoking
the handler and jquery not setting the right `which` field in all circumstances.
According to http://stackoverflow.com/questions/2166771 switching over to
`keydown` works and it appears to do the trick. Tested in Safari, Firefox, and
Chrome.

Closes #15011

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 agorustdoc: Hide impls for #[doc(hidden)] traits
Alex Crichton [Fri, 25 Jul 2014 15:26:17 +0000 (08:26 -0700)]
rustdoc: Hide impls for #[doc(hidden)] traits

Closes #14585

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

10 years agorustdoc: Add a --target flag
Alex Crichton [Fri, 25 Jul 2014 14:55:25 +0000 (07:55 -0700)]
rustdoc: Add a --target flag

Closes #13893

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 agoEmit lifetime end markers in unwinding codepaths
Björn Steinbrink [Fri, 25 Jul 2014 12:31:05 +0000 (14:31 +0200)]
Emit lifetime end markers in unwinding codepaths

Currently we don't emit lifetime end markers when translating the
unwinding code. I omitted that when I added the support for lifetime
intrinsics, because I initially made the mistake of just returning true
in clean_on_unwind(). That caused almost all calls to be translated as
invokes, leading to quite awful results.

To correctly emit the lifetime end markers, we must differentiate
between cleanup that requires unwinding and such cleanup that just wants
to emit code during unwinding.

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 agomk: Some fixes to grammar.mk
Brian Anderson [Fri, 25 Jul 2014 04:30:43 +0000 (21:30 -0700)]
mk: Some fixes to grammar.mk

Invoke rustc in a way that sets LD_LIBRARY_PATH,
and disable the deps on RustLexer.class when antlr isn't available.

10 years agomk: Add comments to primary check targets
Brian Anderson [Wed, 23 Jul 2014 22:02:11 +0000 (15:02 -0700)]
mk: Add comments to primary check targets

10 years agomk: Add check-secondary target for tests with no x-platform risk.
Brian Anderson [Wed, 23 Jul 2014 21:57:07 +0000 (14:57 -0700)]
mk: Add check-secondary target for tests with no x-platform risk.

We'll use this to run a subset of the test suite onto a dedicated
bot.

This puts the grammar tests and the pretty-printer tests under
check-secondary. It leanves the pretty tests under plain `check`
for now, until the new bot is added to take over.

Because check-secondary is not run as part of `make check` there
will be a set of tests that most users never run and are only
checked by bors. I think this will be ok because grammar tests
should rarely regress, and the people regressing such tests
should have the fortitude to deal with it.

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