]> git.lizzy.rs Git - rust.git/log
rust.git
9 years agorollup merge of #20564: bombless/patch-3
Alex Crichton [Tue, 6 Jan 2015 02:41:23 +0000 (18:41 -0800)]
rollup merge of #20564: bombless/patch-3

Update keyword list according to https://github.com/rust-lang/rust/blob/master/src/libsyntax/parse/token.rs

9 years agorollup merge of #20560: aturon/stab-2-iter-ops-slice
Alex Crichton [Tue, 6 Jan 2015 02:41:20 +0000 (18:41 -0800)]
rollup merge of #20560: aturon/stab-2-iter-ops-slice

Conflicts:
src/libcollections/slice.rs
src/libcore/iter.rs
src/libstd/sync/mpsc/mod.rs
src/libstd/sync/rwlock.rs

9 years agorollup merge of #20554: huonw/mut-pattern
Alex Crichton [Tue, 6 Jan 2015 02:38:51 +0000 (18:38 -0800)]
rollup merge of #20554: huonw/mut-pattern

Conflicts:
src/librustc_typeck/check/_match.rs

9 years agorollup merge of #20548: tshepang/fix-ping-pong-benchmark
Alex Crichton [Tue, 6 Jan 2015 02:38:02 +0000 (18:38 -0800)]
rollup merge of #20548: tshepang/fix-ping-pong-benchmark

Looks like no one has checked this benchmark in a long time: its main thread quit too early, taking down the worker threads before they were done.

9 years agorollup merge of #20538: EchoAce/issue-20529
Alex Crichton [Tue, 6 Jan 2015 02:38:01 +0000 (18:38 -0800)]
rollup merge of #20538: EchoAce/issue-20529

Docs in ```tuple.rs``` edited.

Edit: for some reason commits from something else found their way into here.

9 years agorollup merge of #20519: ville-h/rwlock-rename
Alex Crichton [Tue, 6 Jan 2015 02:37:58 +0000 (18:37 -0800)]
rollup merge of #20519: ville-h/rwlock-rename

Conflicts:
src/libstd/sync/rwlock.rs

9 years agorollup merge of #20518: nagisa/weighted-bool
Alex Crichton [Tue, 6 Jan 2015 02:37:25 +0000 (18:37 -0800)]
rollup merge of #20518: nagisa/weighted-bool

1 in 1 chance to return true always results in true.

9 years agorollup merge of #20517: nikomatsakis/safety-issue-19997
Alex Crichton [Tue, 6 Jan 2015 02:37:24 +0000 (18:37 -0800)]
rollup merge of #20517: nikomatsakis/safety-issue-19997

Fixes various safety issues.

r? @aturon

9 years agorollup merge of #20511: csouth3/derive-lint
Alex Crichton [Tue, 6 Jan 2015 02:37:23 +0000 (18:37 -0800)]
rollup merge of #20511: csouth3/derive-lint

`#[deriving]` has been changed to `#[derive]`, so we should update this lint accordingly so that it remains consistent with the language.

Also register the rename with the LintStore.

I've changed the one reference to `raw_pointer_deriving` that occurs in the tests (as well as renamed the file appropriately), but the rest of the `raw_pointer_deriving`s in the Rust codebase will need to wait for a snapshot to be changed because stage0 doesn't know about the new lint name.  I'll take care of the remaining renaming after the next snapshot.

Closes #20498.

9 years agorollup merge of #20507: alexcrichton/issue-20444
Alex Crichton [Tue, 6 Jan 2015 02:37:22 +0000 (18:37 -0800)]
rollup merge of #20507: alexcrichton/issue-20444

This commit is an implementation of [RFC 494][rfc] which removes the entire
`std::c_vec` module and redesigns the `std::c_str` module as `std::ffi`.

[rfc]: https://github.com/rust-lang/rfcs/blob/master/text/0494-c_str-and-c_vec-stability.md

The interface of the new `CString` is outlined in the linked RFC, the primary
changes being:

* The `ToCStr` trait is gone, meaning the `with_c_str` and `to_c_str` methods
  are now gone. These two methods are replaced with a `CString::from_slice`
  method.
* The `CString` type is now just a wrapper around `Vec<u8>` with a static
  guarantee that there is a trailing nul byte with no internal nul bytes. This
  means that `CString` now implements `Deref<Target = [c_char]>`, which is where
  it gains most of its methods from. A few helper methods are added to acquire a
  slice of `u8` instead of `c_char`, as well as including a slice with the
  trailing nul byte if necessary.
* All usage of non-owned `CString` values is now done via two functions inside
  of `std::ffi`, called `c_str_to_bytes` and `c_str_to_bytes_with_nul`. These
  functions are now the one method used to convert a `*const c_char` to a Rust
  slice of `u8`.

Many more details, including newly deprecated methods, can be found linked in
the RFC. This is a:

[breaking-change]
Closes #20444

9 years agorollup merge of #20488: ltratt/nondeterministic_tempdir
Alex Crichton [Tue, 6 Jan 2015 02:37:20 +0000 (18:37 -0800)]
rollup merge of #20488: ltratt/nondeterministic_tempdir

The previous scheme made it possible for another user/attacker to cause the
temporary directory creation scheme to panic. All you needed to know was the pid
of the process you wanted to target ('other_pid') and the suffix it was using
(let's pretend it's 'sfx') and then code such as this would, in essence, DOS it:

    for i in range(0u, 1001) {
        let tp = &Path::new(format!("/tmp/rs-{}-{}-sfx", other_pid, i));
        match fs::mkdir(tp, io::USER_RWX) { _ => () }
    }

Since the scheme only 1000 times to create a temporary directory before dying,
the next time the attacked process called TempDir::new("sfx") after that would
typically cause a panic. Of course, you don't necessarily need an attacker to
cause such a DOS: creating 1000 temporary directories without closing any of the
previous would be enough to DOS yourself.

This patch broadly follows the OpenBSD implementation of mkstemp. It uses the
operating system's random number generator to produce random directory names
that are impractical to guess (and, just in case someone manages to do that, it
retries creating the directory for a long time before giving up; OpenBSD
retries INT_MAX times, although 1<<31 seems enough to thwart even the most
patient attacker).

As a small additional change while the file name is changing, this patch also
makes the argument that TempDir::new takes a prefix rather than a suffix.
This is because 1) it more closely matches what mkstemp and friends do 2)
if you're going to have a deterministic part of a filename, you really want it at
the beginning so that shell completion is useful.

9 years agorollup merge of #20483: nagisa/rng-copy
Alex Crichton [Tue, 6 Jan 2015 02:37:18 +0000 (18:37 -0800)]
rollup merge of #20483: nagisa/rng-copy

* Implement (derive) `Clone` for `ChaChaRng`, `Isaac*Rng`, `StdRng` and `ThreadRng`;
* Derive `XorShiftRng` `Clone` implementation instead of implementing it explicitly.

`OsRng` is the only Rng which does not implement `Clone` or `Copy` after this patch because of its dependence on `Reader`.

r? @huonw I guess?

9 years agorollup merge of #20478: SeanTAllen/master
Alex Crichton [Tue, 6 Jan 2015 02:36:38 +0000 (18:36 -0800)]
rollup merge of #20478: SeanTAllen/master

Number of rustc calls would depending on various circumstances. Two is misleading.

9 years agorollup merge of #20472: mneumann/llvm-dragonfly
Alex Crichton [Tue, 6 Jan 2015 02:36:37 +0000 (18:36 -0800)]
rollup merge of #20472: mneumann/llvm-dragonfly

9 years agorollup merge of #20465: nikomatsakis/assoc-types-regions-20303
Alex Crichton [Tue, 6 Jan 2015 02:36:34 +0000 (18:36 -0800)]
rollup merge of #20465: nikomatsakis/assoc-types-regions-20303

Treat associated types the same as type parameters when it comes to region bounding. Fixes #20303.

Strictly speaking, this is a [breaking-change] (if you are using
associated types). You are no longer free to wantonly violate the type
system rules by closing associated types into objects without any form
of region bound. Instead you should add region bounds like `T::X :
'a`, just as you would with a normal type parameter.

r? @aturon

9 years agorollup merge of #20434: steveklabnik/five_eye
Alex Crichton [Tue, 6 Jan 2015 02:36:32 +0000 (18:36 -0800)]
rollup merge of #20434: steveklabnik/five_eye

This takes advantage of integer fallback to stop recomending `i` so much.

9 years agorollup merge of #20424: jroesch/tuple-struct-where-clause-fix
Alex Crichton [Tue, 6 Jan 2015 02:36:30 +0000 (18:36 -0800)]
rollup merge of #20424: jroesch/tuple-struct-where-clause-fix

Fixes #17904. All the cases that I believe we should support are detailed in the test case, let me know if there is there is any more desired behavior. cc @japaric.

r? @nikomatsakis or whoever is appropriate.

9 years agorollup merge of #20258: sanxiyn/show-span-2
Alex Crichton [Tue, 6 Jan 2015 02:36:28 +0000 (18:36 -0800)]
rollup merge of #20258: sanxiyn/show-span-2

9 years agorollup merge of #20197: pczarn/ring_buf-collections-reform
Alex Crichton [Tue, 6 Jan 2015 02:36:27 +0000 (18:36 -0800)]
rollup merge of #20197: pczarn/ring_buf-collections-reform

Part of collections reform part 1 and 2, #18424 and #19986

* shrink_to_fit
* swap_back_remove
* swap_front_remove
* truncate
* resize

9 years agorollup merge of #20099: P1start/parse-more-macro-ops
Alex Crichton [Tue, 6 Jan 2015 02:36:25 +0000 (18:36 -0800)]
rollup merge of #20099: P1start/parse-more-macro-ops

Closes #20093.

9 years agorollup merge of #20092: barosl/rustdoc-line-number-clickable
Alex Crichton [Tue, 6 Jan 2015 02:36:21 +0000 (18:36 -0800)]
rollup merge of #20092: barosl/rustdoc-line-number-clickable

While talking on IRC, someone wanted to post a link to the Rust source code, but while the lines of the rendered source code do have anchors (`<span id="[line number]">`), there is no convenient way to make links as they are not clickable. This PR makes them clickable.

Also, a minor fix of the FAQ is included.

9 years agorollup merge of #19998: th0114nd/unicode-bottom
Alex Crichton [Tue, 6 Jan 2015 02:36:20 +0000 (18:36 -0800)]
rollup merge of #19998: th0114nd/unicode-bottom

In the HTML version of the documentation, it isn't rendered so might as well use the unicode representation.

9 years agorollup merge of #19888: steveklabnik/gh19861
Alex Crichton [Tue, 6 Jan 2015 02:36:18 +0000 (18:36 -0800)]
rollup merge of #19888: steveklabnik/gh19861

Fixes #19861

/cc @huonw

9 years agorollup merge of #19736: steveklabnik/gh19662
Alex Crichton [Tue, 6 Jan 2015 02:36:17 +0000 (18:36 -0800)]
rollup merge of #19736: steveklabnik/gh19662

Fixes #19662.

9 years agorollup merge of #19235: bjz/reference
Alex Crichton [Tue, 6 Jan 2015 02:36:16 +0000 (18:36 -0800)]
rollup merge of #19235: bjz/reference

cc. @steveklabnik

9 years agoauto merge of #20578 : japaric/rust/no-more-bc, r=nmatsakis
bors [Mon, 5 Jan 2015 23:51:00 +0000 (23:51 +0000)]
auto merge of #20578 : japaric/rust/no-more-bc, r=nmatsakis

This PR removes boxed closures from the language, the closure type syntax (`let f: |int| -> bool = /* ... */`) has been obsoleted. Move all your uses of closures to the new unboxed closure system (i.e. `Fn*` traits).

[breaking-change] patterns

- `lef f = || {}`

This binding used to type check to a boxed closure. Now that boxed closures are gone, you need to annotate the "kind" of the unboxed closure, i.e. you need pick one of these: `|&:| {}`, `|&mut:| {}` or `|:| {}`.

In the (near) future we'll have closure "kind" inference, so the compiler will infer which `Fn*` trait to use based on how the closure is used. Once this inference machinery is in place, we'll be able to remove the kind annotation from most closures.

- `type Alias<'a> = |int|:'a -> bool`

Use a trait object: `type Alias<'a> = Box<FnMut(int) -> bool + 'a>`. Use the `Fn*` trait that makes sense for your use case.

- `fn foo(&self, f: |uint| -> bool)`

In this case you can use either a trait object or an unboxed closure:

``` rust
fn foo(&self, f: F) where F: FnMut(uint) -> bool;
// or
fn foo(&self, f: Box<FnMut(uint) -> bool>);
```

- `struct Struct<'a> { f: |uint|:'a -> bool }`

Again, you can use either a trait object or an unboxed closure:

``` rust
struct Struct<F> where F: FnMut(uint) -> bool { f: F }
// or
struct Struct<'a> { f: Box<FnMut(uint) -> bool + 'a> }
```

- Using `|x, y| f(x, y)` for closure "borrows"

This comes up in recursive functions, consider the following (contrived) example:

``` rust
fn foo(x: uint, f: |uint| -> bool) -> bool {
    //foo(x / 2, f) && f(x)  // can't use this because `f` gets moved away in the `foo` call
    foo(x / 2, |x| f(x)) && f(x)  // instead "borrow" `f` in the `foo` call
}
```

If you attempt to do the same with unboxed closures you'll hit ""error: reached the recursion limit during monomorphization" (see #19596):

``` rust
fn foo<F>(x: uint, mut f: F) -> bool where F: FnMut(uint) -> bool {
    foo(x / 2, |x| f(x)) && f(x)
    //~^ error: reached the recursion limit during monomorphization
}
```

Instead you *should* be able to write this:

``` rust
fn foo<F>(x: uint, mut f: F) -> bool where F: FnMut(uint) -> bool {
    foo(x / 2, &mut f) && f(x)
    //~^ error: the trait `FnMut` is not implemented for the type `&mut F`
}
```

But as you see above `&mut F` doesn't implement the `FnMut` trait. `&mut F` *should* implement the `FnMut` and the above code *should* work, but due to a bug (see #18835) it doesn't (for now).

You can work around the issue by rewriting the function to take `&mut F` instead of `F`:

``` rust
fn foo<F>(x: uint, f: &mut F) -> bool where F: FnMut(uint) -> bool {
    foo(x / 2, f) && (*f)(x)
}
```

This finally works! However writing `foo(0, &mut |x| x == 0)` is unergonomic. So you can use a private helper function to avoid this:

``` rust
// public API function
pub fn foo<F>(x: uint, mut f: F) -> bool where F: FnMut(uint) -> bool {
    foo_(x, &mut f)
}

// private helper function
fn foo_<F>(x: uint, f: &mut F) -> bool where F: FnMut(uint) -> bool {
    foo_(x / 2, f) && (*f)(x)
}
```

Closes #14798

---

There is more cleanup to do: like renaming functions/types from `unboxed_closure` to just `closure`, removing more dead code, simplify functions which now have unused arguments, update the documentation, etc. But that can be done in another PR.

r? @nikomatsakis @aturon (You probably want to focus on the deleted/modified tests.)
cc @eddyb

9 years agoRemove i suffix in docs
Steve Klabnik [Fri, 2 Jan 2015 17:21:00 +0000 (12:21 -0500)]
Remove i suffix in docs

9 years agoStabilization of impls and fallout from stabilization
Aaron Turon [Mon, 5 Jan 2015 00:16:55 +0000 (16:16 -0800)]
Stabilization of impls and fallout from stabilization

9 years agoremove more stage0 stuff
Jorge Aparicio [Mon, 5 Jan 2015 21:19:15 +0000 (16:19 -0500)]
remove more stage0 stuff

9 years agounignore and fix doctests in guide and reference
Jorge Aparicio [Mon, 5 Jan 2015 21:02:28 +0000 (16:02 -0500)]
unignore and fix doctests in guide and reference

9 years agofix tests
Jorge Aparicio [Mon, 5 Jan 2015 21:02:07 +0000 (16:02 -0500)]
fix tests

9 years agoreplace `f.call_mut(a, b, ..)` with `f(a, b, ..)`
Jorge Aparicio [Mon, 5 Jan 2015 19:07:10 +0000 (14:07 -0500)]
replace `f.call_mut(a, b, ..)` with `f(a, b, ..)`

9 years agoCorrectly "detuple" arguments when creating trait object shims for a trait method...
Niko Matsakis [Mon, 5 Jan 2015 18:53:39 +0000 (13:53 -0500)]
Correctly "detuple" arguments when creating trait object shims for a trait method with rust-call ABI.

9 years agoFix ICE caused by forgotten bcx
Niko Matsakis [Mon, 5 Jan 2015 16:06:20 +0000 (11:06 -0500)]
Fix ICE caused by forgotten bcx

9 years agoaddress Niko's comments
Jorge Aparicio [Mon, 5 Jan 2015 17:07:49 +0000 (12:07 -0500)]
address Niko's comments

9 years agoignore boxed closure doctests in the guide/reference
Jorge Aparicio [Mon, 5 Jan 2015 13:25:55 +0000 (08:25 -0500)]
ignore boxed closure doctests in the guide/reference

9 years agofix benchmarks
Jorge Aparicio [Mon, 5 Jan 2015 13:23:55 +0000 (08:23 -0500)]
fix benchmarks

9 years agofix debuginfo tests
Jorge Aparicio [Mon, 5 Jan 2015 13:23:17 +0000 (08:23 -0500)]
fix debuginfo tests

9 years agofix pretty tests
Jorge Aparicio [Mon, 5 Jan 2015 13:22:04 +0000 (08:22 -0500)]
fix pretty tests

9 years agofix run-make test
Jorge Aparicio [Mon, 5 Jan 2015 04:33:35 +0000 (23:33 -0500)]
fix run-make test

9 years agofix cfail tests
Jorge Aparicio [Sat, 3 Jan 2015 15:45:00 +0000 (10:45 -0500)]
fix cfail tests

9 years agofix rpass tests
Jorge Aparicio [Fri, 2 Jan 2015 22:32:54 +0000 (17:32 -0500)]
fix rpass tests

9 years agotypeck: remove dead code
Jorge Aparicio [Sun, 4 Jan 2015 15:53:03 +0000 (10:53 -0500)]
typeck: remove dead code

9 years agotrans: remove dead code
Jorge Aparicio [Sun, 4 Jan 2015 15:50:24 +0000 (10:50 -0500)]
trans: remove dead code

9 years agorustc: remove dead code
Jorge Aparicio [Sun, 4 Jan 2015 15:42:51 +0000 (10:42 -0500)]
rustc: remove dead code

9 years agosyntax: remove dead code
Jorge Aparicio [Sun, 4 Jan 2015 15:42:11 +0000 (10:42 -0500)]
syntax: remove dead code

9 years agotypeck: there are only unboxed closures now
Jorge Aparicio [Sun, 4 Jan 2015 15:39:03 +0000 (10:39 -0500)]
typeck: there are only unboxed closures now

9 years agosyntax: make the closure type `f: |uint| -> bool` syntax obsolete
Jorge Aparicio [Thu, 1 Jan 2015 22:21:25 +0000 (17:21 -0500)]
syntax: make the closure type `f: |uint| -> bool` syntax obsolete

9 years agotrans: remove Closure
Jorge Aparicio [Mon, 5 Jan 2015 00:27:20 +0000 (19:27 -0500)]
trans: remove Closure

9 years agoremove mk_closure
Jorge Aparicio [Sun, 4 Jan 2015 14:55:16 +0000 (09:55 -0500)]
remove mk_closure

9 years agoremove AdjustAddEnv
Jorge Aparicio [Sun, 4 Jan 2015 14:53:08 +0000 (09:53 -0500)]
remove AdjustAddEnv

9 years agoremove TyClosure
Jorge Aparicio [Sun, 4 Jan 2015 14:51:37 +0000 (09:51 -0500)]
remove TyClosure

9 years agoremove ty_closure
Jorge Aparicio [Sun, 4 Jan 2015 14:50:17 +0000 (09:50 -0500)]
remove ty_closure

9 years agocoretest: remove/ignore tests
Jorge Aparicio [Mon, 5 Jan 2015 04:34:23 +0000 (23:34 -0500)]
coretest: remove/ignore tests

9 years agocompiletest: remove boxed closures
Jorge Aparicio [Mon, 5 Jan 2015 03:05:29 +0000 (22:05 -0500)]
compiletest: remove boxed closures

9 years agodriver: remove unboxed closures
Jorge Aparicio [Mon, 5 Jan 2015 01:36:57 +0000 (20:36 -0500)]
driver: remove unboxed closures

9 years agotrans: remove remaining boxed closures
Jorge Aparicio [Sun, 4 Jan 2015 22:23:01 +0000 (17:23 -0500)]
trans: remove remaining boxed closures

9 years agotypeck: remove remaining boxed closures
Jorge Aparicio [Sun, 4 Jan 2015 22:22:50 +0000 (17:22 -0500)]
typeck: remove remaining boxed closures

9 years agorustc: remove remaining boxed closures
Jorge Aparicio [Sun, 4 Jan 2015 21:10:27 +0000 (16:10 -0500)]
rustc: remove remaining boxed closures

9 years agoEncodeInlinedItem: convert to "unboxed" closures
Jorge Aparicio [Sun, 4 Jan 2015 14:13:48 +0000 (09:13 -0500)]
EncodeInlinedItem: convert to "unboxed" closures

9 years agoDecodeInlinedItem: convert to "unboxed" closures
Jorge Aparicio [Sun, 4 Jan 2015 14:07:13 +0000 (09:07 -0500)]
DecodeInlinedItem: convert to "unboxed" closures

9 years agoconv_did: convert to "unboxed" closure
Jorge Aparicio [Sat, 3 Jan 2015 22:28:38 +0000 (17:28 -0500)]
conv_did: convert to "unboxed" closure

9 years agosyntax: remove remaining boxed closures
Jorge Aparicio [Thu, 1 Jan 2015 23:32:49 +0000 (18:32 -0500)]
syntax: remove remaining boxed closures

9 years agostd: remove remaining boxed closures
Jorge Aparicio [Thu, 1 Jan 2015 23:07:31 +0000 (18:07 -0500)]
std: remove remaining boxed closures

9 years agoregister snapshot
Jorge Aparicio [Mon, 5 Jan 2015 13:34:44 +0000 (08:34 -0500)]
register snapshot

9 years agoStabilize collection modules
Aaron Turon [Mon, 5 Jan 2015 00:35:20 +0000 (16:35 -0800)]
Stabilize collection modules

The earlier collections stabilization did not cover the modules
themselves. This commit marks as stable those modules whose types have
been stabilized.

9 years agoFinal alpha stabilization of std::slice
Aaron Turon [Sun, 4 Jan 2015 23:53:00 +0000 (15:53 -0800)]
Final alpha stabilization of std::slice

Marks as `#[stable]`:

* Various iterator structs for stable methods, e.g. `Chunks` and
  `Windows`.
* The `SliceExt` trait itself.

9 years agoStabilize core::ops
Aaron Turon [Sun, 4 Jan 2015 23:42:51 +0000 (15:42 -0800)]
Stabilize core::ops

This commit marks as stable those parts of `core::ops` that are in their
final planned form: `Drop`, all of the mathematical operators (`Add`,
`Sub`, etc), `Deref`/`DerefMut`. It leaves the `Index*`, `Slice*` and
`Fn*` traits unstable, as they are still undergoing active changes.

9 years agoFinal alpha stabilization of core::iter
Aaron Turon [Sun, 4 Jan 2015 16:43:27 +0000 (08:43 -0800)]
Final alpha stabilization of core::iter

This commit wraps up the adjustments to the iterator for recent language
changes.

* Moves `rposition` from `ExactSizeIterator` to `IteratorExt` using a
  `where` clause, thereby removing the `ExactSizeIterator:
  DoubleEndedIterator` constraint.

* Merges `MutableDoubleEndedIterator` into `IteratorExt`, renaming
  `reverse_` to `reverse_in_place`.

* Merges `IteratorOrdExt`, `IteratorCloneExt` and `CloneIteratorExt`
  into `IteratorExt` using `where` clauses.

Marks as `#[stable]`:

* the `iter` module itself
* `FromIterator`, `Extend`
* `Iterator`, `IteratorExt`
* `map`
* `filter`
* `filter_map`
* `skip_while`
* `take_while`
* `scan`
* `flat_map`
* `inspect`
* `collect`
* `fold`
* `all`
* `any`
* `find`
* `rposition`
* `max`, `min`
* Various adapter types related to the above methods

Because of the trait merging, this is a:

[breaking-change]

9 years agoremoving whitespace
FakeKane [Mon, 5 Jan 2015 21:46:46 +0000 (16:46 -0500)]
removing whitespace

9 years agoexamples added for element access
FakeKane [Mon, 5 Jan 2015 21:22:03 +0000 (16:22 -0500)]
examples added for element access

9 years agoauto merge of #20572 : nikomatsakis/rust/assoc-supertrait-stuff, r=brson
bors [Mon, 5 Jan 2015 20:02:14 +0000 (20:02 +0000)]
auto merge of #20572 : nikomatsakis/rust/assoc-supertrait-stuff, r=brson

The first few commits in the PR are just general refactoring. I was intending them for some other code I didn't get around to writing yet, but might as well land them now.

cc @japaric

Fixes #19541

9 years agoEnsure that LLVM is rebuilt with recent changes
Michael Neumann [Mon, 5 Jan 2015 09:54:40 +0000 (10:54 +0100)]
Ensure that LLVM is rebuilt with recent changes

9 years agoSegmented stack support for DragonFly
Michael Neumann [Sat, 3 Jan 2015 11:42:34 +0000 (12:42 +0100)]
Segmented stack support for DragonFly

9 years agoAdd lifetime elision information to the ownership guide.
Steve Klabnik [Thu, 11 Dec 2014 16:37:20 +0000 (11:37 -0500)]
Add lifetime elision information to the ownership guide.

Fixes #19662.

9 years agoAdd a test for issue #18865. Fixes #18865.
Niko Matsakis [Sat, 3 Jan 2015 11:07:07 +0000 (06:07 -0500)]
Add a test for issue #18865. Fixes #18865.

9 years agoDon't ICE just because an impl is missing an associated type. Trust in the other...
Niko Matsakis [Sat, 3 Jan 2015 11:01:56 +0000 (06:01 -0500)]
Don't ICE just because an impl is missing an associated type. Trust in the other compiler passes.
Fixes #17359.

9 years agostd: Redesign c_str and c_vec
Alex Crichton [Tue, 25 Nov 2014 21:28:35 +0000 (13:28 -0800)]
std: Redesign c_str and c_vec

This commit is an implementation of [RFC 494][rfc] which removes the entire
`std::c_vec` module and redesigns the `std::c_str` module as `std::ffi`.

[rfc]: https://github.com/rust-lang/rfcs/blob/master/text/0494-c_str-and-c_vec-stability.md

The interface of the new `CString` is outlined in the linked RFC, the primary
changes being:

* The `ToCStr` trait is gone, meaning the `with_c_str` and `to_c_str` methods
  are now gone. These two methods are replaced with a `CString::from_slice`
  method.
* The `CString` type is now just a wrapper around `Vec<u8>` with a static
  guarantee that there is a trailing nul byte with no internal nul bytes. This
  means that `CString` now implements `Deref<Target = [c_char]>`, which is where
  it gains most of its methods from. A few helper methods are added to acquire a
  slice of `u8` instead of `c_char`, as well as including a slice with the
  trailing nul byte if necessary.
* All usage of non-owned `CString` values is now done via two functions inside
  of `std::ffi`, called `c_str_to_bytes` and `c_str_to_bytes_with_nul`. These
  functions are now the one method used to convert a `*const c_char` to a Rust
  slice of `u8`.

Many more details, including newly deprecated methods, can be found linked in
the RFC. This is a:

[breaking-change]
Closes #20444

9 years agoreverting other changes
FakeKane [Mon, 5 Jan 2015 13:57:43 +0000 (08:57 -0500)]
reverting other changes

9 years agoTreat associated types the same as type parameters when it comes to region bounding...
Niko Matsakis [Sat, 3 Jan 2015 09:40:33 +0000 (04:40 -0500)]
Treat associated types the same as type parameters when it comes to region bounding. Fixes #20303.

Strictly speaking, this is a [breaking-change] (if you are using
associated types). You are no longer free to wantonly violate the type
system rules by closing associated types into objects without any form
of region bound. Instead you should add region bounds like `T::X :
'a`, just as you would with a normal type parameter.

9 years agoauto merge of #20514 : alexcrichton/rust/serialize-associated-type, r=aturon
bors [Mon, 5 Jan 2015 14:51:03 +0000 (14:51 +0000)]
auto merge of #20514 : alexcrichton/rust/serialize-associated-type, r=aturon

This commit moves the libserialize crate (and will force the hand of the
rustc-serialize crate) to not require the `old_orphan_check` feature gate as
well as using associated types wherever possible. Concretely, the following
changes were made:

* The error type of `Encoder` and `Decoder` is now an associated type, meaning
  that these traits have no type parameters.

* The `Encoder` and `Decoder` type parameters on the `Encodable` and `Decodable`
  traits have moved to the corresponding method of the trait. This movement
  alleviates the dependency on `old_orphan_check` but implies that
  implementations can no longer be specialized for the type of encoder/decoder
  being implemented.

Due to the trait definitions changing, this is a:

[breaking-change]

9 years agoImplement a few methods for RingBuf
Piotr Czarnecki [Mon, 5 Jan 2015 14:48:58 +0000 (15:48 +0100)]
Implement a few methods for RingBuf

* shrink_to_fit
* swap_back_remove
* swap_front_remove
* truncate
* resize

9 years agoImprove test to include a projection, per @huonw's suggestion.
Niko Matsakis [Mon, 5 Jan 2015 14:14:03 +0000 (09:14 -0500)]
Improve test to include a projection, per @huonw's suggestion.

9 years agoMake supertrait references work in object types too.
Niko Matsakis [Mon, 5 Jan 2015 11:08:03 +0000 (06:08 -0500)]
Make supertrait references work in object types too.

9 years agoMinor code formatting cleanups.
Niko Matsakis [Mon, 5 Jan 2015 10:37:11 +0000 (05:37 -0500)]
Minor code formatting cleanups.

9 years agoPermit bindings of (and references to) associated types defined in supertraits.
Niko Matsakis [Mon, 5 Jan 2015 10:36:41 +0000 (05:36 -0500)]
Permit bindings of (and references to) associated types defined in supertraits.

9 years agoIntroduce a CollectCtxt and impl AstConv on *that*. Also make all fns
Niko Matsakis [Mon, 5 Jan 2015 09:24:00 +0000 (04:24 -0500)]
Introduce a CollectCtxt and impl AstConv on *that*. Also make all fns
in collect private except the public entry point.

9 years agoStop writing code that is (unnecessarily) generic over any AstConv in collect,
Niko Matsakis [Sun, 4 Jan 2015 11:37:49 +0000 (06:37 -0500)]
Stop writing code that is (unnecessarily) generic over any AstConv in collect,
just hard-code the ccx.

9 years agoConvert astconv and friends to use object types, not generics. No need to compile
Niko Matsakis [Sun, 4 Jan 2015 11:10:34 +0000 (06:10 -0500)]
Convert astconv and friends to use object types, not generics. No need to compile
all that stuff twice. Also, code reads so much nicer.

9 years agoauto merge of #20451 : brson/rust/installer, r=alexcrichton
bors [Mon, 5 Jan 2015 11:10:57 +0000 (11:10 +0000)]
auto merge of #20451 : brson/rust/installer, r=alexcrichton

This fixes a mostly harmless syntax error in the install script.

9 years agoAdd tests for ChaCha and Isaac Clone impls
Simonas Kazlauskas [Sat, 3 Jan 2015 19:58:20 +0000 (21:58 +0200)]
Add tests for ChaCha and Isaac Clone impls

9 years agoImplement Clone for PRNGs
Simonas Kazlauskas [Tue, 23 Dec 2014 11:55:12 +0000 (13:55 +0200)]
Implement Clone for PRNGs

9 years agoMake temporary directory names non-deterministic.
Laurence Tratt [Sat, 3 Jan 2015 21:49:01 +0000 (21:49 +0000)]
Make temporary directory names non-deterministic.

The previous scheme made it possible for another user/attacker to cause the
temporary directory creation scheme to panic. All you needed to know was the pid
of the process you wanted to target ('other_pid') and the suffix it was using
(let's pretend it's 'sfx') and then code such as this would, in essence, DOS it:

    for i in range(0u, 1001) {
        let tp = &Path::new(format!("/tmp/rs-{}-{}-sfx", other_pid, i));
        match fs::mkdir(tp, io::USER_RWX) { _ => () }
    }

Since the scheme retried only 1000 times to create a temporary directory before
dying, the next time the attacked process called TempDir::new("sfx") after that
would typically cause a panic. Of course, you don't necessarily need an attacker
to cause such a DOS: creating 1000 temporary directories without closing any of
the previous would be enough to DOS yourself.

This patch broadly follows the OpenBSD implementation of mkstemp. It uses the
operating system's random number generator to produce random directory names
that are impractical to guess (and, just in case someone manages to do that, it
retries creating the directory for a long time before giving up; OpenBSD
retries INT_MAX times, although 1<<31 seems enough to thwart even the most
patient attacker).

As a small additional change, this patch also makes the argument that
TempDir::new takes a prefix rather than a suffix. This is because 1) it more
closely matches what mkstemp and friends do 2) if you're going to have a
deterministic part of a filename, you really want it at the beginning so that
shell completion is useful.

9 years agoRefactor struct parsing and add tests
Jared Roesch [Sun, 4 Jan 2015 10:35:14 +0000 (02:35 -0800)]
Refactor struct parsing and add tests

9 years agokate syntax highlight: update keyword list
York Xiang [Mon, 5 Jan 2015 07:11:54 +0000 (15:11 +0800)]
kate syntax highlight: update keyword list

9 years agoserialize: Use assoc types + less old_orphan_check
Alex Crichton [Sun, 4 Jan 2015 06:24:50 +0000 (22:24 -0800)]
serialize: Use assoc types + less old_orphan_check

This commit moves the libserialize crate (and will force the hand of the
rustc-serialize crate) to not require the `old_orphan_check` feature gate as
well as using associated types wherever possible. Concretely, the following
changes were made:

* The error type of `Encoder` and `Decoder` is now an associated type, meaning
  that these traits have no type parameters.

* The `Encoder` and `Decoder` type parameters on the `Encodable` and `Decodable`
  traits have moved to the corresponding method of the trait. This movement
  alleviates the dependency on `old_orphan_check` but implies that
  implementations can no longer be specialized for the type of encoder/decoder
  being implemented.

Due to the trait definitions changing, this is a:

[breaking-change]

9 years agoauto merge of #20395 : huonw/rust/char-stab-2, r=aturon
bors [Mon, 5 Jan 2015 06:45:39 +0000 (06:45 +0000)]
auto merge of #20395 : huonw/rust/char-stab-2, r=aturon

cc #19260

The casing transformations are left unstable (it is highly likely to be better to adopt the proper non-1-to-1 case mappings, per #20333) as are `is_xid_*`.

I've got a little todo list in the last commit of things I thought about/was told about that I haven't yet handled (I'd also like some feedback).

9 years agoChange `&` pat to only work with &T, and `&mut` with &mut T.
Huon Wilson [Fri, 5 Dec 2014 23:56:25 +0000 (15:56 -0800)]
Change `&` pat to only work with &T, and `&mut` with &mut T.

This implements RFC 179 by making the pattern `&<pat>` require matching
against a variable of type `&T`, and introducing the pattern `&mut
<pat>` which only works with variables of type `&mut T`.

The pattern `&mut x` currently parses as `&(mut x)` i.e. a pattern match
through a `&T` or a `&mut T` that binds the variable `x` to have type
`T` and to be mutable. This should be rewritten as follows, for example,

    for &mut x in slice.iter() {

becomes

    for &x in slice.iter() {
        let mut x = x;

Due to this, this is a

[breaking-change]

Closes #20496.

9 years agoauto merge of #20285 : FlaPer87/rust/oibit-send-and-friends, r=nikomatsakis
bors [Mon, 5 Jan 2015 04:20:46 +0000 (04:20 +0000)]
auto merge of #20285 : FlaPer87/rust/oibit-send-and-friends, r=nikomatsakis

This commit introduces the syntax for negative implementations of traits
as shown below:

`impl !Trait for Type {}`

cc #13231
Part of RFC rust-lang/rfcs#127

r? @nikomatsakis

9 years agoFix the parsing of where-clauses for structs
Jared Roesch [Fri, 2 Jan 2015 12:02:50 +0000 (04:02 -0800)]
Fix the parsing of where-clauses for structs