Commit graph

26341 commits

Author SHA1 Message Date
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
Jakub Wieczorek
774f36b5d8 Remove further code duplication 2014-06-02 20:49:44 +02:00
Jakub Wieczorek
19e10e3a81 Improve code reuse in check_match::specialize() 2014-06-02 18:41:48 +02:00
Alex Crichton
60e0f6fbb0 test: Add tests for closed issue #10764
Closes #10764
2014-06-02 09:24:03 -07:00
Alex Crichton
f02f739a82 rustdoc: Correctly inline required/provided methods
Apparently relying on provided_source in ty::Method is unreliable!

Closes #14594
2014-06-02 09:18:32 -07:00
Alex Crichton
287af7fa1a rustdoc: Deduplicate lists of implementors
Inlining caused implementors to show up multiple times.

cc #14584
2014-06-02 09:18:26 -07:00
klutzy
976c8324e1 syntax: Remove use of pub use globs
`quote_expr!` now injects two more (priv) `use` globs.
This may cause extra unused_imports warning.
2014-06-02 23:21:40 +09:00
klutzy
e38fde71b1 doc: Remove use of pub use globs 2014-06-02 23:21:35 +09:00
Florian Gilcher
20fb7c62d4 docs: Stop using notrust
Now that rustdoc understands proper language tags
as the code not being Rust, we can tag everything
properly.

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.
2014-06-02 12:37:54 +02:00
bors
46dad765f0 auto merge of #14596 : Sawyer47/rust/encodable-fix, r=alexcrichton
Closes #14021
2014-06-02 01:06:39 -07:00
Piotr Jawniak
1dc13e4ad4 Fix deriving Encodable trait for unit structs
Closes #14021
2014-06-02 07:46:32 +02:00
bors
b981add9ee auto merge of #14569 : skade/rust/rustdoc-robust-langstring-parsing, r=alexcrichton
This changes the parsing of the language string
in code examples so that unrecognized examples
are not considered Rust code. This was, for example,
the case when a code example was marked `sh` for shell
code.

This relieves authors of having to mark those samples
as `notrust`.

Also adds recognition of the positive marker `rust`.

By default, unmarked examples are still considered rust.
2014-06-01 22:01:36 -07:00
Alex Crichton
e1e8db7e4a rustdoc: Ensure external impls are inlined once
If the type associated with the impl is `pub use`'d or referenced twice in a
downstream crate, the impl will attempt to be inlined twice.

Closes #14584
2014-06-01 21:53:43 -07:00
Alex Crichton
f71f97b7c2 rustdoc: Filter private methods from inlined impls
Closes #14583
2014-06-01 21:53:43 -07:00
Alex Crichton
0dbfa5f611 rustdoc: Fix some more broken links 2014-06-01 21:53:43 -07:00
klutzy
42e4464198 test: Enable #9205-related tests on windows
Fixes #9205.
2014-06-02 12:08:19 +09:00
Florian Gilcher
3fef7a74ca rustdoc: make langstring parsing more robust
This changes the parsing of the language string
in code examples so that unrecognized examples
are not considered Rust code. This was, for example,
the case when a code example was marked `sh` for shell
code.

This relieves authors of having to mark those samples
as `notrust`.

Also adds recognition of the positive marker `rust`.

By default, unmarked examples are still considered rust.

If any rust-specific tags are seen, code is considered
rust unless marked as "notrust".

Adds test cases for the detection logic.
2014-06-02 00:16:48 +02:00
Alex Crichton
bba701c59d std: Drop Total from Total{Eq,Ord}
This completes the last stage of the renaming of the comparison hierarchy of
traits. This change renames TotalEq to Eq and TotalOrd to Ord.

In the future the new Eq/Ord will be filled out with their appropriate methods,
but for now this change is purely a renaming change.

[breaking-change]
2014-06-01 10:31:27 -07:00
bors
c605c2b57b auto merge of #14580 : utkarshkukreti/rust/fix-docs-for-result-map, r=alexcrichton
`reader.read_line()` includes trailing newline char, which makes
`from_str` always return `None`.
2014-06-01 04:36:38 -07:00
bors
dfaea70963 auto merge of #14578 : huonw/rust/as_slice-cheatsheet, r=sfackler
doc: add an `.as_slice` example to the cheatsheet.

A lot of questions about this on IRC and stackoverflow.
2014-06-01 02:36:39 -07:00
bors
064dbb9200 auto merge of #14571 : bnoordhuis/rust/libtest-check-isatty, r=alexcrichton
Fixes #14570.
2014-06-01 00:56:42 -07:00
Utkarsh Kukreti
cf4864a7a5 Fix docs for core::result::Result::map.
`reader.read_line()` includes trailing newline char, which makes
`from_str` always return `None`.
2014-06-01 12:18:39 +05:30
bors
4e0b936900 auto merge of #14513 : alexcrichton/rust/rustdoc-primitives, r=huonw
This is currently rebased on top of #14478, but that's just to preemptively avoid rebase conflicts and to provide a better preview. This can land independently of that PR.

This change crates a dedicated page in rustdoc for primitive types to outline everything you can do with them (at least in a basic way).

* Preview - http://people.mozilla.org/~acrichton/doc/
* Exhibit A - http://people.mozilla.org/~acrichton/doc/std/#primitives
* Exhibit B - http://people.mozilla.org/~acrichton/doc/std/primitive.str.html
* Exhibit C - http://people.mozilla.org/~acrichton/doc/std/primitive.slice.html

Please don't hesitate to be nitpickity, it's easy to overlook a thing here or there!
2014-05-31 23:16:42 -07:00
Alex Crichton
d58f27a82f syntax: Fix an accidental hyperlink in a comment 2014-05-31 22:00:26 -07:00
Alex Crichton
31f5de610f rustdoc: Don't inline tuple struct constructors
These don't actually point to anything, so there's no need to inline them.
2014-05-31 21:59:50 -07:00
Alex Crichton
7ec6df5f45 rustdoc: Fix cross-crate links to reexported items
Cross crate links can target items which are not rendered in the documentation.
If the item is reexported at a higher level, the destination of the link (a
concatenation of the fully qualified name) may actually lead to nowhere. This
fixes this problem by altering rustdoc to emit pages which redirect to the local
copy of the reexported structure.

cc #14515
Closes #14137
2014-05-31 21:59:50 -07:00
Alex Crichton
c5830a954e doc: Fix a number of broken links
cc #14515
2014-05-31 21:59:50 -07:00
Alex Crichton
8c669d7f74 rustdoc: Suck in all impls from external crates
There is currently no way to query all impls for a type from an external crate,
and with primitive types in play this is also quite difficult. Instead of
filtering, just suck in all impls from upstream crates into the local AST, and
have them get stripped later.

This will allow population of all implementations of traits for primitive types,
as well as filling in some corner cases with inlining documentation in other
cases.
2014-05-31 21:59:50 -07:00
Alex Crichton
c2564b8fd4 rustdoc: Filter inlining private external items
This prevents structures like RcBox from showing up in the documentation
2014-05-31 21:59:50 -07:00
Alex Crichton
c2e3aa37da rustdoc: Create anchor pages for primitive types
This commit adds support in rustdoc to recognize the `#[doc(primitive = "foo")]`
attribute. This attribute indicates that the current module is the "owner" of
the primitive type `foo`. For rustdoc, this means that the doc-comment for the
module is the doc-comment for the primitive type, plus a signal to all
downstream crates that hyperlinks for primitive types will be directed at the
crate containing the `#[doc]` directive.

Additionally, rustdoc will favor crates closest to the one being documented
which "implements the primitive type". For example, documentation of libcore
links to libcore for primitive types, but documentation for libstd and beyond
all links to libstd for primitive types.

This change involves no compiler modifications, it is purely a rustdoc change.
The landing pages for the primitive types primarily serve to show a list of
implemented traits for the primitive type itself.

The primitive types documented includes both strings and slices in a semi-ad-hoc
way, but in a way that should provide at least somewhat meaningful
documentation.

Closes #14474
2014-05-31 21:59:50 -07:00
Alex Crichton
ba9be0a72b rustdoc: Fill in external type parameters correctly
Type parameters were filled in for some areas, but not all. This commit unifies
the two code paths to fill in type parameters everywhere.

Closes #14508
2014-05-31 21:59:50 -07:00
Alex Crichton
19fe4aad68 rustdoc: Stringify more named lifetimes
cc #14462
2014-05-31 21:59:50 -07:00
Alex Crichton
658924068e rustdoc: Show all implementors of traits
When inlining documentation across crates, primitive implementors of traits were
not shown. This commit tweaks the infrastructure to treat primitive and
Path-like impls the same way, displaying all implementors everywhere.

cc #14462
2014-05-31 21:59:50 -07:00
Alex Crichton
0777ce86e1 rustdoc: Freeze the cache ASAP
The cache is going to be used earlier in the HTML generation process, which
means that it needs to get into TLS as soon as possible.
2014-05-31 21:59:50 -07:00
Alex Crichton
356423d8f1 rustdoc: Refactor structure of html::run
Instead of one giant function, this breaks it up into several smaller functions
which have explicit dependencies among one another.

There are no code changes as a result of this commit.
2014-05-31 21:59:50 -07:00
bors
5527c5dc06 auto merge of #14561 : jakub-/rust/issue-11319, r=alexcrichton
Fixes #11319
2014-05-31 21:41:46 -07:00
Huon Wilson
aec7f46902 doc: add an .as_slice example to the cheatsheet.
A lot of questions about this on IRC and stackoverflow.
2014-06-01 14:13:10 +10:00
bors
ee97698f85 auto merge of #14567 : cburgdorf/rust/patch-2, r=brson
This rewrites the example to also be more aligned with
the same example given in the main tutorial.
2014-05-31 20:01:45 -07:00
Christoph Burgdorf
ade5a9d2fe Fix example in lifetime guide
This rewrites the example to also be more aligned with
the same example given in the main tutorial.
2014-05-31 23:41:50 +02:00
Christoph Burgdorf
b657af8946 Rename variable in tutorial
Renamed `owned_box` to `on_the_heap` to use a consistent
naming across the tutorial and the life time guide.
Also it makes the example easier to grasp.
2014-05-31 23:33:03 +02:00
Ben Noordhuis
87ecd4f75b libtest: Only colorize output if stdout is a tty
Fixes #14570.
2014-05-31 21:55:18 +02:00
Jakub Wieczorek
b64046a5b0 Make the match arm type mismatch message point to the arm's span
Fixes #11319
2014-05-31 21:10:02 +02:00
bors
60b4a97de7 auto merge of #14562 : jakub-/rust/issue-14541, r=alexcrichton
Fixes #14541
2014-05-31 11:21:38 -07:00
bors
b38712071e auto merge of #14565 : fhartwig/rust/master, r=sfackler 2014-05-31 09:36:39 -07:00
Florian Hartwig
096f80e770 Fix broken markup in query_to_str documentation 2014-05-31 17:46:35 +02:00
bors
2f221c766b auto merge of #14563 : dotdash/rust/clone_kill, r=huonw
By dropping the intermediate vector that holds the relevant candidates
including duplicates and directly building the vector that has the
duplicates removed we can eliminate quite a few allocations. This
reduces the times for type checking by 5-10% (measured with libstd,
libsyntax and librustc).
2014-05-31 07:56:39 -07:00
bors
0839e940a5 auto merge of #14557 : zwarich/rust/missing-comment, r=alexcrichton
For some reason, I had this comment in my local tree but not in the
branch I sent with the PR.
2014-05-31 06:16:40 -07:00
Björn Steinbrink
cd844c5fb5 Remove unnecessary allocations / clones during method lookup
By dropping the intermediate vector that holds the relevant candidates
including duplicates and directly building the vector that has the
duplicates removed we can eliminate quite a few allocations. This
reduces the times for type checking by 5-10% (measured with libstd,
libsyntax and librustc).
2014-05-31 14:58:12 +02:00
bors
bcf3464827 auto merge of #14556 : sfackler/rust/kill-workcache, r=alexcrichton
This was only ever used by rustpkg and is very unmaintained.

[breaking-change]
2014-05-31 04:26:40 -07:00
Jakub Wieczorek
80e84e0001 Use RHS's struct def ID for error messages in pattern matching
Fixes #14541
2014-05-31 12:50:14 +02:00
bors
2652ba1505 auto merge of #14555 : tomjakubowski/rust/fix-snappy-link, r=alexcrichton
Google have migrated snappy to GitHub.
2014-05-31 02:46:38 -07:00
bors
faa7ba75a7 auto merge of #14553 : reem/rust/nuke-owned-vectors, r=alexcrichton
I removed all remaining deprecated owned vectors from the docs. All example tests pass.
2014-05-31 01:06:40 -07:00
Steven Fackler
c56c286b10 Remove libworkcache
This was only ever used by rustpkg and is very unmaintained.

[breaking-change]
2014-05-30 23:44:05 -07:00
bors
92c43dba50 auto merge of #14544 : aturon/rust/issue-14352, r=alexcrichton
Adds a platform-specific function, `split_paths` to the `os` module. This
function can be used to parse PATH-like environment variables according to
local platform conventions.

Closes #14352.
2014-05-30 23:01:43 -07:00
Cameron Zwarich
3bc76d27ae Add a comment missing from 5aff0e7
For some reason, I had this comment in my local tree but not in the
branch I sent with the PR.
2014-05-30 22:31:05 -07:00
Jonathan Reem
1959925e51 Remove deprecated owned vector from tutorial. 2014-05-30 21:30:21 -07:00
Jonathan Reem
66ee71a517 Remove deprecated owned vector from rust.md 2014-05-30 21:30:21 -07:00
Jonathan Reem
f740e8dde1 Remove deprecated owned vector from macro guide. 2014-05-30 21:30:20 -07:00
Jonathan Reem
c3825cbb9d Remove deprecated owned vector from intro. 2014-05-30 21:30:20 -07:00
Jonathan Reem
0033a8b269 Remove deprecated owned vector from complement cheatsheet. 2014-05-30 21:30:18 -07:00
Tom Jakubowski
7cd4879126 Fix outgoing link to snappy in the FFI guide
Google have migrated snappy to GitHub.
2014-05-30 21:27:47 -07:00
bors
60a43f9bc5 auto merge of #14534 : alexcrichton/rust/snapshots, r=sfackler
This is part 2 of the saga of renaming the Partial/Total equality and comparison traits.
2014-05-30 21:21:39 -07:00
Aaron Turon
b1fbbf3e48 Add os::split_paths
Adds a platform-specific function, `split_paths` to the `os` module. This
function can be used to parse PATH-like environment variables according to
local platform conventions.

Closes #14352.
2014-05-30 21:10:48 -07:00
Alex Crichton
bb96ee6123 syntax: Prepare for Total{Eq,Ord} => {Eq,Ord}
This commit adds the groundwork for the renaming of the Total{Eq,Ord} traits.
After this commit hits a snapshot, the traits can be renamed.
2014-05-30 16:03:25 -07:00
bors
cc4513202d auto merge of #14547 : reem/rust/remove-owned-vec-docs, r=alexcrichton
The last example in the containers and iterators guide had a superfluous owned vector in it. Everything works fine without it, so I removed it to avoid confusion.
2014-05-30 16:01:35 -07:00
Alex Crichton
748bc3ca49 std: Rename {Eq,Ord} to Partial{Eq,Ord}
This is part of the ongoing renaming of the equality traits. See #12517 for more
details. All code using Eq/Ord will temporarily need to move to Partial{Eq,Ord}
or the Total{Eq,Ord} traits. The Total traits will soon be renamed to {Eq,Ord}.

cc #12517

[breaking-change]
2014-05-30 15:52:24 -07:00
Alex Crichton
f4fa7c8a07 Register new snapshots 2014-05-30 15:52:23 -07:00
bors
e5e865b804 auto merge of #14536 : zwarich/rust/issue-14498, r=luqmana
Make check_for_assignment_to_restricted_or_frozen_location treat
mutation through an owning pointer the same way it treats mutation
through an &mut pointer, where mutability must be inherited from the
base path.

I also included GC pointers in this check, as that is what the
corresponding code in gather_loans/restrictions.rs does, but I don't
think there is a way to test this with the current language.

Fixes #14498.
2014-05-30 12:41:39 -07:00
Jonathan Reem
3dace35044 Remove deprecated owned vector from iterator example. 2014-05-30 12:18:52 -07:00
bors
24e489f1e1 auto merge of #14520 : Ryman/rust/SnakeCaseLint, r=alexcrichton
This enforces `snake_case` for functions and methods only. Might be worth extending it to fields and locals too at some point in the future.

A number of breaking changes each detailed in the attached commits.
2014-05-30 11:01:37 -07:00
Kevin Butler
030b3a2499 windows: Allow snake_case errors for now. 2014-05-30 17:59:41 +01:00
Kevin Butler
09fc34066b librustc: Fix snake case errors.
A number of functions/methods have been moved or renamed to align
better with rust standard conventions.

rustc:🔙🔗:WriteOutputFile => write_output_file
rustc::middle::ty::EmptyBuiltinBounds => empty_builtin_bounds
rustc::middle::ty::AllBuiltinBounds => all_builtin_bounds
rustc::middle::liveness::IrMaps => IrMaps::new
rustc::middle::liveness::Liveness => Liveness::new
rustc::middle::resolve::NameBindings => NameBindings::new
rustc::middle::resolve::PrimitiveTypeTable => PrimitiveTypeTable::new
rustc::middle::resolve::Resolver => Resolver::new
rustc::middle::trans::datum::Datum => Datum::new
rustc::middle::trans::datum::DatumBlock => DatumBlock::new
rustc::middle::trans::datum::Rvalue => Rvalue::new
rustc::middle::typeck::infer::new_ValsAndBindings => ::infer::unify::ValsAndBindings::new
rustc::middle::typeck::infer::region_inference::RegionVarBindings => RegionVarBindings::new

[breaking-change]
2014-05-30 17:55:42 +01:00
Kevin Butler
ed5bf6621e lib{serialize, uuid}: Fix snake case errors.
A number of functions/methods have been moved or renamed to align
better with rust standard conventions.

serialize::ebml::reader::Doc => seriaize::ebml::Doc::new
serialize::ebml::reader::Decoder => Decoder::new
serialize::ebml::writer::Encoder => Encoder::new

[breaking-change]
2014-05-30 17:55:41 +01:00
Kevin Butler
3faa6762c1 lib{std,core,debug,rustuv,collections,native,regex}: Fix snake_case errors.
A number of functions/methods have been moved or renamed to align
better with rust standard conventions.

std::reflect::MovePtrAdaptor => MovePtrAdaptor::new
debug::reflect::MovePtrAdaptor => MovePtrAdaptor::new
std::repr::ReprVisitor => ReprVisitor::new
debug::repr::ReprVisitor => ReprVisitor::new
rustuv::homing::HomingIO.go_to_IO_home => go_to_io_home

[breaking-change]
2014-05-30 17:55:41 +01:00
Kevin Butler
190d8bdbc6 libsyntax: Fix snake_case errors.
A number of functions/methods have been moved or renamed to align
better with rust standard conventions.

syntax::ext::mtwt::xorPush => xor_push
syntax::parse::parser::Parser => Parser::new

[breaking-change]
2014-05-30 17:55:41 +01:00
Kevin Butler
16f15ce391 rustc: Add lint for snake_case functions & methods. 2014-05-30 17:55:41 +01:00
bors
36c2c56277 auto merge of #14535 : sfackler/rust/bitv-show, r=alexcrichton
Closes #14531
2014-05-30 08:26:36 -07:00
bors
874b56d337 auto merge of #14524 : ahmedcharles/rust/to_string, r=alexcrichton 2014-05-30 06:01:41 -07:00
bors
32b6fc1eff auto merge of #14522 : aturon/rust/make_unique, r=alexcrichton,alexcrichton,me
This patch makes `Arc::make_unique` examine the number of weak
references as well as strong references, which is required for safety.

It also adds a `make_unique` method to the `Rc` type for consistency.

Closes #14521.
2014-05-30 04:21:41 -07:00
bors
3a105464fb auto merge of #14517 : lucy/rust/issue-14499, r=alexcrichton
Fixes #8537
Fixes #14499 (duplicate of #8537)

Old:
```rust
test.rs:2 	pub extern "xxxxx" fn add(x: int, y: int) -> int {
          	                   ^~
```

New:
```rust
test.rs:2 	pub extern "xxxxx" fn add(x: int, y: int) -> int {
          	           ^~~~~~~
```
2014-05-30 02:11:45 -07:00
bors
25951b2242 auto merge of #14514 : Randati/rust/patch-1, r=huonw 2014-05-30 00:31:44 -07:00
Cameron Zwarich
5aff0e7cec Fix the handling of assignments to owning pointer paths in check_loans
Make check_for_assignment_to_restricted_or_frozen_location treat
mutation through an owning pointer the same way it treats mutation
through an &mut pointer, where mutability must be inherited from the
base path.

I also included GC pointers in this check, as that is what the
corresponding code in gather_loans/restrictions.rs does, but I don't
think there is a way to test this with the current language.

Fixes #14498.
2014-05-29 22:02:57 -07:00
Piotr Jawniak
aa7b215f04 Rename OSRng to OsRng
According to Rust's style guide acronyms in type names should be
CamelCase.

[breaking-change]
2014-05-30 06:37:31 +02:00
Steven Fackler
8e8f6a0372 Implement Show for Bitv{,Set}
Closes #14531
2014-05-29 21:29:06 -07:00
bors
6510527e15 auto merge of #14510 : kballard/rust/rename_strallocating_into_owned, r=alexcrichton
We already have into_string(), but it was implemented in terms of
into_owned(). Flip it around and deprecate into_owned().

Remove a few spurious calls to .into_owned() that existed in libregex
and librustdoc.
2014-05-29 19:31:42 -07:00
bors
81c022317a auto merge of #14427 : alexcrichton/rust/librand, r=huonw
This commit shuffles around some of the `rand` code, along with some
reorganization. The new state of the world is as follows:

* The librand crate now only depends on libcore. This interface is experimental.
* The standard library has a new module, `std::rand`. This interface will
  eventually become stable.

Unfortunately, this entailed more of a breaking change than just shuffling some
names around. The following breaking changes were made to the rand library:

* Rng::gen_vec() was removed. This has been replaced with Rng::gen_iter() which
  will return an infinite stream of random values. Previous behavior can be
  regained with `rng.gen_iter().take(n).collect()`

* Rng::gen_ascii_str() was removed. This has been replaced with
  Rng::gen_ascii_chars() which will return an infinite stream of random ascii
  characters. Similarly to gen_iter(), previous behavior can be emulated with
  `rng.gen_ascii_chars().take(n).collect()`

* {IsaacRng, Isaac64Rng, XorShiftRng}::new() have all been removed. These all
  relied on being able to use an OSRng for seeding, but this is no longer
  available in librand (where these types are defined). To retain the same
  functionality, these types now implement the `Rand` trait so they can be
  generated with a random seed from another random number generator. This allows
  the stdlib to use an OSRng to create seeded instances of these RNGs.

* Rand implementations for `Box<T>` and `@T` were removed. These seemed to be
  pretty rare in the codebase, and it allows for libcore to not depend on
  liballoc.  Additionally, other pointer types like Rc<T> and Arc<T> were not
  supported.  If this is undesirable, librand can depend on liballoc and regain
  these implementations.

* The WeightedChoice structure is no longer built with a `Vec<Weighted<T>>`,
   but rather a `&mut [Weighted<T>]`. This means that the WeightedChoice
   structure now has a lifetime associated with it.

cc #13851

[breaking-change]
2014-05-29 16:41:42 -07:00
Alex Crichton
925ff65118 std: Recreate a rand module
This commit shuffles around some of the `rand` code, along with some
reorganization. The new state of the world is as follows:

* The librand crate now only depends on libcore. This interface is experimental.
* The standard library has a new module, `std::rand`. This interface will
  eventually become stable.

Unfortunately, this entailed more of a breaking change than just shuffling some
names around. The following breaking changes were made to the rand library:

* Rng::gen_vec() was removed. This has been replaced with Rng::gen_iter() which
  will return an infinite stream of random values. Previous behavior can be
  regained with `rng.gen_iter().take(n).collect()`

* Rng::gen_ascii_str() was removed. This has been replaced with
  Rng::gen_ascii_chars() which will return an infinite stream of random ascii
  characters. Similarly to gen_iter(), previous behavior can be emulated with
  `rng.gen_ascii_chars().take(n).collect()`

* {IsaacRng, Isaac64Rng, XorShiftRng}::new() have all been removed. These all
  relied on being able to use an OSRng for seeding, but this is no longer
  available in librand (where these types are defined). To retain the same
  functionality, these types now implement the `Rand` trait so they can be
  generated with a random seed from another random number generator. This allows
  the stdlib to use an OSRng to create seeded instances of these RNGs.

* Rand implementations for `Box<T>` and `@T` were removed. These seemed to be
  pretty rare in the codebase, and it allows for librand to not depend on
  liballoc.  Additionally, other pointer types like Rc<T> and Arc<T> were not
  supported.  If this is undesirable, librand can depend on liballoc and regain
  these implementations.

* The WeightedChoice structure is no longer built with a `Vec<Weighted<T>>`,
  but rather a `&mut [Weighted<T>]`. This means that the WeightedChoice
  structure now has a lifetime associated with it.

* The `sample` method on `Rng` has been moved to a top-level function in the
  `rand` module due to its dependence on `Vec`.

cc #13851

[breaking-change]
2014-05-29 16:18:26 -07:00
bors
0935beba71 auto merge of #14486 : michaelwoerister/rust/unified_enum_rep, r=luqmana
So far the DWARF information for enums was different for regular enums, univariant enums, Option-like enums, etc. Regular enums were encoded as unions of structs, while the other variants were encoded as bare structs. With the changes in this PR all enums are encoded as unions so that debuggers can reconstruct if something originally was a struct, a univariant enum, or an Option-like enum.  For the latter case, information about the *Null* variant is encoded into the union field name. This information can then be used by the debugger to print a `None` value actually as `None` instead of `Some(0x0)`.

The changes in this PR should also fix the regression reported in #14385 and #14411, but I want to close these only after I have confirmation from the original reporters that the issues are actually fixed for them.
2014-05-29 14:41:42 -07:00
Aaron Turon
7889c95124 Make Arc::make_unique check weak refs; add make_unique to Rc
This patch makes `Arc::make_unique` examine the number of weak
references as well as strong references, which is required for safety.

It also adds a `make_unique` method to the `Rc` type for consistency.

Closes #14521.
2014-05-29 13:26:23 -07:00
Ahmed Charles
2dfad3bf52 Change to_owned() to to_string(). 2014-05-29 12:28:08 -07:00
bors
729ee20338 auto merge of #14483 : ahmedcharles/rust/patbox, r=alexcrichton 2014-05-29 12:11:40 -07:00
lucy
1b3a030092 syntax: Fix span on illegal ABI errors
Fixes #8537
Fixes #14499
2014-05-29 19:09:46 +02:00
bors
50b8528970 auto merge of #14492 : alexcrichton/rust/totaleq, r=pnkfelix
This is a transitionary step towards completing #12517. This change modifies the
compiler to accept Partial{Ord,Eq} as deriving modes which will currently expand
to implementations of PartialOrd and PartialEq (synonyms for Eq/Ord).

After a snapshot, all of deriving(Eq, Ord) will be removed, and after a snapshot
of that, TotalEq/TotalOrd will be renamed to Eq/Ord.
2014-05-29 10:01:37 -07:00
bors
c631d3d804 auto merge of #14488 : SimonSapin/rust/patch-11, r=alexcrichton
According to the corresponding section, accessing a mutable static variable requires `unsafe` too, and I believe it counts as as language level feature. Add it to the relevant list in the Unsafety section.
2014-05-29 07:51:40 -07:00
bors
bee4e6adac auto merge of #14487 : arielb1/rust/fix-13933, r=alexcrichton
Fix issue #13933 in a few files. A more complete fix would require core::raw::MutSlice.
2014-05-29 06:11:39 -07:00
Michael Woerister
eea329b0f7 debuginfo: Make DWARF representation of enums uniform.
So far the DWARF information for enums was different
for regular enums, univariant enums, Option-like enums,
etc. Regular enums were encoded as unions of structs,
while the other variants were encoded as bare structs.

With the changes in this PR all enums are encoded as
unions so that debuggers can reconstruct if something
originally was a struct, a univariant enum, or an
Option-like enum. For the latter case, information
about the Null variant is encoded into the union field
name. This information can then be used by the
debugger to print a None value actually as None
instead of Some(0x0).
2014-05-29 14:21:03 +02:00
Michael Woerister
138089355d debuginfo: Add documentation comments to debuginfo.rs
Conflicts:
	src/librustc/middle/trans/debuginfo.rs
2014-05-29 14:19:57 +02:00
Randati
0e12934ed3 Revert erroneous fix to tutorial 2014-05-29 15:11:53 +03:00
bors
ff2bf58e9e auto merge of #14481 : alexcrichton/rust/no-format-strbuf, r=sfackler
* Removes `format_strbuf!()`
2014-05-29 03:31:39 -07:00
bors
cb3c4f9c82 auto merge of #14472 : huonw/rust/native-lib-warnings, r=alexcrichton
rustc: clarify warning about native deps for a staticlib.

This adjusts the "unlinked native library" warning one receives when
compiling with `crate_type="staticlib"`. The warning is just trying to
tell the user that they need to link against these libraries, but the
old text wasn't making this obvious, the new text says this explicitly.
2014-05-29 00:16:41 -07:00
bors
a6a1c9071a auto merge of #14477 : alexcrichton/rust/issue-14456, r=brson
When spawning a process, stdio file descriptors can be configured to be ignored,
which basically means that they'll be closed. Currently this is done by
literally closing the file descriptors in the child, but this can have adverse
side effects if the child process then opens a new file descriptor, assigning it
to a stdio number.

To work around the problems of the child, this commit alters the process
spawning code to map stdio fds to /dev/null on unix (and a similar equivalent on
windows) when they are specified as being ignored. This should allow spawned
programs to have more expected behavior when opening new files.

Closes #14456
2014-05-28 22:41:38 -07:00
Kevin Ballard
eb98c9eeaa Replace StrAllocating.into_owned() with .into_string()
We already have into_string(), but it was implemented in terms of
into_owned(). Flip it around and deprecate into_owned().

Remove a few spurious calls to .into_owned() that existed in libregex
and librustdoc.
2014-05-28 21:31:19 -07:00
bors
1489374750 auto merge of #14451 : alexcrichton/rust/issue-14442, r=brson
This avoids having to perform conversions from `*u8` to `&'static str` which can
suck in a good deal of code.

Closes #14442
2014-05-28 20:01:37 -07:00
bors
aa151956a7 auto merge of #14465 : Ryman/rust/patch-1, r=alexcrichton 2014-05-28 16:01:36 -07:00
bors
dc5ce0a970 auto merge of #14298 : kmcallister/rust/pattern-macros, r=huonw
First commit is an unrelated fix for a test suite warning I introduced last week.
2014-05-28 14:21:40 -07:00
Keegan McAllister
fd40d0cf5b Test pattern macros 2014-05-28 12:42:21 -07:00
Keegan McAllister
55776f2822 Parse macros in patterns
Fixes #6830.
2014-05-28 12:42:21 -07:00
Keegan McAllister
b2f6dd53c9 Expand macros in patterns 2014-05-28 12:42:21 -07:00
Keegan McAllister
00704ea33b Add patterns to MacResult 2014-05-28 12:42:21 -07:00
Keegan McAllister
5fdd0e4b05 Add AST node for pattern macros 2014-05-28 12:42:21 -07:00
Keegan McAllister
28a4ee5eeb Silence warning in RefCell test suite 2014-05-28 12:42:21 -07:00
bors
e865415c2f auto merge of #14464 : Sawyer47/rust/issue-12925, r=alexcrichton
This is an attempt of fixing #12925.

This PR moves almost all trait implementations for primitive types ((), bool, char, i*, u*, f*) near trait definitions. Only Float trait implementations weren't moved because they heavily rely on constants defined in f32.rs and f64.rs.

Some trait implementations had cfg(not(test)) attribute. I suspect it's because of issue 2912.
Still, someone who knows the problem better should probably check this code.

Closes #12925
2014-05-28 12:41:40 -07:00
Alex Crichton
f786f9bb15 rustc: Accept PartialOrd/PartialOrdEq for Eq/Ord
This is a transitionary step towards completing #12517. This change modifies the
compiler to accept Partial{Ord,Eq} as deriving modes which will currently expand
to implementations of PartialOrd and PartialEq (synonyms for Eq/Ord).

After a snapshot, all of deriving(Eq, Ord) will be removed, and after a snapshot
of that, TotalEq/TotalOrd will be renamed to Eq/Ord.
2014-05-28 10:02:06 -07:00
Ariel Ben-Yehuda
2e8bc9924c Issue #13933: Remove transmute_mut from Arc
directly use the internal pointer instead.
2014-05-28 19:39:46 +03:00
bors
cd6fb59ee2 auto merge of #14437 : Sawyer47/rust/utf16-items, r=alexcrichton
According to Rust's style guide acronyms should be CamelCase.
2014-05-28 09:26:42 -07:00
Ariel Ben-Yehuda
def2232595 Issue #13933: Remove transmute_mut from IO
The IO libraries casted self to mut so they can pass it to seek(SEEK_CUR, 0).
Fix this by introducing a private seek function that takes &self
  - of course one should be careful with it if he lacks an
    exclusive reference to self.
2014-05-28 19:25:51 +03:00
Alex Crichton
42aed6bde2 std: Remove format_strbuf!()
This was only ever a transitionary macro.
2014-05-28 08:35:41 -07:00
Piotr Jawniak
dd0d495f50 Move trait impls for primitives near trait definition
Closes #12925
2014-05-28 17:15:35 +02:00
bors
9659a50957 auto merge of #14463 : SergioBenitez/rust/deprecation-fix, r=alexcrichton
The deprecation warning text for mem::move_val_init was incorrect. It should point users to `overwrite` instead of itself.
2014-05-28 07:46:45 -07:00
Simon Sapin
17697c78c5 Doc: static mut is unsafe too
According to the corresponding section, accessing a mutable static variable requires `unsafe` too, and I believe it counts as as language level feature. Add it to the relevant list in the Unsafety section.
2014-05-28 14:19:25 +01:00
bors
24b1ce1daf auto merge of #14458 : huonw/rust/rustdoc-cross-crate-link-path, r=alexcrichton
Previously this was adding one-too-many `..`s to the path for the
`gotosrc=...` links for local crates. Also, the `root_path` already ends
in `/`s so a trailing / shouldn't be added after the root (some servers
treat `...//...` different to `.../...` including the one running
doc.rust-lang.org).
2014-05-28 06:06:47 -07:00
Huon Wilson
3482ab3699 rustdoc: cross-crate source links are one level lower.
Previously this was adding one-too-many `..`s to the path for the
`gotosrc=...` links for local crates. Also, the `root_path` already ends
in `/`s so a trailing / shouldn't be added after the root (some servers
treat `...//...` different to `.../...` including the one running
doc.rust-lang.org).
2014-05-28 22:02:14 +10:00
bors
bee42a9413 auto merge of #14459 : seanmonstar/rust/select-docs, r=alexcrichton 2014-05-28 04:21:42 -07:00
bors
0a092a8158 auto merge of #14455 : crabtw/rust/mips, r=alexcrichton
Because IPv4 address conversion doesn't consider big-endian target, I add functions to handle that.
These function names may need to be changed, but I can't come up with a good one.
2014-05-28 02:41:44 -07:00
Piotr Jawniak
8c5a8e10b2 Rename UTF16Item[s] to Utf16Item[s]
According to Rust's style guide acronyms should be CamelCase.

[breaking-change]
2014-05-28 11:31:21 +02:00
bors
7e049fefc7 auto merge of #14452 : alexcrichton/rust/issue-14438, r=huonw
This commit alters rustdoc to keep a hash set of known inlined items which is a
whitelist for generating URLs to.

Closes #14438
2014-05-27 23:26:47 -07:00
Ahmed Charles
4e3db5e0f4 Rename PatUniq to PatBox. Fixes part of #13910. 2014-05-27 22:19:29 -07:00
bors
1dea8834cc auto merge of #14364 : alexcrichton/rust/libdebug, r=brson
This commit moves reflection (as well as the {:?} format modifier) to a new
libdebug crate, all of which is marked experimental.

This is a breaking change because it now requires the debug crate to be
explicitly linked if the :? format qualifier is used. This means that any code
using this feature will have to add `extern crate debug;` to the top of the
crate. Any code relying on reflection will also need to do this.

Closes #12019

[breaking-change]
2014-05-27 21:46:46 -07:00
Alex Crichton
b53454e2e4 Move std::{reflect,repr,Poly} to a libdebug crate
This commit moves reflection (as well as the {:?} format modifier) to a new
libdebug crate, all of which is marked experimental.

This is a breaking change because it now requires the debug crate to be
explicitly linked if the :? format qualifier is used. This means that any code
using this feature will have to add `extern crate debug;` to the top of the
crate. Any code relying on reflection will also need to do this.

Closes #12019

[breaking-change]
2014-05-27 21:44:51 -07:00
Alex Crichton
4ef535ebd0 rustdoc: Only link to local inlined foreign items
This commit alters rustdoc to keep a hash set of known inlined items which is a
whitelist for generating URLs to.

Closes #14438
2014-05-27 19:33:57 -07:00
bors
73dac7e4e6 auto merge of #14387 : alan-andrade/rust/remove_managed_boxes_and_gc, r=brson
My main goals were:
- be clear when we talk about "references" and "pointers"
- remove Managed boxes completely and the concept of GC.

https://github.com/mozilla/rust/issues/13987
2014-05-27 19:31:46 -07:00
Alex Crichton
034eb4e724 native: Ignore stdio fds with /dev/null
When spawning a process, stdio file descriptors can be configured to be ignored,
which basically means that they'll be closed. Currently this is done by
literally closing the file descriptors in the child, but this can have adverse
side effects if the child process then opens a new file descriptor, assigning it
to a stdio number.

To work around the problems of the child, this commit alters the process
spawning code to map stdio fds to /dev/null on unix (and a similar equivalent on
windows) when they are specified as being ignored. This should allow spawned
programs to have more expected behavior when opening new files.

Closes #14456
2014-05-27 17:49:31 -07:00
bors
911cc9c352 auto merge of #14414 : richo/rust/features/nerf_unused_string_fns, r=alexcrichton
This should block on #14323
2014-05-27 17:46:48 -07:00
bors
30bf73fd78 auto merge of #14447 : erickt/rust/show-treemap, r=kballard
This is a hodge podge of a couple small cleanup commits. It implements `Show` for `TreeMap` and `TreeSet`, and some removal of commented out code.
2014-05-27 16:11:39 -07:00
Huon Wilson
a167caf106 rustc: clarify warning about native deps for a staticlib.
This adjusts the "unlinked native library" warning one receives when
compiling with `crate_type="staticlib"`. The warning is just trying to
tell the user that they need to link against these libraries, but the
old text wasn't making this obvious; the new text says this explicitly.
2014-05-28 09:03:51 +10:00
bors
1fc29ef0c8 auto merge of #14444 : huonw/rust/nice-for-errors, r=alexcrichton
Change `for` desugaring & make refutable pattern errors more precise

This changes for to desugar to the `let`-based pattern match as described in #14390, and adjusts the compiler to use this information for error messages that even mention that it's in a `for` loop.

Also, it makes the compiler record the exact positions of refutable parts of a pattern, to point to exactly them in error messages.
2014-05-27 14:36:40 -07:00
Ryman
ada85a202b rust manual: supertraits seperator is wrong 2014-05-27 21:40:50 +01:00
bors
1e2bb09bbb auto merge of #14435 : P1start/rust/str-docs-fix, r=sfackler
This tweaks the `std::str` docs to compensate for the recent shift from `~str` to `String`.
2014-05-27 13:01:40 -07:00
Richo Healey
c256dcf8b6 doc: Fix link to string
This was missed in 553074506e
2014-05-27 12:59:31 -07:00
Richo Healey
1f1b2e42d7 std: Rename strbuf operations to string
[breaking-change]
2014-05-27 12:59:31 -07:00
bors
5811d2bd96 auto merge of #14428 : alexcrichton/rust/issue-14422, r=pcwalton
This ensures that a public typedef to a private item is ensured to be public in
terms of linkage. This affects both the visibility of the library's symbols as
well as other lints based on privacy (dead_code for example).

Closes #14421
Closes #14422
2014-05-27 11:26:40 -07:00
Sergio Benitez
ac833da183 Fixed deprecation warning text for mem::move_val_init and its associated comment. 2014-05-27 14:15:34 -04:00
Richo Healey
4348e23b26 std: Remove String's to_owned 2014-05-27 11:11:15 -07:00
Erick Tryzelaar
926504c885 collections: implement Show for Tree{Map,Set} 2014-05-27 10:38:52 -07:00
Erick Tryzelaar
e9e799f750 collections: add Show impl test for HashMap 2014-05-27 10:20:02 -07:00
Erick Tryzelaar
85d9cfb809 serialize: Remove old commented out code 2014-05-27 10:20:02 -07:00
Jyun-Yan You
abc2a92d9c fix MIPS target 2014-05-28 01:15:24 +08:00