Commit Graph

24598 Commits

Author SHA1 Message Date
bors
d9c06586f2 auto merge of #11120 : alexcrichton/rust/rustdoc-test, r=brson
This commit adds a `--test` flag to rustdoc to expose the ability to test code examples in doc strings. This work by using sundown's `lang` attribute to figure out how a code block should be tested. The format for this is:

```
1. ```rust
2. ```rust,ignore
3. ```rust,notest
4. ```rust,should_fail
```

Where `rust` means that rustdoc will attempt to test is, `ignore` means that it will not execute the test but it will compile it, `notest` means that rustdoc completely ignores it, and `should_fail` means that the test should fail. This commit also leverages `extra::test` for the testing harness in order to allow parallelization and whatnot.

I have fixed all existing code examples in libstd and libextra, but I have not made a pass through the crates in order to change code blocks to testable code blocks.

It may also be a questionable decision to require opting-in to a testable code block.

Finally, I kept our sugar in the doc suite to omit lines starting with `#` in documentation but still process them during tests.

Closes #2925
2013-12-23 09:16:37 -08:00
Alex Crichton
f9b231cd08 Fixing more doc tests 2013-12-23 09:10:37 -08:00
Alex Crichton
316345610a doc: Expand rustdoc's documentation for testing 2013-12-23 09:10:37 -08:00
Alex Crichton
fe8b360c9d mk: Run doc tests as part of 'make check'
Don't run doc tests during make check-fast because it involves spawning lots of
processes.
2013-12-23 09:10:37 -08:00
Alex Crichton
d882b1d4f9 extra: Fix all code examples 2013-12-23 09:10:36 -08:00
Alex Crichton
9f1739a8e1 std: Fix all code examples 2013-12-23 09:10:36 -08:00
Alex Crichton
6c9c045064 rustdoc: Add the ability to test code in comments
This adds support for the `--test` flag to rustdoc which will parse a crate,
extract all code examples in doc comments, and then run each test in the
extra::test driver.
2013-12-23 09:10:36 -08:00
bors
f71c0dc2cd auto merge of #11069 : alexcrichton/rust/issue-11067, r=brson
Turns out libuv's build system doesn't like us telling them that the build
directory is a relative location, as it always spits out a warning about a
circular dependency being dropped. By using an absolute path, turns out the
warnings isn't spit out, who knew?

Closes #11067
2013-12-22 22:36:30 -08:00
Alex Crichton
9d59e358d9 uv: Suppress a warning by using an absolute path
Turns out libuv's build system doesn't like us telling them that the build
directory is a relative location, as it always spits out a warning about a
circular dependency being dropped. By using an absolute path, turns out the
warnings isn't spit out, who knew?

Closes #11067
2013-12-22 22:30:51 -08:00
bors
57724012ff auto merge of #11111 : alexcrichton/rust/issue-11039, r=brson
None of these primitives should be Freeze because sharing them in an Arc is a
very bad idea.

Closes #11039
2013-12-22 18:21:34 -08:00
bors
1b4bbc89b3 auto merge of #11109 : sfackler/rust/arc, r=alexcrichton
Closes #11097
2013-12-22 16:56:31 -08:00
bors
9e00272441 auto merge of #11046 : zargony/rust/dep-info, r=alexcrichton
Using --dep-info writes Makefile-compatible dependency info to a file that is by default named based on the crate source filename. This adds an optional string argument to the --dep-info option which allows to write dependency info to an arbitrary filename.

cc #10698
2013-12-22 15:06:32 -08:00
bors
0c0c492101 auto merge of #11101 : jhasse/rust/patch-msys-quickfix, r=luqmana
I had this fixed but somehow forgot to commit it in my final patch. Sorry!
2013-12-22 13:51:35 -08:00
Andreas Neuhaus
66e3fbebd9 Allow optional filename argument for --dep-info 2013-12-22 21:38:55 +01:00
Andreas Neuhaus
5d0fea1441 Use --crate-file-name to find out the library filename in dep-info test 2013-12-22 21:37:33 +01:00
bors
0478142b5f auto merge of #11096 : brson/rust/pp, r=alexcrichton 2013-12-22 12:36:35 -08:00
bors
2e4cd83a0a auto merge of #11082 : brson/rust/noat, r=alexcrichton 2013-12-22 11:21:36 -08:00
bors
9b1e7db71c auto merge of #11114 : klutzy/rust/a, r=cmr 2013-12-22 04:16:37 -08:00
klutzy
dd44a25fd0 mk: Clean .lib files 2013-12-22 21:05:50 +09:00
bors
55cbef611a auto merge of #11064 : huonw/rust/vec-sort, r=alexcrichton
This uses quite a bit of unsafe code for speed and failure safety, and allocates `2*n` temporary storage.

[Performance](https://gist.github.com/huonw/5547f2478380288a28c2):

|      n |      new | priority_queue |   quick3 |
|-------:|---------:|---------------:|---------:|
|      5 |      200 |            155 |      106 |
|    100 |     6490 |           8750 |     5810 |
|  10000 |  1300000 |        1790000 |  1060000 |
| 100000 | 16700000 |       23600000 | 12700000 |
| sorted |   520000 |        1380000 | 53900000 |
|  trend |  1310000 |        1690000 |  1100000 |

(The times are in nanoseconds, having subtracted the set-up time (i.e. the `just_generate` bench target).)

I imagine that there is still significant room for improvement, particularly because both priority_queue and quick3 are doing a static call via `Ord` or `TotalOrd` for the comparisons, while this is using a (boxed) closure.

Also, this code does not `clone`, unlike `quick_sort3`; and is stable, unlike both of the others.
2013-12-22 00:41:39 -08:00
Huon Wilson
645fff4bc8 fix check-fast tests. 2013-12-22 19:32:17 +11:00
Huon Wilson
2e8c522c62 std::vec: make the sorting closure use Ordering rather than just being
(implicitly) less_eq.
2013-12-22 18:16:50 +11:00
bors
cd13f4d599 auto merge of #10997 : cadencemarseille/rust/issue-10755-ICE-for-missing-linker, r=alexcrichton
Trap the io_error condition so that a more informative error message is
displayed when the linker program cannot be started, such as when the
name of the linker binary is accidentally mistyped.

closes #10755
2013-12-21 22:16:37 -08:00
Alex Crichton
67c0222252 Guarantee comm primitives are not Freeze
None of these primitives should be Freeze because sharing them in an Arc is a
very bad idea.

Closes #11039
2013-12-21 21:54:05 -08:00
bors
9a8f79133b auto merge of #11110 : alexcrichton/rust/attempt-to-fix-osx-segfaulting, r=brson
Upon inspecting the core dumps, they're all segfaulting at the same instruction
with the same value in a register that looks fishy. It appears to be indexing
into an array with a -1 index and then getting some weird overflow and dying.

I have attempted to fix this as part of
alexcrichton/libuv@fd5308383c,
but I am unsure of whether this is the actual cause of the problem, so I am not
going to upstream it just yet. I have a fairly high confidence that this is
indeed the problem, but I want to make sure that the bots to segfault all over
the place before upstreaming.
2013-12-21 21:01:51 -08:00
Alex Crichton
61222b00e2 Attempt to fix the segfaulting osx bots
Upon inspecting the core dumps, they're all segfaulting at the same instruction
with the same value in a register that looks fishy. It appears to be indexing
into an array with a -1 index and then getting some weird overflow and dying.

I have attempted to fix this as part of
alexcrichton/libuv@fd5308383c,
but I am unsure of whether this is the actual cause of the problem, so I am not
going to upstream it just yet. I have a fairly high confidence that this is
indeed the problem, but I want to make sure that the bots to segfault all over
the place before upstreaming.
2013-12-21 20:17:23 -08:00
Steven Fackler
2490b59da0 Remove unneccessary mut from arc 2013-12-21 21:10:45 -07:00
Steven Fackler
7a1e486b2a Don't poison ARCs that are used while unwinding
Closes #11097
2013-12-21 20:53:43 -07:00
bors
256f6976ad auto merge of #11095 : brson/rust/issue-11094, r=alexcrichton 2013-12-21 19:46:35 -08:00
Brian Anderson
6f16df4aa3 std: Remove some @-boxes 2013-12-21 17:50:54 -08:00
Jan Niklas Hasse
5746e0cd2a Remove unnecessary semicolon 2013-12-21 17:31:24 +01:00
bors
ba801d8116 auto merge of #11100 : klutzy/rust/win-no-pthread-2, r=alexcrichton 2013-12-21 00:56:30 -08:00
klutzy
dfe58a9851 rustuv: Stop link to pthread on Windows 2013-12-21 15:44:18 +09:00
bors
20f13b228f auto merge of #10930 : DaGenix/rust/remove-unnecessary-fields, r=alexcrichton
3 minor clean-ups now that #9629 is fixed:

* Update MutChunkIter to remove the ```remainder``` that existed just to allow the size_hint() method to be implemented. This is no longer necessary since we can just access the length of the slice directly.
* Update MutSplitIterator to address the FIXME in its size_hint() method. This method was only partially implemented due to the issue. Also, implement a minor optimization in the case that its the last iteration.
* Update ByRef iterator to implement the size_hint() method.

I noticed that MutSplitIterator returns an empty slice if called on an empty slice. I don't know if this is intended or not, but I left the ```finished``` field in-place to preserve this behavior.

@TeXitoi @blake2-ppc
2013-12-20 20:01:41 -08:00
bors
35fc0c8fe4 auto merge of #11079 : chris-morgan/rust/fix-11072-regressions, r=brson
(#11072)

There, concrete evidence that I shouldn't try doing such things at 1:30am.
2013-12-20 18:46:31 -08:00
Brian Anderson
a5d26a2e37 mk: Remove obsolete source reformatting rules 2013-12-20 18:31:00 -08:00
Brian Anderson
675aac3001 mk: Work around problem with run-make tests on multiple targets. #11094 2013-12-20 18:06:12 -08:00
Palmer Cox
765bc9064f Implement size_hint() for ByRef iterator 2013-12-20 20:40:16 -05:00
Palmer Cox
2c539d4eec Update next() and size_hint() for MutSpliterIterator
Update the next() method to just return self.v in the case that we've reached
the last element that the iterator will yield. This produces equivalent
behavior as before, but without the cost of updating the field.

Update the size_hint() method to return a better hint now that #9629 is fixed.
2013-12-20 20:40:16 -05:00
Palmer Cox
efd619467d Remove remainder field from MutChunkIter
This field is no longer necessary now that #9629 is fixed since we can just
access the length of the remaining slice directly.
2013-12-20 20:40:16 -05:00
bors
45d24a5f7c auto merge of #11031 : jhasse/rust/patch-msys-3, r=cmr
Enable ANSI colors if TERM is set to cygwin and terminfo is not available (msys terminal on Windows). See #2807
2013-12-20 17:31:51 -08:00
bors
9d1de0b699 auto merge of #11077 : alexcrichton/rust/crate-id, r=cmr
Right now the --crate-id and related flags are all process *after* the entire
crate is parsed. This is less than desirable when used with makefiles because it
means that just to learn the output name of the crate you have to parse the
entire crate (unnecessary).

This commit changes the behavior to lift the handling of these flags much sooner
in the compilation process. This allows us to not have to parse the entire crate
and only have to worry about parsing the crate attributes themselves. The
related methods have all been updated to take an array of attributes rather than
a crate.

Additionally, this ceases duplication of the "what output are we producing"
logic in order to correctly handle things in the case of --test.

Finally, this adds tests for all of this functionality to ensure that it does
not regress.
2013-12-20 15:21:33 -08:00
Huon Wilson
1b1e4caa79 std::vec: add a sugary .sort() method for plain Ord sorting.
This moves the custom sorting to `.sort_by`.
2013-12-21 09:35:18 +11:00
Jan Niklas Hasse
5cf2f54bb1 Support ANSI colors in msys terminals. See #2807 2013-12-20 22:32:27 +01:00
bors
d5d5c5064b auto merge of #10986 : adridu59/rust/patch-new, r=alexcrichton
Thanks to @huonw for some mentoring. 🍰
2013-12-20 12:41:33 -08:00
Adrien Tétar
bf5f2f2631 doc: forward-port the conditions tutorial + fixup libstd example 2013-12-20 18:40:26 +01:00
bors
810c4de6a4 auto merge of #11075 : alexcrichton/rust/issue-10392, r=brson
We decided in the 12/10/13 weekly meeting that trailing commas should be
accepted pretty much anywhere. They are currently not allowed in struct
patterns, and this commit adds support for that.

Closes #10392
2013-12-20 09:11:33 -08:00
Alex Crichton
87add53327 rustc: Improve crate id extraction
Right now the --crate-id and related flags are all process *after* the entire
crate is parsed. This is less than desirable when used with makefiles because it
means that just to learn the output name of the crate you have to parse the
entire crate (unnecessary).

This commit changes the behavior to lift the handling of these flags much sooner
in the compilation process. This allows us to not have to parse the entire crate
and only have to worry about parsing the crate attributes themselves. The
related methods have all been updated to take an array of attributes rather than
a crate.

Additionally, this ceases duplication of the "what output are we producing"
logic in order to correctly handle things in the case of --test.

Finally, this adds tests for all of this functionality to ensure that it does
not regress.
2013-12-20 09:10:11 -08:00
bors
5399c82d56 auto merge of #11081 : alexcrichton/rust/comm-adapters, r=huonw
I accidentally removed this module from compilation awhile back, this adds it
back in.

Closes #11076
2013-12-20 04:36:32 -08:00
bors
6023350082 auto merge of #11017 : alexcrichton/rust/faster-read, r=thestinger
We were previously reading metadata via `ar p`, but as learned from rustdoc
awhile back, spawning a process to do something is pretty slow. Turns out LLVM
has an Archive class to read archives, but it cannot write archives.

This commits adds bindings to the read-only version of the LLVM archive class
(with a new type that only has a read() method), and then it uses this class
when reading the metadata out of rlibs. When you put this in tandem of not
compressing the metadata, reading the metadata is 4x faster than it used to be
The timings I got for reading metadata from the respective libraries was:

    libstd-04ff901e-0.9-pre.dylib    => 100ms
    libstd-04ff901e-0.9-pre.rlib     => 23ms
    librustuv-7945354c-0.9-pre.dylib => 4ms
    librustuv-7945354c-0.9-pre.rlib  => 1ms
    librustc-5b94a16f-0.9-pre.dylib  => 87ms
    librustc-5b94a16f-0.9-pre.rlib   => 35ms
    libextra-a6ebb16f-0.9-pre.dylib  => 63ms
    libextra-a6ebb16f-0.9-pre.rlib   => 15ms
    libsyntax-2e4c0458-0.9-pre.dylib => 86ms
    libsyntax-2e4c0458-0.9-pre.rlib  => 22ms

In order to always take advantage of these faster metadata read-times, I sort
the files in filesearch based on whether they have an rlib extension or not
(prefer all rlib files first).

Overall, this halved the compile time for a `fn main() {}` crate from 0.185s to
0.095s on my system (when preferring dynamic linking). Reading metadata is still
the slowest pass of the compiler at 0.035s, but it's getting pretty close to
linking at 0.021s! The next best optimization is to just not copy the metadata
from LLVM because that's the most expensive part of reading metadata right now.
2013-12-20 02:06:34 -08:00