]> git.lizzy.rs Git - rust.git/log
rust.git
9 years agoAuto merge of #24177 - alexcrichton:rustdoc, r=aturon
bors [Fri, 10 Apr 2015 16:18:44 +0000 (16:18 +0000)]
Auto merge of #24177 - alexcrichton:rustdoc, r=aturon

This commit series starts out with more official test harness support for rustdoc tests, and then each commit afterwards adds a test (where appropriate). Each commit should also test and finish independently of all others (they're all pretty separable).

I've uploaded a [copy of the documentation](http://people.mozilla.org/~acrichton/doc/std/) generated after all these commits were applied, and a double check on issues being closed would be greatly appreciated! I'll also browse the docs a bit and make sure nothing regressed too horribly.

9 years agoAuto merge of #24034 - alexcrichton:cloexec, r=aturon
bors [Fri, 10 Apr 2015 12:42:46 +0000 (12:42 +0000)]
Auto merge of #24034 - alexcrichton:cloexec, r=aturon

The commit messages have more details as to what's going on, but this is a breaking change for any libraries which expect file descriptors to be inherited by default.

Closes #12148

9 years agostd: Unconditionally close all file descriptors
Alex Crichton [Fri, 3 Apr 2015 22:44:14 +0000 (15:44 -0700)]
std: Unconditionally close all file descriptors

The logic for only closing file descriptors >= 3 was inherited from quite some
time ago and ends up meaning that some internal APIs are less consistent than
they should be. By unconditionally closing everything entering a `FileDesc` we
ensure that we're consistent in our behavior as well as robustly handling the
stdio case.

9 years agoTest fixes and review feedback
Alex Crichton [Wed, 8 Apr 2015 03:11:59 +0000 (20:11 -0700)]
Test fixes and review feedback

9 years agoAuto merge of #24180 - huonw:optimise-max-etc, r=alexcrichton
bors [Fri, 10 Apr 2015 07:54:18 +0000 (07:54 +0000)]
Auto merge of #24180 - huonw:optimise-max-etc, r=alexcrichton

The main change in this patch is removing the use of `Option` inside the
inner loops of those functions to avoid comparisons where one branch
will only trigger on the first pass through the loop.

The included benchmarks go from:

    test bench_max    ... bench:       372 ns/iter (+/- 118)
    test bench_max_by ... bench:       428 ns/iter (+/- 33)
    test bench_max_by2 ... bench:      7128 ns/iter (+/- 326)

to:

    test bench_max    ... bench:       317 ns/iter (+/- 64)
    test bench_max_by ... bench:       356 ns/iter (+/- 270)
    test bench_max_by2 ... bench:      1387 ns/iter (+/- 183)

Problem noticed in http://www.reddit.com/r/rust/comments/31syce/using_iterators_to_find_the_index_of_the_min_or/

9 years agoOptimise Iterator::{max, max_by, min, min_by}.
Huon Wilson [Wed, 8 Apr 2015 04:25:22 +0000 (14:25 +1000)]
Optimise Iterator::{max, max_by, min, min_by}.

The main change in this patch is removing the use of `Option` inside the
inner loops of those functions to avoid comparisons where one branch
will only trigger on the first pass through the loop.

The included benchmarks go from:

    test bench_max    ... bench:       372 ns/iter (+/- 118)
    test bench_max_by ... bench:       428 ns/iter (+/- 33)
    test bench_max_by2 ... bench:      7128 ns/iter (+/- 326)

to:

    test bench_max    ... bench:       317 ns/iter (+/- 64)
    test bench_max_by ... bench:       356 ns/iter (+/- 270)
    test bench_max_by2 ... bench:      1387 ns/iter (+/- 183)

Problem noticed in http://www.reddit.com/r/rust/comments/31syce/using_iterators_to_find_the_index_of_the_min_or/

9 years agostd: Clean up process spawn impl on unix
Alex Crichton [Fri, 3 Apr 2015 22:34:15 +0000 (15:34 -0700)]
std: Clean up process spawn impl on unix

* De-indent quite a bit by removing usage of FnOnce closures
* Clearly separate code for the parent/child after the fork
* Use `fs2::{File, OpenOptions}` instead of calling `open` manually
* Use RAII to close I/O objects wherever possible
* Remove loop for closing all file descriptors, all our own ones are now
  `CLOEXEC` by default so they cannot be inherited

9 years agostd: Set CLOEXEC for all fds opened on unix
Alex Crichton [Fri, 3 Apr 2015 22:30:10 +0000 (15:30 -0700)]
std: Set CLOEXEC for all fds opened on unix

This commit starts to set the CLOEXEC flag for all files and sockets opened by
the standard library by default on all unix platforms. There are a few points of
note in this commit:

* The implementation is not 100% satisfactory in the face of threads. File
  descriptors only have the `F_CLOEXEC` flag set *after* they are opened,
  allowing for a fork/exec to happen in the middle and leak the descriptor.
  Some platforms do support atomically opening a descriptor while setting the
  `CLOEXEC` flag, and it is left as a future extension to bind these apis as it
  is unclear how to do so nicely at this time.

* The implementation does not offer a method of opting into the old behavior of
  not setting `CLOEXEC`. This will possibly be added in the future through
  extensions on `OpenOptions`, for example.

* This change does not yet audit any Windows APIs to see if the handles are
  inherited by default by accident.

This is a breaking change for users who call `fork` or `exec` outside of the
standard library itself and expect file descriptors to be inherted. All file
descriptors created by the standard library will no longer be inherited.

[breaking-change]

9 years agoAuto merge of #24205 - brson:debug, r=alexcrichton
bors [Thu, 9 Apr 2015 23:52:02 +0000 (23:52 +0000)]
Auto merge of #24205 - brson:debug, r=alexcrichton

This makes the default configuration fully optimized, with no debugging options, no llvm asserts, renames --enable-debug to --enable-debug-assertions, and adds --enable-debug as a blanket option that toggles various things, per #17665. It does not add a `--enable-release` flag since that would be a no-op.

cc @nrc

Fixes https://github.com/rust-lang/rust/issues/22390
Fixes https://github.com/rust-lang/rust/issues/17081
Partially addresses https://github.com/rust-lang/rust/issues/17665

9 years agoAuto merge of #24232 - Manishearth:rollup, r=Manishearth
bors [Thu, 9 Apr 2015 20:38:36 +0000 (20:38 +0000)]
Auto merge of #24232 - Manishearth:rollup, r=Manishearth

None

9 years agofixup windows std_misc
Manish Goregaokar [Thu, 9 Apr 2015 20:39:19 +0000 (02:09 +0530)]
fixup windows std_misc

9 years agoRollup merge of #24217 - aturon:iterator-fixes, r=alexcrichton
Manish Goregaokar [Thu, 9 Apr 2015 16:00:06 +0000 (21:30 +0530)]
Rollup merge of #24217 - aturon:iterator-fixes, r=alexcrichton

9 years agoRollup merge of #24225 - nrc:for-span, r=pnkfelix
Manish Goregaokar [Thu, 9 Apr 2015 10:25:18 +0000 (15:55 +0530)]
Rollup merge of #24225 - nrc:for-span, r=pnkfelix

9 years agoRollup merge of #24170 - omo:omo-typo-fix, r=steveklabnik
Manish Goregaokar [Thu, 9 Apr 2015 10:25:12 +0000 (15:55 +0530)]
Rollup merge of #24170 - omo:omo-typo-fix, r=steveklabnik

 Can anyone take a look? Very trivial.

9 years agoRollup merge of #24221 - nrc:debug-loc, r=sfackler
Manish Goregaokar [Thu, 9 Apr 2015 10:25:05 +0000 (15:55 +0530)]
Rollup merge of #24221 - nrc:debug-loc, r=sfackler

9 years agoRollup merge of #24218 - lstat:remove-ignore-tidy, r=alexcrichton
Manish Goregaokar [Thu, 9 Apr 2015 10:24:58 +0000 (15:54 +0530)]
Rollup merge of #24218 - lstat:remove-ignore-tidy, r=alexcrichton

 This is a really minor issue. I noticed some tests no longer need the ignore
tidy comment directive.

A quick grep turned up the following files:

    src/test/compile-fail/bad-mid-path-type-params.rs
    src/test/compile-fail/bad-sized.rs
    src/test/compile-fail/coherence-default-trait-impl.rs
    src/test/compile-fail/coherence-orphan.rs
    src/test/compile-fail/issue-8767.rs
    src/test/compile-fail/lint-stability.rs
    src/test/compile-fail/lint-uppercase-variables.rs
    src/test/compile-fail/typeck-default-trait-impl-outside-crate.rs
    src/test/compile-fail/use-after-move-implicity-coerced-object.rs
    src/test/debuginfo/gdb-pretty-std.rs

It didn't seem like it was worth opening an issue for this, but if that is not
the case (i.e. it is required), I'll open one up. Thanks!

9 years agoRollup merge of #24216 - alexcrichton:stabilize-from-raw-os-error, r=aturon
Manish Goregaokar [Thu, 9 Apr 2015 10:24:43 +0000 (15:54 +0530)]
Rollup merge of #24216 - alexcrichton:stabilize-from-raw-os-error, r=aturon

 This commit stabilizes the old `io::Error::from_os_error` after being renamed to
use the `raw_os_error` terminology instead. This function is often useful when
writing bindings to OS functions but only actually converting to an I/O error at
a later point.

9 years agoRollup merge of #24215 - alexcrichton:stabilize-clone-from, r=aturon
Manish Goregaokar [Thu, 9 Apr 2015 10:24:36 +0000 (15:54 +0530)]
Rollup merge of #24215 - alexcrichton:stabilize-clone-from, r=aturon

 This method hasn't really changed since is inception, and it can often be a
nice performance win for some situations. This method also imposes no burden on
implementors or users of `Clone` as it's just a default method on the side.

9 years agoRollup merge of #24212 - alexcrichton:destabilize-begin-unwind, r=huonw
Manish Goregaokar [Thu, 9 Apr 2015 10:24:28 +0000 (15:54 +0530)]
Rollup merge of #24212 - alexcrichton:destabilize-begin-unwind, r=huonw

 Now that we have a `#[allow_internal_unstable]` attribute for macros there's no
need for these two `begin_unwind` functions to be stable. Right now the `panic!`
interface is the only one we wish to stabilize, so remove the stability markers
from these functions.

While this is a breaking change, it is highly unlikely to break any actual code.
It is recommended to use the `panic!` macro instead if it breaks explicit calls
into `std::rt`.

[breaking-change]
cc #24208

9 years agoRollup merge of #24207 - kmcallister:llvm-plugin, r=brson
Manish Goregaokar [Thu, 9 Apr 2015 10:24:18 +0000 (15:54 +0530)]
Rollup merge of #24207 - kmcallister:llvm-plugin, r=brson

 r? @brson

I'm using this to integrate rustc with [american-fuzzy-lop](http://lcamtuf.coredump.cx/afl/). Building with afl instrumentation is no different from loading any other plugin library.

I'd like this PR to include a `run-make` test with a custom LLVM pass; however I'm not sure it's worth the trouble of building C++ code and linking LLVM from the test suite (are there existing tests that do this?)

9 years agoRollup merge of #24205 - brson:debug, r=alexcrichton
Manish Goregaokar [Thu, 9 Apr 2015 10:24:11 +0000 (15:54 +0530)]
Rollup merge of #24205 - brson:debug, r=alexcrichton

 This makes the default configuration fully optimized, with no debugging options, no llvm asserts, renames --enable-debug to --enable-debug-assertions, and adds --enable-debug as a blanket option that toggles various things, per #17665. It does not add a `--enable-release` flag since that would be a no-op.

cc @nrc

Fixes https://github.com/rust-lang/rust/issues/22390
Fixes https://github.com/rust-lang/rust/issues/17081
Partially addresses https://github.com/rust-lang/rust/issues/17665

9 years agoRollup merge of #24193 - lstat:needstest, r=alexcrichton
Manish Goregaokar [Thu, 9 Apr 2015 10:24:04 +0000 (15:54 +0530)]
Rollup merge of #24193 - lstat:needstest, r=alexcrichton

 Closes #22289
Closes #22370
Closes #22384

9 years agoRollup merge of #24191 - nikomatsakis:issue-20791, r=pnkfelix
Manish Goregaokar [Thu, 9 Apr 2015 10:23:59 +0000 (15:53 +0530)]
Rollup merge of #24191 - nikomatsakis:issue-20791, r=pnkfelix

 Modify the ExprUseVisitor to walk each part of an AutoRef, and in
particular to treat an AutoUnsize as as kind of \"instantaneous\" borrow
of the value being unsized. This prevents us from feeding uninitialized
data.

This caused a problem for the eager reborrow of comparison traits,
because that wound up introducing a \"double AutoRef\", which was not
being thoroughly checked before but turned out not to type check.
Fortunately, we can just remove that \"eager reborrow\" as it is no longer
needed now that `PartialEq` doesn't force both LHS and RHS to have the
same type (and even if we did have this problem, the better way would be
to lean on introducing a common supertype).

Fixes #20791.

r? @nrc

9 years agoNightly gets LLVM assertions
Brian Anderson [Thu, 9 Apr 2015 18:51:46 +0000 (11:51 -0700)]
Nightly gets LLVM assertions

9 years agoImprove bounds in Iterator API
Aaron Turon [Thu, 9 Apr 2015 00:01:03 +0000 (17:01 -0700)]
Improve bounds in Iterator API

This commit changes `Iterator`'s API by:

* Generalizing bounds from `Iterator` to `IntoIterator` whenever
  possible, matching the semantics and ergonomics of `for` loops.

* Tightens up a few method-level bounds so that you get an error
  earlier. For example, `rev` did not require `DoubleEndedIterator` even
  though the result is only an `Iterator` when the original iterator was
  double-ended.

Closes #23587

The bound-tightening is technically a:

[breaking-change]

but no code should break in practice.

9 years agoAuto merge of #24176 - kballard:bufreader-seek-impl, r=aturon
bors [Thu, 9 Apr 2015 12:07:24 +0000 (12:07 +0000)]
Auto merge of #24176 - kballard:bufreader-seek-impl, r=aturon

9 years agoRollup merge of #24176 - kballard:bufreader-seek-impl, r=aturon
Manish Goregaokar [Thu, 9 Apr 2015 10:23:48 +0000 (15:53 +0530)]
Rollup merge of #24176 - kballard:bufreader-seek-impl, r=aturon

9 years agoRollup merge of #24175 - dhuseby:bitrig_fixing_tests_2, r=alexcrichton
Manish Goregaokar [Thu, 9 Apr 2015 10:23:43 +0000 (15:53 +0530)]
Rollup merge of #24175 - dhuseby:bitrig_fixing_tests_2, r=alexcrichton

 I'm not sure why this is failing.  This patch disables this test until I can figure out what is wrong.

9 years agoRollup merge of #24171 - rillian:rustup, r=brson
Manish Goregaokar [Thu, 9 Apr 2015 10:23:36 +0000 (15:53 +0530)]
Rollup merge of #24171 - rillian:rustup, r=brson

 The idea here is if you don't want rust in /usr/local
you can put something like this is your .profile:

```
export RUSTUP_PREFIX=$HOME/.local/rust
export PATH=$PATH:${RUSTUP_PREFIX}/bin
export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:${RUSTUP_PREFIX}/lib
```
Then when you run rustup, it will update the install
in ${RUSTUP_PREFIX} without having to remember to pass
an explicit --prefix argument every time.

9 years agoFix the span for `for` expressions
Nick Cameron [Thu, 9 Apr 2015 08:35:27 +0000 (20:35 +1200)]
Fix the span for `for` expressions

9 years agoAuto merge of #24171 - rillian:rustup, r=brson
bors [Thu, 9 Apr 2015 07:49:26 +0000 (07:49 +0000)]
Auto merge of #24171 - rillian:rustup, r=brson

The idea here is if you don't want rust in /usr/local
you can put something like this is your .profile:

```
export RUSTUP_PREFIX=$HOME/.local/rust
export PATH=$PATH:${RUSTUP_PREFIX}/bin
export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:${RUSTUP_PREFIX}/lib
```
Then when you run rustup, it will update the install
in ${RUSTUP_PREFIX} without having to remember to pass
an explicit --prefix argument every time.

9 years agoDebug impls for a few things in syntax::codemap
Nick Cameron [Thu, 9 Apr 2015 06:25:48 +0000 (18:25 +1200)]
Debug impls for a few things in syntax::codemap

9 years agoAuto merge of #24168 - kballard:clone-for-extern-c-unsafe-fns, r=alexcrichton
bors [Thu, 9 Apr 2015 04:56:23 +0000 (04:56 +0000)]
Auto merge of #24168 - kballard:clone-for-extern-c-unsafe-fns, r=alexcrichton

We only implemented Clone on `extern "Rust" fn`s (for up to 8
parameters). This didn't cover `extern "C"` or `unsafe` (or
`unsafe extern "C"`) `fn`s, but there's no reason why they shouldn't be
cloneable as well.

The new impls are marked unstable because the existing impl for `extern
"Rust" fn`s is.

Fixes #24161.

9 years agoImplement io::Seek for io::BufWriter<W> where W: io::Seek
Kevin Ballard [Wed, 8 Apr 2015 00:29:33 +0000 (17:29 -0700)]
Implement io::Seek for io::BufWriter<W> where W: io::Seek

Seeking the `BufWriter` writes out its internal buffer before seeking.

9 years agoImplement io::Seek for io::BufReader<R> where R: io::Seek
Kevin Ballard [Tue, 7 Apr 2015 23:01:21 +0000 (16:01 -0700)]
Implement io::Seek for io::BufReader<R> where R: io::Seek

Seeking the `BufReader` discards the internal buffer (and adjusts the
offset appropriately when seeking with `SeekFrom::Current(_)`).

9 years agoDon't deoptimize llvm when --enable-debug
Brian Anderson [Thu, 9 Apr 2015 01:01:46 +0000 (18:01 -0700)]
Don't deoptimize llvm when --enable-debug

libLTO fails to link here.

9 years agoAuto merge of #24158 - sanxiyn:cast, r=nrc
bors [Thu, 9 Apr 2015 01:00:37 +0000 (01:00 +0000)]
Auto merge of #24158 - sanxiyn:cast, r=nrc

Fix #13993.
Fix #17167.

9 years agoRemove pretty-expanded from failing tests
Alex Crichton [Wed, 8 Apr 2015 23:27:10 +0000 (16:27 -0700)]
Remove pretty-expanded from failing tests

This commit removes pretty-expanded from all tests that wind up calling panic!
one way or another now that its internals are unstable.

9 years agostd: Stabilize io::Error::from_raw_os_error
Alex Crichton [Wed, 8 Apr 2015 23:41:14 +0000 (16:41 -0700)]
std: Stabilize io::Error::from_raw_os_error

This commit stabilizes the old `io::Error::from_os_error` after being renamed to
use the `raw_os_error` terminology instead. This function is often useful when
writing bindings to OS functions but only actually converting to an I/O error at
a later point.

9 years agostd: Stabilize Clone::clone_from
Alex Crichton [Wed, 8 Apr 2015 23:38:38 +0000 (16:38 -0700)]
std: Stabilize Clone::clone_from

This method hasn't really changed since is inception, and it can often be a
nice performance win for some situations. This method also imposes no burden on
implementors or users of `Clone` as it's just a default method on the side.

9 years agostd: Destabilize the internals of panic!
Alex Crichton [Wed, 8 Apr 2015 22:48:46 +0000 (15:48 -0700)]
std: Destabilize the internals of panic!

Now that we have a `#[allow_internal_unstable]` attribute for macros there's no
need for these two `begin_unwind` functions to be stable. Right now the `panic!`
interface is the only one we wish to stabilize, so remove the stability markers
from these functions.

While this is a breaking change, it is highly unlikely to break any actual code.
It is recommended to use the `panic!` macro instead if it breaks explicit calls
into `std::rt`.

[breaking-change]
cc #24208

9 years agoRemove `ignore-tidy-linelength` from tests that no longer need it
Luke Gallagher [Wed, 8 Apr 2015 22:20:51 +0000 (08:20 +1000)]
Remove `ignore-tidy-linelength` from tests that no longer need it

9 years agoconfigure: Add --enable-debug-jemalloc
Brian Anderson [Wed, 8 Apr 2015 22:12:08 +0000 (15:12 -0700)]
configure: Add --enable-debug-jemalloc

9 years agoAuto merge of #24144 - richo:ptr-formatter, r=alexcrichton
bors [Wed, 8 Apr 2015 22:08:31 +0000 (22:08 +0000)]
Auto merge of #24144 - richo:ptr-formatter, r=alexcrichton

~~I believe this should fix the issue. Opening a PR to ensure noone duplicates effort, I'm running check now.~~

Closes #24091

9 years agoAdd --enable-debug to control multiple perf options
Brian Anderson [Wed, 8 Apr 2015 21:21:36 +0000 (14:21 -0700)]
Add --enable-debug to control multiple perf options

9 years agoAllow plugins to register LLVM passes
Keegan McAllister [Wed, 8 Apr 2015 19:52:58 +0000 (12:52 -0700)]
Allow plugins to register LLVM passes

9 years agoconfigure: Add --enable-debuginfo
Brian Anderson [Wed, 8 Apr 2015 20:57:37 +0000 (13:57 -0700)]
configure: Add --enable-debuginfo

9 years agoconfigure: Clarify --enable-debug-assertions status message
Brian Anderson [Wed, 8 Apr 2015 20:31:26 +0000 (13:31 -0700)]
configure: Clarify --enable-debug-assertions status message

9 years agoconfigure: Disable LLVM asserts by default
Brian Anderson [Wed, 8 Apr 2015 20:27:12 +0000 (13:27 -0700)]
configure: Disable LLVM asserts by default

9 years agoconfigure: Clarify help message for --enable-debug-assertions
Brian Anderson [Wed, 8 Apr 2015 20:25:20 +0000 (13:25 -0700)]
configure: Clarify help message for --enable-debug-assertions

9 years agoconfigure: Disable debug assertions by default
Brian Anderson [Wed, 8 Apr 2015 20:23:44 +0000 (13:23 -0700)]
configure: Disable debug assertions by default

9 years agoconfigure: Rename --enable-debug to --enable-debug-assertions
Brian Anderson [Wed, 8 Apr 2015 20:17:46 +0000 (13:17 -0700)]
configure: Rename --enable-debug to --enable-debug-assertions

9 years agoconfigure: Remove obsolete --disable-verify option
Brian Anderson [Wed, 8 Apr 2015 19:16:45 +0000 (12:16 -0700)]
configure: Remove obsolete --disable-verify option

rust-installer never verifies.

9 years agoconfigure: Remove obsolete --nightly flag
Brian Anderson [Wed, 8 Apr 2015 19:06:29 +0000 (12:06 -0700)]
configure: Remove obsolete --nightly flag

9 years agoAuto merge of #24029 - nagisa:print-locking, r=alexcrichton
bors [Wed, 8 Apr 2015 19:03:09 +0000 (19:03 +0000)]
Auto merge of #24029 - nagisa:print-locking, r=alexcrichton

write_fmt calls write for each formatted field. The default implementation of write_fmt is used,
which will call write on not-yet-locked stdout (and write locking after), therefore making print!
in multithreaded environment still interleave contents of two separate prints.

I’m not sure whether we want to do this change, though, because it has the same deadlock hazard which we tried to avoid by not locking inside write_fmt itself (see [this comment](https://github.com/rust-lang/rust/blob/80def6c2447d23a624e611417f24cf0ab2a5a676/src/libstd/io/stdio.rs#L267)).

Spotted on [reddit].

cc @alexcrichton

[reddit]: http://www.reddit.com/r/rust/comments/31comh/println_with_multiple_threads/

9 years agoImplement reentrant mutexes and make stdio use them
Simonas Kazlauskas [Fri, 3 Apr 2015 21:46:54 +0000 (00:46 +0300)]
Implement reentrant mutexes and make stdio use them

write_fmt calls write for each formatted field. The default implementation of write_fmt is used,
which will call write on not-yet-locked stdout (and write locking after), therefore making print!
in multithreaded environment still interleave contents of two separate prints.

This patch implements reentrant mutexes, changes stdio handles to use these mutexes and overrides
write_fmt to lock the stdio handle for the whole duration of the call.

9 years agoAuto merge of #24195 - steveklabnik:rollup, r=steveklabnik
bors [Wed, 8 Apr 2015 15:59:10 +0000 (15:59 +0000)]
Auto merge of #24195 - steveklabnik:rollup, r=steveklabnik

- Successful merges: #24143, #24149, #24167, #24178
- Failed merges:

9 years agoRollup merge of #24178 - steveklabnik:new_toc, r=nikomatsakis
Steve Klabnik [Wed, 8 Apr 2015 15:34:12 +0000 (11:34 -0400)]
Rollup merge of #24178 - steveklabnik:new_toc, r=nikomatsakis

Basically, the overall structure is this:

* Getting Started - getting an environment up and running
* Learn Rust - project-based learning the basics
* Effective Rust - higher level concepts that lead to writing good rust
* Syntax and Semantics - chunks of exactly what it sounds like
* Nightly Rust - unstable stuff, a staging area for documenting features
* Glossary - self-explanatory

There's a number of weaknesses with the current TOC, but I'll just focus on the strengths of the new one:

We start off with getting our environment set up. That's "getting started".

Then, we basically present you with two choices: do you want to start small, with bits of syntax? Or do you want to dive in with projects?

I'm guessing more people will choose the second, so that's the next part: "Learn Rust." I don't have any chapters here, but this would have an updated guessing game, a tutorial on building a little `wc` clone, and something else I haven't decided yet. Lots of options. But the idea is to just dive in and get your hands dirty. I'll heavily link to the 'syntax and semantics' sections that are relevant.

Then, a section I'm calling 'Effective Rust'. it feels greedy to steal that title, so I'm hoping to give it another name. These are higher-level things than syntax that Rust programmers should know: error handling is a great example. Most of these are sort of 'how do I use the standard library together' kinds of things. This also contains informations about systems programming that those new to it might not know: the stack vs the heap, for example.

Then, "Syntax and Semantics." This has one section for each bit of Rust. Small, focused, but explains _everything_. These are positioned to be almost entirely in-order, but heavily cross-link, so you can go out of order if you want to, but you can also use it as a reference.

Next, "Nightly Rust," where documenting unstable things goes. If we want to get good feedback on new features, they'll need to be documented, but we don't want to taint the main docs, so that's what this is for.

Finally, the glossary. Straightforward enough.

--------------------------------

This is going to be a terrible PR to review, so I just did the TOC re-organization, with basically no editing. So it'll be a bit jumbled at first. But next steps are to go through and edit / revise / tweak / add stuff to get it in tip-top shape for 1.0!

9 years agoRollup merge of #24167 - hauleth:remove-incorrect-example-from-mpsc, r=steveklabnik
Steve Klabnik [Wed, 8 Apr 2015 15:34:12 +0000 (11:34 -0400)]
Rollup merge of #24167 - hauleth:remove-incorrect-example-from-mpsc, r=steveklabnik

As beta is now released and is "suggested" version of `rustc` then there should be no code (in documentation) that will not compile with it. This one does not.

So according to [this great talk](http://delete-your-code.herokuapp.com/), I am doing what should be done.

9 years agoRollup merge of #24149 - bombless:update-faq, r=steveklabnik
Steve Klabnik [Wed, 8 Apr 2015 15:34:12 +0000 (11:34 -0400)]
Rollup merge of #24149 - bombless:update-faq, r=steveklabnik

I think "let is used to introduce variables" is incorrent.
You can use
```rust
match (42, true) {
    (x, y) => { /* ... */ }
}
```
to replace
```rust
let x = 42;
let y = true;
```
so it's nothing special for `let`.

9 years agoRollup merge of #24143 - michaelsproul:extended-errors, r=pnkfelix
Steve Klabnik [Wed, 8 Apr 2015 15:34:11 +0000 (11:34 -0400)]
Rollup merge of #24143 - michaelsproul:extended-errors, r=pnkfelix

I've taken another look at extended errors - fixing up the printing and adding a few more for match expressions.

With regards to printing, the previous behaviour was to just print the error message string directly, despite it containing indentation which caused it to overflow the standard terminal width of 80 columns (try `rustc --explain E0004`). The first approach I considered was to strip the leading whitespace from each line and lay out the text dynamically, inserting spaces in between. This approach became quite messy when taking multi-paragraph errors into account (and seemed overkill). The approach I settled on removes the indentation in the string itself and begins each message with a newline that is stripped before printing.

I feel like complete extended errors would be nice to have for 1.0.0 and I'm happy to spearhead an effort to get them written. Brian got me onto writing them at an SF meetup and I think it shouldn't be too hard to get the remaining 80 or so written with the help of people who don't really work on compiler innards.

9 years agoModify the ExprUseVisitor to walk each part of an AutoRef, and in
Niko Matsakis [Wed, 8 Apr 2015 08:31:51 +0000 (04:31 -0400)]
Modify the ExprUseVisitor to walk each part of an AutoRef, and in
particular to treat an AutoUnsize as as kind of "instantaneous" borrow
of the value being unsized. This prevents us from feeding uninitialized
data.

This caused a problem for the eager reborrow of comparison traits,
because that wound up introducing a "double AutoRef", which was not
being thoroughly checked before but turned out not to type check.
Fortunately, we can just remove that "eager reborrow" as it is no longer
needed now that `PartialEq` doesn't force both LHS and RHS to have the
same type (and even if we did have this problem, the better way would be
to lean on introducing a common supertype).

9 years agoAdd tests for #22289, #22370 and #22384
Luke Gallagher [Wed, 8 Apr 2015 13:23:43 +0000 (23:23 +1000)]
Add tests for #22289, #22370 and #22384

Closes #22289
Closes #22370
Closes #22384

9 years agoAuto merge of #24021 - pnkfelix:fn-params-outlive-body, r=nikomatsakis
bors [Wed, 8 Apr 2015 12:57:58 +0000 (12:57 +0000)]
Auto merge of #24021 - pnkfelix:fn-params-outlive-body, r=nikomatsakis

Encode more precise scoping rules for function params

Function params outlive everything in the body (incl temporaries).  Thus if we assign them their own `CodeExtent`, the region inference can properly show that it is sound to have temporaries with destructors that reference the parameters (because such temporaries will be dropped before the parameters are dropped).

Fix #23338

9 years agoAddress review nit by making `map_id` take an `FnMut`.
Felix S. Klock II [Wed, 8 Apr 2015 11:55:01 +0000 (13:55 +0200)]
Address review nit by making `map_id` take an `FnMut`.

9 years agoAuto merge of #23998 - nrc:impl-self, r=nikomatsakis
bors [Wed, 8 Apr 2015 09:58:05 +0000 (09:58 +0000)]
Auto merge of #23998 - nrc:impl-self, r=nikomatsakis

Closes #23909

r? @nikomatsakis (or anyone else, really)

9 years agoAuto merge of #24120 - aturon:range-perf, r=alexcrichton
bors [Wed, 8 Apr 2015 07:02:06 +0000 (07:02 +0000)]
Auto merge of #24120 - aturon:range-perf, r=alexcrichton

A recent change to the implementation of range iterators meant that,
even when stepping by 1, the iterators *always* involved checked
arithmetic.

This commit reverts to the earlier behavior (while retaining the
refactoring into traits).

Fixes #24095
Closes #24119
cc #24014

r? @alexcrichton

9 years agoAddress review comments
Seo Sanghyeon [Wed, 8 Apr 2015 04:55:18 +0000 (13:55 +0900)]
Address review comments

9 years agoalloc: impl fmt::Pointer for Rc, Arc and Box
Richo Healey [Tue, 7 Apr 2015 07:40:22 +0000 (00:40 -0700)]
alloc: impl fmt::Pointer for Rc, Arc and Box

Closes #24091

9 years agoAuto merge of #24078 - whipsch:extra-token-msg, r=huonw
bors [Wed, 8 Apr 2015 04:10:12 +0000 (04:10 +0000)]
Auto merge of #24078 - whipsch:extra-token-msg, r=huonw

Addresses issue #22425.  See `src/test/compile-fail/macro-incomplete-parse.rs` for a relevant test:

    macro-incomplete-parse.rs:15:9: 15:10 error: macro expansion ignores token `,` and any following
    macro-incomplete-parse.rs:15         , //~ ERROR macro expansion ignores token `,`
                                         ^
    macro-incomplete-parse.rs:27:1: 27:17 note: caused by the macro expansion here; the usage of `ignored_item` is likely invalid in this context
    macro-incomplete-parse.rs:27 ignored_item!();
                                 ^~~~~~~~~~~~~~~~
    macro-incomplete-parse.rs:20:14: 20:15 error: macro expansion ignores token `,` and any following
    macro-incomplete-parse.rs:20     () => ( 1, 2 ) //~ ERROR macro expansion ignores token `,`
                                              ^
    macro-incomplete-parse.rs:30:5: 30:21 note: caused by the macro expansion here; the usage of `ignored_expr` is likely invalid in this context
    macro-incomplete-parse.rs:30     ignored_expr!();
                                     ^~~~~~~~~~~~~~~~
    macro-incomplete-parse.rs:24:14: 24:15 error: macro expansion ignores token `,` and any following
    macro-incomplete-parse.rs:24     () => ( 1, 2 ) //~ ERROR macro expansion ignores token `,`
                                              ^
    macro-incomplete-parse.rs:32:9: 32:23 note: caused by the macro expansion here; the usage of `ignored_pat` is likely invalid in this context
    macro-incomplete-parse.rs:32         ignored_pat!() => (),
                                         ^~~~~~~~~~~~~~

This does not address the case of improper expansion inside of an impl { } as seen in issue #21607.

I'm not sure if the note text is ideal, but it can be refined if needed.

9 years agoUpdate "`let` is used to introduce variables" paragraph
York Xiang [Wed, 8 Apr 2015 02:29:11 +0000 (10:29 +0800)]
Update "`let` is used to introduce variables" paragraph

9 years agoImport real content.
Steve Klabnik [Wed, 8 Apr 2015 02:16:02 +0000 (22:16 -0400)]
Import real content.

9 years agorustdoc: Add a test for should_fail in doctests
Alex Crichton [Wed, 8 Apr 2015 00:40:13 +0000 (17:40 -0700)]
rustdoc: Add a test for should_fail in doctests

Closes #23744

9 years agorustdoc: Index inherent methods on primitives
Alex Crichton [Wed, 8 Apr 2015 00:35:23 +0000 (17:35 -0700)]
rustdoc: Index inherent methods on primitives

The set of types which can have an inherent impl changed slightly and rustdoc
just needed to catch up to understand what it means to see a `impl str`!

Closes #23511

9 years agostd: Hide facade extension traits in docs
Alex Crichton [Wed, 8 Apr 2015 00:15:58 +0000 (17:15 -0700)]
std: Hide facade extension traits in docs

These traits are currently all just unstable parts of the facade which are
implementation details for primitives further up the facade. This may make it
more difficult to find what set of methods you get if only linking to libcore,
but for now that's also unstable behavior.

Closes #22025

9 years agostd: Reorganize thread::local a bit
Alex Crichton [Wed, 8 Apr 2015 00:10:09 +0000 (17:10 -0700)]
std: Reorganize thread::local a bit

Make the structure more amenable to what rustdoc is expecting to ensure that
everything renders all nice and pretty in the output.

Closes #23705
Closes #23910

9 years agorustdoc: Handle duplicate reexports listed
Alex Crichton [Tue, 7 Apr 2015 23:18:49 +0000 (16:18 -0700)]
rustdoc: Handle duplicate reexports listed

This ends up causing duplicate output in rustdoc. The source of these duplicates
is that the item is defined in both resolve namespaces, so it's listed twice.

Closes #23207

9 years agorustdoc: Handle tests with bare `#` marks
Alex Crichton [Tue, 7 Apr 2015 22:30:05 +0000 (15:30 -0700)]
rustdoc: Handle tests with bare `#` marks

Strip them from output like other `# `-starting lines.

Closes #23106

9 years agobook: Fix a hyperlink to CONFIGS.md
Alex Crichton [Tue, 7 Apr 2015 22:22:57 +0000 (15:22 -0700)]
book: Fix a hyperlink to CONFIGS.md

Right now rustdoc replaces the string ".md)" with ".html)" to fix links between
markdown files, so use a different syntax that doesn't get caught in the
crossfire.

Closes #22900

9 years agomk: Stop documenating non-facade crates
Alex Crichton [Tue, 7 Apr 2015 22:11:16 +0000 (15:11 -0700)]
mk: Stop documenating non-facade crates

This commit ceases documentation-by-default of crates such as `term`,
`serialize`, and `alloc`. Crates like `term` and `rand` have duplicates on
`crates.io` and the search index entries generated in the local tree end up
only leading to confusion. Crates like the entire compiler infrastructure,
`flate`, or `rbml` don't need to be documented in such a prominent location.

This change also means that doc tests will no longer be run for crates beyond
the facade (e.g. `serialize` or `term`), but there were very few doc tests in
there to begin with.

Closes #22168

9 years agorustdoc: Encode ABI in all methods
Alex Crichton [Tue, 7 Apr 2015 21:22:55 +0000 (14:22 -0700)]
rustdoc: Encode ABI in all methods

This commit ensures that the ABI of functions is propagated all the way through
to the documentation.

Closes #22038

9 years agorustdoc: Simplify predicates with paren notation
Alex Crichton [Tue, 7 Apr 2015 19:20:24 +0000 (12:20 -0700)]
rustdoc: Simplify predicates with paren notation

This change is aimed at improving cross-crate (inlined) notation of generic
closures. The change modifies `simplify::where_predicates` to handle
parenthesized notation as well as starting to handle supertrait bounds as well.
This was necessary because all output constraints of closures are bound to
`FnOnce` but most trait bounds are that of `FnMut`.

Close #21801

9 years agorustdoc: Detect provided methods on inlined traits
Alex Crichton [Tue, 7 Apr 2015 18:50:14 +0000 (11:50 -0700)]
rustdoc: Detect provided methods on inlined traits

Closes #23864

9 years agobook: Emit links to play.rust-lang.org to run examples
Alex Crichton [Tue, 7 Apr 2015 18:23:14 +0000 (11:23 -0700)]
book: Emit links to play.rust-lang.org to run examples

Had to fix a bug in `--markdown-playground-url` for markdown files in rustdoc as
well as adding some necessary JS to the rustbook output as well.

Closes #21553

9 years agorustdoc: Don't duplicate inlined impl blocks
Alex Crichton [Tue, 7 Apr 2015 18:08:21 +0000 (11:08 -0700)]
rustdoc: Don't duplicate inlined impl blocks

Closes #21474

9 years agorustdoc: Add a test for #21092
Alex Crichton [Tue, 7 Apr 2015 17:53:10 +0000 (10:53 -0700)]
rustdoc: Add a test for #21092

Close #21092

9 years agorustdoc: Improve handling inlined associated types
Alex Crichton [Tue, 7 Apr 2015 07:16:35 +0000 (00:16 -0700)]
rustdoc: Improve handling inlined associated types

* All bounds are now discovered through the trait to be inlined.
* The `?Sized` bound now renders correctly for inlined associated types.
* All `QPath`s (`<A as B>::C`) instances are rendered as `A::C` where `C` is a
  hyperlink to the trait `B`. This should improve at least how the docs look at
  least.
* Supertrait bounds are now separated and display as the source lists them.

Closes #20727
Closes #21145

9 years agorustdoc: Simplify cross-crate where clauses
Alex Crichton [Tue, 7 Apr 2015 04:17:51 +0000 (21:17 -0700)]
rustdoc: Simplify cross-crate where clauses

Add a custom module to rustdoc which simplifies the output of `middle::ty` into
a more readable form which tends to be written down anyway!

Closes #20646

9 years agorustdoc: Show impls for references to types
Alex Crichton [Tue, 7 Apr 2015 03:15:59 +0000 (20:15 -0700)]
rustdoc: Show impls for references to types

It's somewhat common to impl traits for `&T` and `&mut T` so show these on the
pages for `T` to ensure they're listed somewhere at least.

Closes #20175

9 years agorustdoc: Render methods/impls for bare traits
Alex Crichton [Tue, 7 Apr 2015 02:21:52 +0000 (19:21 -0700)]
rustdoc: Render methods/impls for bare traits

This renders a "Methods" and "Trait Implementations" section for each item
implemented for a bare trait itself.

Closes #19055

9 years agostd: Deny most warnings in doctests
Alex Crichton [Tue, 7 Apr 2015 01:52:18 +0000 (18:52 -0700)]
std: Deny most warnings in doctests

Allow a few specific ones but otherwise this helps ensure that our examples are
squeaky clean!

Closes #18199

9 years agorustdoc: Allowing specifying attrs for doctests
Alex Crichton [Tue, 7 Apr 2015 01:39:39 +0000 (18:39 -0700)]
rustdoc: Allowing specifying attrs for doctests

This adds support in rustdoc to blanket apply crate attributes to all doc tests
for a crate at once. The syntax for doing this is:

    #![doc(test(attr(...)))]

Each meta item in `...` will be applied to each doctest as a crate attribute.

cc #18199

9 years agorustdoc: Link "Trait Implementations" to sources
Alex Crichton [Tue, 7 Apr 2015 00:56:35 +0000 (17:56 -0700)]
rustdoc: Link "Trait Implementations" to sources

All methods listed in "Trait Implementations" now hyperlink to the source trait
instead of themselves, allowing easy browsing of the documentation of a trait
method.

Closes #17476

9 years agorustdoc: Only hide possibly private modules
Alex Crichton [Mon, 6 Apr 2015 23:43:55 +0000 (16:43 -0700)]
rustdoc: Only hide possibly private modules

If an empty public module has no documentation, it shouldn't emit a page that's
just a redirect loop to itself!

Closes #16265

9 years agorustdoc: Add a test for fixed issue #16019
Alex Crichton [Mon, 6 Apr 2015 23:32:57 +0000 (16:32 -0700)]
rustdoc: Add a test for fixed issue #16019

Closes #16019

9 years agorustdoc: Add a test for fixed issue #15347
Alex Crichton [Mon, 6 Apr 2015 23:02:04 +0000 (16:02 -0700)]
rustdoc: Add a test for fixed issue #15347

Closes #15347

9 years agorustdoc: Add a primitive page for raw pointers
Alex Crichton [Mon, 6 Apr 2015 22:58:23 +0000 (15:58 -0700)]
rustdoc: Add a primitive page for raw pointers

Closes #15318

9 years agomk: Pass the same flags to rustdoc as rustc
Alex Crichton [Mon, 6 Apr 2015 22:26:27 +0000 (15:26 -0700)]
mk: Pass the same flags to rustdoc as rustc

This ensures that def ids don't drift too much over time.

Closes #15309

9 years agorustdoc: Add a test for #15169
Alex Crichton [Mon, 6 Apr 2015 22:21:15 +0000 (15:21 -0700)]
rustdoc: Add a test for #15169

9 years agorustdoc: Run external traits through filters
Alex Crichton [Mon, 6 Apr 2015 22:10:55 +0000 (15:10 -0700)]
rustdoc: Run external traits through filters

This ensures that all external traits are run through the same filters that the
rest of the AST goes through, stripping hidden function as necessary.

Closes #13698