]> git.lizzy.rs Git - rust.git/log
rust.git
9 years agoRemove mention of Dequeue in collections docs.
Steve Klabnik [Sun, 7 Dec 2014 19:12:01 +0000 (14:12 -0500)]
Remove mention of Dequeue in collections docs.

  https://botbot.me/mozilla/rust/2014-12-07/?msg=27003846&page=20

9 years agoauto merge of #19539 : cmr/rust/18959, r=nikomatsakis
bors [Sun, 7 Dec 2014 16:12:22 +0000 (16:12 +0000)]
auto merge of #19539 : cmr/rust/18959, r=nikomatsakis

Closes #18959

Technically, this causes code that once compiled to no longer compile, but
that code probably never ran.

[breaking-change]

------------

Not quite sure the error message is good enough, I feel like it ought to tell you "because it inherits from non-object-safe trait Foo", so I've opened up a follow-up issue #19538

9 years agoauto merge of #19522 : mukilan/rust/import-conflicts-item, r=cmr
bors [Sun, 7 Dec 2014 13:42:18 +0000 (13:42 +0000)]
auto merge of #19522 : mukilan/rust/import-conflicts-item, r=cmr

Fixes #19498

9 years agoauto merge of #19488 : jbranchaud/rust/add-btree-set-doctests, r=alexcrichton
bors [Sun, 7 Dec 2014 07:12:16 +0000 (07:12 +0000)]
auto merge of #19488 : jbranchaud/rust/add-btree-set-doctests, r=alexcrichton

There is already a test for `union` in the test namespace, but this commit adds a doctest that will appear in the rustdocs.

Someone on IRC said, *Write doctests!*, so here I am.

I am not sure this is the best way to demonstrate the behavior of the union function, so I am open to suggestions for improving this. If I am on the right track I'd be glad to include similar doctests for `intersection`, `difference`, etc.

9 years agoauto merge of #19407 : frewsxcv/rust/rm-reexports, r=cmr
bors [Sun, 7 Dec 2014 04:12:20 +0000 (04:12 +0000)]
auto merge of #19407 : frewsxcv/rust/rm-reexports, r=cmr

In regards to:

https://github.com/rust-lang/rust/issues/19253#issuecomment-64836729

This commit:

* Changes the #deriving code so that it generates code that utilizes fewer
  reexports (in particur Option::\*, Result::\*, and Ordering::\*), which is necessary to
  remove those reexports in the future
* Changes other areas of the codebase so that fewer reexports are utilized

9 years agoAdd compile-fail tests for #19498
Mukilan Thiyagarajan [Sun, 7 Dec 2014 01:51:58 +0000 (07:21 +0530)]
Add compile-fail tests for #19498

9 years agoauto merge of #19579 : alexcrichton/rust/snapshots, r=nikomatsakis
bors [Sat, 6 Dec 2014 23:12:17 +0000 (23:12 +0000)]
auto merge of #19579 : alexcrichton/rust/snapshots, r=nikomatsakis

9 years agoauto merge of #19431 : erickt/rust/buf-writer-error, r=alexcrichton
bors [Sat, 6 Dec 2014 20:12:13 +0000 (20:12 +0000)]
auto merge of #19431 : erickt/rust/buf-writer-error, r=alexcrichton

Previously, `BufWriter::write` would just return an `std::io::OtherIoError` if someone attempted to write past the end of the wrapped buffer. This pull request changes the error to support partial writes and return a `std::io::ShortWrite`, or an `io::io::EndOfFile` if it's been fully exhausted.

 I've also optimized away a bounds check inside `BufWriter::write`, which should help shave off some nanoseconds in an inner loops.

9 years agoauto merge of #19590 : sfackler/rust/fix-android, r=sfackler
bors [Sat, 6 Dec 2014 17:42:16 +0000 (17:42 +0000)]
auto merge of #19590 : sfackler/rust/fix-android, r=sfackler

Seems to be blocking forever

9 years agoIgnore wait-forked-but-failed-child
Steven Fackler [Sat, 6 Dec 2014 06:58:04 +0000 (22:58 -0800)]
Ignore wait-forked-but-failed-child

Test will be fixed in #19588

9 years agorustc: check supertraits for object safety
Corey Richardson [Thu, 27 Nov 2014 16:28:51 +0000 (11:28 -0500)]
rustc: check supertraits for object safety

Closes #18959

Technically, this causes code that once compiled to no longer compile, but
that code probably never ran.

[breaking-change]

9 years agoIgnore issue #16671 test on android
Steven Fackler [Sat, 6 Dec 2014 04:22:35 +0000 (20:22 -0800)]
Ignore issue #16671 test on android

Seems to be blocking forever

9 years agoRegister new snapshots
Alex Crichton [Fri, 5 Dec 2014 23:21:03 +0000 (15:21 -0800)]
Register new snapshots

9 years agoUtilize fewer reexports
Corey Farwell [Fri, 28 Nov 2014 16:57:41 +0000 (11:57 -0500)]
Utilize fewer reexports

In regards to:

https://github.com/rust-lang/rust/issues/19253#issuecomment-64836729

This commit:

* Changes the #deriving code so that it generates code that utilizes fewer
  reexports (in particur Option::* and Result::*), which is necessary to
  remove those reexports in the future
* Changes other areas of the codebase so that fewer reexports are utilized

9 years agoAdd doctests for union, diff, sym_diff, and intersection.
jbranchaud [Wed, 3 Dec 2014 04:59:24 +0000 (22:59 -0600)]
Add doctests for union, diff, sym_diff, and intersection.

Add a rustdoc test for union to exhibit how it is used.

There is already a test for union in the test namespace, but this commit
adds a doctest that will appear in the rustdocs.

Add a doctest for the difference function.

Add a doctest for the symmetric_difference function.

Add a doctest for the intersection function.

Update the union et al. doctests based on @Gankro's comments.

Make the union et al. doctests a bit more readable.

9 years agoauto merge of #19508 : cmr/rust/rollup-2014_12_03, r=cmr
bors [Fri, 5 Dec 2014 20:23:10 +0000 (20:23 +0000)]
auto merge of #19508 : cmr/rust/rollup-2014_12_03, r=cmr

9 years agoMerge remote-tracking branch 'csouth3/trieset-bitops' into rollup-2014_12_03
Corey Richardson [Fri, 5 Dec 2014 19:19:50 +0000 (11:19 -0800)]
Merge remote-tracking branch 'csouth3/trieset-bitops' into rollup-2014_12_03

Conflicts:
src/libcollections/trie/set.rs

9 years agoImplement BitOps for TrieSet
Chase Southwood [Thu, 4 Dec 2014 06:35:38 +0000 (00:35 -0600)]
Implement BitOps for TrieSet

9 years agorollup merge of #19553: sfackler/issue-19543
Corey Richardson [Fri, 5 Dec 2014 18:08:33 +0000 (10:08 -0800)]
rollup merge of #19553: sfackler/issue-19543

Closes #19543

9 years agorollup merge of #19534: scialex/liballoc-cfg
Corey Richardson [Fri, 5 Dec 2014 18:08:28 +0000 (10:08 -0800)]
rollup merge of #19534: scialex/liballoc-cfg

Adds the ability to use a custom allocator heap by passing either --cfg
external_crate and --extern external=<allocator_crate_name> or --cfg
external_funcs and defining the allocator functions prefixed by 'rust_'
somewhere.

This is useful for many applications including OS/embedded development,
and allocator development and testing.

9 years agorollup merge of #19530: aochagavia/remove-test
Corey Richardson [Fri, 5 Dec 2014 18:08:26 +0000 (10:08 -0800)]
rollup merge of #19530: aochagavia/remove-test

Fixes https://github.com/rust-lang/rust/issues/19510

9 years agorollup merge of #19528: aliblong/add_vecmap_capacity
Corey Richardson [Fri, 5 Dec 2014 18:08:24 +0000 (10:08 -0800)]
rollup merge of #19528: aliblong/add_vecmap_capacity

Part of #18424

Adds `capacity()` function to VecMap, as per the collections reform.

(Salvaged from #19516, #19523, while we await an RFC regarding `reserve`/`reserve_index` for `VecMap`)

9 years agorollup merge of #19526: steveklabnik/gh19402
Corey Richardson [Fri, 5 Dec 2014 18:07:49 +0000 (10:07 -0800)]
rollup merge of #19526: steveklabnik/gh19402

Fixes #19402.

9 years agorollup merge of #19525: steveklabnik/guide_edits
Corey Richardson [Fri, 5 Dec 2014 18:07:48 +0000 (10:07 -0800)]
rollup merge of #19525: steveklabnik/guide_edits

Fixes #19335. (or at least, the actionable parts)

9 years agorollup merge of #19520: csouth3/derefmut-unsized
Corey Richardson [Fri, 5 Dec 2014 18:07:47 +0000 (10:07 -0800)]
rollup merge of #19520: csouth3/derefmut-unsized

Right now, `DerefMut` is not `for Sized?`, so you can't impl `DerefMut<T> for Foo` where `Foo` is unsized.  However, there is no reason that it can't be `for Sized?`, so this pull request fixes the issue.

Closes #19493.

9 years agorollup merge of #19518: csouth3/trieset-bitops
Corey Richardson [Fri, 5 Dec 2014 18:07:45 +0000 (10:07 -0800)]
rollup merge of #19518: csouth3/trieset-bitops

Implement the `BitOr`, `BitAnd`, `BitXor`, and `Sub` traits from `std::ops` for TrieSet.  The behavior of these operator overloads is consistent with [RFC 235](https://github.com/rust-lang/rfcs/blob/master/text/0235-collections-conventions.md#combinations).

9 years agorollup merge of #19515: lifthrasiir/rustdoc-wrong-dedup
Corey Richardson [Fri, 5 Dec 2014 18:07:44 +0000 (10:07 -0800)]
rollup merge of #19515: lifthrasiir/rustdoc-wrong-dedup

Fixes #17332.

9 years agorollup merge of #19513: lifthrasiir/rustdoc-fat-redirect
Corey Richardson [Fri, 5 Dec 2014 18:07:42 +0000 (10:07 -0800)]
rollup merge of #19513: lifthrasiir/rustdoc-fat-redirect

We heavily rely on queries and fragments in the URL structure, so it is desired to preserve them even in the redirects. The generated redirect pages try to preserve them with scripts, which take precedence over the original `Refresh` metadata. Non-scripting browsers would continue to work (with no queries and fragments).

(This in turn solves a number of semi-broken links to the source code, which are actually linked to redirect pages.)

9 years agorollup merge of #19512: cybergeek94/master
Corey Richardson [Fri, 5 Dec 2014 18:07:41 +0000 (10:07 -0800)]
rollup merge of #19512: cybergeek94/master

Added the example from [this Reddit thread][1], reworked to be more robust with correct logic (first link skipped the 0th and 1st Fibonacci numbers, second forgot about the last two valid values before overflow). Will yield all Fibonacci numbers sequentially in the range `[0, <u32 as Int>::max_value())`.

If the example is too complicated I can change it to a more naive version, perhaps using signed integers to check for overflow instead of `Option` and `.checked_add()`.

Also reworded the doc comments to clarify the usage and behavior of `Unfold`, as the thread suggested that it wasn't really clear how `Unfold` worked and when one should use it.

This change is in the `core` crate but I based the example on `std` since that's where most readers will find the example. I included a note about `core` for clarity. Edit: removed.

Tested with `rustdoc src/libcore/lib.rs`. Rebased against latest master as of the creation of this PR.

[1]: http://www.reddit.com/r/rust/comments/2ny8r1/a_question_about_loops/cmighu4?context=10000

9 years agorollup merge of #19503: lifthrasiir/xenophobic-rustdoc
Corey Richardson [Fri, 5 Dec 2014 18:07:38 +0000 (10:07 -0800)]
rollup merge of #19503: lifthrasiir/xenophobic-rustdoc

This series of commits deals with broken links to the source code. It also refactors some repetitive codes from Rustdoc. The most important commit, 1cb1f00d40f000ac7633b62a603db4fcea835ca6, describes the rationale; this will fix a half of #16289. Other commits are reasonably independent to each other and can be made into indiviudal PRs at the request.

### Notes on the broken source links

As of bda97e8557820cc4ec13645dbdf976e5ccaa0ce1 (I've used this to check the PR works as intended), there are 281 (!) such broken links. They can be further classified as follows:

* 178 links to incorrect item types. This is the first half of #16289, and this PR fixes all of them.
* 89 links to redirect pages. They are not technically "broken" but still doesn't give a source code. I have a fix for this in mind, which would make a redirect page slightly *fat*.
* 14 links to incorrect `DefId` in the `gotosrc` parameter. This is #15309, and affects many `liballoc` reexports in `libstd` but *nothing else* (curiously). I'm yet to track this down; might be a metadata bug (not sure).
* 0 links to the crate reexported as a different name. This is the second half of #16289, and seems not hard to fix but I'm running out of time.

Prevalence of this kind of bugs calls for a full link verifier integrated into the testing process. :S

9 years agorollup merge of #19494: P1start/better-expected
Corey Richardson [Fri, 5 Dec 2014 18:07:36 +0000 (10:07 -0800)]
rollup merge of #19494: P1start/better-expected

As an example of what this changes, the following code:

```rust
let x: [int ..4];
```

Currently spits out ‘expected `]`, found `..`’. However, a comma would also be valid there, as would a number of other tokens. This change adjusts the parser to produce more accurate errors, so that that example now produces ‘expected one of `(`, `+`, `,`, `::`, or `]`, found `..`’.

(Thanks to cramer on IRC for pointing out this problem with diagnostics.)

9 years agorollup merge of #19492: steveklabnik/remove_outdated_comment
Corey Richardson [Fri, 5 Dec 2014 18:07:34 +0000 (10:07 -0800)]
rollup merge of #19492: steveklabnik/remove_outdated_comment

https://github.com/rust-lang/rust/pull/19472#issuecomment-65370278

/cc @alexcrichton

9 years agorollup merge of #19491: oli-obk/libtest_tojson_dependency
Corey Richardson [Fri, 5 Dec 2014 18:07:31 +0000 (10:07 -0800)]
rollup merge of #19491: oli-obk/libtest_tojson_dependency

deriving encodable + using json::PrettyEncoder removes the only ToJson trait implementation in the rust repository outside of libserialize

@pcwalton does this agree with your FIXME comment?

9 years agorollup merge of #19483: cgaebel/copy_memory-comment
Corey Richardson [Fri, 5 Dec 2014 18:07:23 +0000 (10:07 -0800)]
rollup merge of #19483: cgaebel/copy_memory-comment

9 years agorollup merge of #19480: cmr/es6-escape
Corey Richardson [Fri, 5 Dec 2014 18:07:18 +0000 (10:07 -0800)]
rollup merge of #19480: cmr/es6-escape

First half of bootstrapping https://github.com/rust-lang/rfcs/pull/446

9 years agorollup merge of #19474: luqmana/fl
Corey Richardson [Fri, 5 Dec 2014 18:07:11 +0000 (10:07 -0800)]
rollup merge of #19474: luqmana/fl

Fixes #19339.

9 years agorollup merge of #19472: nick29581/iflet
Corey Richardson [Fri, 5 Dec 2014 18:07:10 +0000 (10:07 -0800)]
rollup merge of #19472: nick29581/iflet

Closes #19469

r?

9 years agorollup merge of #19468: victorvde/master
Corey Richardson [Fri, 5 Dec 2014 18:07:07 +0000 (10:07 -0800)]
rollup merge of #19468: victorvde/master

1. Made small improvements to the docs for checked_sub, checked_mul and checked_div.
2. Updated a confusingly outdated comment for intrinsics, noticed before at <https://stackoverflow.com/questions/23582931/>.

9 years agorollup merge of #19462: MatejLach/but-and_guide
Corey Richardson [Fri, 5 Dec 2014 18:07:04 +0000 (10:07 -0800)]
rollup merge of #19462: MatejLach/but-and_guide

Using `and` here instead of `but` sounds better to me, as but makes it sound like an item which is still under active development shouldn't normally require more testing, but this one does - or something like that :-)
@steveklabnik?

9 years agorollup merge of #19458: MatejLach/guess_style_fix_guide
Corey Richardson [Fri, 5 Dec 2014 18:07:03 +0000 (10:07 -0800)]
rollup merge of #19458: MatejLach/guess_style_fix_guide

I think that this wording makes it more clear as to what we're doing here.
Opinions @steveklabnik ?

9 years agorollup merge of #19454: nodakai/libstd-reap-failed-child
Corey Richardson [Fri, 5 Dec 2014 18:07:02 +0000 (10:07 -0800)]
rollup merge of #19454: nodakai/libstd-reap-failed-child

After the library successfully called `fork(2)`, the child does several
setup works such as setting UID, GID and current directory before it
calls `exec(2)`.  When those setup works failed, the child exits but the
parent didn't call `waitpid(2)` and left it as a zombie.

This patch also add several sanity checks.  They shouldn't make any
noticeable impact to runtime performance.

The new test case in `libstd/io/process.rs` calls the ps command to check
if the new code can really reap a zombie.
The output of `ps -A -o pid,sid,command` should look like this:

```
  PID   SID COMMAND
    1     1 /sbin/init
    2     0 [kthreadd]
    3     0 [ksoftirqd/0]
...
12562  9237 ./spawn-failure
12563  9237 [spawn-failure] <defunct>
12564  9237 [spawn-failure] <defunct>
...
12592  9237 [spawn-failure] <defunct>
12593  9237 ps -A -o pid,sid,command
12884 12884 /bin/zsh
12922 12922 /bin/zsh
...
```

where `./spawn-failure` is my test program which intentionally leaves many
zombies.  Filtering the output with the "SID" (session ID) column is
a quick way to tell if a process (zombie) was spawned by my own test
program.  Then the number of "defunct" lines is the number of zombie
children.

9 years agorollup merge of #19453: pshc/rustdoc-check-a-href
Corey Richardson [Fri, 5 Dec 2014 18:06:58 +0000 (10:06 -0800)]
rollup merge of #19453: pshc/rustdoc-check-a-href

Fixes the JS error in #18354 at least. I don't know if there's a more underlying issue that needs addressing.

9 years agorollup merge of #19422: scialex/fix-fmt-macro-doc
Corey Richardson [Fri, 5 Dec 2014 18:06:55 +0000 (10:06 -0800)]
rollup merge of #19422: scialex/fix-fmt-macro-doc

these are missing standard #![doc(...)]. add them

9 years agorollup merge of #19416: sfackler/global-stdin
Corey Richardson [Fri, 5 Dec 2014 18:06:52 +0000 (10:06 -0800)]
rollup merge of #19416: sfackler/global-stdin

io::stdin returns a new `BufferedReader` each time it's called, which
results in some very confusing behavior with disappearing output. It now
returns a `StdinReader`, which wraps a global singleton
`Arc<Mutex<BufferedReader<StdReader>>`. `Reader` is implemented directly
on `StdinReader`. However, `Buffer` is not, as the `fill_buf` method is
fundamentaly un-thread safe. A `lock` method is defined on `StdinReader`
which returns a smart pointer wrapping the underlying `BufferedReader`
while guaranteeing mutual exclusion.

Code that treats the return value of io::stdin as implementing `Buffer`
will break. Add a call to `lock`:

```rust
io::stdin().read_line();
// =>
io::stdin().lock().read_line();
```

Closes #14434

[breaking-change]

9 years agorollup merge of #19413: P1start/more-trailing-commas
Corey Richardson [Fri, 5 Dec 2014 18:06:50 +0000 (10:06 -0800)]
rollup merge of #19413: P1start/more-trailing-commas

The only other place I know of that doesn’t allow trailing commas is closure types (#19414), and those are a bit tricky to fix (I suspect it might be impossible without infinite lookahead) so I didn’t implement that in this patch. There are other issues surrounding closure type parsing anyway, in particular #19410.

9 years agorollup merge of #19396: kulakowski/patch-1
Corey Richardson [Fri, 5 Dec 2014 18:06:45 +0000 (10:06 -0800)]
rollup merge of #19396: kulakowski/patch-1

9 years agorollup merge of #19387: jauhien/fix-expand_quote_ty
Corey Richardson [Fri, 5 Dec 2014 18:06:44 +0000 (10:06 -0800)]
rollup merge of #19387: jauhien/fix-expand_quote_ty

Subj., expand_quote_ty produces wrong call to parse_ty now.

9 years agorollup merge of #19386: tbu-/pr_refcell_stuff
Corey Richardson [Fri, 5 Dec 2014 18:06:43 +0000 (10:06 -0800)]
rollup merge of #19386: tbu-/pr_refcell_stuff

9 years agorollup merge of #19364: steveklabnik/doc_buffered_reader
Corey Richardson [Fri, 5 Dec 2014 18:06:42 +0000 (10:06 -0800)]
rollup merge of #19364: steveklabnik/doc_buffered_reader

We don't need this &mut, and vec could use []s

9 years agorollup merge of #19359: japaric/clone-cow
Corey Richardson [Fri, 5 Dec 2014 18:06:41 +0000 (10:06 -0800)]
rollup merge of #19359: japaric/clone-cow

Now we can use `#[deriving(Clone)]` on structs that contain `Cow`.

r? @aturon or anyone else

9 years agorollup merge of #19274: alexcrichton/rewrite-sync
Corey Richardson [Fri, 5 Dec 2014 18:06:39 +0000 (10:06 -0800)]
rollup merge of #19274: alexcrichton/rewrite-sync

This commit is a reimplementation of `std::sync` to be based on the
system-provided primitives wherever possible. The previous implementation was
fundamentally built on top of channels, and as part of the runtime reform it has
become clear that this is not the level of abstraction that the standard level
should be providing. This rewrite aims to provide as thin of a shim as possible
on top of the system primitives in order to make them safe.

The overall interface of the `std::sync` module has in general not changed, but
there are a few important distinctions, highlighted below:

* The condition variable type, `Condvar`, has been separated out of a `Mutex`.
  A condition variable is now an entirely separate type. This separation
  benefits users who only use one mutex, and provides a clearer distinction of
  who's responsible for managing condition variables (the application).

* All of `Condvar`, `Mutex`, and `RWLock` are now directly built on top of
  system primitives rather than using a custom implementation. The `Once`,
  `Barrier`, and `Semaphore` types are still built upon these abstractions of
  the system primitives.

* The `Condvar`, `Mutex`, and `RWLock` types all have a new static type and
  constant initializer corresponding to them. These are provided primarily for C
  FFI interoperation, but are often useful to otherwise simply have a global
  lock. The types, however, will leak memory unless `destroy()` is called on
  them, which is clearly documented.

* The fundamental architecture of this design is to provide two separate layers.
  The first layer is that exposed by `sys_common` which is a cross-platform
  bare-metal abstraction of the system synchronization primitives. No attempt is
  made at making this layer safe, and it is quite unsafe to use! It is currently
  not exported as part of the API of the standard library, but the stabilization
  of the `sys` module will ensure that these will be exposed in time. The
  purpose of this layer is to provide the core cross-platform abstractions if
  necessary to implementors.

  The second layer is the layer provided by `std::sync` which is intended to be
  the thinnest possible layer on top of `sys_common` which is entirely safe to
  use. There are a few concerns which need to be addressed when making these
  system primitives safe:

    * Once used, the OS primitives can never be **moved**. This means that they
      essentially need to have a stable address. The static primitives use
      `&'static self` to enforce this, and the non-static primitives all use a
      `Box` to provide this guarantee.

    * Poisoning is leveraged to ensure that invalid data is not accessible from
      other tasks after one has panicked.

  In addition to these overall blanket safety limitations, each primitive has a
  few restrictions of its own:

    * Mutexes and rwlocks can only be unlocked from the same thread that they
      were locked by. This is achieved through RAII lock guards which cannot be
      sent across threads.

    * Mutexes and rwlocks can only be unlocked if they were previously locked.
      This is achieved by not exposing an unlocking method.

    * A condition variable can only be waited on with a locked mutex. This is
      achieved by requiring a `MutexGuard` in the `wait()` method.

    * A condition variable cannot be used concurrently with more than one mutex.
      This is guaranteed by dynamically binding a condition variable to
      precisely one mutex for its entire lifecycle. This restriction may be able
      to be relaxed in the future (a mutex is unbound when no threads are
      waiting on the condvar), but for now it is sufficient to guarantee safety.

* Condvars support timeouts for their blocking operations. The
  implementation for these operations is provided by the system.

Due to the modification of the `Condvar` API, removal of the `std::sync::mutex`
API, and reimplementation, this is a breaking change. Most code should be fairly
easy to port using the examples in the documentation of these primitives.

[breaking-change]

Closes #17094
Closes #18003

9 years agostd: change BufWriter to return ShortWrite/EndOfFile
Erick Tryzelaar [Fri, 5 Dec 2014 17:42:48 +0000 (09:42 -0800)]
std: change BufWriter to return ShortWrite/EndOfFile

9 years agoauto merge of #19233 : erickt/rust/bench-stats, r=erickt
bors [Fri, 5 Dec 2014 17:33:00 +0000 (17:33 +0000)]
auto merge of #19233 : erickt/rust/bench-stats, r=erickt

There are a bunch stats that libtest keeps track of that we don't expose. This adds `--error-bar` and `--stats` to expose this to the users.

9 years agoFall out of the std::sync rewrite
Alex Crichton [Mon, 24 Nov 2014 19:16:40 +0000 (11:16 -0800)]
Fall out of the std::sync rewrite

9 years agotest: expose boxplot and the extra stats test keeps track of
Erick Tryzelaar [Fri, 5 Dec 2014 17:04:55 +0000 (09:04 -0800)]
test: expose boxplot and the extra stats test keeps track of

[breaking-change]

9 years agoauto merge of #19334 : alexcrichton/rust/issue-19333, r=aturon
bors [Fri, 5 Dec 2014 15:03:18 +0000 (15:03 +0000)]
auto merge of #19334 : alexcrichton/rust/issue-19333, r=aturon

This may have inadvertently switched during the runtime overhaul, so this
switches TcpListener back to using sockets instead of file descriptors. This
also renames a bunch of variables called `fd` to `socket` to clearly show that
it's not a file descriptor.

Closes #19333

9 years agoauto merge of #19362 : nikomatsakis/rust/crateification, r=nikomatsakis
bors [Fri, 5 Dec 2014 09:23:09 +0000 (09:23 +0000)]
auto merge of #19362 : nikomatsakis/rust/crateification, r=nikomatsakis

This has the goal of further reducing peak memory usage and enabling more parallelism. This patch should allow trans/typeck to build in parallel. The plan is to proceed by moving as many additional passes as possible into distinct crates that lay alongside typeck/trans. Basically, the idea is that there is the `rustc` crate which defines the common data structures shared between passes. Individual passes then go into their own crates. Finally, the `rustc_driver` crate knits it all together.

cc @jakub-: One wrinkle is the diagnostics plugin. Currently, it assumes all diagnostics are defined and used within one crate in order to track what is used and what is duplicated. I had to disable this. We'll have to find an alternate strategy, but I wasn't sure what was best so decided to just disable the duplicate checking for now.

9 years agostd: Rewrite the `sync` module
Alex Crichton [Mon, 24 Nov 2014 19:16:40 +0000 (11:16 -0800)]
std: Rewrite the `sync` module

This commit is a reimplementation of `std::sync` to be based on the
system-provided primitives wherever possible. The previous implementation was
fundamentally built on top of channels, and as part of the runtime reform it has
become clear that this is not the level of abstraction that the standard level
should be providing. This rewrite aims to provide as thin of a shim as possible
on top of the system primitives in order to make them safe.

The overall interface of the `std::sync` module has in general not changed, but
there are a few important distinctions, highlighted below:

* The condition variable type, `Condvar`, has been separated out of a `Mutex`.
  A condition variable is now an entirely separate type. This separation
  benefits users who only use one mutex, and provides a clearer distinction of
  who's responsible for managing condition variables (the application).

* All of `Condvar`, `Mutex`, and `RWLock` are now directly built on top of
  system primitives rather than using a custom implementation. The `Once`,
  `Barrier`, and `Semaphore` types are still built upon these abstractions of
  the system primitives.

* The `Condvar`, `Mutex`, and `RWLock` types all have a new static type and
  constant initializer corresponding to them. These are provided primarily for C
  FFI interoperation, but are often useful to otherwise simply have a global
  lock. The types, however, will leak memory unless `destroy()` is called on
  them, which is clearly documented.

* The `Condvar` implementation for an `RWLock` write lock has been removed. This
  may be added back in the future with a userspace implementation, but this
  commit is focused on exposing the system primitives first.

* The fundamental architecture of this design is to provide two separate layers.
  The first layer is that exposed by `sys_common` which is a cross-platform
  bare-metal abstraction of the system synchronization primitives. No attempt is
  made at making this layer safe, and it is quite unsafe to use! It is currently
  not exported as part of the API of the standard library, but the stabilization
  of the `sys` module will ensure that these will be exposed in time. The
  purpose of this layer is to provide the core cross-platform abstractions if
  necessary to implementors.

  The second layer is the layer provided by `std::sync` which is intended to be
  the thinnest possible layer on top of `sys_common` which is entirely safe to
  use. There are a few concerns which need to be addressed when making these
  system primitives safe:

    * Once used, the OS primitives can never be **moved**. This means that they
      essentially need to have a stable address. The static primitives use
      `&'static self` to enforce this, and the non-static primitives all use a
      `Box` to provide this guarantee.

    * Poisoning is leveraged to ensure that invalid data is not accessible from
      other tasks after one has panicked.

  In addition to these overall blanket safety limitations, each primitive has a
  few restrictions of its own:

    * Mutexes and rwlocks can only be unlocked from the same thread that they
      were locked by. This is achieved through RAII lock guards which cannot be
      sent across threads.

    * Mutexes and rwlocks can only be unlocked if they were previously locked.
      This is achieved by not exposing an unlocking method.

    * A condition variable can only be waited on with a locked mutex. This is
      achieved by requiring a `MutexGuard` in the `wait()` method.

    * A condition variable cannot be used concurrently with more than one mutex.
      This is guaranteed by dynamically binding a condition variable to
      precisely one mutex for its entire lifecycle. This restriction may be able
      to be relaxed in the future (a mutex is unbound when no threads are
      waiting on the condvar), but for now it is sufficient to guarantee safety.

* Condvars now support timeouts for their blocking operations. The
  implementation for these operations is provided by the system.

Due to the modification of the `Condvar` API, removal of the `std::sync::mutex`
API, and reimplementation, this is a breaking change. Most code should be fairly
easy to port using the examples in the documentation of these primitives.

[breaking-change]

Closes #17094
Closes #18003

9 years agostd: Close TcpListener with closesocket()
Alex Crichton [Wed, 26 Nov 2014 05:53:08 +0000 (21:53 -0800)]
std: Close TcpListener with closesocket()

This may have inadvertently switched during the runtime overhaul, so this
switches TcpListener back to using sockets instead of file descriptors. This
also renames a bunch of variables called `fd` to `socket` to clearly show that
it's not a file descriptor.

Closes #19333

9 years agoRemove crates from test list so that we don't waste time building them.
Niko Matsakis [Fri, 5 Dec 2014 07:01:57 +0000 (02:01 -0500)]
Remove crates from test list so that we don't waste time building them.

9 years agoFix various references in late-running tests and things
Niko Matsakis [Fri, 5 Dec 2014 05:00:06 +0000 (00:00 -0500)]
Fix various references in late-running tests and things

9 years agoMake missing_doc lint check typedefs
Steven Fackler [Fri, 5 Dec 2014 04:20:09 +0000 (20:20 -0800)]
Make missing_doc lint check typedefs

Closes #19543

9 years agolibstd/sys/unix/process.rs: reap a zombie who didn't get through to exec(2).
NODA, Kai [Thu, 4 Dec 2014 18:05:57 +0000 (02:05 +0800)]
libstd/sys/unix/process.rs: reap a zombie who didn't get through to exec(2).

After the library successfully called fork(2), the child does several
setup works such as setting UID, GID and current directory before it
calls exec(2).  When those setup works failed, the child exits but the
parent didn't call waitpid(2) and left it as a zombie.

This patch also add several sanity checks.  They shouldn't make any
noticeable impact to runtime performance.

The new test case run-pass/wait-forked-but-failed-child.rs calls the ps
command to check if the new code can really reap a zombie.  When
I intentionally create many zombies with my test program
./spawn-failure, The output of "ps -A -o pid,sid,command" should look
like this:

  PID   SID COMMAND
    1     1 /sbin/init
    2     0 [kthreadd]
    3     0 [ksoftirqd/0]
...
12562  9237 ./spawn-failure
12563  9237 [spawn-failure] <defunct>
12564  9237 [spawn-failure] <defunct>
...
12592  9237 [spawn-failure] <defunct>
12593  9237 ps -A -o pid,sid,command
12884 12884 /bin/zsh
12922 12922 /bin/zsh
...

Filtering the output with the "SID" (session ID) column is a quick way
to tell if a process (zombie) was spawned by my own test program.  Then
the number of "defunct" lines is the number of zombie children.

Signed-off-by: NODA, Kai <nodakai@gmail.com>
9 years agoauto merge of #19303 : nodakai/rust/libsyntax-reject-dirs, r=alexcrichton
bors [Fri, 5 Dec 2014 00:22:58 +0000 (00:22 +0000)]
auto merge of #19303 : nodakai/rust/libsyntax-reject-dirs, r=alexcrichton

On *BSD systems, we can `open(2)` a directory and directly `read(2)` from it due to an old tradition.  We should avoid doing so by explicitly calling `fstat(2)` to check the type of the opened file.

Opening a directory as a module file can't always be avoided.  Even when there's no "path" attribute trick involved, there can always be a *directory* named `my_module.rs`.

Incidentally, remove unnecessary mutability of `&self` from `io::fs::File::stat()`.

9 years agoImplement BitOps for TrieSet
Chase Southwood [Thu, 4 Dec 2014 06:35:38 +0000 (00:35 -0600)]
Implement BitOps for TrieSet

9 years agoDelete diagnostics tests because that model doesn't scale to multiple crates
Niko Matsakis [Thu, 4 Dec 2014 21:34:13 +0000 (16:34 -0500)]
Delete diagnostics tests because that model doesn't scale to multiple crates

9 years agoauto merge of #18980 : erickt/rust/reader, r=erickt
bors [Thu, 4 Dec 2014 21:33:07 +0000 (21:33 +0000)]
auto merge of #18980 : erickt/rust/reader, r=erickt

This continues the work @thestinger started in #18885 (which hasn't landed yet, so wait for that to land before landing this one). Instead of adding more methods to `BufReader`, this just allows a `&[u8]` to be used directly as a `Reader`. It also adds an impl of `Writer` for `&mut [u8]`.

9 years agoAdd ability to use custom alloc::heap::imp
Alexander Light [Thu, 4 Dec 2014 20:02:59 +0000 (15:02 -0500)]
Add ability to use custom alloc::heap::imp

Adds the ability to use a custom allocator heap by passing either --cfg
external_crate and --extern external=<allocator_crate_name> or --cfg
external_funcs and defining the allocator functions prefixed by 'rust_'
somewhere.

This is useful for many reasons including OS/embedded development, and
allocator development and testing.

9 years agoRemove reduntant compile-fail test
Adolfo Ochagavía [Thu, 4 Dec 2014 19:56:44 +0000 (20:56 +0100)]
Remove reduntant compile-fail test

Fixes https://github.com/rust-lang/rust/issues/19510

9 years agoAdd capacity() to VecMap
Aaron Liblong [Thu, 4 Dec 2014 17:14:06 +0000 (12:14 -0500)]
Add capacity() to VecMap

Changed capacity() tag to unstable and fixed doc assert

9 years agoTasks aren't actually lightweight :frown:
Steve Klabnik [Thu, 4 Dec 2014 16:43:22 +0000 (11:43 -0500)]
Tasks aren't actually lightweight :frown:

Fixes #19402.

9 years agoSome small copy edits to the guide.
Steve Klabnik [Thu, 4 Dec 2014 16:36:08 +0000 (11:36 -0500)]
Some small copy edits to the guide.

Fixes #19335.

9 years agocore: fix a doctest
Erick Tryzelaar [Thu, 4 Dec 2014 15:57:13 +0000 (07:57 -0800)]
core: fix a doctest

9 years agoFIXME(#19497) -- Stop messing around and just give rustc 32MB of stack unconditionall...
Niko Matsakis [Wed, 3 Dec 2014 13:33:45 +0000 (08:33 -0500)]
FIXME(#19497) -- Stop messing around and just give rustc 32MB of stack unconditionally. This is prompted by some sort of bug in trans that causes a stack overflow when the modules in trans are made private. (In particular, the overflow can also be avoided by making `controlflow` and `callee` public, but that seems strictly worse than just using more stack.)

9 years agoSeparate the driver into its own crate that uses trans, typeck.
Niko Matsakis [Thu, 27 Nov 2014 14:57:47 +0000 (09:57 -0500)]
Separate the driver into its own crate that uses trans, typeck.

9 years agoMove typeck into its own crate.
Niko Matsakis [Wed, 26 Nov 2014 11:11:29 +0000 (06:11 -0500)]
Move typeck into its own crate.

9 years agoRemove dependencies on driver from trans et al. by moving various
Niko Matsakis [Thu, 27 Nov 2014 12:21:26 +0000 (07:21 -0500)]
Remove dependencies on driver from trans et al. by moving various
structs out from driver and into other places.

9 years agoModify libsyntax/diagnostics to not be so persnickety. The scheme
Niko Matsakis [Thu, 27 Nov 2014 01:49:36 +0000 (20:49 -0500)]
Modify libsyntax/diagnostics to not be so persnickety. The scheme
doesn't work in a multi-crate context. We'll need to come up with
something better.

9 years agoMove `typeck` logically in the module tree out to the root and clamp
Niko Matsakis [Wed, 26 Nov 2014 10:48:57 +0000 (05:48 -0500)]
Move `typeck` logically in the module tree out to the root and clamp
down on its exports. Remove some dead code that is revealed.

9 years agoRemove one dependence on typeck from const_eval.
Niko Matsakis [Wed, 26 Nov 2014 09:52:02 +0000 (04:52 -0500)]
Remove one dependence on typeck from const_eval.

9 years agoRemove "dependence" on typeck from comment in substs.
Niko Matsakis [Wed, 26 Nov 2014 01:16:28 +0000 (20:16 -0500)]
Remove "dependence" on typeck from comment in substs.

9 years agoRemove dependence on typeck from ppaux.
Niko Matsakis [Wed, 26 Nov 2014 01:15:58 +0000 (20:15 -0500)]
Remove dependence on typeck from ppaux.

9 years agoRemove dependency on typeck from lint.
Niko Matsakis [Wed, 26 Nov 2014 00:48:49 +0000 (19:48 -0500)]
Remove dependency on typeck from lint.

9 years agoMove infer out of `middle::typeck` and into just `middle`.
Niko Matsakis [Tue, 25 Nov 2014 21:59:02 +0000 (16:59 -0500)]
Move infer out of `middle::typeck` and into just `middle`.

9 years agoMove various data structures out of typeck and into ty.
Niko Matsakis [Tue, 25 Nov 2014 19:21:20 +0000 (14:21 -0500)]
Move various data structures out of typeck and into ty.

9 years agoauto merge of #19170 : erickt/rust/rustup, r=erickt
bors [Thu, 4 Dec 2014 15:03:39 +0000 (15:03 +0000)]
auto merge of #19170 : erickt/rust/rustup, r=erickt

This closes #19168.

Please be careful reviewing this since this gets used all over the place. I've tested all the options and everything appears to be working though.

9 years agoHandle conflicting import of items declared in the same module
Mukilan Thiyagarajan [Thu, 4 Dec 2014 13:21:44 +0000 (18:51 +0530)]
Handle conflicting import of items declared in the same module

Fixes #19498

9 years agoauto merge of #19167 : japaric/rust/rhs-cmp, r=aturon
bors [Thu, 4 Dec 2014 12:02:56 +0000 (12:02 +0000)]
auto merge of #19167 : japaric/rust/rhs-cmp, r=aturon

Comparison traits have gained an `Rhs` input parameter that defaults to `Self`. And now the comparison operators can be overloaded to work between different types. In particular, this PR allows the following operations (and their commutative versions):

- `&str` == `String` == `CowString`
- `&[A]` == `&mut [B]` == `Vec<C>` == `CowVec<D>` == `[E, ..N]` (for `N` up to 32)
- `&mut A` == `&B` (for `Sized` `A` and `B`)

Where `A`, `B`, `C`, `D`, `E` may be different types that implement `PartialEq`. For example, these comparisons are now valid: `string == "foo"`, and `vec_of_strings == ["Hello", "world"]`.

[breaking-change]s

Since the `==` may now work on different types, operations that relied on the old "same type restriction" to drive type inference, will need to be type annotated. These are the most common fallout cases:

- `some_vec == some_iter.collect()`: `collect` needs to be type annotated: `collect::<Vec<_>>()`
- `slice == &[a, b, c]`: RHS doesn't get coerced to an slice, use an array instead `[a, b, c]`
- `lhs == []`: Change expression to `lhs.is_empty()`
- `lhs == some_generic_function()`: Type annotate the RHS as necessary

cc #19148

r? @aturon

9 years agocore::iter::Unfold: reword docs and add example
Austin Bonander [Thu, 4 Dec 2014 00:31:21 +0000 (16:31 -0800)]
core::iter::Unfold: reword docs and add example

Remove note about core

9 years ago`DerefMut` should be `for Sized?`
Chase Southwood [Thu, 4 Dec 2014 09:10:58 +0000 (03:10 -0600)]
`DerefMut` should be `for Sized?`

9 years agoauto merge of #19449 : nikomatsakis/rust/unboxed-closure-fn-impl, r=pcwalton
bors [Thu, 4 Dec 2014 08:52:47 +0000 (08:52 +0000)]
auto merge of #19449 : nikomatsakis/rust/unboxed-closure-fn-impl, r=pcwalton

Implement the `Fn` trait for bare fn pointers in the compiler rather
than doing it using hard-coded impls. This means that it works also
for more complex fn types involving bound regions.

9 years agoBack io::stdin with a global singleton BufferedReader
Steven Fackler [Sun, 30 Nov 2014 07:07:43 +0000 (23:07 -0800)]
Back io::stdin with a global singleton BufferedReader

io::stdin returns a new `BufferedReader` each time it's called, which
results in some very confusing behavior with disappearing output. It now
returns a `StdinReader`, which wraps a global singleton
`Arc<Mutex<BufferedReader<StdReader>>`. `Reader` is implemented directly
on `StdinReader`. However, `Buffer` is not, as the `fill_buf` method is
fundamentaly un-thread safe. A `lock` method is defined on `StdinReader`
which returns a smart pointer wrapping the underlying `BufferedReader`
while guaranteeing mutual exclusion.

Code that treats the return value of io::stdin as implementing `Buffer`
will break. Add a call to `lock`:

```rust
io::stdin().lines()
// =>
io::stdin().lock().lines()
```

Closes #14434

[breaking-change]

9 years agoAdjust nits from pcwalton.
Niko Matsakis [Thu, 4 Dec 2014 05:57:38 +0000 (00:57 -0500)]
Adjust nits from pcwalton.

9 years agoAdd a cache so we don't create so many shims.
Niko Matsakis [Thu, 4 Dec 2014 01:23:15 +0000 (20:23 -0500)]
Add a cache so we don't create so many shims.

9 years agoImplement the `Fn` trait for bare fn pointers in the compiler rather than doing it...
Niko Matsakis [Mon, 1 Dec 2014 14:23:40 +0000 (09:23 -0500)]
Implement the `Fn` trait for bare fn pointers in the compiler rather than doing it using hard-coded impls. This means that it works also for more complex fn types involving bound regions. Fixes #19126.

9 years agoauto merge of #18613 : steveklabnik/rust/ownership_guide, r=huonw
bors [Thu, 4 Dec 2014 04:52:37 +0000 (04:52 +0000)]
auto merge of #18613 : steveklabnik/rust/ownership_guide, r=huonw

This is a work in progress, but this should get *extensive* review, so I'm putting it up early and often.

This is the start of a draft of the new 'ownership guide,' which explains ownership, borrowing, etc. I'm feeling better about this framing than last time's, but we'll see.

9 years agorustdoc: Do not deduplicate items when their parents differ.
Kang Seonghoon [Thu, 4 Dec 2014 04:52:23 +0000 (13:52 +0900)]
rustdoc: Do not deduplicate items when their parents differ.

Fixes #17332.

9 years agorustdoc: Preserve query/fragment in redirects whenever possible.
Kang Seonghoon [Thu, 4 Dec 2014 03:48:16 +0000 (12:48 +0900)]
rustdoc: Preserve query/fragment in redirects whenever possible.

We heavily rely on queries and fragments in the URL structure, so
it is desired to preserve them even in the redirects. The generated
redirect pages try to preserve them with scripts, which take
precedence over the original `Refresh` metadata. Non-scripting
browsers would continue to work (with no queries and fragments).

9 years agolibstd: explicitly disallow io::fs::File to open a directory.
NODA, Kai [Tue, 2 Dec 2014 22:06:59 +0000 (06:06 +0800)]
libstd: explicitly disallow io::fs::File to open a directory.

On *BSD systems, we can open(2) a directory and directly read(2) from
it due to an old tradition.  We should avoid doing so by explicitly
calling fstat(2) to check the type of the opened file.

Opening a directory as a module file can't always be avoided.
Even when there's no "path" attribute trick involved, there can always
be a *directory* named "my_module.rs".

Fix #12460

Signed-off-by: NODA, Kai <nodakai@gmail.com>
9 years agolibstd: io::fs::File::stat() need not to take &mut self.
NODA, Kai [Tue, 25 Nov 2014 14:12:24 +0000 (22:12 +0800)]
libstd: io::fs::File::stat() need not to take &mut self.

The same goes for sys::fs::FileDesc::fstat() on Windows.

Signed-off-by: NODA, Kai <nodakai@gmail.com>