Commit graph

31629 commits

Author SHA1 Message Date
Barosl Lee
ca4f53655e 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]
2014-12-08 18:02:12 +09:00
Eduard Burtescu
15ca63081b test: adjust pretty/issue-4264 for formatting changes. 2014-12-08 09:14:21 +02:00
Eduard Burtescu
fe4fdcc0f6 core: make the public fmt API completely safe. 2014-12-08 09:14:21 +02:00
Eduard Burtescu
c75e8d46c2 core: remove the dead function fmt::argumentstr. 2014-12-08 09:14:21 +02:00
Jon Haddad
956c581111 documentation incorrectly described from_utf8
Docs said from_utf8 accepts a vector when it actually accepts a slice of bytes.
2014-12-07 22:57:40 -08:00
bors
1e69dfa261 auto merge of #19555 : jbranchaud/rust/add-doctests-for-key-values-of-btreemap, r=Gankro 2014-12-08 05:52:28 +00:00
bors
83a44c7fa6 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
2014-12-08 02:32:31 +00:00
bors
8bca470c5a 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
2014-12-08 00:12:30 +00:00
Steven Fackler
a20926a51a Mention expected in testing docs 2014-12-07 16:04:56 -08:00
bluss
a81346966d string: Add test for FromIterator<&str> and Extend<&str> 2014-12-07 23:13:04 +01:00
bluss
56c4e97e83 string: Add test for FromIterator<char> and Extend<char> 2014-12-07 23:12:45 +01:00
Jorge Aparicio
8dcdd1e76a syntax: use UFCS in the expansion of #[deriving(Ord)]
cc #18755
2014-12-07 16:46:46 -05:00
bluss
5ba7c5da62 string: Implement FromIterator<&str> and Extend<&str> for String
&str is a "particle" of a string already, see the graphemes iterator,
so it seems natural that we should be able to use it with Extend.
2014-12-07 22:45:27 +01:00
bluss
d7d5ccf9bb string: Use the iterator size_hint() in .extend() 2014-12-07 21:31:24 +01:00
Steve Klabnik
c8bd9d2beb Remove mention of Dequeue in collections docs.
https://botbot.me/mozilla/rust/2014-12-07/?msg=27003846&page=20
2014-12-07 14:24:57 -05:00
bors
77cd5cc54e auto merge of #19548 : luqmana/rust/mfb, r=nikomatsakis
Fixes #19367.
2014-12-07 19:02:18 +00:00
Peter Atashian
58f12743c2 Make MemoryMap use HANDLE on Windows.
Also fixes some conflicting module names.

Signed-off-by: Peter Atashian <retep998@gmail.com>
2014-12-07 13:25:51 -05:00
bors
558f8d8e3e 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
2014-12-07 16:12:22 +00:00
Jorge Aparicio
1fea900de7 Fix syntax error on android tests 2014-12-07 08:49:17 -05:00
bors
a243e8820a auto merge of #19522 : mukilan/rust/import-conflicts-item, r=cmr
Fixes #19498
2014-12-07 13:42:18 +00:00
Steve Klabnik
e294772072 Add enum namespacing to the Guide.
Closes #19556.
2014-12-07 07:55:30 -05:00
Steve Klabnik
131f20279e Correct the reference with regards to floats
Fixes #19595.
2014-12-07 07:30:15 -05:00
Steve Klabnik
8ba5605233 remove usage of notrust from the docs
Fixes #19599
2014-12-07 04:18:56 -05:00
bors
1e835cc7e3 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.
2014-12-07 07:12:16 +00:00
Jorge Aparicio
2ed42bfbd1 libtime: remove unnecessary to_string() calls 2014-12-06 23:53:02 -05:00
Jorge Aparicio
66f52f4c9b libtest: remove unnecessary to_string() calls 2014-12-06 23:53:02 -05:00
Jorge Aparicio
00c7786690 libterm: remove unnecessary to_string() calls 2014-12-06 23:53:02 -05:00
Jorge Aparicio
93e99b55f8 libsyntax: remove unnecessary to_string() calls 2014-12-06 23:53:02 -05:00
Jorge Aparicio
c2da923fc9 libstd: remove unnecessary to_string() calls 2014-12-06 23:53:02 -05:00
Jorge Aparicio
ba01ea3730 libserialize: remove unnecessary to_string() calls 2014-12-06 23:53:02 -05:00
Jorge Aparicio
71d8d578c6 librustc_back: remove unnecessary to_string() calls 2014-12-06 23:53:02 -05:00
Jorge Aparicio
8379d72293 libgetopts: remove unnecessary to_string() calls 2014-12-06 23:53:02 -05:00
Jorge Aparicio
98ae63753b libcollections: remove unnecessary to_string() calls 2014-12-06 23:53:02 -05:00
Jorge Aparicio
976660f3f7 libtest: remove unnecessary as_mut_slice() calls 2014-12-06 23:53:02 -05:00
Jorge Aparicio
6132a90788 libstd: remove unnecessary as_mut_slice calls 2014-12-06 23:53:01 -05:00
Jorge Aparicio
5172981207 librustdoc: remove unnecessary as_mut_slice calls 2014-12-06 23:53:01 -05:00
Jorge Aparicio
a0a354ff22 librustc_trans: remove unnecessary as_mut_slice calls 2014-12-06 23:53:01 -05:00
Jorge Aparicio
d64fd22c71 librustc: remove unnecessary as_mut_slice calls 2014-12-06 23:53:01 -05:00
Jorge Aparicio
5a24058889 libcollections: remove unnecessary as_mut_slice() calls 2014-12-06 23:53:01 -05:00
Jorge Aparicio
a0621f8eba libtest: remove unnecessary as_slice() calls 2014-12-06 23:53:01 -05:00
Jorge Aparicio
53b479c195 libterm: remove unnecessary as_slice() calls 2014-12-06 23:53:01 -05:00
Jorge Aparicio
39f44c0c20 libsyntax: remove unnecessary as_slice() calls 2014-12-06 23:53:01 -05:00
Jorge Aparicio
60338d91c4 libstd: remove unnecessary as_slice() calls 2014-12-06 23:53:00 -05:00
bors
f7d18b92f8 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
2014-12-07 04:12:20 +00:00
Mukilan Thiyagarajan
4b75a5d8da Add compile-fail tests for #19498 2014-12-07 07:37:15 +05:30
Jorge Aparicio
09f7713dd4 libserialize: remove unnecessary as_slice() calls 2014-12-06 19:05:58 -05:00
Jorge Aparicio
e6bd217ce8 librustdoc: remove unnecessary as_slice() calls 2014-12-06 19:05:58 -05:00
Jorge Aparicio
8bb5ef9df5 librustc_trans: remove unnecessary as_slice calls 2014-12-06 19:05:58 -05:00
Jorge Aparicio
7d8eabb226 librustc_back: remove unnecessary as_slice() calls 2014-12-06 19:05:58 -05:00
Jorge Aparicio
00f3c3f7a7 librustc: remove unnecessary as_slice() calls 2014-12-06 19:05:58 -05:00
Jorge Aparicio
ae555a99a6 libregex_macros: remove unnecessary as_slice calls 2014-12-06 19:05:58 -05:00
Jorge Aparicio
89e6a81ef9 libregex: remove unnecessary as_slice calls 2014-12-06 19:05:58 -05:00
Jorge Aparicio
0ea31348d9 liblog: remove unnecessary as_slice calls 2014-12-06 19:05:58 -05:00
Jorge Aparicio
c0ef959b31 libgraphviz: remove unnecessary as_slice() calls 2014-12-06 19:05:58 -05:00
Jorge Aparicio
6efc87945b libgetops: remove unnecessary as_slice() calls 2014-12-06 19:05:58 -05:00
Jorge Aparicio
a7960136ac libfmt_macros: remove unnecessary as_slice() calls 2014-12-06 19:05:58 -05:00
Jorge Aparicio
0f54f32a9c libflate: remove unnecessary as_slice() calls 2014-12-06 19:05:58 -05:00
Jorge Aparicio
5257a5b284 libcoretest: remove unnecessary as_slice() calls 2014-12-06 19:05:58 -05:00
Jorge Aparicio
0ac3b166df liballoc: remove unnecessary as_slice() calls 2014-12-06 19:05:58 -05:00
Jorge Aparicio
f2af07e6d5 libcollections: remove unnecessary as_slice() calls 2014-12-06 19:05:58 -05:00
jbranchaud
2171c95553 Add missing semicolon to hello world program in intro. 2014-12-06 17:36:32 -06:00
Steven Fackler
3246d4f369 Change from message to expected 2014-12-06 15:16:38 -08:00
Steven Fackler
616af6eb83 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];
}
```
2014-12-06 15:13:48 -08:00
bors
a31ad6bfcd auto merge of #19579 : alexcrichton/rust/snapshots, r=nikomatsakis 2014-12-06 23:12:17 +00:00
NODA, Kai
87424c6a32 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@74fb798a20 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>
2014-12-07 07:07:26 +08:00
Vadim Chugunov
de8f48b10a - 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.
2014-12-06 12:48:32 -08:00
bors
de83d7dd19 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.
2014-12-06 20:12:13 +00:00
Steven Fackler
2e2aca9eb8 Ignore wait-forked-but-failed-child
Test will be fixed in #19588
2014-12-06 08:13:57 -08:00
Corey Richardson
6e18b5af93 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]
2014-12-05 22:27:21 -08:00
jbranchaud
9cb26e2db0 Add a doctest for BTreeMap's iter method. 2014-12-05 23:50:13 -06:00
Steven Fackler
8a288d3aff Ignore issue #16671 test on android
Seems to be blocking forever
2014-12-05 20:22:35 -08:00
Huon Wilson
b800ce1608 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.
2014-12-05 19:04:13 -08:00
Huon Wilson
e8524198e3 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.
2014-12-05 17:54:45 -08:00
mdinger
796e4b8a88 Typo 2014-12-05 20:14:28 -05:00
Matt Windsor
363ed2f7ad Correct minor typos on the ownership guide.
liftimes -> lifetimes
2014-12-06 00:30:03 +00:00
Chase Southwood
da50db0ca2 Implement BitOps for TreeSet 2014-12-05 18:03:45 -06:00
Luqman Aden
8ebc1c9fd8 librustc: Fix debuginfo for captured variables in non-FnOnce unboxed closures. 2014-12-05 18:56:40 -05:00
Aidan Cully
c394a6c238 prefer "FIXME" to "TODO". 2014-12-05 18:39:58 -05:00
Alex Crichton
9b443289cf Register new snapshots 2014-12-05 15:39:26 -08:00
Corey Farwell
4ef16741e3 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
2014-12-05 18:13:04 -05:00
jbranchaud
451cc7e5c0 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.
2014-12-05 17:00:24 -06:00
Aidan Cully
7bf7bd6a75 work around portability issue on FreeBSD, in which the key returned from
pthread_key_create can be 0.
2014-12-05 17:20:44 -05:00
Nafis
e1b77b0709 fix 404 2014-12-06 08:17:49 +10:00
jbranchaud
d6b6df0dfa 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.
2014-12-05 15:40:46 -06:00
bors
6f4c11be3b auto merge of #19508 : cmr/rust/rollup-2014_12_03, r=cmr 2014-12-05 20:23:10 +00:00
Erick Tryzelaar
e20ea0b67d 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.
2014-12-05 11:29:41 -08:00
Corey Richardson
33f34bdb4e Merge remote-tracking branch 'csouth3/trieset-bitops' into rollup-2014_12_03
Conflicts:
	src/libcollections/trie/set.rs
2014-12-05 11:19:50 -08:00
Luqman Aden
2dccb5a77f librustc: Don't reuse same alloca for match on struct/tuple field which we reassign to in match body. 2014-12-05 14:16:20 -05:00
Andrew Paseltiner
600faba5bc libcore: Fix Sized bounds on overloaded function traits.
- Remove the `for Sized?` bound on `core::ops::FnOnce`, as it takes
  `self` by value and can never be implemented by an unsized type.
- Add a missing `Sized?` bound to the blanket `core::ops::FnMut` impl,
  as both `Fn` and `FnMut` are `for Sized?`.
2014-12-05 14:04:57 -05:00
Chase Southwood
309ab34b7a Implement BitOps for TrieSet 2014-12-05 12:58:45 -06:00
Corey Richardson
090110779f rollup merge of #19553: sfackler/issue-19543
Closes #19543
2014-12-05 10:08:33 -08:00
Corey Richardson
a90e0d70cc 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.
2014-12-05 10:08:28 -08:00
Corey Richardson
b8eaf7bc8a rollup merge of #19530: aochagavia/remove-test
Fixes https://github.com/rust-lang/rust/issues/19510
2014-12-05 10:08:26 -08:00
Corey Richardson
d602c058ae 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`)
2014-12-05 10:08:24 -08:00
Corey Richardson
39646d2ff6 rollup merge of #19526: steveklabnik/gh19402
Fixes #19402.
2014-12-05 10:07:49 -08:00
Corey Richardson
0fb040f4bd rollup merge of #19525: steveklabnik/guide_edits
Fixes #19335. (or at least, the actionable parts)
2014-12-05 10:07:48 -08:00
Corey Richardson
c7d545e2f7 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.
2014-12-05 10:07:47 -08:00
Corey Richardson
d58aecb6b3 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).
2014-12-05 10:07:45 -08:00
Corey Richardson
4e492cbaf8 rollup merge of #19515: lifthrasiir/rustdoc-wrong-dedup
Fixes #17332.
2014-12-05 10:07:44 -08:00
Corey Richardson
f3a85cf822 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.)
2014-12-05 10:07:42 -08:00
Corey Richardson
33e96be299 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
2014-12-05 10:07:41 -08:00
Corey Richardson
a8c1812f36 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, 1cb1f00d40, 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 bda97e8557 (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
2014-12-05 10:07:38 -08:00
Corey Richardson
fdb395626b 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.)
2014-12-05 10:07:36 -08:00
Corey Richardson
13befdff91 rollup merge of #19492: steveklabnik/remove_outdated_comment
https://github.com/rust-lang/rust/pull/19472#issuecomment-65370278

/cc @alexcrichton
2014-12-05 10:07:34 -08:00
Corey Richardson
3489fc4134 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?
2014-12-05 10:07:31 -08:00
Corey Richardson
a6358f571e rollup merge of #19483: cgaebel/copy_memory-comment 2014-12-05 10:07:23 -08:00
Corey Richardson
1b2b24a6af rollup merge of #19480: cmr/es6-escape
First half of bootstrapping https://github.com/rust-lang/rfcs/pull/446
2014-12-05 10:07:18 -08:00
Corey Richardson
7464a29a37 rollup merge of #19474: luqmana/fl
Fixes #19339.
2014-12-05 10:07:11 -08:00
Corey Richardson
6f173cdba6 rollup merge of #19472: nick29581/iflet
Closes #19469

r?
2014-12-05 10:07:10 -08:00
Corey Richardson
560b8f6c59 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/>.
2014-12-05 10:07:07 -08:00
Corey Richardson
fb55cbda8d 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?
2014-12-05 10:07:04 -08:00
Corey Richardson
f2b81888c1 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 ?
2014-12-05 10:07:03 -08:00
Corey Richardson
64d58dcac2 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.
2014-12-05 10:07:02 -08:00
Corey Richardson
ea8bb5d18d 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.
2014-12-05 10:06:58 -08:00
Corey Richardson
7f8f4abc55 rollup merge of #19422: scialex/fix-fmt-macro-doc
these are missing standard #![doc(...)]. add them
2014-12-05 10:06:55 -08:00
Corey Richardson
a6ce402401 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]
2014-12-05 10:06:52 -08:00
Corey Richardson
26f2867c2e 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.
2014-12-05 10:06:50 -08:00
Corey Richardson
2af097da0d rollup merge of #19396: kulakowski/patch-1 2014-12-05 10:06:45 -08:00
Corey Richardson
b738ece85f rollup merge of #19387: jauhien/fix-expand_quote_ty
Subj., expand_quote_ty produces wrong call to parse_ty now.
2014-12-05 10:06:44 -08:00
Corey Richardson
be75f2e090 rollup merge of #19386: tbu-/pr_refcell_stuff 2014-12-05 10:06:43 -08:00
Corey Richardson
d066b5c4be rollup merge of #19364: steveklabnik/doc_buffered_reader
We don't need this &mut, and vec could use []s
2014-12-05 10:06:42 -08:00
Corey Richardson
9525af74a7 rollup merge of #19359: japaric/clone-cow
Now we can use `#[deriving(Clone)]` on structs that contain `Cow`.

r? @aturon or anyone else
2014-12-05 10:06:41 -08:00
Corey Richardson
08ce178866 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
2014-12-05 10:06:39 -08:00
Erick Tryzelaar
72bc461ce3 std: change BufWriter to return ShortWrite/EndOfFile 2014-12-05 09:42:48 -08:00
bors
95d1771139 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.
2014-12-05 17:33:00 +00:00
Alex Crichton
c3adbd34c4 Fall out of the std::sync rewrite 2014-12-05 09:12:25 -08:00
Erick Tryzelaar
d913310748 test: expose boxplot and the extra stats test keeps track of
[breaking-change]
2014-12-05 09:04:55 -08:00
bors
4573da6f4f 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
2014-12-05 15:03:18 +00:00
bors
52636007ce 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.
2014-12-05 09:23:09 +00:00
Alex Crichton
71d4e77db8 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
2014-12-05 00:53:22 -08:00
Alex Crichton
d6d4088bbf 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
2014-12-05 00:49:31 -08:00
Niko Matsakis
70c1463519 Fix various references in late-running tests and things 2014-12-05 01:52:18 -05:00
Steven Fackler
714ce79197 Make missing_doc lint check typedefs
Closes #19543
2014-12-04 20:20:09 -08:00
NODA, Kai
74fb798a20 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>
2014-12-05 10:04:06 +08:00
bors
361baabb07 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()`.
2014-12-05 00:22:58 +00:00
Chase Southwood
d424af480f Implement BitOps for TrieSet 2014-12-04 17:16:38 -06:00
Niko Matsakis
14f9127d8a Delete diagnostics tests because that model doesn't scale to multiple crates 2014-12-04 16:34:13 -05:00
bors
d9c7c00b9a 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]`.
2014-12-04 21:33:07 +00:00
Alexander Light
87235687a1 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.
2014-12-04 16:23:29 -05:00
Adolfo Ochagavía
fdb0d9026e Remove reduntant compile-fail test
Fixes https://github.com/rust-lang/rust/issues/19510
2014-12-04 20:56:44 +01:00
Aaron Liblong
0d3c415617 Add capacity() to VecMap
Changed capacity() tag to unstable and fixed doc assert
2014-12-04 13:21:43 -05:00
Steve Klabnik
010cbd011a Tasks aren't actually lightweight :frown:
Fixes #19402.
2014-12-04 11:43:22 -05:00
Steve Klabnik
f0f7a90068 Some small copy edits to the guide.
Fixes #19335.
2014-12-04 11:39:13 -05:00
Erick Tryzelaar
298b525951 core: fix a doctest 2014-12-04 07:57:13 -08:00
Niko Matsakis
5d19432679 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.) 2014-12-04 10:04:52 -05:00
Niko Matsakis
61edb0ccb7 Separate the driver into its own crate that uses trans, typeck. 2014-12-04 10:04:52 -05:00
Niko Matsakis
93eb4333a0 Move typeck into its own crate. 2014-12-04 10:04:52 -05:00
Niko Matsakis
e135fa5b49 Remove dependencies on driver from trans et al. by moving various
structs out from driver and into other places.
2014-12-04 10:04:51 -05:00
Niko Matsakis
cc32f867d8 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.
2014-12-04 10:04:51 -05:00
Niko Matsakis
1e112e94c3 Move typeck logically in the module tree out to the root and clamp
down on its exports. Remove some dead code that is revealed.
2014-12-04 10:04:51 -05:00
Niko Matsakis
55470abe72 Remove one dependence on typeck from const_eval. 2014-12-04 10:04:51 -05:00
Niko Matsakis
00ca861f9d Remove "dependence" on typeck from comment in substs. 2014-12-04 10:04:51 -05:00
Niko Matsakis
9aeaaab334 Remove dependence on typeck from ppaux. 2014-12-04 10:04:51 -05:00
Niko Matsakis
adda9c1520 Remove dependency on typeck from lint. 2014-12-04 10:04:51 -05:00
Niko Matsakis
db75f8aa91 Move infer out of middle::typeck and into just middle. 2014-12-04 10:04:51 -05:00
Niko Matsakis
7c44561ad6 Move various data structures out of typeck and into ty. 2014-12-04 10:04:26 -05:00
bors
4053e82acb 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.
2014-12-04 15:03:39 +00:00
Mukilan Thiyagarajan
7403b0ceaa Handle conflicting import of items declared in the same module
Fixes #19498
2014-12-04 18:51:44 +05:30
bors
6d965cc2c9 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
2014-12-04 12:02:56 +00:00
Austin Bonander
2e1911b47a core::iter::Unfold: reword docs and add example
Remove note about core
2014-12-04 01:28:16 -08:00
Chase Southwood
cddbb6a75b DerefMut should be for Sized? 2014-12-04 03:10:58 -06:00
bors
53e8bd641a 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.
2014-12-04 08:52:47 +00:00
Steven Fackler
e7c1f57d6c 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]
2014-12-03 23:18:52 -08:00
Niko Matsakis
f2731ffb52 Adjust nits from pcwalton. 2014-12-04 01:49:42 -05:00
Niko Matsakis
64bf5a8687 Add a cache so we don't create so many shims. 2014-12-04 01:49:42 -05:00
Niko Matsakis
39221a013f 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. 2014-12-04 01:49:42 -05:00
bors
3c89031e1f 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.
2014-12-04 04:52:37 +00:00
Kang Seonghoon
a12b83996e rustdoc: Do not deduplicate items when their parents differ.
Fixes #17332.
2014-12-04 13:52:23 +09:00
Kang Seonghoon
4b271f3f64 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).
2014-12-04 12:48:16 +09:00
NODA, Kai
3980cdecd0 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>
2014-12-04 11:19:55 +08:00
NODA, Kai
805a06ca6a 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>
2014-12-04 11:19:55 +08:00
Huon Wilson
1a620661b7 Special-case transmute for primitive, SIMD & pointer types.
This detects (a subset of) the cases when `transmute::<T, U>(x)` can be
lowered to a direct `bitcast T x to U` in LLVM. This assists with
efficiently handling a SIMD vector as multiple different types,
e.g. swapping bytes/words/double words around inside some larger vector
type.

C compilers like GCC and Clang handle integer vector types as `__m128i`
for all widths, and implicitly insert bitcasts as required. This patch
allows Rust to express this, even if it takes a bit of `unsafe`, whereas
previously it was impossible to do at all without inline assembly.

Example:

    pub fn reverse_u32s(u: u64x2) -> u64x2 {
        unsafe {
            let tmp = mem::transmute::<_, u32x4>(u);
            let swapped = u32x4(tmp.3, tmp.2, tmp.1, tmp.0);
            mem::transmute::<_, u64x2>(swapped)
        }
    }

Compiling with `--opt-level=3` gives:

Before

    define <2 x i64> @_ZN12reverse_u32s20hbdb206aba18a03d8tbaE(<2 x i64>) unnamed_addr #0 {
    entry-block:
      %1 = bitcast <2 x i64> %0 to i128
      %u.0.extract.trunc = trunc i128 %1 to i32
      %u.4.extract.shift = lshr i128 %1, 32
      %u.4.extract.trunc = trunc i128 %u.4.extract.shift to i32
      %u.8.extract.shift = lshr i128 %1, 64
      %u.8.extract.trunc = trunc i128 %u.8.extract.shift to i32
      %u.12.extract.shift = lshr i128 %1, 96
      %u.12.extract.trunc = trunc i128 %u.12.extract.shift to i32
      %2 = insertelement <4 x i32> undef, i32 %u.12.extract.trunc, i64 0
      %3 = insertelement <4 x i32> %2, i32 %u.8.extract.trunc, i64 1
      %4 = insertelement <4 x i32> %3, i32 %u.4.extract.trunc, i64 2
      %5 = insertelement <4 x i32> %4, i32 %u.0.extract.trunc, i64 3
      %6 = bitcast <4 x i32> %5 to <2 x i64>
      ret <2 x i64> %6
    }

    _ZN12reverse_u32s20hbdb206aba18a03d8tbaE:
    	.cfi_startproc
    	movd	%xmm0, %rax
    	punpckhqdq	%xmm0, %xmm0
    	movd	%xmm0, %rcx
    	movq	%rcx, %rdx
    	shrq	$32, %rdx
    	movq	%rax, %rsi
    	shrq	$32, %rsi
    	movd	%eax, %xmm0
    	movd	%ecx, %xmm1
    	punpckldq	%xmm0, %xmm1
    	movd	%esi, %xmm2
    	movd	%edx, %xmm0
    	punpckldq	%xmm2, %xmm0
    	punpckldq	%xmm1, %xmm0
    	retq

After

    define <2 x i64> @_ZN12reverse_u32s20hbdb206aba18a03d8tbaE(<2 x i64>) unnamed_addr #0 {
    entry-block:
      %1 = bitcast <2 x i64> %0 to <4 x i32>
      %2 = shufflevector <4 x i32> %1, <4 x i32> undef, <4 x i32> <i32 3, i32 2, i32 1, i32 0>
      %3 = bitcast <4 x i32> %2 to <2 x i64>
      ret <2 x i64> %3
    }

    _ZN12reverse_u32s20hbdb206aba18a03d8tbaE:
    	.cfi_startproc
    	pshufd	$27, %xmm0, %xmm0
    	retq
2014-12-03 17:15:02 -08:00
bors
207a508411 auto merge of #18770 : pczarn/rust/hash_map-explicit-shrinking, r=Gankro
Part of enforcing capacity-related conventions, for #18424, the collections reform.

Implements `fn shrink_to_fit` for HashMap.
The `reserve` method now takes as an argument the *extra* space to reserve.
2014-12-04 01:07:48 +00:00
P1start
108bca53f0 Make the parser’s ‘expected <foo>, found <bar>’ errors more accurate
As an example of what this changes, the following code:

    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 `..`’.
2014-12-04 13:47:35 +13:00
Erick Tryzelaar
f86737973a rustup: simplify downloading packages 2014-12-03 15:21:16 -08:00
Erick Tryzelaar
694500b07d rustup: extract the tarballs as part of installation 2014-12-03 15:20:24 -08:00
Erick Tryzelaar
bd8dac8f75 rustup: rewrite to protect against truncation
This closes #19168. It's possible that if the downloading of `rustup.sh`
is interrupted, bad things could happen, such as running a naked
"rm -rf /" instead of "rm -rf /path/to/tmpdir". This wraps rustup.sh's
functionality in a function that gets called at the last time that should
protect us from these truncation errors.
2014-12-03 15:18:52 -08:00
Erick Tryzelaar
8ca8e6fa4d rustup: factor out installing packages into a function 2014-12-03 15:17:36 -08:00
Erick Tryzelaar
b388dc61a5 rustup: factor out downloading and extracting the snapshot tarballs 2014-12-03 15:17:32 -08:00
Corey Richardson
2e1a50121e syntax: support ES6-style unicode escapes
First half of bootstrapping https://github.com/rust-lang/rfcs/pull/446
2014-12-03 15:10:51 -08:00
bors
daa0745886 auto merge of #18749 : nikomatsakis/rust/builtin-bounds-like-other-traits, r=pcwalton
Treat builtin bounds like all other kinds of trait matches. Introduce a simple hashset in the fulfillment context to catch cases where we register the exact same obligation twice. This helps prevent duplicate error reports but also handles the recursive obligations created by builtin bounds.

r? @pcwalton 
cc @FlaPer87
2014-12-03 22:57:40 +00:00
Erick Tryzelaar
4f65d97bf8 rustup: factor out the install flags into a CFG_INSTALL_FLAGS variable 2014-12-03 14:40:33 -08:00
Erick Tryzelaar
fcb31e8347 rustup: rename TMP_DIR to CFG_TMP_DIR 2014-12-03 14:40:33 -08:00
Erick Tryzelaar
e688eb3b4f rustup: add a RUST_ prefix to the rust-specific variables 2014-12-03 14:40:33 -08:00
Erick Tryzelaar
98f01f1f54 rustup: probe for the existance of tar 2014-12-03 14:40:33 -08:00
Erick Tryzelaar
3b4ad726f1 rustup: make rustup executable 2014-12-03 14:40:33 -08:00
Erick Tryzelaar
c7ae4a9664 whitespace cleanup 2014-12-03 14:40:33 -08:00
Alexander Light
e621116b86 make fmt_macros and rustdoc have standard doc attributes 2014-12-03 12:49:59 -05:00
Nick Cameron
c200ae5a8a Remove feature gates for if let, while let, and tuple indexing
Closes #19469
2014-12-03 09:45:08 -08:00
Alex Crichton
719c36c9b9 test: Ignore issue-19501 pretty for now
I don't have enough time to investigate this thoroughly, so for now let's get
the queue moving by ignoring this test.

cc #19501
2014-12-03 09:22:13 -08:00
Kang Seonghoon
1068855925 rustdoc: Avoid rendering foreign items to the sidebar.
Otherwise the generated documentation is 30% larger. The sidebar
renders an entry for each item to all items, so large modules have
O(n^2) items rendered in the sidebars. Not a correct solution, but
at least it works.
2014-12-04 01:00:01 +09:00
Kang Seonghoon
1cb1f00d40 rustdoc: Removed Foreign{Function,Static} item types.
They are just (unsafe) functions and static items to most users
and even compilers! The metadata doesn't distinguish them, so Rustdoc
ended up producing broken links (generated `ffi.*.html`, links to
`fn.*.html`). It would be best to avoid this pitfall at all.
2014-12-04 01:00:01 +09:00
Kang Seonghoon
a3bb8585e8 rustdoc: Refactored various uses of ItemType.
In particular, ItemType variants are no longer reexported. Since
we already do namespace them via `item_type` mod, it's fine.
2014-12-04 00:59:52 +09:00
Kang Seonghoon
131d4ed018 rustdoc: Fixed a missing rendering of ForeignStaticItems. 2014-12-04 00:58:09 +09:00
Jorge Aparicio
5cfac94201 Deprecate Equiv 2014-12-03 10:41:48 -05:00
Jorge Aparicio
09707d70a4 Fix fallout 2014-12-03 10:41:48 -05:00
Jorge Aparicio
eac635de01 Remove unused transmutes from tests 2014-12-03 10:41:48 -05:00
Jorge Aparicio
b32b24d13a Replace equiv method calls with == operator sugar 2014-12-03 10:41:48 -05:00
Jorge Aparicio
2840d58dab Overload the == operator
- String == &str == CowString
- Vec ==  &[T] ==  &mut [T] == [T, ..N] == CowVec
- InternedString == &str
2014-12-03 10:41:42 -05:00
Steve Klabnik
861e11ceeb Remove outdated comment.
https://github.com/rust-lang/rust/pull/19472#issuecomment-65370278
2014-12-03 03:29:57 -05:00
Steve Klabnik
7213704812 New Guide: Ownership
This replaces the previous "Lifetimes guide," since we are discussing
things from an owernship perspective now.
2014-12-03 03:27:17 -05:00
Oliver Schneider
ea6f628709 libtest: get rid of dependency to ToJson
deriving encodable + using json::PrettyEncoder removes the only ToJson trait implementation in the rust repository outside of libserialize
2014-12-03 09:16:00 +01:00
Clark Gaebel
851c7b5e0f Fixed out of date comment on copy_memory 2014-12-02 17:50:26 -08:00
Niko Matsakis
931758c88a FIXME(#19481) -- workaround valgrind cleanup failure (but the code is nicer this way anyhow) 2014-12-02 20:17:55 -05:00
Niko Matsakis
594e21f19b Correct various compile-fail tests. Most of the changes are because we
now don't print duplicate errors within one context, so I sometimes
had to break functions into two functions.
2014-12-02 19:05:14 -05:00
Niko Matsakis
d85ff16173 Treat builtin bounds like all other kinds of trait matches. Introduce a simple hashset in the fulfillment context to catch cases where we register the exact same obligation twice. This helps prevent duplicate error reports but also handles the recursive obligations created by builtin bounds. 2014-12-02 19:05:14 -05:00
Jorge Aparicio
2578de9d60 Test PartialEq multidispatch 2014-12-02 18:52:50 -05:00
Jorge Aparicio
b258de7bda libcore: add Rhs input parameter to comparison traits 2014-12-02 18:52:50 -05:00
Luqman Aden
89d0995373 gdb: Fix pretty printer for nullable-opt enums with fat pointers. 2014-12-02 18:28:43 -05:00
Luqman Aden
886ff4f3c3 lldb: Fix pretty printer for nullable-opt enums with fat pointers. 2014-12-02 17:33:52 -05:00
Victor van den Elzen
d8c5269dd2 Update comment to current file path for intrinsics 2014-12-02 20:57:00 +01:00
Victor van den Elzen
6182084e58 Improve documentation of checked_* functions 2014-12-02 20:56:41 +01:00
Matej Lach
ebf22cbf6a replace 'but' with 'and' 2014-12-02 16:45:57 +00:00
Matej Lach
5bbe5d6d93 better wording 2014-12-02 13:40:18 +00:00
bors
738d9803ac auto merge of #19443 : nodakai/rust/another-missing-extracflags, r=alexcrichton
rust-lang/rust@102b1a5bf1 was not enough!
2014-12-02 12:02:06 +00:00
bors
2b35e6fa08 auto merge of #19357 : michaelwoerister/rust/fix-issue-18791, r=alexcrichton
One negative side-effect of this change is that there might be quite a bit of copying strings out of the codemap, i.e. one copy for every block that gets translated, just for taking a look at the last character of the block. If this turns out to cause a performance problem then `CodeMap::span_to_snippet()` could be changed return `Option<&str>` instead of `Option<String>`.

Fixes #18791
2014-12-02 10:06:58 +00:00
bors
8dbe63200d auto merge of #19427 : scialex/rust/doc-attr-macros, r=sfackler
this allows one to, for example, use #[doc = $macro_var ] in macros.
2014-12-02 07:22:02 +00:00
Paul Collier
e407472f90 rustdoc: Check for href when prepending rootPath
Fixes #18354.
2014-12-01 20:53:32 -08:00
bors
8a210af7e5 auto merge of #19450 : jbapple/rust/pq-pop-time, r=Gankro
pop calls siftdown, siftdown calls siftdown_range, and siftdown_range
loops on an index that can start as low as 0 and approximately doubles
each iteration.
2014-12-02 02:52:15 +00:00
Jim Apple
0212dff902 Pop on binary heaps does not have constant time complexity.
pop calls siftdown, siftdown calls siftdown_range, and siftdown_range
loops on an index that can start as low as 0 and approximately doubles
each iteration.
2014-12-01 18:12:48 -08:00
Michael Woerister
61a0a7f0a3 debuginfo: Fix multi-byte character related bug in cleanup scope handling.
Also see issue #18791.
2014-12-01 16:22:00 -08:00
bors
5484d6f6d2 auto merge of #19439 : nodakai/rust/liblibc-getsid, r=acrichto
```
#include <unistd.h>

pid_t getsid(pid_t pid);

CONFORMING TO
       SVr4, POSIX.1-2001.
```
2014-12-02 00:22:00 +00:00
bors
21ba1d5e58 auto merge of #19405 : jfager/rust/de-match-pyramid, r=bstrie
No semantic changes, no enabling `if let` where it wasn't already enabled.
2014-12-01 21:56:53 +00:00
NODA, Kai
2d3de6686e test/run-make: another missing $(EXTRACFLAGS).
rust-lang/rust@102b1a5bf1 was not enough!

Signed-off-by: NODA, Kai <nodakai@gmail.com>
2014-12-02 04:52:29 +08:00
NODA, Kai
2018510dd9 liblibc: getsid() was missing though setsid() was already there.
include <unistd.h>

pid_t getsid(pid_t pid);

CONFORMING TO
       SVr4, POSIX.1-2001.

Signed-off-by: NODA, Kai <nodakai@gmail.com>
2014-12-02 02:50:57 +08:00
Alexander Light
d3bbfb48bd added negative test for macro expansion in attributes 2014-12-01 11:08:29 -05:00
Kang Seonghoon
08fb9aa2d2 rustdoc: Use relative paths in source renders.
Before: doc/src/collections/home/lifthrasiir/git/rust/src/libcollections/vec.rs.html
After: doc/src/collections/vec.rs.html

If the source code is in the parent dirs relative to the crate root,
`..` is replaced with `up` as expected. Any other error like non-UTF-8
paths or drive-relative paths falls back to the absolute path.

There might be a way to improve on false negatives, but this alone
should be enough for fixing #18370.
2014-12-01 20:53:11 +09:00
Alexander Light
5c20a1535e Add test for expanding doc strings in macros. 2014-11-30 21:05:32 -05:00
bors
222a1eb7e8 auto merge of #19418 : P1start/rust/unsafe-extern-trait, r=alexcrichton
Fixes #19398.
2014-12-01 01:56:52 +00:00
Erick Tryzelaar
0d24780793 std: add Reader impl for &[u8] 2014-11-30 16:55:53 -08:00
Erick Tryzelaar
6687b2a6e1 std: add tests for the Vec<u8> Writer impl 2014-11-30 16:55:08 -08:00
jfager
a779e3b5c4 fix missed switch pointed out in review plus a few others 2014-11-30 18:11:40 -05:00
Piotr Czarnecki
b82624bf20 std: Change the behavior of reserve for HashMap.
HashMap's `reserve` method now takes as an argument the *extra* space
to reserve.

[breaking-change]
2014-11-30 22:52:11 +01:00
Piotr Czarnecki
72c96badd2 std: Remove implicit shrinking from hash_map.
Implements fn shrink_to_fit for HashMap.
2014-11-30 22:52:10 +01:00
bors
acad03a420 auto merge of #19415 : P1start/rust/error-message-fixes, r=alexcrichton
This is the style followed by most other error messages.
2014-11-30 19:46:53 +00:00
bors
3ee471cab5 auto merge of #19411 : lifthrasiir/rust/asm-clobbers-expanded, r=alexcrichton
I.e. we should not prematurely build operand constraints at the expansion time. Otherwise `--pretty expanded` diverges:

```
$ cat t.rs
#![feature(asm)]

pub fn main() { unsafe { asm!("" : : : "hello", "world") }; }

$ rustc t.rs --pretty
#![feature(asm)]

pub fn main() { unsafe { asm!("" : : : "hello" , "world") }; }

$ rustc t.rs --pretty expanded
#![feature(asm)]
#![feature(phase)]
#![no_std]
#![feature(globs)]
#[phase(plugin, link)]
extern crate "std" as std;
#[prelude_import]
use std::prelude::*;

pub fn main() { unsafe { asm!("":  :  : "~{hello},~{world}") }; }
```

(The last code *does* compile, but won't do the expected thing.)
2014-11-30 17:21:48 +00:00
Alexander Light
798da23772 allow macro expansions in attributes 2014-11-30 09:51:15 -05:00
Tobias Bucher
5048953deb Simplify RefCell code a bit, make deref a no-op. 2014-11-30 11:50:35 +01:00
bors
52888a7c47 auto merge of #19369 : seanmonstar/rust/cow-str, r=alexcrichton
This implementation existed on MaybeOwned, but has been lost in the
transition to Cows. Let's put it back.

@aturon r?
2014-11-30 10:21:49 +00:00
Kang Seonghoon
133266f01c trans: Eliminated redundant allocations. 2014-11-30 18:52:44 +09:00
P1start
f5715f7867 Allow trailing commas in array patterns and attributes 2014-11-30 22:28:54 +13:00
P1start
63553a10ad Fix the ordering of unsafe and extern in methods
This breaks code that looks like this:

    trait Foo {
        extern "C" unsafe fn foo();
    }

    impl Foo for Bar {
        extern "C" unsafe fn foo() { ... }
    }

Change such code to look like this:

    trait Foo {
        unsafe extern "C" fn foo();
    }

    impl Foo for Bar {
        unsafe extern "C" fn foo() { ... }
    }

Fixes #19398.

[breaking-change]
2014-11-30 21:33:04 +13:00
P1start
432adc675e Adjust some error messages to start with a lowercase letter and not finish with a full stop 2014-11-30 20:26:53 +13:00
bors
dfaad04b7a auto merge of #19365 : frewsxcv/rust/getopts-cleanup, r=alexcrichton
* Remove public reexports, as a part of #19253
* Rename getopts::Fail_ to getopts::Fail
 * Didn't see a reason for the suffixed '_'
* Removed getopts::FailType
 * Looked like it was only beings used for tests; refactored the tests
   to stop requiring it
* A few other non-breaking trivial refactoring changes

[breaking-change]
2014-11-30 06:56:41 +00:00
Kang Seonghoon
989f906af3 syntax: Make asm! clobbers a proper vector.
Otherwise `--pretty expanded` diverges.
2014-11-30 11:58:23 +09:00
bors
8d8f41b75f auto merge of #19392 : murarth/rust/rustc-compile-twice, r=nick29581
Closes #19371
2014-11-29 21:51:34 +00:00
jfager
232ffa039d Replace some verbose match statements with their if let equivalent.
No semantic changes, no enabling `if let` where it wasn't already enabled.
2014-11-29 16:41:21 -05:00
Murarth
004533ea75 Fix rustc panic on second compile_input 2014-11-29 09:50:48 -07:00
Matej Lach
d9a3ea88fc Fix a simple typo 2014-11-29 13:26:32 +00:00
kulakowski
9460d1744f Fix typo in reference.md 2014-11-29 01:38:32 -06:00