1. 06 12月, 2014 31 次提交
    • C
      rollup merge of #19528: aliblong/add_vecmap_capacity · d602c058
      Corey Richardson 提交于
      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`)
      d602c058
    • C
      rollup merge of #19526: steveklabnik/gh19402 · 39646d2f
      Corey Richardson 提交于
      Fixes #19402.
      39646d2f
    • C
      rollup merge of #19525: steveklabnik/guide_edits · 0fb040f4
      Corey Richardson 提交于
      Fixes #19335. (or at least, the actionable parts)
      0fb040f4
    • C
      rollup merge of #19520: csouth3/derefmut-unsized · c7d545e2
      Corey Richardson 提交于
      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.
      c7d545e2
    • C
      rollup merge of #19518: csouth3/trieset-bitops · d58aecb6
      Corey Richardson 提交于
      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).
      d58aecb6
    • C
      rollup merge of #19515: lifthrasiir/rustdoc-wrong-dedup · 4e492cba
      Corey Richardson 提交于
      Fixes #17332.
      4e492cba
    • C
      rollup merge of #19513: lifthrasiir/rustdoc-fat-redirect · f3a85cf8
      Corey Richardson 提交于
      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.)
      f3a85cf8
    • C
      rollup merge of #19512: cybergeek94/master · 33e96be2
      Corey Richardson 提交于
      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
      33e96be2
    • C
      rollup merge of #19503: lifthrasiir/xenophobic-rustdoc · a8c1812f
      Corey Richardson 提交于
      This series of commits deals with broken links to the source code. It also refactors some repetitive codes from Rustdoc. The most important commit, 1cb1f00d, 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 bda97e85 (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
      a8c1812f
    • C
      rollup merge of #19494: P1start/better-expected · fdb39562
      Corey Richardson 提交于
      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.)
      fdb39562
    • C
    • C
      rollup merge of #19491: oli-obk/libtest_tojson_dependency · 3489fc41
      Corey Richardson 提交于
      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?
      3489fc41
    • C
      a6358f57
    • C
      rollup merge of #19480: cmr/es6-escape · 1b2b24a6
      Corey Richardson 提交于
      First half of bootstrapping https://github.com/rust-lang/rfcs/pull/446
      1b2b24a6
    • C
      rollup merge of #19474: luqmana/fl · 7464a29a
      Corey Richardson 提交于
      Fixes #19339.
      7464a29a
    • C
      rollup merge of #19472: nick29581/iflet · 6f173cdb
      Corey Richardson 提交于
      Closes #19469
      
      r?
      6f173cdb
    • C
      rollup merge of #19468: victorvde/master · 560b8f6c
      Corey Richardson 提交于
      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/>.
      560b8f6c
    • C
      rollup merge of #19462: MatejLach/but-and_guide · fb55cbda
      Corey Richardson 提交于
      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?
      fb55cbda
    • C
      rollup merge of #19458: MatejLach/guess_style_fix_guide · f2b81888
      Corey Richardson 提交于
      I think that this wording makes it more clear as to what we're doing here.
      Opinions @steveklabnik ?
      f2b81888
    • C
      rollup merge of #19454: nodakai/libstd-reap-failed-child · 64d58dca
      Corey Richardson 提交于
      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.
      64d58dca
    • C
      rollup merge of #19453: pshc/rustdoc-check-a-href · ea8bb5d1
      Corey Richardson 提交于
      Fixes the JS error in #18354 at least. I don't know if there's a more underlying issue that needs addressing.
      ea8bb5d1
    • C
      rollup merge of #19422: scialex/fix-fmt-macro-doc · 7f8f4abc
      Corey Richardson 提交于
      these are missing standard #![doc(...)]. add them
      7f8f4abc
    • C
      rollup merge of #19416: sfackler/global-stdin · a6ce4024
      Corey Richardson 提交于
      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]
      a6ce4024
    • C
      rollup merge of #19413: P1start/more-trailing-commas · 26f2867c
      Corey Richardson 提交于
      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.
      26f2867c
    • C
      rollup merge of #19396: kulakowski/patch-1 · 2af097da
      Corey Richardson 提交于
      2af097da
    • C
      rollup merge of #19387: jauhien/fix-expand_quote_ty · b738ece8
      Corey Richardson 提交于
      Subj., expand_quote_ty produces wrong call to parse_ty now.
      b738ece8
    • C
      rollup merge of #19386: tbu-/pr_refcell_stuff · be75f2e0
      Corey Richardson 提交于
      be75f2e0
    • C
      rollup merge of #19364: steveklabnik/doc_buffered_reader · d066b5c4
      Corey Richardson 提交于
      We don't need this &mut, and vec could use []s
      d066b5c4
    • C
      rollup merge of #19359: japaric/clone-cow · 9525af74
      Corey Richardson 提交于
      Now we can use `#[deriving(Clone)]` on structs that contain `Cow`.
      
      r? @aturon or anyone else
      9525af74
    • C
      rollup merge of #19274: alexcrichton/rewrite-sync · 08ce1788
      Corey Richardson 提交于
      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
      08ce1788
    • A
      Fall out of the std::sync rewrite · c3adbd34
      Alex Crichton 提交于
      c3adbd34
  2. 05 12月, 2014 9 次提交
    • B
      auto merge of #19334 : alexcrichton/rust/issue-19333, r=aturon · 4573da6f
      bors 提交于
      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
      4573da6f
    • B
      auto merge of #19362 : nikomatsakis/rust/crateification, r=nikomatsakis · 52636007
      bors 提交于
      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.
      52636007
    • A
      std: Rewrite the `sync` module · 71d4e77d
      Alex Crichton 提交于
      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
      71d4e77d
    • A
      std: Close TcpListener with closesocket() · d6d4088b
      Alex Crichton 提交于
      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
      d6d4088b
    • N
    • N
      70c14635
    • N
      libstd/sys/unix/process.rs: reap a zombie who didn't get through to exec(2). · 74fb798a
      NODA, Kai 提交于
      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: NNODA, Kai <nodakai@gmail.com>
      74fb798a
    • B
      auto merge of #19303 : nodakai/rust/libsyntax-reject-dirs, r=alexcrichton · 361baabb
      bors 提交于
      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()`.
      361baabb
    • C
      Implement BitOps for TrieSet · d424af48
      Chase Southwood 提交于
      d424af48