Commit Graph

31159 Commits

Author SHA1 Message Date
bors
e0d10bb69a auto merge of #16016 : tomjakubowski/rust/rustdoc-fix-15490, r=alexcrichton
Previously, private and `#[doc(hidden)]` struct fields appeared in the
search index despite being hidden from the struct's documentation.

Fix #15490
2014-07-27 09:46:15 +00:00
Ruud van Asseldonk
d7993153a4 docs: Fix typo in container guide. 2014-07-27 10:14:44 +02:00
bors
ad4fa46f5b auto merge of #16001 : Gankro/rust/rawstrings-proof, r=pnkfelix
Stumbled across this and thought it would be cool to prove. I've never used Ogden's Lemma before, but I'm pretty sure I used it right. The pumping lemma definitely doesn't seem sufficient for the job. In particular, when using the pumping lemma, you can always just pump one of the quotes, and it's fine. Ogden's Lemma lets you effectively force the pumper to use certain characters in the string.

@cmr
2014-07-27 08:01:14 +00:00
bors
d114ddac03 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
2014-07-27 06:16:14 +00:00
Alexis Beingessner
6444b5e82b adding proof of context-sensitivy of raw string literals 2014-07-27 02:13:19 -04:00
bors
2de3fad72c auto merge of #16021 : brson/rust/mb, r=pcwalton
No longer does anything.
2014-07-27 04:21:14 +00:00
Brian Anderson
aa48654740 Remove managed_box gate from tests
No longer does anything.
2014-07-26 21:05:29 -07: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
3d7a7f645f 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?
2014-07-27 00:31:13 +00:00
Tom Jakubowski
c05cfab7f9 rustdoc: Keep hidden struct fields out of search
Previously, private and `#[doc(hidden)]` struct fields appeared in the
search index despite being hidden from the struct's documentation.

Fix #15490
2014-07-26 16:13:01 -07:00
nham
fadbc0b88b Manually implement Hash for SmallIntMap 2014-07-26 18:47:33 -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
nham
3f1c37e96d Small fixes for tests 2014-07-26 12:06:52 -04: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
Guillaume Pinot
92792248c1 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
2014-07-26 15:06:40 +02: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
nham
1e997d62b7 Implement PartialEq/Eq/Clone/Hash/FromIterator/Extendable for SmallIntMap and Show/Clone for TrieMap and TrieSet 2014-07-25 21:34:01 -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
53f0eae386 Revert "Use fewer instructions for fail!"
This reverts commit c61f9763e2.

Conflicts:
	src/librustrt/unwind.rs
	src/libstd/macros.rs
2014-07-25 15:57:15 -07:00
Brian Anderson
cf7a89f0c0 std: Use correct conventions for statics in macros 2014-07-25 15:54:56 -07:00
Brian Anderson
a43e7d5cb9 core: Remove unneeded cfgs 2014-07-25 15:54:10 -07:00
Patrick Walton
b2eb88843d librustc: Disallow mutation and assignment in pattern guards, and modify
the CFG for match statements.

There were two bugs in issue #14684. One was simply that the borrow
check didn't know about the correct CFG for match statements: the
pattern must be a predecessor of the guard. This disallows the bad
behavior if there are bindings in the pattern. But it isn't enough to
prevent the memory safety problem, because of wildcards; thus, this
patch introduces a more restrictive rule, which disallows assignments
and mutable borrows inside guards outright.

I discussed this with Niko and we decided this was the best plan of
action.

This breaks code that performs mutable borrows in pattern guards. Most
commonly, the code looks like this:

    impl Foo {
        fn f(&mut self, ...) {}
        fn g(&mut self, ...) {
            match bar {
                Baz if self.f(...) => { ... }
                _ => { ... }
            }
        }
    }

Change this code to not use a guard. For example:

    impl Foo {
        fn f(&mut self, ...) {}
        fn g(&mut self, ...) {
            match bar {
                Baz => {
                    if self.f(...) {
                        ...
                    } else {
                        ...
                    }
                }
                _ => { ... }
            }
        }
    }

Sometimes this can result in code duplication, but often it illustrates
a hidden memory safety problem.

Closes #14684.

[breaking-change]
2014-07-25 15:26:21 -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