Commit Graph

26487 Commits

Author SHA1 Message Date
Steven Fackler 89c76bb142 Implement Hash for Bitv and BitvSet
Closes #14744
2014-06-08 10:29:55 -07:00
bors 17ba0cf428 auto merge of #14745 : huonw/rust/timer-doc, r=alexcrichton
std::io: expand the oneshot/periodic docs.

Examples!

Fixes #14714.
2014-06-08 06:01:49 -07:00
Jakub Wieczorek f7d86b2f4a Remove the dead code identified by the new lint 2014-06-08 13:36:28 +02:00
Jakub Wieczorek 0271224bda Add detection of dead struct fields 2014-06-08 13:30:04 +02:00
bors 9239bb4960 auto merge of #14741 : sfackler/rust/visit-attr, r=alexcrichton
The lint was missing a *lot* of cases previously.
2014-06-08 04:16:53 -07:00
bors 010d96ede9 auto merge of #14728 : TeXitoi/rust/relicense-shootout-regex-dna, r=brson
Part of #14248

The authors are @pcwalton and @BurntSushi, and we have their agreement.

@brson OK?
2014-06-08 02:31:53 -07:00
Huon Wilson e8d180df46 std::io: expand the oneshot/periodic docs.
Examples!

Fixes #14714.
2014-06-08 18:32:15 +10:00
bors 7580ef902e auto merge of #14743 : Sawyer47/rust/range-msg, r=huonw
Range allows char and numeric types, but previous error message
mentioned only numeric types.
2014-06-08 00:46:57 -07:00
Steven Fackler 9452cd24fb Remove unused name_str_pair method 2014-06-08 00:21:35 -07:00
Steven Fackler 862cd65dca Add back hint for crate level attributes 2014-06-08 00:21:15 -07:00
Piotr Jawniak 90339ef189 Improve error message for range in match
Range allows char and numeric types, but previous error message
mentioned only numeric types.
2014-06-08 08:57:33 +02:00
Steven Fackler 42a18bd985 Remove the attribute_usage lint
It has been superseded by the unused_attribute lint.

[breaking change]
2014-06-07 23:46:32 -07:00
Steven Fackler 3654ac68be Add visit_attribute to Visitor, use it for unused_attribute
The lint was missing a *lot* of cases previously.
2014-06-07 23:21:33 -07:00
P1start c1c76590cb update identifier naming warnings to give an example
This updates identifier warnings such as ``struct `foo_bar` should have a
camel case identifier`` to provide an example.

Closes #14738.
2014-06-08 17:56:09 +12:00
bors bbd448a27c auto merge of #14733 : sfackler/rust/partial-eq-nan-docs, r=alexcrichton
It is in fact the case that `NaN != NaN`. The true relations for
compareQuietNotEqual are LT, GT *and* UN.

I also rephrased the docs for PartialOrd since floats are not the only
types which are not totally ordered.
2014-06-07 18:01:46 -07:00
Steven Fackler 6b3d3803eb Clarify restrictions on ne
I can't think of any sane cases where this restriction would not hold,
and the standard library seems to assume it pretty much everywhere.
2014-06-07 17:52:48 -07:00
Steven Fackler 92221aba7b Fix PartialEq documentation with regards to floats
It is in fact the case that `NaN != NaN`. The true relations for
compareQuietNotEqual are LT, GT *and* UN.

I also rephrased the docs for PartialOrd since floats are not the only
types which are not totally ordered.
2014-06-07 17:48:54 -07:00
bors fa1832800a auto merge of #14725 : aochagavia/rust/show, r=alexcrichton 2014-06-07 15:31:44 -07:00
bors 01eb0ce122 auto merge of #14722 : hannobraun/rust/quote-args, r=alexcrichton
The need for this came up while I worked on a procedural macro that parses an argument and adds the same argument to a generated function.
2014-06-07 13:46:42 -07:00
bors ddd09df137 auto merge of #14730 : alexcrichton/rust/issue-14723, r=cmr
Closes #14723
2014-06-07 12:01:41 -07:00
Alex Crichton 3688c1d0ca rustdoc: More selectively remove execute links
Closes #14723
2014-06-07 10:53:22 -07:00
Adolfo Ochagavía 9731c28e11 Implement Show for SmallIntMap 2014-06-07 19:44:45 +02:00
Guillaume Pinot fe7fc4aeb2 relicense shootout-regex-dna.rs
Part of #14248

The authors are @pcwalton and @BurntSushi, and we have their agreement.
2014-06-07 19:34:29 +02:00
bors ffdb881337 auto merge of #14717 : zwarich/rust/borrowck-tests, r=cmr
After sitting down to build on the work merged in #14318, I realized that some of the test names were not clear, others probably weren't testing the right thing, and they were also not as exhaustive as they could have been.
2014-06-07 10:17:38 -07:00
Hanno Braun cc28ae5201 Implement ToSource and ToToken for ast::Arg
This makes ast::Arg usable in the quote_ macros.

Please note that this commit doesn't include a regression test. There
are tests that use the quote macros, but all of them are ignored. Due to
that, there is no obvious (to me) way to test this.

Since this change is absolutely trivial and only hooks up an additional
type to existing infrastructure (which presumably is tested elsewhere),
I concluded it's not worth the effort to follow up on this.
2014-06-07 13:46:41 +00:00
Adolfo Ochagavía f1bff592b1 Implement Show for DList 2014-06-07 15:01:44 +02:00
Cameron Zwarich 4666792ac6 Clean up borrows in borrowck field-sensitivity tests
Instead of calling a borrow() function that takes a pointer type, just
create a local pointer and dereference it. The dereference is there to
outsmart any future liveness analysis in borrowck.
2014-06-07 03:03:03 -07:00
Cameron Zwarich 653f57af20 Fix bad borrowck tests and move them from run-pass to compile-fail
The move_after_borrow / fu_move_after_borrow tests in
run-pass/borrowck-field-sensitivity.rs are not testing the right thing,
since the scope of the borrow is limited to the call to borrow(). When
fixed, these tests fail and thus should be moved to the corresponding
compile-fail test file.
2014-06-07 03:03:03 -07:00
Cameron Zwarich 61c81bf00c Add more borrowck tests for functional update moves
Add more borrowck field-sensitivity tests for functional update moves.
This makes the collection of test functions more combinatorially
exhaustive.
2014-06-07 02:31:01 -07:00
Cameron Zwarich 8a543ffc76 Make borrowck test functions better match their names
A number of borrowck field-sensitivity tests perform more moves and
copies than their naming scheme would indicate. This is only necessary
for borrowed pointers (to ensure that the borrowws stay alive in the
near future when borrow liveness is tracked), but all other test
functions should be changed to match their name more closely.
2014-06-07 02:31:01 -07:00
Cameron Zwarich 53198ffda6 Mention the specific kind of use in borrowck test function names
Some of the borrowck field-sensitivity test functions have 'use' in
their name, but they don't refer to the specific kind of use (whether a
copy or a deref). It would be better if the name more precisely
reflected what the function is testing.
2014-06-07 02:30:33 -07:00
bors 8e9e484d70 auto merge of #14708 : gereeter/rust/faster-sem, r=alexcrichton
Currently, `Sem`, which is used as a building block for all the blocking primitives, uses a very ugly hack to implement `Share` and be able to mutate the stored `WaitQueue` by hiding it all behind a `transmute`d `*()`. This PR replaces all that ugly machinery with `Unsafe`. Beyond being cleaner and not requiring `transmute`, this removes an allocation in the creation and removes an indirection for access.
2014-06-07 00:51:36 -07:00
Alex Crichton 75014f7b17 libs: Fix miscellaneous fallout of librustrt 2014-06-06 23:00:01 -07:00
Alex Crichton d743b8831e test: Fix fallout of previous changes 2014-06-06 22:19:57 -07:00
Alex Crichton 550c347d7b rustuv: Deal with the rtio changes 2014-06-06 22:19:57 -07:00
Alex Crichton 51348b068b native: Deal with the rtio changes 2014-06-06 22:19:57 -07:00
Alex Crichton da2293c6f6 std: Deal with fallout of rtio changes 2014-06-06 22:19:57 -07:00
Alex Crichton 5ec36c358f std: Extract librustrt out of libstd
As part of the libstd facade efforts, this commit extracts the runtime interface
out of the standard library into a standalone crate, librustrt. This crate will
provide the following services:

* Definition of the rtio interface
* Definition of the Runtime interface
* Implementation of the Task structure
* Implementation of task-local-data
* Implementation of task failure via unwinding via libunwind
* Implementation of runtime initialization and shutdown
* Implementation of thread-local-storage for the local rust Task

Notably, this crate avoids the following services:

* Thread creation and destruction. The crate does not require the knowledge of
  an OS threading system, and as a result it seemed best to leave out the
  `rt::thread` module from librustrt. The librustrt module does depend on
  mutexes, however.
* Implementation of backtraces. There is no inherent requirement for the runtime
  to be able to generate backtraces. As will be discussed later, this
  functionality continues to live in libstd rather than librustrt.

As usual, a number of architectural changes were required to make this crate
possible. Users of "stable" functionality will not be impacted by this change,
but users of the `std::rt` module will likely note the changes. A list of
architectural changes made is:

* The stdout/stderr handles no longer live directly inside of the `Task`
  structure. This is a consequence of librustrt not knowing about `std::io`.
  These two handles are now stored inside of task-local-data.

  The handles were originally stored inside of the `Task` for perf reasons, and
  TLD is not currently as fast as it could be. For comparison, 100k prints goes
  from 59ms to 68ms (a 15% slowdown). This appeared to me to be an acceptable
  perf loss for the successful extraction of a librustrt crate.

* The `rtio` module was forced to duplicate more functionality of `std::io`. As
  the module no longer depends on `std::io`, `rtio` now defines structures such
  as socket addresses, addrinfo fiddly bits, etc. The primary change made was
  that `rtio` now defines its own `IoError` type. This type is distinct from
  `std::io::IoError` in that it does not have an enum for what error occurred,
  but rather a platform-specific error code.

  The native and green libraries will be updated in later commits for this
  change, and the bulk of this effort was put behind updating the two libraries
  for this change (with `rtio`).

* Printing a message on task failure (along with the backtrace) continues to
  live in libstd, not in librustrt. This is a consequence of the above decision
  to move the stdout/stderr handles to TLD rather than inside the `Task` itself.
  The unwinding API now supports registration of global callback functions which
  will be invoked when a task fails, allowing for libstd to register a function
  to print a message and a backtrace.

  The API for registering a callback is experimental and unsafe, as the
  ramifications of running code on unwinding is pretty hairy.

* The `std::unstable::mutex` module has moved to `std::rt::mutex`.

* The `std::unstable::sync` module has been moved to `std::rt::exclusive` and
  the type has been rewritten to not internally have an Arc and to have an RAII
  guard structure when locking. Old code should stop using `Exclusive` in favor
  of the primitives in `libsync`, but if necessary, old code should port to
  `Arc<Exclusive<T>>`.

* The local heap has been stripped down to have fewer debugging options. None of
  these were tested, and none of these have been used in a very long time.

[breaking-change]
2014-06-06 22:19:41 -07:00
Alex Crichton a3f9aa9ef8 rtio: Remove usage of `Path`
The rtio interface is a thin low-level interface over the I/O subsystems, and
the `Path` type is a little too high-level for this interface.
2014-06-06 22:19:41 -07:00
Alex Crichton b830b4b86b rtio: Remove unused stuct 2014-06-06 22:19:41 -07:00
Alex Crichton 8bf6da0836 Test fixes from the rollup 2014-06-06 20:37:26 -07:00
Alex Crichton e5bbbca33e rustdoc: Submit examples to play.rust-lang.org
This grows a new option inside of rustdoc to add the ability to submit examples
to an external website. If the `--markdown-playground-url` command line option
or crate doc attribute `html_playground_url` is present, then examples will have
a button on hover to submit the code to the playground specified.

This commit enables submission of example code to play.rust-lang.org. The code
submitted is that which is tested by rustdoc, not necessarily the exact code
shown in the example.

Closes #14654
2014-06-06 20:00:16 -07:00
Alex Crichton cc63d4c61b doc: Turn off special features for rustdoc tests
These were only used for the markdown tests, and there's no reason they should
be distinct from the other tests.
2014-06-06 20:00:07 -07:00
Axel Viala 5915763106 Removing unused wrapper to libc::close. 2014-06-06 19:52:25 -07:00
Alex Crichton d4dec4701a rustc: Preserve reachable extern fns with LTO
All rust functions are internal implementation details with respect to the ABI
exposed by crates, but extern fns are public components of the ABI and shouldn't
be stripped. This commit serializes reachable extern fns to metadata, so when
LTO is performed all of their symbols are not stripped.

Closes #14500
2014-06-06 19:52:21 -07:00
Alex Crichton cb12e7ab74 mk: Run doc tests with --cfg dox
There were a few examples in the macros::builtin module that weren't being run
because they were being #[cfg]'d out.

Closes #14697
2014-06-06 19:51:52 -07:00
Huon Wilson 1f4d8f924e url: encode small bytes correctly.
Previously, bytes less than 16 would be encoded as %X, rather than %XX,
since the output width was left to be automatic.
2014-06-06 19:51:49 -07:00
Steven Fackler b662aa5ec0 Implement Eq for HashSet and HashMap
Also fix documentation references to PartialEq.
2014-06-06 19:51:37 -07:00
Aaron Turon 1bde6e3fcb Rename Iterator::len to count
This commit carries out the request from issue #14678:

> The method `Iterator::len()` is surprising, as all the other uses of
> `len()` do not consume the value. `len()` would make more sense to be
> called `count()`, but that would collide with the current
> `Iterator::count(|T| -> bool) -> unit` method. That method, however, is
> a bit redundant, and can be easily replaced with
> `iter.filter(|x| x < 5).count()`.
> After this change, we could then define the `len()` method
> on `iter::ExactSize`.

Closes #14678.

[breaking-change]
2014-06-06 19:51:31 -07:00
fort 1bc29924dc Remove reference to ~str in documentation 2014-06-06 19:51:26 -07:00
Alex Crichton 06f3f9a0c9 rustdoc: Inline static documentation across crates 2014-06-06 19:51:24 -07:00
Alex Crichton 2290dbb8cc rustc: Avoid 16-byte filenames in rlibs
In addition to avoiding 16-byte filenames with bytecode files, this commit also
avoids 16-byte filenames with object files pulled in from native libraries.
2014-06-06 19:51:19 -07:00
Michael Woerister 6a43af3f84 Add workaround for archive reading bug in LLDB.
LLDB contains a bug that makes it crash if an archive it reads
contains a file the name of which is exactly 16 bytes long. This
bug recently has made it impossible to debug Rust applications with
LLDB because some standard libraries triggered it indirectly:
For rlibs, rustc includes the LLVM bytecode in the archive, giving
it the extension ".bc.deflate". For liballoc (for example) this
results in the 16 character filename "alloc.bc.deflate", which is
bad.

This commit replaces the ".bc.deflate" suffix with
".bytecode.deflate" which itself is already longer than 16 bytes,
thus making sure that the bug won't be run into anymore.

The bug could still be run into with 14 character filenames because
then the .o files will trigger it. However, this is much more rare
and working around it would introduce more complexity than necessary
at the moment. It can always be done later on, if the need arises.

Fixes #14356.
2014-06-06 19:51:19 -07:00
Luqman Aden 735e518a81 librustc: Update AutoObject adjustment in writeback. 2014-06-06 19:51:17 -07:00
Alex Crichton f35328caed rustc: Avoid UB with signed division/remainder
Division and remainder by 0 are undefined behavior, and are detected at runtime.
This commit adds support for ensuring that MIN / -1 is also checked for at
runtime, as this would cause signed overflow, or undefined behvaior.

Closes #8460
2014-06-06 19:51:13 -07:00
Alex Crichton 9fd075f5af rustc: Encode argument names for traits
This ensures that rustdoc can properly document inlined traits across crates.

Closes #14670
2014-06-06 19:51:08 -07:00
bors bd6683c729 auto merge of #14702 : nikomatsakis/rust/issue-5527-namespace-substs-b, r=pnkfelix
Separate out initial refactorings for PR #14604
2014-06-06 17:02:00 -07:00
Niko Matsakis 4a51e9c549 Fix resolve to not permit refs to type vars from outer fns
(Fixes #14603)
2014-06-06 19:51:24 -04:00
Niko Matsakis 3fecd10428 Add missing test case for contravariant trait matching 2014-06-06 19:51:23 -04:00
Niko Matsakis bc5eb7d98c Stop passing around Option<&substs> in trans and just pass &substs, making the code more regular 2014-06-06 19:51:23 -04:00
Niko Matsakis 0f03b5608c Move Def out of syntax crate, where it does not belong 2014-06-06 19:51:23 -04:00
Niko Matsakis 14d626a9fa Simplify MonoId not to include parameters which, given coherence, are purely derived 2014-06-06 19:46:38 -04:00
Niko Matsakis f24a53757e Move subst data structures into subst.rs, fix capitalization 2014-06-06 19:46:38 -04:00
bors 8a414858ac auto merge of #14680 : Kimundi/rust/master, r=brson
Also updated/corrected a few other details in the tuple and struct sections.
2014-06-06 15:21:59 -07:00
Jonathan S f2f1991c81 Make sync::raw::Sem use Unsafe to manage mutability instead of transmuting an unsafe pointer 2014-06-06 15:24:14 -05:00
bors 61d79175c0 auto merge of #14318 : zwarich/rust/check-loans-refactor, r=nikomatsakis
I tried to split up the less mechanical changes into separate commits so they are easier to review. One thing I'm not quite sure of is whether `MoveReason` should just be replaced with `move_data::MoveKind`.
2014-06-06 12:17:10 -07:00
Cameron Zwarich f1542a6a7d Add a test for borrowck errors with multiple closure captures.
When converting check_loans to use ExprUseVisitor I encountered a few
issues where the wrong number of errors were being emitted for multiple
closure captures, but there is no existing test for this.
2014-06-06 11:59:33 -07:00
Cameron Zwarich 74eb4b4b57 Add new tests for borrowck field-sensitivity. 2014-06-06 11:59:33 -07:00
Cameron Zwarich c53d296e12 Change check_loans to use ExprUseVisitor. 2014-06-06 11:59:33 -07:00
Cameron Zwarich 78934b03e3 Add a kind_of_move_of_path method to FlowedMoveData. 2014-06-06 11:59:33 -07:00
Cameron Zwarich 40e3fb4c0b Use the MoveReason to determine a more precise MoveKind in gather_moves. 2014-06-06 11:59:33 -07:00
Cameron Zwarich 5ccb7644be Add a move reason to the Move ConsumeMode.
Currently it is not possible to distinguish moves caused by captures
in the ExprUseVisitor interface. Since check_Loans needs to make that
distinction for generating good diagnostics, this is necessary for
check_loans to switch to ExprUseVisitor.
2014-06-06 11:59:33 -07:00
Cameron Zwarich f63fad5d60 Add an Init mode to MutateMode.
This isn't necessary right now, but check_loans needs to be able to
distinguish between initialization and writes in the ExprUseVisitor
mutate callback.
2014-06-06 11:59:32 -07:00
Cameron Zwarich 0339b27e6d Fix mem_categorization to treat an AutoObject adjustment as an rvalue.
Currently mem_categorization categorizes an AutoObject adjustment the
same as the original expression. This can cause two moves to be
generated for the same underlying expression. Currently this isn't a
problem in practice, since check_loans doesn't rely on ExprUseVisitor.
2014-06-06 11:59:32 -07:00
Cameron Zwarich d123188b20 Clean up check_loans.
Refactor a number of functions in check_loans to take node IDs and spans
rather than taking expressions directly. Also rename some variables to
make them less ambiguous.

This is the first step towards using ExprUseVisitor in check_loans, as
now some of the interfaces more closely match those used in
ExprUseVisitor.
2014-06-06 11:59:32 -07:00
bors 3744940706 auto merge of #14677 : alexcrichton/rust/issue-2665, r=brson
There's no need to distribute these ABI helpers for tests with the standard rust
distribution they're only needed for our tests.

Closes #2665
2014-06-06 10:36:55 -07:00
bors 124e997f36 auto merge of #14676 : brson/rust/double-rainbow, r=alexcrichton 2014-06-06 08:07:07 -07:00
bors 76baa5f086 auto merge of #14668 : aochagavia/rust/pr3, r=alexcrichton
Closes https://github.com/mozilla/rust/issues/14577
Closes https://github.com/mozilla/rust/issues/14639
2014-06-06 03:01:57 -07:00
bors 732e057815 auto merge of #14667 : aochagavia/rust/pr2, r=huonw 2014-06-06 01:21:54 -07:00
Adolfo Ochagavía 501b904bb7 Change to_str().to_string() to just to_str() 2014-06-06 09:56:59 +02:00
Adolfo Ochagavía 75891274c4 Document BigInt's new and from_slice methods
Fixes https://github.com/mozilla/rust/issues/14639
2014-06-06 09:09:59 +02:00
Adolfo Ochagavía 7d07a1e74b Fix documentation for `slice()`
Fixes https://github.com/mozilla/rust/issues/14577
2014-06-06 09:09:58 +02:00
bors 100ff4cf30 auto merge of #14669 : TeXitoi/rust/relicense-shootout-meteor, r=brson
part of #14248, fix #14420

Removed @richo's contribution (outdated comment)

Quoting @brson: let's move forward with this one. The only
statement I'm missing is @richo's and it sounds like his was a
minor patch.
2014-06-05 23:36:56 -07:00
bors ae9577052d auto merge of #14664 : reem/rust/lifetimes-guide-grammar, r=brson
Removed strange fragment-like thing in the intro.
2014-06-05 20:16:53 -07:00
Alex Crichton 5cdc36517e mk: Move rust_test_helpers out of libstd
There's no need to distribute these ABI helpers for tests with the standard rust
distribution they're only needed for our tests.

Closes #2665
2014-06-05 17:55:41 -07:00
bors 5ec49c7924 auto merge of #14641 : darnuria/rust/add_documentation_to_std_os, r=alexcrichton
Just opening a pull request for adding code examples and documentation to std::os.

More to come soon.
2014-06-05 16:41:53 -07:00
bors ba3ba002d5 auto merge of #14538 : alexcrichton/rust/libcollections, r=brson
As with the previous commit with `librand`, this commit shuffles around some
`collections` code. The new state of the world is similar to that of librand:

* The libcollections crate now only depends on libcore and liballoc.
* The standard library has a new module, `std::collections`. All functionality
  of libcollections is reexported through this module.

I would like to stress that this change is purely cosmetic. There are very few
alterations to these primitives.

There are a number of notable points about the new organization:

* std::{str, slice, string, vec} all moved to libcollections. There is no reason
  that these primitives shouldn't be necessarily usable in a freestanding
  context that has allocation. These are all reexported in their usual places in
  the standard library.

* The `hashmap`, and transitively the `lru_cache`, modules no longer reside in
  `libcollections`, but rather in libstd. The reason for this is because the
  `HashMap::new` contructor requires access to the OSRng for initially seeding
  the hash map. Beyond this requirement, there is no reason that the hashmap
  could not move to libcollections.

  I do, however, have a plan to move the hash map to the collections module. The
  `HashMap::new` function could be altered to require that the `H` hasher
  parameter ascribe to the `Default` trait, allowing the entire `hashmap` module
  to live in libcollections. The key idea would be that the default hasher would
  be different in libstd. Something along the lines of:

      // src/libstd/collections/mod.rs

      pub type HashMap<K, V, H = RandomizedSipHasher> =
            core_collections::HashMap<K, V, H>;

  This is not possible today because you cannot invoke static methods through
  type aliases. If we modified the compiler, however, to allow invocation of
  static methods through type aliases, then this type definition would
  essentially be switching the default hasher from `SipHasher` in libcollections
  to a libstd-defined `RandomizedSipHasher` type. This type's `Default`
  implementation would randomly seed the `SipHasher` instance, and otherwise
  perform the same as `SipHasher`.

  This future state doesn't seem incredibly far off, but until that time comes,
  the hashmap module will live in libstd to not compromise on functionality.

* In preparation for the hashmap moving to libcollections, the `hash` module has
  moved from libstd to libcollections. A previously snapshotted commit enables a
  distinct `Writer` trait to live in the `hash` module which `Hash`
  implementations are now parameterized over.

  Due to using a custom trait, the `SipHasher` implementation has lost its
  specialized methods for writing integers. These can be re-added
  backwards-compatibly in the future via default methods if necessary, but the
  FNV hashing should satisfy much of the need for speedier hashing.

A list of breaking changes:

* HashMap::{get, get_mut} no longer fails with the key formatted into the error
  message with `{:?}`, instead, a generic message is printed. With backtraces,
  it should still be not-too-hard to track down errors.

* The HashMap, HashSet, and LruCache types are now available through
  std::collections instead of the collections crate.

* Manual implementations of hash should be parameterized over `hash::Writer`
  instead of just `Writer`.

[breaking-change]
2014-06-05 15:01:54 -07:00
Alex Crichton 760b93adc0 Fallout from the libcollections movement 2014-06-05 13:55:11 -07:00
Alex Crichton 6a585375a0 std: Recreate a `collections` module
As with the previous commit with `librand`, this commit shuffles around some
`collections` code. The new state of the world is similar to that of librand:

* The libcollections crate now only depends on libcore and liballoc.
* The standard library has a new module, `std::collections`. All functionality
  of libcollections is reexported through this module.

I would like to stress that this change is purely cosmetic. There are very few
alterations to these primitives.

There are a number of notable points about the new organization:

* std::{str, slice, string, vec} all moved to libcollections. There is no reason
  that these primitives shouldn't be necessarily usable in a freestanding
  context that has allocation. These are all reexported in their usual places in
  the standard library.

* The `hashmap`, and transitively the `lru_cache`, modules no longer reside in
  `libcollections`, but rather in libstd. The reason for this is because the
  `HashMap::new` contructor requires access to the OSRng for initially seeding
  the hash map. Beyond this requirement, there is no reason that the hashmap
  could not move to libcollections.

  I do, however, have a plan to move the hash map to the collections module. The
  `HashMap::new` function could be altered to require that the `H` hasher
  parameter ascribe to the `Default` trait, allowing the entire `hashmap` module
  to live in libcollections. The key idea would be that the default hasher would
  be different in libstd. Something along the lines of:

      // src/libstd/collections/mod.rs

      pub type HashMap<K, V, H = RandomizedSipHasher> =
            core_collections::HashMap<K, V, H>;

  This is not possible today because you cannot invoke static methods through
  type aliases. If we modified the compiler, however, to allow invocation of
  static methods through type aliases, then this type definition would
  essentially be switching the default hasher from `SipHasher` in libcollections
  to a libstd-defined `RandomizedSipHasher` type. This type's `Default`
  implementation would randomly seed the `SipHasher` instance, and otherwise
  perform the same as `SipHasher`.

  This future state doesn't seem incredibly far off, but until that time comes,
  the hashmap module will live in libstd to not compromise on functionality.

* In preparation for the hashmap moving to libcollections, the `hash` module has
  moved from libstd to libcollections. A previously snapshotted commit enables a
  distinct `Writer` trait to live in the `hash` module which `Hash`
  implementations are now parameterized over.

  Due to using a custom trait, the `SipHasher` implementation has lost its
  specialized methods for writing integers. These can be re-added
  backwards-compatibly in the future via default methods if necessary, but the
  FNV hashing should satisfy much of the need for speedier hashing.

A list of breaking changes:

* HashMap::{get, get_mut} no longer fails with the key formatted into the error
  message with `{:?}`, instead, a generic message is printed. With backtraces,
  it should still be not-too-hard to track down errors.

* The HashMap, HashSet, and LruCache types are now available through
  std::collections instead of the collections crate.

* Manual implementations of hash should be parameterized over `hash::Writer`
  instead of just `Writer`.

[breaking-change]
2014-06-05 13:55:10 -07:00
bors 3ec321f535 auto merge of #14647 : BurntSushi/rust/fix-14185, r=alexcrichton
This fix suppresses dead_code warnings from code generated by regex! when
the result of regex! is unused. Correct behavior should be a single
unused variable warning.

Regression tests are included for both `let` and `static` bound regex!
values.

see #14185
2014-06-05 13:26:53 -07:00
Marvin Löbel 792fae35f7 Purged "record" from the manual.
Also updated/corrected a few other details in the tuple and struct sections.
2014-06-05 21:31:57 +02:00
bors d70a9b93d0 auto merge of #14526 : pczarn/rust/hashmap-opt, r=alexcrichton
An interface that gives a better control over the load factor and the minimum capacity for HashMap.
The size of `HashMap<K, V>` is now 64 bytes by default on a 64-bit platform (or at least 40 bytes, that is 3 words less, with FNV and without minimum capacity)

Unanswered questions about `ResizePolicy`

* should it control the `INITIAL_CAPACITY`?
* should it fully control the resizing behavior? Even though the capacity always changes by a factor of 2.
* is caching `grow_at` desirable?

special thanks to @eddyb and @pnkfelix
2014-06-05 11:06:53 -07:00
Brian Anderson b45553f075 How about a less cringe-worthy double-failure message? 2014-06-05 10:21:35 -07:00
Axel Viala 85adc09b19 Improve documentation on std::os::env. 2014-06-05 17:36:15 +02:00
bors 57e7147f3e auto merge of #14644 : alexcrichton/rust/more-no-runtime-use-cases, r=brson
A few notable improvements were implemented to cut down on the number of aborts
triggered by the standard library when a local task is not found.

* Primarily, the unwinding functionality was restructured to support an unsafe
  top-level function, `try`. This function invokes a closure, capturing any
  failure which occurs inside of it. The purpose of this function is to be as
  lightweight of a "try block" as possible for rust, intended for use when the
  runtime is difficult to set up.

  This function is *not* meant to be used by normal rust code, nor should it be
  consider for use with normal rust code.

* When invoking spawn(), a `fail!()` is triggered rather than an abort.

* When invoking LocalIo::borrow(), which is transitively called by all I/O
  constructors, None is returned rather than aborting to indicate that there is
  no local I/O implementation.

A test case was also added showing the variety of things that you can do without
a runtime or task set up now. In general, this is just a refactoring to abort
less quickly in the standard library when a local task is not found.
2014-06-05 08:26:51 -07:00
bors bb57e417ea auto merge of #14643 : jakub-/rust/infinite-loop-unreachable, r=alexcrichton 2014-06-05 06:46:54 -07:00
bors a7ac6a4eb7 auto merge of #14642 : aochagavia/rust/pr, r=alexcrichton
The contents of a `RingBuf` are shown in the same way as the contents of a `Vector`. See the tests for examples.
2014-06-05 05:11:54 -07:00
bors f2821f2c29 auto merge of #14640 : tomjakubowski/rust/fix-14636, r=huonw
Previously, documentation for an inlined trait (i.e. a trait imported
and reexported from another crate) didn't display the trait's supertraits.

Closes #14636
2014-06-05 03:36:52 -07:00
Axel Viala f377dfe5ac Adding examples and possible failures for getcwd.
For both window and unix platforms.
2014-06-05 11:39:01 +02:00
Tom Jakubowski 2382bf42df rustdoc: Include supertraits on inlined traits
Previously, documentation for an inlined trait (i.e. a trait imported
and reexported from another crate) didn't display the trait's
supertraits.

Closes #14636
2014-06-05 01:43:30 -07:00
Guillaume Pinot ec8ef0d24d relicense shootout-meteor.rs
part of #14248, fix #14420

Removed @richo's contribution (outdated comment)

Quoting @brson: let's move forward with this one. The only
statement I'm missing is @richo's and it sounds like his was a
minor patch.
2014-06-05 10:39:09 +02:00
bors 0c74911f87 auto merge of #14568 : erickt/rust/slice-update, r=alexcrichton
This PR adds two features to make it possible to transform an `Iterator<u8>` into a `Reader`. The first patch adds a method to mutable slices that allows it to be updated with an `Iterator<T>` without paying for the bounds cost. The second adds a Iterator adaptor, `IterReader`, to provide that `Reader` interface.

I had two questions. First, are these named the right things? Second, should `IterReader` instead wrap an `Iterator<Result<u8, E>>`? This would allow you to `IterReader::new(rdr.bytes())`, which could be useful if you want to apply some iterator transformations on a reader while still exporting the Reader interface, but I'd expect there'd be a lot of overhead annotating each byte with an error result.
2014-06-05 00:51:48 -07:00
Jonathan Reem 7e0cc34d62 Fixed weird grammar in lifetimes guide. 2014-06-04 22:27:21 -07:00
bors 073c8f10fc auto merge of #14592 : alexcrichton/rust/rustdoc-links, r=huonw
These are a few assorted fixes for some issues I found this morning (details in the commits).
2014-06-04 22:21:43 -07:00
bors 422d54bed2 auto merge of #14610 : alexcrichton/rust/issue-14008, r=brson
This commit removes the <M: Any + Send> type parameter from Option::expect in
favor of just taking a hard-coded `&str` argument. This allows this function to
move into libcore.

Previous code using strings with `expect` will continue to work, but code using
this implicitly to transmit task failure will need to unwrap manually with a
`match` statement.

[breaking-change]
Closes #14008
2014-06-04 20:41:44 -07:00
Brian Anderson 9b228f8424 core: Apply stability attributes to ptr mod
* null and mut_null are unstable. Their names may change if the unsafe
  pointer types change.
* copy_memory and copy_overlapping_memory are unstable. We think they
  aren't going to change.
* set_memory and zero_memory are experimental. Both the names and
  the semantics are under question.
* swap and replace are unstable and probably won't change.
* read is unstable, probably won't change
* read_and_zero is experimental. It's necessity is in doubt.
* mem::overwrite is now called ptr::write to match read and is
  unstable. mem::overwrite is now deprecated
* array_each, array_each_with_len, buf_len, and position are
  all deprecated because they use old style iteration and their
  utility is generally under question.
2014-06-04 18:21:21 -07:00
bors aa09561bb6 auto merge of #14633 : huonw/rust/nodylibc, r=alexcrichton
libc: only provide an rlib.

There's absolutely no reason for `libc` to be offered as a dynamic
library.
2014-06-04 15:26:50 -07:00
Andrew Gallant 0f73bf32fe Fixes #14185.
This fix suppresses dead_code warnings from code generated by regex! when
the result of regex! is unused. Correct behavior should be a single
unused variable warning.

Regression tests are included for both `let` and `static` bound regex!
values.
2014-06-04 16:59:27 -04:00
bors ef9bf3a4ee auto merge of #14630 : cmr/rust/rewrite-lexer, r=alexcrichton
These are a pain to rebase, so I'm separating this from the rest of my work.
Nothing controversial here, just some simple refactoring and removal of an
unused entry in the token table. Brings the lexer into 2012 with methods!
2014-06-04 13:06:47 -07:00
Corey Richardson 181e5f3fc8 syntax: use doc comments in the interner 2014-06-04 12:10:46 -07:00
Corey Richardson 46d1af28b5 syntax: methodify the lexer 2014-06-04 12:10:46 -07:00
Alex Crichton 0c7c93b8e8 std: Improve non-task-based usage
A few notable improvements were implemented to cut down on the number of aborts
triggered by the standard library when a local task is not found.

* Primarily, the unwinding functionality was restructured to support an unsafe
  top-level function, `try`. This function invokes a closure, capturing any
  failure which occurs inside of it. The purpose of this function is to be as
  lightweight of a "try block" as possible for rust, intended for use when the
  runtime is difficult to set up.

  This function is *not* meant to be used by normal rust code, nor should it be
  consider for use with normal rust code.

* When invoking spawn(), a `fail!()` is triggered rather than an abort.

* When invoking LocalIo::borrow(), which is transitively called by all I/O
  constructors, None is returned rather than aborting to indicate that there is
  no local I/O implementation.

* Invoking get() on a TLD key will return None if no task is available

* Invoking replace() on a TLD key will fail if no task is available.

A test case was also added showing the variety of things that you can do without
a runtime or task set up now. In general, this is just a refactoring to abort
less quickly in the standard library when a local task is not found.
2014-06-04 11:13:12 -07:00
bors 7645982efc auto merge of #14623 : exscape/rust-fork/master, r=alexcrichton
Unlike ImmutableClonableVector::permutations() which returns an iterator,
cloning the entire array each iteration, these methods mutate the vector in-place.
For that reason, these methods are much faster; between 35-55 times faster,
depending on the benchmark. They also generate permutations in lexicographical order.
2014-06-04 11:06:49 -07:00
Piotr Czarnecki 2202b104d4 collections: optimize `HashMap`. Add `DefaultResizePolicy`.
Refactored the load factor and the minimum capacity out of HashMap.
The size of HashMap<K, V> is now 64 bytes by default on a 64-bit platform
(or 48 bytes, that is 2 words less, with FNV)
Added a documentation in a few places to clarify the behavior.
2014-06-04 19:04:38 +02:00
Jakub Wieczorek b9752b68ae Fix an ICE when a function argument is of the bottom type
Fixes #13352
2014-06-04 18:38:02 +02:00
Jakub Wieczorek 6d3e89e33c Mark the exit of infinite loops as unreachable 2014-06-04 18:37:46 +02:00
bors a6401b5226 auto merge of #14616 : forticulous/rust/rc-show, r=alexcrichton
Show impl for Rc
2014-06-04 08:11:51 -07:00
Adolfo Ochagavía 8e4e3abb1d Implement Show for RingBuf 2014-06-04 16:40:30 +02:00
Axel Viala 650909244e Add code example to std::os::getenv for unix. 2014-06-04 16:02:48 +02:00
Huon Wilson 96cc48fba2 libc: only provide an rlib.
There's absolutely no reason for `libc` to be offered as a dynamic
library.
2014-06-04 19:10:40 +10:00
bors d130acc0d0 auto merge of #14635 : BurntSushi/rust/regex-doco-touchups, r=alexcrichton 2014-06-03 23:51:41 -07:00
bors 5a6dc40a10 auto merge of #14634 : BurntSushi/rust/fix-13843, r=alexcrichton
An empty regex is a valid regex that always matches. This behavior
is consistent with at least Go and Python.

A couple regression tests are included.

I'd just assume that an empty regex is an invalid regex and that an error should be returned (I can't think of any reason to use an empty regex?), but it's probably better to be consistent with other regex libraries.
2014-06-03 22:01:43 -07:00
Corey Richardson 5343eb7e0c Add comments for the token table 2014-06-03 21:01:53 -07:00
Corey Richardson 024df5c8a6 syntax: shuffle some allocation out of binop_to_str 2014-06-03 21:00:55 -07:00
Andrew Gallant 179fc6dbfd Some minor documentation touchups for libregex. Fixes #13800. 2014-06-03 23:45:54 -04:00
Andrew Gallant 9d39178f2f Fixes #13843.
An empty regex is a valid regex that always matches. This behavior
is consistent with at least Go and Python.

A couple regression tests are included.
2014-06-03 23:04:59 -04:00
bors 3eeaa84a50 auto merge of #14628 : luqmana/rust/fcr, r=nikomatsakis
#14589.
2014-06-03 19:36:42 -07:00
Alex Crichton 1827241840 rustdoc: Put primitives in respective modules
The logical location for the documentation of a primitive is in the module that
declared it was a module for that primitive.
2014-06-03 18:49:14 -07:00
bors 507c1a0fc9 auto merge of #14632 : luqmana/rust/cu, r=huonw
The distinction doesn't make sense any more since we don't have do blocks anymore.
2014-06-03 17:46:46 -07:00
Alex Crichton 896cfcc67f std: Remove generics from Option::expect
This commit removes the <M: Any + Send> type parameter from Option::expect in
favor of just taking a hard-coded `&str` argument. This allows this function to
move into libcore.

Previous code using strings with `expect` will continue to work, but code using
this implicitly to transmit task failure will need to unwrap manually with a
`match` statement.

[breaking-change]
Closes #14008
2014-06-03 17:19:56 -07:00
Luqman Aden 559ff5e64b librustc: remove check::FnKind enum since we only ever use one variant. 2014-06-03 19:04:29 -04:00
bors f5ead0dd66 auto merge of #14627 : Indiv0/rust/fix-crateid-doc-typo, r=alexcrichton
Example URL in CrateId documentation is:

    `gihub.com/mozilla/rust`

Instead of:

    `github.com/mozilla/rust`

Also update libsyntax/crateid.rs licensing header for 2014.
2014-06-03 16:01:44 -07:00
bors 2ec3eeaba8 auto merge of #14626 : klutzy/rust/issue-14618, r=alexcrichton
As part of removing `pub use` glob, two extra import globs were
injected to make `quote_expr!` work. However the globs caused
`unused_import` warning in some places.

Quasiquoter needed the globs since it generated idents (e.g. `TyU`)
rather than absolute paths (`::syntax::ast::TyU`).
This patch removes the extra globs and makes quasiquoter use absolute
paths.

Fixes #14618

cc @sfackler
2014-06-03 14:06:42 -07:00
Luqman Aden 0a9eafaa1c librustc: Try to resolve before coercions. 2014-06-03 15:38:04 -04:00
bors 8d8a291e1c auto merge of #14625 : japaric/rust/slice-tojson, r=alexcrichton
Let me know if the amount of tests is enough or too much.
2014-06-03 11:46:51 -07:00
Nikita Pekin 296102ec86 Fix typo "gihub" in libsyntax/crateid.
Update licensing header for 2014.
2014-06-03 14:30:59 -04:00
bors 7fa5baa7ca auto merge of #14622 : reillywatson/rust/master, r=alexcrichton 2014-06-03 10:01:40 -07:00
klutzy 1ec6de3ecf syntax: Make quasiquoter use absolute paths
As part of removing `pub use` glob, two extra import globs were
injected to make `quote_expr!` work. However the globs caused
`unused_import` warning in some places.

Quasiquoter needed the globs since it generated idents (e.g. `TyU`)
rather than absolute paths (`::syntax::ast::TyU`).
This patch removes the extra globs and makes quasiquoter use absolute
paths.

Fixes #14618
2014-06-04 02:00:03 +09:00
Jorge Aparicio a413d005a7 Implement ToJson for &[T], and add tests. Closes #14619 2014-06-03 10:52:54 -05:00
Reilly Watson 5b80172f10 Doc: grammar fix in intro.md 2014-06-03 10:24:54 -04:00
Thomas Backman 3b5d6fd254 Add next_permutation and prev_permutation onto MutableOrdVector<T>.
Unlike ImmutableClonableVector::permutations() which returns an iterator,
cloning the entire array each iteration, these methods mutate the vector in-place.
For that reason, these methods are much faster; between 35-55 times faster,
depending on the benchmark. They also generate permutations in lexicographical order.
2014-06-03 16:11:47 +02:00
Piotr Jawniak 468cabf8d9 Update README file for src/ directory 2014-06-03 14:06:54 +02:00
bors 918dbfea60 auto merge of #14609 : aturon/rust/issue-12882, r=alexcrichton 2014-06-02 20:51:30 -07:00
Erick Tryzelaar 30a8bcbe3d std: add `IterReader` to adapt iterators into readers 2014-06-02 20:42:41 -07:00
bors eb1664600c auto merge of #14605 : jakub-/rust/pattern-matching-refactor, r=pcwalton
I've been working around these parts of code and it seems like it could use a bit of a refactor. This is the first step.
2014-06-02 19:01:32 -07:00
fort c6f10f8831 Adding show impl for Rc 2014-06-02 18:53:08 -07:00
bors 63e9b8f105 auto merge of #14601 : skade/rust/remove-notrust-tags, r=alexcrichton
Now that rustdoc understands proper language tags
as the code not being Rust, we can tag everything
properly. `norust` as a negative statement is a bad
tag.

This change tags examples in other languages by
their language. Plain notations are marked as `text`.
Console examples are marked as `console`.

Also fix markdown.rs to not highlight non-rust code.

Amends the documentation to reflect the new
behaviour.
2014-06-02 17:16:31 -07:00
bors 455f574470 auto merge of #14598 : alexcrichton/rust/triage, r=huonw
Closes #10764
2014-06-02 15:26:29 -07:00
Aaron Turon 7526a80ede Document failure cases for `char_at` and friends. 2014-06-02 15:22:17 -07:00
bors 837013717a auto merge of #14509 : klutzy/rust/de-pub-use-glob, r=alexcrichton
This patchset removes `pub use` usage except for `test/`.
cc #11870
2014-06-02 12:46:31 -07:00