Commit Graph

35026 Commits

Author SHA1 Message Date
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
602fc781ff Remove crates from test list so that we don't waste time building them. 2014-12-05 02:01:57 -05: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