Commit Graph

30989 Commits

Author SHA1 Message Date
nham
9fa4424b71 Hash the length of the RingBuf before hashing elements 2014-07-27 12:37:32 -04:00
nham
6361577808 Implement PartialOrd for RingBuf 2014-07-26 23:18:56 -04:00
nham
1cfa6569f9 Implement Hash for RingBuf 2014-07-26 22:33:47 -04:00
bors
32e521ffab auto merge of #15941 : treeman/rust/doc-lru, r=alexcrichton 2014-07-26 22:46:13 +00:00
bors
e6e544f261 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]
2014-07-26 21:01:15 +00:00
Alex Crichton
e5da6a71a6 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]
2014-07-26 13:12:20 -07:00
bors
ecce58c6fd auto merge of #15762 : nham/rust/ringbuf_docs, r=alexcrichton
This adds examples for get(), get_mut(), swap(), iter() and mut_iter()
2014-07-26 19:16:16 +00:00
nham
ebe8097128 Add examples for RingBuf methods get, get_mut, iter, mut_iter 2014-07-26 13:42:55 -04:00
bors
d4dfb7d84c auto merge of #16000 : emkay/rust/lifetimes-guide-typo, r=alexcrichton 2014-07-26 17:31:16 +00:00
bors
7aa407958b 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
}
```
2014-07-26 15:46:18 +00:00
bors
50c62b4667 auto merge of #15996 : nham/rust/smallintmap_not_hashmap, r=sanxiyn
SmallIntMap doesn't involve hashing?
2014-07-26 14:01:22 +00:00
bors
ee21b009bb 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
2014-07-26 12:16:21 +00:00
bors
0d53597ce2 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
2014-07-26 10:31:23 +00:00
bors
cf61980db2 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
2014-07-26 08:46:21 +00:00
bors
c0fa8764ef 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.
2014-07-26 06:56:23 +00:00
Michael Matuzak
ca18c12243 fix small typo in guide-lifetimes 2014-07-25 21:13:39 -07:00
bors
34a6a8fc59 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.
2014-07-26 03:31:22 +00:00
Luqman Aden
a78c0f1019 rustllvm: Stub out some functions for llvm < 3.5 2014-07-25 19:47:29 -07:00
nham
b2e81d1618 Fix a typo in SmallIntMap documentation 2014-07-25 21:40:47 -04:00
Luqman Aden
e10d674de0 librustc: Use dereferenceable attribute instead of nonnull where we can. 2014-07-25 18:33:10 -07:00
bors
cf1381c1d0 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.
2014-07-26 00:46:16 +00:00
Brian Anderson
6e03944dde Add tests that the injected runtime is inaccessible 2014-07-25 16:54:09 -07:00
Luqman Aden
17256197a9 librustc: Use builder for llvm attributes. 2014-07-25 16:06:44 -07:00
bors
92c97059ff 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.
2014-07-25 23:01:16 +00:00
Patrick Walton
5de8ed541a 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]
2014-07-25 15:58:01 -07:00
Brian Anderson
3382ffef32 mk: Print grammar info message like others 2014-07-25 14:32:34 -07:00
Brian Anderson
ae97e6f8d3 mk: Remove check-syntax target
This appears to be redundantly named with a shortcut target for
testing the syntax crate.
2014-07-25 14:28:55 -07:00
Brian Anderson
8f692e6ab0 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]
2014-07-25 14:17:28 -07:00
bors
66a0b528a6 auto merge of #15979 : Randati/rust/patch-2, r=kballard 2014-07-25 20:36:10 +00:00
bors
74db69995a 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
2014-07-25 18:51:09 +00:00
Alex Crichton
98f48630fc rustdoc: Inline items from foreign mods
These were all just previously skipped.

Closes #15648
2014-07-25 10:37:23 -07:00
Alex Crichton
8d7eb0598a 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.
2014-07-25 10:24:29 -07:00
Alex Crichton
431622e1e2 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
2014-07-25 10:24:26 -07:00
Alex Crichton
15a727bba1 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
2014-07-25 09:07:20 -07:00
Alex Crichton
80efb220e0 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
2014-07-25 08:56:00 -07:00
bors
d30776ec24 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%)
```
2014-07-25 15:41:08 +00:00
Alex Crichton
724bcec089 rustdoc: Hide impls for #[doc(hidden)] traits
Closes #14585
2014-07-25 08:26:17 -07:00
Randati
c7700077a1 Fix assert message 2014-07-25 18:12:21 +03:00
Alex Crichton
51355478f4 rustdoc: Add a --target flag
Closes #13893
2014-07-25 07:55:25 -07:00
bors
7ff5bbd494 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.
2014-07-25 13:56:08 +00:00
Björn Steinbrink
b13cad3a9c 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.
2014-07-25 14:31:05 +02:00
bors
44019c79e0 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.
2014-07-25 12:11:08 +00:00
bors
470dbef29a 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
2014-07-25 09:31:10 +00:00
Patrick Walton
f1520ea0cf 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]
2014-07-25 00:50:35 -07:00
bors
e5984640e6 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
2014-07-25 07:46:12 +00:00
bors
4e388859a2 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
2014-07-25 06:01:13 +00:00
Alex Crichton
bd838a3b7e 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.
2014-07-24 22:41:52 -07:00
John Kåre Alsaker
4c2d4cd3de 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.
2014-07-25 07:29:12 +02:00
nham
74b1aed0ec Add methods for obtaining iterators over the keys and values of a TrieMap 2014-07-25 01:14:49 -04:00
nham
0b339e09ab Add methods for obtaining iterators over the keys and values of a SmallIntMap 2014-07-25 00:48:05 -04:00