]> git.lizzy.rs Git - rust.git/log
rust.git
9 years agolibserialize: Remove float preprocessing in serialize::json::Encoder
Barosl Lee [Sun, 23 Nov 2014 17:22:30 +0000 (02:22 +0900)]
libserialize: Remove float preprocessing in serialize::json::Encoder

serialize::json::Encoder currently uses f64 to emit any integral type.
This is possibly due to the behavior of JavaScript, which uses f64 to
represent any numeric value.

This leads to a problem that only the integers in the range of [-2^53+1,
2^53-1] can be encoded. Therefore, i64 and u64 cannot be used reliably
in the current implementation.

RFC 7159 suggests that good interoperability can be achieved if the
range is respected by implementations. However, it also says that
implementations are allowed to set the range of number accepted. And it
seems that the JSON encoders outside of the JavaScript world usually
make use of i64 values.

This commit removes the float preprocessing done in the emit_* methods.
It also increases performance, because transforming f64 into String
costs more than that of an integral type.

Fixes #18319

[breaking-change]

9 years agoauto merge of #19378 : japaric/rust/no-as-slice, r=alexcrichton
bors [Mon, 8 Dec 2014 02:32:31 +0000 (02:32 +0000)]
auto merge of #19378 : japaric/rust/no-as-slice, r=alexcrichton

Now that we have an overloaded comparison (`==`) operator, and that `Vec`/`String` deref to `[T]`/`str` on method calls, many `as_slice()`/`as_mut_slice()`/`to_string()` calls have become redundant. This patch removes them. These were the most common patterns:

- `assert_eq(test_output.as_slice(), "ground truth")` -> `assert_eq(test_output, "ground truth")`
- `assert_eq(test_output, "ground truth".to_string())` -> `assert_eq(test_output, "ground truth")`
- `vec.as_mut_slice().sort()` -> `vec.sort()`
- `vec.as_slice().slice(from, to)` -> `vec.slice(from_to)`

---

Note that e.g. `a_string.push_str(b_string.as_slice())` has been left untouched in this PR, since we first need to settle down whether we want to favor the `&*b_string` or the `b_string[]` notation.

This is rebased on top of #19167

cc @alexcrichton @aturon

9 years agoauto merge of #19561 : csouth3/rust/treeset-bitops, r=Gankro
bors [Mon, 8 Dec 2014 00:12:30 +0000 (00:12 +0000)]
auto merge of #19561 : csouth3/rust/treeset-bitops, r=Gankro

Implement the `BitOr`, `BitAnd`, `BitXor`, and `Sub` traits from `std::ops` for TreeSet.  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).

r? @Gankro

9 years agoauto merge of #19548 : luqmana/rust/mfb, r=nikomatsakis
bors [Sun, 7 Dec 2014 19:02:18 +0000 (19:02 +0000)]
auto merge of #19548 : luqmana/rust/mfb, r=nikomatsakis

Fixes #19367.

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 agoFix syntax error on android tests
Jorge Aparicio [Sun, 7 Dec 2014 13:49:17 +0000 (08:49 -0500)]
Fix syntax error on android tests

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 agolibtime: remove unnecessary `to_string()` calls
Jorge Aparicio [Fri, 28 Nov 2014 00:58:14 +0000 (19:58 -0500)]
libtime: remove unnecessary `to_string()` calls

9 years agolibtest: remove unnecessary `to_string()` calls
Jorge Aparicio [Fri, 28 Nov 2014 00:55:37 +0000 (19:55 -0500)]
libtest: remove unnecessary `to_string()` calls

9 years agolibterm: remove unnecessary `to_string()` calls
Jorge Aparicio [Fri, 28 Nov 2014 00:53:58 +0000 (19:53 -0500)]
libterm: remove unnecessary `to_string()` calls

9 years agolibsyntax: remove unnecessary `to_string()` calls
Jorge Aparicio [Fri, 28 Nov 2014 00:52:53 +0000 (19:52 -0500)]
libsyntax: remove unnecessary `to_string()` calls

9 years agolibstd: remove unnecessary `to_string()` calls
Jorge Aparicio [Fri, 28 Nov 2014 00:45:47 +0000 (19:45 -0500)]
libstd: remove unnecessary `to_string()` calls

9 years agolibserialize: remove unnecessary `to_string()` calls
Jorge Aparicio [Fri, 28 Nov 2014 00:36:41 +0000 (19:36 -0500)]
libserialize: remove unnecessary `to_string()` calls

9 years agolibrustc_back: remove unnecessary `to_string()` calls
Jorge Aparicio [Fri, 28 Nov 2014 00:23:53 +0000 (19:23 -0500)]
librustc_back: remove unnecessary `to_string()` calls

9 years agolibgetopts: remove unnecessary `to_string()` calls
Jorge Aparicio [Fri, 28 Nov 2014 00:18:54 +0000 (19:18 -0500)]
libgetopts: remove unnecessary `to_string()` calls

9 years agolibcollections: remove unnecessary `to_string()` calls
Jorge Aparicio [Fri, 28 Nov 2014 00:09:59 +0000 (19:09 -0500)]
libcollections: remove unnecessary `to_string()` calls

9 years agolibtest: remove unnecessary `as_mut_slice()` calls
Jorge Aparicio [Fri, 28 Nov 2014 00:00:21 +0000 (19:00 -0500)]
libtest: remove unnecessary `as_mut_slice()` calls

9 years agolibstd: remove unnecessary `as_mut_slice` calls
Jorge Aparicio [Thu, 27 Nov 2014 21:50:34 +0000 (16:50 -0500)]
libstd: remove unnecessary `as_mut_slice` calls

9 years agolibrustdoc: remove unnecessary `as_mut_slice` calls
Jorge Aparicio [Thu, 27 Nov 2014 21:49:29 +0000 (16:49 -0500)]
librustdoc: remove unnecessary `as_mut_slice` calls

9 years agolibrustc_trans: remove unnecessary `as_mut_slice` calls
Jorge Aparicio [Thu, 27 Nov 2014 21:49:02 +0000 (16:49 -0500)]
librustc_trans: remove unnecessary `as_mut_slice` calls

9 years agolibrustc: remove unnecessary `as_mut_slice` calls
Jorge Aparicio [Thu, 27 Nov 2014 21:47:48 +0000 (16:47 -0500)]
librustc: remove unnecessary `as_mut_slice` calls

9 years agolibcollections: remove unnecessary `as_mut_slice()` calls
Jorge Aparicio [Thu, 27 Nov 2014 21:44:57 +0000 (16:44 -0500)]
libcollections: remove unnecessary `as_mut_slice()` calls

9 years agolibtest: remove unnecessary `as_slice()` calls
Jorge Aparicio [Thu, 27 Nov 2014 20:06:09 +0000 (15:06 -0500)]
libtest: remove unnecessary `as_slice()` calls

9 years agolibterm: remove unnecessary `as_slice()` calls
Jorge Aparicio [Thu, 27 Nov 2014 20:03:37 +0000 (15:03 -0500)]
libterm: remove unnecessary `as_slice()` calls

9 years agolibsyntax: remove unnecessary `as_slice()` calls
Jorge Aparicio [Thu, 27 Nov 2014 20:00:50 +0000 (15:00 -0500)]
libsyntax: remove unnecessary `as_slice()` calls

9 years agolibstd: remove unnecessary `as_slice()` calls
Jorge Aparicio [Thu, 27 Nov 2014 19:43:55 +0000 (14:43 -0500)]
libstd: remove unnecessary `as_slice()` calls

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 agolibserialize: remove unnecessary `as_slice()` calls
Jorge Aparicio [Thu, 27 Nov 2014 19:28:51 +0000 (14:28 -0500)]
libserialize: remove unnecessary `as_slice()` calls

9 years agolibrustdoc: remove unnecessary `as_slice()` calls
Jorge Aparicio [Thu, 27 Nov 2014 19:19:27 +0000 (14:19 -0500)]
librustdoc: remove unnecessary `as_slice()` calls

9 years agolibrustc_trans: remove unnecessary `as_slice` calls
Jorge Aparicio [Thu, 27 Nov 2014 19:10:25 +0000 (14:10 -0500)]
librustc_trans: remove unnecessary `as_slice` calls

9 years agolibrustc_back: remove unnecessary `as_slice()` calls
Jorge Aparicio [Thu, 27 Nov 2014 18:57:31 +0000 (13:57 -0500)]
librustc_back: remove unnecessary `as_slice()` calls

9 years agolibrustc: remove unnecessary `as_slice()` calls
Jorge Aparicio [Thu, 27 Nov 2014 18:53:34 +0000 (13:53 -0500)]
librustc: remove unnecessary `as_slice()` calls

9 years agolibregex_macros: remove unnecessary `as_slice` calls
Jorge Aparicio [Thu, 27 Nov 2014 18:28:57 +0000 (13:28 -0500)]
libregex_macros: remove unnecessary `as_slice` calls

9 years agolibregex: remove unnecessary `as_slice` calls
Jorge Aparicio [Thu, 27 Nov 2014 18:27:19 +0000 (13:27 -0500)]
libregex: remove unnecessary `as_slice` calls

9 years agoliblog: remove unnecessary `as_slice` calls
Jorge Aparicio [Thu, 27 Nov 2014 18:21:31 +0000 (13:21 -0500)]
liblog: remove unnecessary `as_slice` calls

9 years agolibgraphviz: remove unnecessary `as_slice()` calls
Jorge Aparicio [Thu, 27 Nov 2014 18:19:57 +0000 (13:19 -0500)]
libgraphviz: remove unnecessary `as_slice()` calls

9 years agolibgetops: remove unnecessary `as_slice()` calls
Jorge Aparicio [Thu, 27 Nov 2014 18:18:39 +0000 (13:18 -0500)]
libgetops: remove unnecessary `as_slice()` calls

9 years agolibfmt_macros: remove unnecessary `as_slice()` calls
Jorge Aparicio [Thu, 27 Nov 2014 18:15:18 +0000 (13:15 -0500)]
libfmt_macros: remove unnecessary `as_slice()` calls

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 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 agoImplement BitOps for TreeSet
Chase Southwood [Fri, 5 Dec 2014 07:14:43 +0000 (01:14 -0600)]
Implement BitOps for TreeSet

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