]> git.lizzy.rs Git - rust.git/log
rust.git
10 years agodocs: Fix typo in container guide.
Ruud van Asseldonk [Sun, 27 Jul 2014 08:14:44 +0000 (10:14 +0200)]
docs: Fix typo in container guide.

10 years agoauto merge of #15963 : nham/rust/moar_15294, r=alexcrichton
bors [Sun, 27 Jul 2014 06:16:14 +0000 (06:16 +0000)]
auto merge of #15963 : nham/rust/moar_15294, r=alexcrichton

Implements PartialEq/Eq/Clone/Hash/FromIterator/Extendable for SmallIntMap and Clone/Show for TrieMap/TrieSet. cc #15294

10 years agoauto merge of #16021 : brson/rust/mb, r=pcwalton
bors [Sun, 27 Jul 2014 04:21:14 +0000 (04:21 +0000)]
auto merge of #16021 : brson/rust/mb, r=pcwalton

No longer does anything.

10 years agoRemove managed_box gate from tests
Brian Anderson [Sun, 27 Jul 2014 04:05:03 +0000 (21:05 -0700)]
Remove managed_box gate from tests

No longer does anything.

10 years agoauto merge of #16006 : TeXitoi/rust/relicense-shootout-k-nucleotide, r=brson
bors [Sun, 27 Jul 2014 00:31:13 +0000 (00:31 +0000)]
auto merge of #16006 : TeXitoi/rust/relicense-shootout-k-nucleotide, r=brson

Everyone agreed except @thestinger. As @thestinger contribution on this file is trivial,
we can relicense it.

Related to #14248, close #15330

@brson OK?

10 years agoManually implement Hash for SmallIntMap
nham [Sat, 26 Jul 2014 16:04:41 +0000 (12:04 -0400)]
Manually implement Hash for SmallIntMap

10 years agoauto merge of #15941 : treeman/rust/doc-lru, r=alexcrichton
bors [Sat, 26 Jul 2014 22:46:13 +0000 (22:46 +0000)]
auto merge of #15941 : treeman/rust/doc-lru, r=alexcrichton

10 years agoauto merge of #15936 : alexcrichton/rust/stability, r=brson
bors [Sat, 26 Jul 2014 21:01:15 +0000 (21:01 +0000)]
auto merge of #15936 : alexcrichton/rust/stability, r=brson

This commit applies stability attributes to the contents of these modules,
summarized here:

* The `unit` and `bool` modules have become #[unstable] as they are purely meant
  for documentation purposes and are candidates for removal.

* The `ty` module has been deprecated, and the inner `Unsafe` type has been
  renamed to `UnsafeCell` and moved to the `cell` module. The `marker1` field
  has been removed as the compiler now always infers `UnsafeCell` to be
  invariant. The `new` method i stable, but the `value` field, `get` and
  `unwrap` methods are all unstable.

* The `tuple` module has its name as stable, the naming of the `TupleN` traits
  as stable while the methods are all #[unstable]. The other impls in the module
  have appropriate stability for the corresponding trait.

* The `arc` module has received the exact same treatment as the `rc` module
  previously did.

* The `any` module has its name as stable. The `Any` trait is also stable, with
  a new private supertrait which now contains the `get_type_id` method. This is
  to make the method a private implementation detail rather than a public-facing
  detail.

  The two extension traits in the module are marked #[unstable] as they will not
  be necessary with DST. The `is` method is #[stable], the as_{mut,ref} methods
  have been renamed to downcast_{mut,ref} and are #[unstable].

  The extension trait `BoxAny` has been clarified as to why it is unstable as it
  will not be necessary with DST.

This is a breaking change because the `marker1` field was removed from the
`UnsafeCell` type. To deal with this change, you can simply delete the field and
only specify the value of the `data` field in static initializers.

[breaking-change]

10 years agostd: Stabilize unit, bool, ty, tuple, arc, any
Alex Crichton [Thu, 24 Jul 2014 02:10:12 +0000 (19:10 -0700)]
std: Stabilize unit, bool, ty, tuple, arc, any

This commit applies stability attributes to the contents of these modules,
summarized here:

* The `unit` and `bool` modules have become #[unstable] as they are purely meant
  for documentation purposes and are candidates for removal.

* The `ty` module has been deprecated, and the inner `Unsafe` type has been
  renamed to `UnsafeCell` and moved to the `cell` module. The `marker1` field
  has been removed as the compiler now always infers `UnsafeCell` to be
  invariant. The `new` method i stable, but the `value` field, `get` and
  `unwrap` methods are all unstable.

* The `tuple` module has its name as stable, the naming of the `TupleN` traits
  as stable while the methods are all #[unstable]. The other impls in the module
  have appropriate stability for the corresponding trait.

* The `arc` module has received the exact same treatment as the `rc` module
  previously did.

* The `any` module has its name as stable. The `Any` trait is also stable, with
  a new private supertrait which now contains the `get_type_id` method. This is
  to make the method a private implementation detail rather than a public-facing
  detail.

  The two extension traits in the module are marked #[unstable] as they will not
  be necessary with DST. The `is` method is #[stable], the as_{mut,ref} methods
  have been renamed to downcast_{mut,ref} and are #[unstable].

  The extension trait `BoxAny` has been clarified as to why it is unstable as it
  will not be necessary with DST.

This is a breaking change because the `marker1` field was removed from the
`UnsafeCell` type. To deal with this change, you can simply delete the field and
only specify the value of the `data` field in static initializers.

[breaking-change]

10 years agoauto merge of #15762 : nham/rust/ringbuf_docs, r=alexcrichton
bors [Sat, 26 Jul 2014 19:16:16 +0000 (19:16 +0000)]
auto merge of #15762 : nham/rust/ringbuf_docs, r=alexcrichton

This adds examples for get(), get_mut(), swap(), iter() and mut_iter()

10 years agoAdd examples for RingBuf methods get, get_mut, iter, mut_iter
nham [Thu, 17 Jul 2014 23:19:51 +0000 (19:19 -0400)]
Add examples for RingBuf methods get, get_mut, iter, mut_iter

10 years agoauto merge of #16000 : emkay/rust/lifetimes-guide-typo, r=alexcrichton
bors [Sat, 26 Jul 2014 17:31:16 +0000 (17:31 +0000)]
auto merge of #16000 : emkay/rust/lifetimes-guide-typo, r=alexcrichton

10 years agoSmall fixes for tests
nham [Sat, 26 Jul 2014 01:35:58 +0000 (21:35 -0400)]
Small fixes for tests

10 years agoauto merge of #15998 : luqmana/rust/nmnnbd, r=thestinger
bors [Sat, 26 Jul 2014 15:46:18 +0000 (15:46 +0000)]
auto merge of #15998 : luqmana/rust/nmnnbd, r=thestinger

LLVM recently added a new attribute, dereferenceable: http://reviews.llvm.org/D4449

>This patch adds a dereferencable attribute. In some sense, this is a companion to the nonnull attribute, but specifies that the pointer is known to be dereferencable in the same sense as a pointer generated by alloca is known to be dereferencable.

With rust, everywhere that we previously marked `nonnull` we can actually mark as `dereferenceable` (which implies nonnull) since we know the size. That is, except for one case: when generating calls for TyVisitor. It seems like we haven't substituted the self type (so we have `ty_param`) and just treat it as an opaque pointer so I just left that bit as nonnull.

With this, LLVM can for example hoist a load out of a loop where it previously couldn't:

```Rust
pub fn baz(c: &uint, n: uint) -> uint {
    let mut res = 0;
    for i in range(0, n) {
        if i > 0 {
            res += *c * i;
        }
    }
    res
}
```

Before:
```llvm
define i64 @baz(i64* noalias nocapture nonnull readonly, i64) unnamed_addr #0 {
entry-block:
  br label %for_loopback.outer

for_loopback.outer:                               ; preds = %then-block-33-, %entry-block
  %.ph = phi i64 [ %.lcssa, %then-block-33- ], [ 0, %entry-block ]
  %res.0.ph = phi i64 [ %8, %then-block-33- ], [ 0, %entry-block ]
  br label %for_loopback

for_exit:                                         ; preds = %for_loopback
  %res.0.ph.lcssa = phi i64 [ %res.0.ph, %for_loopback ]
  ret i64 %res.0.ph.lcssa

for_loopback:                                     ; preds = %for_loopback.outer, %for_body
  %2 = phi i64 [ %4, %for_body ], [ %.ph, %for_loopback.outer ]
  %3 = icmp ult i64 %2, %1
  br i1 %3, label %for_body, label %for_exit

for_body:                                         ; preds = %for_loopback
  %4 = add i64 %2, 1
  %5 = icmp eq i64 %2, 0
  br i1 %5, label %for_loopback, label %then-block-33-

then-block-33-:                                   ; preds = %for_body
  %.lcssa = phi i64 [ %4, %for_body ]
  %.lcssa15 = phi i64 [ %2, %for_body ]
  %6 = load i64* %0, align 8                     ; <------- this load
  %7 = mul i64 %6, %.lcssa15
  %8 = add i64 %7, %res.0.ph
  br label %for_loopback.outer
}
```

After:
```llvm
define i64 @baz(i64* noalias nocapture readonly dereferenceable(8), i64) unnamed_addr #0 {
entry-block:
  %2 = load i64* %0, align 8                    ; <------- load once instead
  br label %for_loopback.outer

for_loopback.outer:                               ; preds = %then-block-33-, %entry-block
  %.ph = phi i64 [ %.lcssa, %then-block-33- ], [ 0, %entry-block ]
  %res.0.ph = phi i64 [ %8, %then-block-33- ], [ 0, %entry-block ]
  br label %for_loopback

for_exit:                                         ; preds = %for_loopback
  %res.0.ph.lcssa = phi i64 [ %res.0.ph, %for_loopback ]
  ret i64 %res.0.ph.lcssa

for_loopback:                                     ; preds = %for_loopback.outer, %for_body
  %3 = phi i64 [ %5, %for_body ], [ %.ph, %for_loopback.outer ]
  %4 = icmp ult i64 %3, %1
  br i1 %4, label %for_body, label %for_exit

for_body:                                         ; preds = %for_loopback
  %5 = add i64 %3, 1
  %6 = icmp eq i64 %3, 0
  br i1 %6, label %for_loopback, label %then-block-33-

then-block-33-:                                   ; preds = %for_body
  %.lcssa = phi i64 [ %5, %for_body ]
  %.lcssa15 = phi i64 [ %3, %for_body ]
  %7 = mul i64 %2, %.lcssa15
  %8 = add i64 %7, %res.0.ph
  br label %for_loopback.outer
}
```

10 years agoauto merge of #15996 : nham/rust/smallintmap_not_hashmap, r=sanxiyn
bors [Sat, 26 Jul 2014 14:01:22 +0000 (14:01 +0000)]
auto merge of #15996 : nham/rust/smallintmap_not_hashmap, r=sanxiyn

SmallIntMap doesn't involve hashing?

10 years agoRelicense shootout-k-nucleotide.rs
Guillaume Pinot [Sat, 26 Jul 2014 13:06:40 +0000 (15:06 +0200)]
Relicense shootout-k-nucleotide.rs

Everyone agreed except @thestinger. As @thestinger contribution on this file is trivial,
we can relicense it.

Related to #14248, close #15330

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 agofix small typo in guide-lifetimes
Michael Matuzak [Sat, 26 Jul 2014 04:13:39 +0000 (21:13 -0700)]
fix small typo in guide-lifetimes

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 agorustllvm: Stub out some functions for llvm < 3.5
Luqman Aden [Sat, 26 Jul 2014 02:47:29 +0000 (19:47 -0700)]
rustllvm: Stub out some functions for llvm < 3.5

10 years agoFix a typo in SmallIntMap documentation
nham [Sat, 26 Jul 2014 01:40:47 +0000 (21:40 -0400)]
Fix a typo in SmallIntMap documentation

10 years agoImplement PartialEq/Eq/Clone/Hash/FromIterator/Extendable for SmallIntMap and Show...
nham [Thu, 24 Jul 2014 21:50:21 +0000 (17:50 -0400)]
Implement PartialEq/Eq/Clone/Hash/FromIterator/Extendable for SmallIntMap and Show/Clone for TrieMap and TrieSet

10 years agolibrustc: Use dereferenceable attribute instead of nonnull where we can.
Luqman Aden [Sat, 26 Jul 2014 01:33:10 +0000 (18:33 -0700)]
librustc: Use dereferenceable attribute instead of nonnull where we can.

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 agolibrustc: Use builder for llvm attributes.
Luqman Aden [Fri, 25 Jul 2014 23:06:44 +0000 (16:06 -0700)]
librustc: Use builder for llvm attributes.

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 agoCleanup LruCache doc.
Jonas Hietala [Thu, 24 Jul 2014 12:40:57 +0000 (14:40 +0200)]
Cleanup LruCache doc.

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.