Skip to content

Rollup of 9 pull requests #40148

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 25 commits into from
Feb 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
7e0c3de
Remove `else`, unindent.
frewsxcv Feb 19, 2017
de2f7e1
Rewrite `match` to use combinators.
frewsxcv Feb 19, 2017
83fe48d
Remove `else`, unindent.
frewsxcv Feb 19, 2017
a97aed7
Remove unnecessary logic when finding simpilar `impl` candidates.
frewsxcv Feb 19, 2017
2436d73
Extract out error message generation.
frewsxcv Feb 19, 2017
10639d7
Add early return, remove `else`, unindent.
frewsxcv Feb 19, 2017
23d9211
Flatten `for` loop using iterator combinators.
frewsxcv Feb 19, 2017
a754ea6
Move `TraitRef` `impl` next to `struct` definition.
frewsxcv Feb 20, 2017
d3b8f56
Add missing urls and examples for Condvar docs
GuillaumeGomez Feb 22, 2017
8c8eda8
Fix nightly-only experimental API display
GuillaumeGomez Feb 23, 2017
8079bf3
Example for how to provide stdin using std::process::Command
robinst Feb 27, 2017
e998666
Remove unnecessary "for"
koba-e964 Feb 27, 2017
b70f929
Make lifetime elision docs clearer
MajorBreakfast Feb 27, 2017
988be44
Add compile fail test for unboxed_closures feature
topecongiro Feb 23, 2017
5933560
Add missing docs and examples for fmt::Write
GuillaumeGomez Feb 27, 2017
fb2d763
Replace ./configure with config.toml in README.md and CONTRIBUTING.md
keeperofdakeys Feb 23, 2017
227285f
Rollup merge of #39977 - frewsxcv:error-reporting-cleanup, r=eddyb
frewsxcv Feb 28, 2017
5be0d9f
Rollup merge of #40033 - GuillaumeGomez:condvar-docs, r=frewsxcv
frewsxcv Feb 28, 2017
922a262
Rollup merge of #40047 - topecongiro:master, r=est31
frewsxcv Feb 28, 2017
2623d35
Rollup merge of #40056 - keeperofdakeys:contributing, r=alexcrichton
frewsxcv Feb 28, 2017
15cd43b
Rollup merge of #40057 - GuillaumeGomez:html-issue, r=frewsxcv
frewsxcv Feb 28, 2017
6ac7bf5
Rollup merge of #40122 - robinst:process-add-example-for-writing-to-s…
frewsxcv Feb 28, 2017
da703a8
Rollup merge of #40124 - koba-e964:patch-1, r=steveklabnik
frewsxcv Feb 28, 2017
c4b6c98
Rollup merge of #40126 - GuillaumeGomez:fmt-write-docs, r=frewsxcv
frewsxcv Feb 28, 2017
a851fc1
Rollup merge of #40131 - MajorBreakfast:patch-3, r=steveklabnik
frewsxcv Feb 28, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 31 additions & 23 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,33 +97,38 @@ system internals, try asking in [`#rust-internals`][pound-rust-internals].

Before you can start building the compiler you need to configure the build for
your system. In most cases, that will just mean using the defaults provided
for Rust. Configuring involves invoking the `configure` script in the project
root.
for Rust.

```
./configure
```
To change configuration, you must copy the file `src/bootstrap/config.toml.example`
to `config.toml` in the directory from which you will be running the build, and
change the settings provided.

There are large number of options provided in this config file that will alter the
configuration used in the build process. Some options to note:

There are large number of options accepted by this script to alter the
configuration used later in the build process. Some options to note:
#### `[llvm]`:
- `ccache = true` - Use ccache when building llvm

- `--enable-debug` - Build a debug version of the compiler (disables optimizations,
which speeds up compilation of stage1 rustc)
- `--enable-optimize` - Enable optimizations (can be used with `--enable-debug`
to make a debug build with optimizations)
- `--disable-valgrind-rpass` - Don't run tests with valgrind
- `--enable-clang` - Prefer clang to gcc for building dependencies (e.g., LLVM)
- `--enable-ccache` - Invoke clang/gcc with ccache to re-use object files between builds
- `--enable-compiler-docs` - Build compiler documentation
#### `[build]`:
- `compiler-docs = true` - Build compiler documentation

To see a full list of options, run `./configure --help`.
#### `[rust]`:
- `debuginfo = true` - Build a compiler with debuginfo
- `optimize = false` - Disable optimizations to speed up compilation of stage1 rust

For more options, the `config.toml` file contains commented out defaults, with
descriptions of what each option will do.

Note: Previously the `./configure` script was used to configure this
project. It can still be used, but it's recommended to use a `config.toml`
file. If you still have a `config.mk` file in your directory - from
`./configure` - you may need to delete it for `config.toml` to work.

### Building

Although the `./configure` script will generate a `Makefile`, this is actually
just a thin veneer over the actual build system driver, `x.py`. This file, at
the root of the repository, is used to build, test, and document various parts
of the compiler. You can execute it as:
The build system uses the `x.py` script to control the build process. This script
is used to build, test, and document various parts of the compiler. You can
execute it as:

```sh
python x.py build
Expand Down Expand Up @@ -185,6 +190,9 @@ To learn about all possible rules you can execute, run:
python x.py build --help --verbose
```

Note: Previously `./configure` and `make` were used to build this project.
They are still available, but `x.py` is the recommended build system.

### Useful commands

Some common invocations of `x.py` are:
Expand Down Expand Up @@ -235,8 +243,8 @@ feature. We use the 'fork and pull' model described there.

Please make pull requests against the `master` branch.

Compiling all of `make check` can take a while. When testing your pull request,
consider using one of the more specialized `make` targets to cut down on the
Compiling all of `./x.py test` can take a while. When testing your pull request,
consider using one of the more specialized `./x.py` targets to cut down on the
amount of time you have to wait. You need to have built the compiler at least
once before running these will work, but that’s only one full build rather than
one each time.
Expand Down Expand Up @@ -307,7 +315,7 @@ To find documentation-related issues, sort by the [A-docs label][adocs].

[adocs]: https://github.com/rust-lang/rust/issues?q=is%3Aopen+is%3Aissue+label%3AA-docs

In many cases, you don't need a full `make doc`. You can use `rustdoc` directly
In many cases, you don't need a full `./x.py doc`. You can use `rustdoc` directly
to check small fixes. For example, `rustdoc src/doc/reference.md` will render
reference to `doc/reference.html`. The CSS might be messed up, but you can
verify that the HTML is right.
Expand Down
59 changes: 40 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ Read ["Installing Rust"] from [The Book].
3. Build and install:

```sh
$ ./configure
$ make && sudo make install
$ ./x.py build && sudo ./x.py dist --install
```

> ***Note:*** Install locations can be adjusted by passing a `--prefix`
> argument to `configure`. Various other options are also supported – pass
> `--help` for more information on them.
> ***Note:*** Install locations can be adjusted by copying the config file
> from `./src/bootstrap/config.toml.example` to `./config.toml`, and
> adjusting the `prefix` option under `[install]`. Various other options are
> also supported, and are documented in the config file.

When complete, `sudo make install` will place several programs into
When complete, `sudo ./x.py dist --install` will place several programs into
`/usr/local/bin`: `rustc`, the Rust compiler, and `rustdoc`, the
API-documentation tool. This install does not include [Cargo],
Rust's package manager, which you may also want to build.
Expand All @@ -59,7 +59,6 @@ for interop with software produced by Visual Studio use the MSVC build of Rust;
for interop with GNU software built using the MinGW/MSYS2 toolchain use the GNU
build.


#### MinGW

[MSYS2][msys2] can be used to easily build Rust on Windows:
Expand Down Expand Up @@ -94,11 +93,10 @@ build.
mingw-w64-x86_64-gcc
```

4. Navigate to Rust's source code (or clone it), then configure and build it:
4. Navigate to Rust's source code (or clone it), then build it:

```sh
$ ./configure
$ make && make install
$ ./x.py build && ./x.py dist --install
```

#### MSVC
Expand All @@ -114,13 +112,6 @@ shell with:
> python x.py build
```

If you're running inside of an msys shell, however, you can run:

```sh
$ ./configure --build=x86_64-pc-windows-msvc
$ make && make install
```

Currently building Rust only works with some known versions of Visual Studio. If
you have a more recent version installed the build system doesn't understand
then you may need to force rustbuild to use an older version. This can be done
Expand All @@ -131,13 +122,43 @@ CALL "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\vcvars64.
python x.py build
```

#### Specifying an ABI

Each specific ABI can also be used from either environment (for example, using
the GNU ABI in powershell) by using an explicit build triple. The available
Windows build triples are:
- GNU ABI (using GCC)
- `i686-pc-windows-gnu`
- `x86_64-pc-windows-gnu`
- The MSVC ABI
- `i686-pc-windows-msvc`
- `x86_64-pc-windows-msvc`

The build triple can be specified by either specifying `--build=ABI` when
invoking `x.py` commands, or by copying the `config.toml` file (as described
in Building From Source), and modifying the `build` option under the `[build]`
section.

### Configure and Make

While it's not the recommended build system, this project also provides a
configure script and makefile (the latter of which just invokes `x.py`).

```sh
$ ./configure
$ make && sudo make install
```

When using the configure script, the generated config.mk` file may override the
`config.toml` file. To go back to the `config.toml` file, delete the generated
`config.mk` file.

## Building Documentation

If you’d like to build the documentation, it’s almost the same:

```sh
$ ./configure
$ make docs
$ ./x.py doc
```

The generated documentation will appear in a top-level `doc` directory,
Expand Down
4 changes: 2 additions & 2 deletions src/doc/book/src/lifetimes.md
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,8 @@ to it.

## Lifetime Elision

Rust supports powerful local type inference in the bodies of functions but not in their item signatures.
It's forbidden to allow reasoning about types based on the item signature alone.
Rust supports powerful local type inference in the bodies of functions, but it
deliberately does not perform any reasoning about types for item signatures.
However, for ergonomic reasons, a very restricted secondary inference algorithm called
“lifetime elision” does apply when judging lifetimes. Lifetime elision is concerned solely with inferring
lifetime parameters using three easily memorizable and unambiguous rules. This means lifetime elision
Expand Down
2 changes: 1 addition & 1 deletion src/doc/book/src/procedural-macros.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ pub fn hello_world(input: TokenStream) -> TokenStream {
So there is a lot going on here. We have introduced two new crates: [`syn`] and
[`quote`]. As you may have noticed, `input: TokenSteam` is immediately converted
to a `String`. This `String` is a string representation of the Rust code for which
we are deriving `HelloWorld` for. At the moment, the only thing you can do with a
we are deriving `HelloWorld`. At the moment, the only thing you can do with a
`TokenStream` is convert it to a string. A richer API will exist in the future.

So what we really need is to be able to _parse_ Rust code into something
Expand Down
71 changes: 62 additions & 9 deletions src/libcore/fmt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,15 @@ pub struct Error;
/// A collection of methods that are required to format a message into a stream.
///
/// This trait is the type which this modules requires when formatting
/// information. This is similar to the standard library's `io::Write` trait,
/// information. This is similar to the standard library's [`io::Write`] trait,
/// but it is only intended for use in libcore.
///
/// This trait should generally not be implemented by consumers of the standard
/// library. The `write!` macro accepts an instance of `io::Write`, and the
/// `io::Write` trait is favored over implementing this trait.
/// library. The [`write!`] macro accepts an instance of [`io::Write`], and the
/// [`io::Write`] trait is favored over implementing this trait.
///
/// [`write!`]: ../../std/macro.write.html
/// [`io::Write`]: ../../std/io/trait.Write.html
#[stable(feature = "rust1", since = "1.0.0")]
pub trait Write {
/// Writes a slice of bytes into this writer, returning whether the write
Expand All @@ -82,29 +85,79 @@ pub trait Write {
///
/// # Errors
///
/// This function will return an instance of `Error` on error.
/// This function will return an instance of [`Error`] on error.
///
/// [`Error`]: struct.Error.html
///
/// # Examples
///
/// ```
/// use std::fmt::{Error, Write};
///
/// fn writer<W: Write>(f: &mut W, s: &str) -> Result<(), Error> {
/// f.write_str(s)
/// }
///
/// let mut buf = String::new();
/// writer(&mut buf, "hola").unwrap();
/// assert_eq!(&buf, "hola");
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
fn write_str(&mut self, s: &str) -> Result;

/// Writes a `char` into this writer, returning whether the write succeeded.
/// Writes a [`char`] into this writer, returning whether the write succeeded.
///
/// A single `char` may be encoded as more than one byte.
/// A single [`char`] may be encoded as more than one byte.
/// This method can only succeed if the entire byte sequence was successfully
/// written, and this method will not return until all data has been
/// written or an error occurs.
///
/// # Errors
///
/// This function will return an instance of `Error` on error.
/// This function will return an instance of [`Error`] on error.
///
/// [`char`]: ../../std/primitive.char.html
/// [`Error`]: struct.Error.html
///
/// # Examples
///
/// ```
/// use std::fmt::{Error, Write};
///
/// fn writer<W: Write>(f: &mut W, c: char) -> Result<(), Error> {
/// f.write_char(c)
/// }
///
/// let mut buf = String::new();
/// writer(&mut buf, 'a').unwrap();
/// writer(&mut buf, 'b').unwrap();
/// assert_eq!(&buf, "ab");
/// ```
#[stable(feature = "fmt_write_char", since = "1.1.0")]
fn write_char(&mut self, c: char) -> Result {
self.write_str(c.encode_utf8(&mut [0; 4]))
}

/// Glue for usage of the `write!` macro with implementors of this trait.
/// Glue for usage of the [`write!`] macro with implementors of this trait.
///
/// This method should generally not be invoked manually, but rather through
/// the `write!` macro itself.
/// the [`write!`] macro itself.
///
/// [`write!`]: ../../std/macro.write.html
///
/// # Examples
///
/// ```
/// use std::fmt::{Error, Write};
///
/// fn writer<W: Write>(f: &mut W, s: &str) -> Result<(), Error> {
/// f.write_fmt(format_args!("{}", s))
/// }
///
/// let mut buf = String::new();
/// writer(&mut buf, "world").unwrap();
/// assert_eq!(&buf, "world");
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
fn write_fmt(&mut self, args: Arguments) -> Result {
// This Adapter is needed to allow `self` (of type `&mut
Expand Down
Loading