1. 01 3月, 2014 13 次提交
    • A
      std: Change assert_eq!() to use {} instead of {:?} · 02882fbd
      Alex Crichton 提交于
      Formatting via reflection has been a little questionable for some time now, and
      it's a little unfortunate that one of the standard macros will silently use
      reflection when you weren't expecting it. This adds small bits of code bloat to
      libraries, as well as not always being necessary. In light of this information,
      this commit switches assert_eq!() to using {} in the error message instead of
      {:?}.
      
      In updating existing code, there were a few error cases that I encountered:
      
      * It's impossible to define Show for [T, ..N]. I think DST will alleviate this
        because we can define Show for [T].
      * A few types here and there just needed a #[deriving(Show)]
      * Type parameters needed a Show bound, I often moved this to `assert!(a == b)`
      * `Path` doesn't implement `Show`, so assert_eq!() cannot be used on two paths.
        I don't think this is much of a regression though because {:?} on paths looks
        awful (it's a byte array).
      
      Concretely speaking, this shaved 10K off a 656K binary. Not a lot, but sometime
      significant for smaller binaries.
      02882fbd
    • B
      auto merge of #12632 : fhahn/rust/issue-12507-rustdoc-std-module, r=alexcrichton · 123eb4eb
      bors 提交于
      This PR for #12507 marks the top level `Module` in rustdoc as a crate and does render the header accordingly.
      123eb4eb
    • B
      auto merge of #12616 : alexcrichton/rust/size, r=huonw · 5b4a141b
      bors 提交于
      I've been playing around with code size when linking to libstd recently, and these were some findings I found that really helped code size. I started out by eliminating all I/O implementations from libnative and instead just return an unimplemented error.
      
      In doing so, a `fn main() {}` executable was ~378K before this patch, and about 170K after the patch. These size wins are all pretty minor, but they all seemed pretty reasonable to me. With native I/O not stubbed out, this takes the size of an LTO executable from 675K to 400K.
      5b4a141b
    • A
      std: Flag run_fmt() as #[inline(always)] · ddc1c212
      Alex Crichton 提交于
      This function is a tiny wrapper that LLVM doesn't want to inline, and it ends up
      causing more bloat than necessary. The bloat is pretty small, but it's a win of
      at least 7k for small executables, and I imagine that the number goes up as
      there are more calls to fail!().
      ddc1c212
    • A
      std: Avoid using "{:?}" in format strings · 79e6ab54
      Alex Crichton 提交于
      This removes all usage of Poly in format strings from libstd. This doesn't
      prevent more future strings from coming in, but it at least removes the ones for
      now.
      79e6ab54
    • A
      std: Remove lots of allocations from log settings · d89074c8
      Alex Crichton 提交于
      Most of these are unnecessary because we're only looking at static strings. This
      also moves to Vec in a few places instead of ~[T].
      
      This didn't end up getting much of a code size win (update_log_settings is the
      third largest function in the executables I'm looking at), but this seems like a
      generally nice improvement regardless.
      d89074c8
    • B
      auto merge of #12607 : alexcrichton/rust/io++, r=brson · 84ebf74e
      bors 提交于
      This lowers the #[allow(missing_doc)] directive into some of the lower modules
      which are less mature. Most I/O modules now require comprehensive documentation.
      84ebf74e
    • B
      auto merge of #12533 : alexcrichton/rust/svh, r=brson · 58ea029d
      bors 提交于
      These hashes are used to detect changes to upstream crates and generate errors which mention that crates possibly need recompilation.
      
      More details can be found in the respective commit messages below. This change is also accompanied with a much needed refactoring of some of the crate loading code to focus more on crate ids instead of name/version pairs.
      
      Closes #12601
      58ea029d
    • A
      std: Improve some I/O documentation · 311ac8f4
      Alex Crichton 提交于
      This lowers the #[allow(missing_doc)] directive into some of the lower modules
      which are less mature. Most I/O modules now require comprehensive documentation.
      311ac8f4
    • A
      syntax: Expand format!() deterministically · 017c5044
      Alex Crichton 提交于
      Previously, format!("{a}{b}", a=foo(), b=bar()) has foo() and bar() run in a
      nondeterminisc order. This is clearly a non-desirable property, so this commit
      uses iteration over a list instead of iteration over a hash map to provide
      deterministic code generation of these format arguments.
      017c5044
    • A
      rustc: Add the concept of a Strict Version Hash · ec57db08
      Alex Crichton 提交于
      This new SVH is used to uniquely identify all crates as a snapshot in time of
      their ABI/API/publicly reachable state. This current calculation is just a hash
      of the entire crate's AST. This is obviously incorrect, but it is currently the
      reality for today.
      
      This change threads through the new Svh structure which originates from crate
      dependencies. The concept of crate id hash is preserved to provide efficient
      matching on filenames for crate loading. The inspected hash once crate metadata
      is opened has been changed to use the new Svh.
      
      The goal of this hash is to identify when upstream crates have changed but
      downstream crates have not been recompiled. This will prevent the def-id drift
      problem where upstream crates were recompiled, thereby changing their metadata,
      but downstream crates were not recompiled.
      
      In the future this hash can be expanded to exclude contents of the AST like doc
      comments, but limitations in the compiler prevent this change from being made at
      this time.
      
      Closes #10207
      ec57db08
    • A
      rustc: Simplify crate loading constraints · 8213e184
      Alex Crichton 提交于
      The previous code passed around a {name,version} pair everywhere, but this is
      better expressed as a CrateId. This patch changes these paths to store and pass
      around crate ids instead of these pairs of name/version. This also prepares the
      code to change the type of hash that is stored in crates.
      8213e184
    • A
      std: Add cfg(test) to UnsafeArc assertions · d5aa795a
      Alex Crichton 提交于
      This is a ubiquitous type in concurrent code, and the assertions are causing
      significant code bloat for simple operations such as reading the pointer
      (injecting a failure point, etc).
      
      I am testing executable sizes with no I/O implementations (everything stubbed
      out to return nothing), and this took the size of a libnative executable from
      328K to 207K (37% reduction in size), so I think that this is one assertion
      that's well worth configuring off for now.
      d5aa795a
  2. 28 2月, 2014 27 次提交
    • B
      auto merge of #12622 : pnkfelix/rust/fsk-improve-vec-partition-doc, r=huonw · 9b1be3d1
      bors 提交于
      Explicitly note in vec `partition` and `partitioned` that the left and
      right parts each map to satisfying and non-satisfying elements.
      9b1be3d1
    • B
      auto merge of #12595 : huonw/rust/pub-vis-typ, r=alexcrichton · 2e51e8d9
      bors 提交于
      These are types that are in exported type signatures, but are not
      exported themselves, e.g.
      
          struct Foo { ... }
      
          pub fn bar() -> Foo { ... }
      
      will warn about the Foo.
      
      Such types are not listed in documentation, and cannot be named outside
      the crate in which they are declared, which is very user-unfriendly.
      
      cc #10573.
      2e51e8d9
    • F
      Improve vec `partition` and `partitioned` method doc. · daa6da76
      Felix S. Klock II 提交于
      Explicitly note in vec `partition` and `partitioned` that the left and
      right parts each map to satisfying and non-satisfying elements.
      daa6da76
    • H
      Publicise types/add #[allow(visible_private_types)] to a variety of places. · 218eae06
      Huon Wilson 提交于
      There's a lot of these types in the compiler libraries, and a few of the
      older or private stdlib ones. Some types are obviously meant to be
      public, others not so much.
      218eae06
    • H
      sync: Rename arc::Condvar to arc::ArcCondvar. · fbdd3b2e
      Huon Wilson 提交于
      The sync submodule also has a `Condvar` type, and its reexport was
      shadowing the `arc` type, making it crate-private.
      fbdd3b2e
    • H
      rustc: implement a lint for publicly visible private types. · 859277df
      Huon Wilson 提交于
      These are types that are in exported type signatures, but are not
      exported themselves, e.g.
      
          struct Foo { ... }
      
          pub fn bar() -> Foo { ... }
      
      will warn about the Foo.
      
      Such types are not listed in documentation, and cannot be named outside
      the crate in which they are declared, which is very user-unfriendly.
      
      cc #10573
      859277df
    • B
      auto merge of #12621 : huonw/rust/time-test-doc, r=pnkfelix · b99a8ffa
      bors 提交于
      Add `time` crate to index, expand docs of `test`.
      b99a8ffa
    • H
      Add `time` crate to index, expand docs of `test`. · 1b5be76b
      Huon Wilson 提交于
      1b5be76b
    • B
      auto merge of #12544 : erickt/rust/hash, r=acrichto · 31e9c947
      bors 提交于
      This PR allows `HashMap`s to work with custom hashers. Also with this patch are:
      
      * a couple generic implementations of `Hash` for a variety of types.
      * added `Default`, `Clone` impls to the hashers.
      * added a `HashMap::with_hasher()` constructor.
      31e9c947
    • B
      auto merge of #12614 : alexcrichton/rust/rollup, r=alexcrichton · 53e90c15
      bors 提交于
      Closes #12546 (Add new target 'make dist-osx' to create a .pkg installer for OS X) r=brson
      Closes #12575 (rustc: Move local native libs back in link-args) r=brson
      Closes #12587 (Provide a more helpful error for tests that fail due to noexec) r=brson
      Closes #12589 (rustc: Remove codemap and reachable from metadata encoder) r=alexcrichton
      Closes #12591 (Fix syntax::ext::deriving{,::*} docs formatting.) r=huonw
      Closes #12592 (Miscellaneous Vim improvements) r=alexcrichton
      Closes #12596 (path: Implement windows::make_non_verbatim()) r=alexcrichton
      Closes #12598 (Improve the ctags function regular expression) r=alexcrichton
      Closes #12599 (Tutorial improvement (new variant of PR #12472).) r=pnkfelix
      Closes #12603 (std: Export the select! macro) r=pcwalton
      Closes #12605 (Fix typo in doc of Binary trait in std::fmt) r=alexcrichton
      Closes #12613 (Fix bytepos_to_file_charpos) r=brson
      53e90c15
    • B
      auto merge of #12348 : brunoabinader/rust/libcollections-list-refactory, r=alexcrichton · f203fc7d
      bors 提交于
      This PR includes:
      - Create an iterator for ```List<T>``` called ```Items<T>```;
      - Move all list operations inside ```List<T>``` impl;
      - Removed functions that are already provided by ```Iterator``` trait;
      - Refactor on ```len()``` and ```is_empty``` using ```Container``` trait;
      - Bunch of minor fixes;
      
      A replacement for using @ is intended, but still in discussion.
      
      Closes #12344.
      f203fc7d
    • N
      Fix bytepos_to_file_charpos. · a8d57a26
      Nick Cameron 提交于
      Make bytepos_to_charpos relative to the start of the filemap rather than its previous behaviour which was to be realtive to the start of the codemap, but ignoring multi-byte chars in earlier filemaps. Rename to bytepos_to_file_charpos. Add tests for multi-byte chars.
      a8d57a26
    • M
      Fix typo in doc of Binary trait in std::fmt · 53a3f281
      Mickaël Delahaye 提交于
      53a3f281
    • A
      std: Export the select! macro · 98782bb5
      Alex Crichton 提交于
      Mark it as #[experimental] for now. In theory this attribute will be read in the
      future. I believe that the implementation is solid enough for general use,
      although I would not be surprised if there were bugs in it still. I think that
      it's at the point now where public usage of it will start to uncover hopefully
      the last few remaining bugs.
      
      Closes #12044
      98782bb5
    • F
    • A
      Documentation : Tutorial improvement... · d028079b
      Axel Viala 提交于
      Refactoring examples on implementation of generics for linked list.
      Fixing typo of 'Note's for coherancy.
      
      Adding internal links inside the tutorial example with traits,
      generics etc...
      d028079b
    • C
      Improve the ctags function regular expression. · 231832d8
      Chris Morgan 提交于
      Before it would only catch lines starting `fn` or `pub fn`.
      
      Now it can cope with:
      
      - attributes (e.g. `#[test] fn`)
      - external functions (e.g. `extern fn`, `extern "C" fn`)
      - unsafe functions (e.g. `unsafe fn`)
      
      … and any correct combination of these
      (e.g. `#[test] extern "C" unsafe fn`).
      231832d8
    • K
      path: Implement windows::make_non_verbatim() · ea0bd40d
      Kevin Ballard 提交于
      make_non_verbatim() takes a WindowsPath and returns a new one that does
      not use the \\?\ verbatim prefix, if possible.
      ea0bd40d
    • K
      path: clean up some lint warnings and an obsolete comment · af38726d
      Kevin Ballard 提交于
      Get rid of the unnecessary parenthesies that crept into some macros.
      Remove a FIXME that was already fixed.
      Fix a comment that wasn't rendering correctly in rustdoc.
      af38726d
    • C
      Update Vim syntax file last change date. · 498a6060
      Chris Morgan 提交于
      498a6060
    • C
      Fix Vim section movements for standard Rust style. · 879ac436
      Chris Morgan 提交于
      (Expressed another way: make `[[` et al. work with the curly brace at
      the end of a line as is standard Rust style, not just at the start is it
      is by default in Vim, from K&R style.)
      
      This came out of #11492, where a simpler but less effective technique
      was initially proposed; some discussion of the techniques, ways and
      means can be found there.
      
      There are still a few caveats:
      
      - Operator-pending mode behaves differently to the standard behaviour:
        if inside curly braces, it should delete up to and including the
        closing of the outermost curly brace (that doesn't seem to me
        consistent with documented behaviour, but it's what it does). Actual
        behaviour (the more logical and consistent, in my opinion): up to the
        start of the next outermost curly brace.
      
      - With folding enabled (`set fdm=syntax`), `[[` and `]]` do not behave
        as they should: the default behaviour treats an entire closed fold as
        one line for these purposes while this code does not (I explicitly
        `set nofoldenable` in the function—the side-effects are worse with
        folds enabled), leading to unexpected behaviour, the worst of which is
        `[[` and/or `]]` not working in visual mode on a closed fold (visual
        mode keeps it at the extreme end of the region line of the folded
        region, so it's always going back to the opening line of that fold and
        immediately being shoved back to the end by visual mode).
      
      - `[[` and `]]` are operating inside comments, whereas the standard
        behaviour skips comments.
      
      - The viewport position is sometimes changed when it should not be
        necessary.
      879ac436
    • C
      Update prelude items in Vim syntax. · 0a663a2d
      Chris Morgan 提交于
      0a663a2d
    • C
      Downgrade `do` to a reserved keyword in Vim. · eda5755a
      Chris Morgan 提交于
      This means it gets highlighted as Error by default.
      eda5755a
    • C
      Highlight the `mod` in `extern mod x;` as Error. · e0088ef8
      Chris Morgan 提交于
      Just like the bare keyword `crate` is highlighted as Error (a little
      dubious, actually, given macros), `mod` is invalid after `extern`: it's
      obsolete syntax.
      e0088ef8
    • C
      Fix syntax::ext::deriving{,::*} docs formatting. · 37f6564a
      Chris Morgan 提交于
      The most significant fix is for `syntax::ext::deriving::encodable`,
      where one of the blocks of code, auspiciously containing `<S>` (recall
      that Markdown allows arbitrary HTML to be contained inside it), was not
      formatted as a code block, with a fun but messy effect.
      37f6564a
    • B
      c5fbc504
    • F
      Provide a more helpful error for tests that fail due to noexec · e3a251a4
      Felix Crux 提交于
      The rustdoc tests create and execute a file in a temporary directory. By
      default on UNIX-like platforms this is in `/tmp`, which some users mount
      with the `noexec` option. In those cases, the tests fail in a mysterious
      way. This change adds a note that suggests what the problem might be, if
      the error looks like it could have been caused by the `noexec` setup.
      
      Closes #12558
      e3a251a4