]> git.lizzy.rs Git - rust.git/log
rust.git
9 years agolibflate: remove unnecessary `as_slice()` calls
Jorge Aparicio [Thu, 27 Nov 2014 18:14:37 +0000 (13:14 -0500)]
libflate: remove unnecessary `as_slice()` calls

9 years agolibcoretest: remove unnecessary `as_slice()` calls
Jorge Aparicio [Thu, 27 Nov 2014 18:12:30 +0000 (13:12 -0500)]
libcoretest: remove unnecessary `as_slice()` calls

9 years agoliballoc: remove unnecessary `as_slice()` calls
Jorge Aparicio [Thu, 27 Nov 2014 18:03:07 +0000 (13:03 -0500)]
liballoc: remove unnecessary `as_slice()` calls

9 years agolibcollections: remove unnecessary `as_slice()` calls
Jorge Aparicio [Thu, 27 Nov 2014 16:45:50 +0000 (11:45 -0500)]
libcollections: remove unnecessary `as_slice()` calls

9 years agoAdd missing semicolon to hello world program in intro.
jbranchaud [Sat, 6 Dec 2014 23:36:32 +0000 (17:36 -0600)]
Add missing semicolon to hello world program in intro.

9 years agoChange from message to expected
Steven Fackler [Sat, 6 Dec 2014 23:16:38 +0000 (15:16 -0800)]
Change from message to expected

9 years agoAllow message specification for should_fail
Steven Fackler [Fri, 5 Dec 2014 07:02:36 +0000 (23:02 -0800)]
Allow message specification for should_fail

The test harness will make sure that the panic message contains the
specified string. This is useful to help make `#[should_fail]` tests a
bit less brittle by decreasing the chance that the test isn't
"accidentally" passing due to a panic occurring earlier than expected.
The behavior is in some ways similar to JUnit's `expected` feature:
`@Test(expected=NullPointerException.class)`.

Without the message assertion, this test would pass even though it's not
actually reaching the intended part of the code:
```rust
 #[test]
 #[should_fail(message = "out of bounds")]
fn test_oob_array_access() {
    let idx: uint = from_str("13o").unwrap(); // oops, this will panic
    [1i32, 2, 3][idx];
}
```

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 agoFix false positive alerts from a run-pass test on Command.
NODA, Kai [Sat, 6 Dec 2014 23:05:13 +0000 (07:05 +0800)]
Fix false positive alerts from a run-pass test on Command.

Reported as a part of rust-lang/rust#19120

The logic of rust-lang/rust@74fb798a200dc82cf5b4a18065e3ea565229adc3 was
flawed because when a CI tool run the test parallely with other tasks,
they all belong to a single session family and the test may pick up
irrelevant zombie processes before they are reaped by the CI tool
depending on timing.

Also, panic! inside a loop over all children makes the logic simpler.

By not destructing the return values of Command::spawn() until
find_zombies() finishes, I believe we can conduct a slightly stricter
test.

Signed-off-by: NODA, Kai <nodakai@gmail.com>
9 years ago- Support gcc-less installation on Windows. To do so in unattended mode run:`<intall...
Vadim Chugunov [Sat, 6 Dec 2014 09:32:57 +0000 (01:32 -0800)]
- Support gcc-less installation on Windows.  To do so in unattended mode run:`<intaller>.exe /TYPE=compact /SILENT`.
- Do not require admin privileges to install.

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 agoAdd a doctest for BTreeMap's iter method.
jbranchaud [Sat, 6 Dec 2014 05:50:13 +0000 (23:50 -0600)]
Add a doctest for BTreeMap's iter method.

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 agoImplement lifetime elision for Foo(...) -> ... type sugar.
Huon Wilson [Sat, 6 Dec 2014 03:01:07 +0000 (19:01 -0800)]
Implement lifetime elision for Foo(...) -> ... type sugar.

This means that `Fn(&A) -> (&B, &C)` is equivalent to `for<'a> Fn(&'a A)
-> (&'a B, &'a C)` similar to the lifetime elision of lower-case `fn` in
types and declarations.

Closes #18992.

9 years agoFeature-gate explicit unboxed closure method calls & manual impls,
Huon Wilson [Fri, 5 Dec 2014 23:53:30 +0000 (15:53 -0800)]
Feature-gate explicit unboxed closure method calls & manual impls,
detect UFCS drop and allow UFCS methods to have explicit type parameters.

Work towards #18875.

Since code could previously call the methods & implement the traits
manually, this is a

[breaking-change]

Closes #19586. Closes #19375.

9 years agoTypo
mdinger [Sat, 6 Dec 2014 01:14:28 +0000 (20:14 -0500)]
Typo

9 years agoCorrect minor typos on the ownership guide.
Matt Windsor [Sat, 6 Dec 2014 00:30:03 +0000 (00:30 +0000)]
Correct minor typos on the ownership guide.

liftimes -> lifetimes

9 years agoImplement BitOps for TreeSet
Chase Southwood [Fri, 5 Dec 2014 07:14:43 +0000 (01:14 -0600)]
Implement BitOps for TreeSet

9 years agolibrustc: Fix debuginfo for captured variables in non-FnOnce unboxed closures.
Luqman Aden [Fri, 5 Dec 2014 23:35:16 +0000 (18:35 -0500)]
librustc: Fix debuginfo for captured variables in non-FnOnce unboxed closures.

9 years agoprefer "FIXME" to "TODO".
Aidan Cully [Fri, 5 Dec 2014 23:39:58 +0000 (18:39 -0500)]
prefer "FIXME" to "TODO".

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 agowork around portability issue on FreeBSD, in which the key returned from
Aidan Cully [Fri, 5 Dec 2014 22:20:44 +0000 (17:20 -0500)]
work around portability issue on FreeBSD, in which the key returned from
pthread_key_create can be 0.

9 years agofix 404
Nafis [Fri, 5 Dec 2014 22:17:49 +0000 (08:17 +1000)]
fix 404

9 years agoAdd doctests for keys() and values() of the BTreeMap collection.
jbranchaud [Fri, 5 Dec 2014 06:10:58 +0000 (00:10 -0600)]
Add doctests for keys() and values() of the BTreeMap collection.

Update keys() and values() for BTreeMap based on @Gankro's comments.

Assign keys and values to variables before doing assertion.

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 agocollections: dramatically speed up Vec::reserve with magic
Erick Tryzelaar [Fri, 5 Dec 2014 19:29:15 +0000 (11:29 -0800)]
collections: dramatically speed up Vec::reserve with magic

Somehow llvm is able to optimize this version of Vec::reserve
into dramatically faster than the old version. In micro-benchmarks
this was 2-10 times faster. It also shaved 14 minutes off of
rust's compile times.

Closes #19281.

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 agolibrustc: Don't reuse same alloca for match on struct/tuple field which we reassign...
Luqman Aden [Fri, 5 Dec 2014 02:32:02 +0000 (21:32 -0500)]
librustc: Don't reuse same alloca for match on struct/tuple field which we reassign to in match body.

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`.