Skip to content

Commit be76056

Browse files
committed
Auto merge of #40148 - frewsxcv:rollup, r=frewsxcv
Rollup of 9 pull requests - Successful merges: #39977, #40033, #40047, #40056, #40057, #40122, #40124, #40126, #40131 - Failed merges: #40101
2 parents 5872a8d + a851fc1 commit be76056

File tree

16 files changed

+663
-362
lines changed

16 files changed

+663
-362
lines changed

CONTRIBUTING.md

+31-23
Original file line numberDiff line numberDiff line change
@@ -97,33 +97,38 @@ system internals, try asking in [`#rust-internals`][pound-rust-internals].
9797

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

103-
```
104-
./configure
105-
```
102+
To change configuration, you must copy the file `src/bootstrap/config.toml.example`
103+
to `config.toml` in the directory from which you will be running the build, and
104+
change the settings provided.
105+
106+
There are large number of options provided in this config file that will alter the
107+
configuration used in the build process. Some options to note:
106108

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

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

119-
To see a full list of options, run `./configure --help`.
115+
#### `[rust]`:
116+
- `debuginfo = true` - Build a compiler with debuginfo
117+
- `optimize = false` - Disable optimizations to speed up compilation of stage1 rust
118+
119+
For more options, the `config.toml` file contains commented out defaults, with
120+
descriptions of what each option will do.
121+
122+
Note: Previously the `./configure` script was used to configure this
123+
project. It can still be used, but it's recommended to use a `config.toml`
124+
file. If you still have a `config.mk` file in your directory - from
125+
`./configure` - you may need to delete it for `config.toml` to work.
120126

121127
### Building
122128

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

128133
```sh
129134
python x.py build
@@ -185,6 +190,9 @@ To learn about all possible rules you can execute, run:
185190
python x.py build --help --verbose
186191
```
187192

193+
Note: Previously `./configure` and `make` were used to build this project.
194+
They are still available, but `x.py` is the recommended build system.
195+
188196
### Useful commands
189197

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

236244
Please make pull requests against the `master` branch.
237245

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

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

310-
In many cases, you don't need a full `make doc`. You can use `rustdoc` directly
318+
In many cases, you don't need a full `./x.py doc`. You can use `rustdoc` directly
311319
to check small fixes. For example, `rustdoc src/doc/reference.md` will render
312320
reference to `doc/reference.html`. The CSS might be messed up, but you can
313321
verify that the HTML is right.

README.md

+40-19
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ Read ["Installing Rust"] from [The Book].
3535
3. Build and install:
3636

3737
```sh
38-
$ ./configure
39-
$ make && sudo make install
38+
$ ./x.py build && sudo ./x.py dist --install
4039
```
4140

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

46-
When complete, `sudo make install` will place several programs into
46+
When complete, `sudo ./x.py dist --install` will place several programs into
4747
`/usr/local/bin`: `rustc`, the Rust compiler, and `rustdoc`, the
4848
API-documentation tool. This install does not include [Cargo],
4949
Rust's package manager, which you may also want to build.
@@ -59,7 +59,6 @@ for interop with software produced by Visual Studio use the MSVC build of Rust;
5959
for interop with GNU software built using the MinGW/MSYS2 toolchain use the GNU
6060
build.
6161
62-
6362
#### MinGW
6463
6564
[MSYS2][msys2] can be used to easily build Rust on Windows:
@@ -94,11 +93,10 @@ build.
9493
mingw-w64-x86_64-gcc
9594
```
9695

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

9998
```sh
100-
$ ./configure
101-
$ make && make install
99+
$ ./x.py build && ./x.py dist --install
102100
```
103101

104102
#### MSVC
@@ -114,13 +112,6 @@ shell with:
114112
> python x.py build
115113
```
116114

117-
If you're running inside of an msys shell, however, you can run:
118-
119-
```sh
120-
$ ./configure --build=x86_64-pc-windows-msvc
121-
$ make && make install
122-
```
123-
124115
Currently building Rust only works with some known versions of Visual Studio. If
125116
you have a more recent version installed the build system doesn't understand
126117
then you may need to force rustbuild to use an older version. This can be done
@@ -131,13 +122,43 @@ CALL "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\vcvars64.
131122
python x.py build
132123
```
133124

125+
#### Specifying an ABI
126+
127+
Each specific ABI can also be used from either environment (for example, using
128+
the GNU ABI in powershell) by using an explicit build triple. The available
129+
Windows build triples are:
130+
- GNU ABI (using GCC)
131+
- `i686-pc-windows-gnu`
132+
- `x86_64-pc-windows-gnu`
133+
- The MSVC ABI
134+
- `i686-pc-windows-msvc`
135+
- `x86_64-pc-windows-msvc`
136+
137+
The build triple can be specified by either specifying `--build=ABI` when
138+
invoking `x.py` commands, or by copying the `config.toml` file (as described
139+
in Building From Source), and modifying the `build` option under the `[build]`
140+
section.
141+
142+
### Configure and Make
143+
144+
While it's not the recommended build system, this project also provides a
145+
configure script and makefile (the latter of which just invokes `x.py`).
146+
147+
```sh
148+
$ ./configure
149+
$ make && sudo make install
150+
```
151+
152+
When using the configure script, the generated config.mk` file may override the
153+
`config.toml` file. To go back to the `config.toml` file, delete the generated
154+
`config.mk` file.
155+
134156
## Building Documentation
135157

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

138160
```sh
139-
$ ./configure
140-
$ make docs
161+
$ ./x.py doc
141162
```
142163

143164
The generated documentation will appear in a top-level `doc` directory,

src/doc/book/src/lifetimes.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -349,8 +349,8 @@ to it.
349349

350350
## Lifetime Elision
351351

352-
Rust supports powerful local type inference in the bodies of functions but not in their item signatures.
353-
It's forbidden to allow reasoning about types based on the item signature alone.
352+
Rust supports powerful local type inference in the bodies of functions, but it
353+
deliberately does not perform any reasoning about types for item signatures.
354354
However, for ergonomic reasons, a very restricted secondary inference algorithm called
355355
“lifetime elision” does apply when judging lifetimes. Lifetime elision is concerned solely with inferring
356356
lifetime parameters using three easily memorizable and unambiguous rules. This means lifetime elision

src/doc/book/src/procedural-macros.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ pub fn hello_world(input: TokenStream) -> TokenStream {
128128
So there is a lot going on here. We have introduced two new crates: [`syn`] and
129129
[`quote`]. As you may have noticed, `input: TokenSteam` is immediately converted
130130
to a `String`. This `String` is a string representation of the Rust code for which
131-
we are deriving `HelloWorld` for. At the moment, the only thing you can do with a
131+
we are deriving `HelloWorld`. At the moment, the only thing you can do with a
132132
`TokenStream` is convert it to a string. A richer API will exist in the future.
133133

134134
So what we really need is to be able to _parse_ Rust code into something

src/libcore/fmt/mod.rs

+62-9
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,15 @@ pub struct Error;
6565
/// A collection of methods that are required to format a message into a stream.
6666
///
6767
/// This trait is the type which this modules requires when formatting
68-
/// information. This is similar to the standard library's `io::Write` trait,
68+
/// information. This is similar to the standard library's [`io::Write`] trait,
6969
/// but it is only intended for use in libcore.
7070
///
7171
/// This trait should generally not be implemented by consumers of the standard
72-
/// library. The `write!` macro accepts an instance of `io::Write`, and the
73-
/// `io::Write` trait is favored over implementing this trait.
72+
/// library. The [`write!`] macro accepts an instance of [`io::Write`], and the
73+
/// [`io::Write`] trait is favored over implementing this trait.
74+
///
75+
/// [`write!`]: ../../std/macro.write.html
76+
/// [`io::Write`]: ../../std/io/trait.Write.html
7477
#[stable(feature = "rust1", since = "1.0.0")]
7578
pub trait Write {
7679
/// Writes a slice of bytes into this writer, returning whether the write
@@ -82,29 +85,79 @@ pub trait Write {
8285
///
8386
/// # Errors
8487
///
85-
/// This function will return an instance of `Error` on error.
88+
/// This function will return an instance of [`Error`] on error.
89+
///
90+
/// [`Error`]: struct.Error.html
91+
///
92+
/// # Examples
93+
///
94+
/// ```
95+
/// use std::fmt::{Error, Write};
96+
///
97+
/// fn writer<W: Write>(f: &mut W, s: &str) -> Result<(), Error> {
98+
/// f.write_str(s)
99+
/// }
100+
///
101+
/// let mut buf = String::new();
102+
/// writer(&mut buf, "hola").unwrap();
103+
/// assert_eq!(&buf, "hola");
104+
/// ```
86105
#[stable(feature = "rust1", since = "1.0.0")]
87106
fn write_str(&mut self, s: &str) -> Result;
88107

89-
/// Writes a `char` into this writer, returning whether the write succeeded.
108+
/// Writes a [`char`] into this writer, returning whether the write succeeded.
90109
///
91-
/// A single `char` may be encoded as more than one byte.
110+
/// A single [`char`] may be encoded as more than one byte.
92111
/// This method can only succeed if the entire byte sequence was successfully
93112
/// written, and this method will not return until all data has been
94113
/// written or an error occurs.
95114
///
96115
/// # Errors
97116
///
98-
/// This function will return an instance of `Error` on error.
117+
/// This function will return an instance of [`Error`] on error.
118+
///
119+
/// [`char`]: ../../std/primitive.char.html
120+
/// [`Error`]: struct.Error.html
121+
///
122+
/// # Examples
123+
///
124+
/// ```
125+
/// use std::fmt::{Error, Write};
126+
///
127+
/// fn writer<W: Write>(f: &mut W, c: char) -> Result<(), Error> {
128+
/// f.write_char(c)
129+
/// }
130+
///
131+
/// let mut buf = String::new();
132+
/// writer(&mut buf, 'a').unwrap();
133+
/// writer(&mut buf, 'b').unwrap();
134+
/// assert_eq!(&buf, "ab");
135+
/// ```
99136
#[stable(feature = "fmt_write_char", since = "1.1.0")]
100137
fn write_char(&mut self, c: char) -> Result {
101138
self.write_str(c.encode_utf8(&mut [0; 4]))
102139
}
103140

104-
/// Glue for usage of the `write!` macro with implementors of this trait.
141+
/// Glue for usage of the [`write!`] macro with implementors of this trait.
105142
///
106143
/// This method should generally not be invoked manually, but rather through
107-
/// the `write!` macro itself.
144+
/// the [`write!`] macro itself.
145+
///
146+
/// [`write!`]: ../../std/macro.write.html
147+
///
148+
/// # Examples
149+
///
150+
/// ```
151+
/// use std::fmt::{Error, Write};
152+
///
153+
/// fn writer<W: Write>(f: &mut W, s: &str) -> Result<(), Error> {
154+
/// f.write_fmt(format_args!("{}", s))
155+
/// }
156+
///
157+
/// let mut buf = String::new();
158+
/// writer(&mut buf, "world").unwrap();
159+
/// assert_eq!(&buf, "world");
160+
/// ```
108161
#[stable(feature = "rust1", since = "1.0.0")]
109162
fn write_fmt(&mut self, args: Arguments) -> Result {
110163
// This Adapter is needed to allow `self` (of type `&mut

0 commit comments

Comments
 (0)