Skip to content

Commit e1968dd

Browse files
committed
Auto merge of rust-lang#2747 - RalfJung:rustup, r=RalfJung
Rustup
2 parents 1010099 + 794cc08 commit e1968dd

File tree

812 files changed

+12080
-5589
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

812 files changed

+12080
-5589
lines changed

CONTRIBUTING.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ members](https://rust-lang.zulipchat.com/#narrow/stream/122652-new-members)
88
Zulip stream. We have lots of docs below of how to get started on your own, but
99
the Zulip stream is the best place to *ask* for help.
1010

11-
Documentation for contributing to Rust is located in the [Guide to Rustc Development](https://rustc-dev-guide.rust-lang.org/),
12-
commonly known as the [rustc-dev-guide]. Despite the name, this guide documents
13-
not just how to develop rustc (the Rust compiler), but also how to contribute to the standard library and rustdoc.
11+
Documentation for contributing to the compiler or tooling is located in the [Guide to Rustc
12+
Development][rustc-dev-guide], commonly known as the [rustc-dev-guide]. Documentation for the
13+
standard library in the [Standard library developers Guide][std-dev-guide], commonly known as the [std-dev-guide].
1414

1515
## About the [rustc-dev-guide]
1616

@@ -35,6 +35,7 @@ refer to [this section][contributing-bug-reports] and [open an issue][issue temp
3535

3636
[Contributing to Rust]: https://rustc-dev-guide.rust-lang.org/contributing.html#contributing-to-rust
3737
[rustc-dev-guide]: https://rustc-dev-guide.rust-lang.org/
38+
[std-dev-guide]: https://std-dev-guide.rust-lang.org/
3839
[contributing-bug-reports]: https://rustc-dev-guide.rust-lang.org/contributing.html#bug-reports
3940
[issue template]: https://github.com/rust-lang/rust/issues/new/choose
4041
[internals]: https://internals.rust-lang.org

Cargo.lock

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2675,9 +2675,9 @@ dependencies = [
26752675

26762676
[[package]]
26772677
name = "owo-colors"
2678-
version = "3.4.0"
2678+
version = "3.5.0"
26792679
source = "registry+https://github.com/rust-lang/crates.io-index"
2680-
checksum = "decf7381921fea4dcb2549c5667eda59b3ec297ab7e2b5fc33eac69d2e7da87b"
2680+
checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f"
26812681

26822682
[[package]]
26832683
name = "packed_simd_2"
@@ -5203,9 +5203,9 @@ dependencies = [
52035203

52045204
[[package]]
52055205
name = "termcolor"
5206-
version = "1.1.2"
5206+
version = "1.1.3"
52075207
source = "registry+https://github.com/rust-lang/crates.io-index"
5208-
checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4"
5208+
checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755"
52095209
dependencies = [
52105210
"winapi-util",
52115211
]
@@ -5309,6 +5309,7 @@ dependencies = [
53095309
"lazy_static",
53105310
"miropt-test-tools",
53115311
"regex",
5312+
"termcolor",
53125313
"walkdir",
53135314
]
53145315

README.md

Lines changed: 65 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,8 @@ standard library, and documentation.
55

66
[Rust]: https://www.rust-lang.org
77

8-
**Note: this README is for _users_ rather than _contributors_.
9-
If you wish to _contribute_ to the compiler, you should read the
10-
[Getting Started][gettingstarted] section of the rustc-dev-guide instead.
11-
You can ask for help in the [#new members Zulip stream][new-members].**
12-
13-
[new-members]: https://rust-lang.zulipchat.com/#narrow/stream/122652-new-members
8+
**Note: this README is for _users_ rather than _contributors_.**
9+
If you wish to _contribute_ to the compiler, you should read [CONTRIBUTING.md](CONTRIBUTING.md) instead.
1410

1511
## Quick Start
1612

@@ -24,22 +20,23 @@ Read ["Installation"] from [The Book].
2420
The Rust build system uses a Python script called `x.py` to build the compiler,
2521
which manages the bootstrapping process. It lives at the root of the project.
2622

27-
The `x.py` command can be run directly on most systems in the following format:
23+
The `x.py` command can be run directly on most Unix systems in the following format:
2824

2925
```sh
3026
./x.py <subcommand> [flags]
3127
```
3228

33-
This is how the documentation and examples assume you are running `x.py`.
34-
35-
Systems such as Ubuntu 20.04 LTS do not create the necessary `python` command by default when Python is installed that allows `x.py` to be run directly. In that case, you can either create a symlink for `python` (Ubuntu provides the `python-is-python3` package for this), or run `x.py` using Python itself:
29+
This is how the documentation and examples assume you are running `x.py`. Some alternative ways are:
3630

3731
```sh
38-
# Python 3
39-
python3 x.py <subcommand> [flags]
32+
# On a Unix shell if you don't have the necessary `python3` command
33+
./x <subcommand> [flags]
4034

41-
# Python 2.7
42-
python2.7 x.py <subcommand> [flags]
35+
# On the Windows Command Prompt (if .py files are configured to run Python)
36+
x.py <subcommand> [flags]
37+
38+
# You can also run Python yourself, e.g.:
39+
python x.py <subcommand> [flags]
4340
```
4441

4542
More information about `x.py` can be found
@@ -48,20 +45,37 @@ by running it with the `--help` flag or reading the [rustc dev guide][rustcguide
4845
[gettingstarted]: https://rustc-dev-guide.rust-lang.org/getting-started.html
4946
[rustcguidebuild]: https://rustc-dev-guide.rust-lang.org/building/how-to-build-and-run.html
5047

51-
### Building on a Unix-like system
52-
1. Make sure you have installed the dependencies:
48+
### Dependencies
49+
50+
Make sure you have installed the dependencies:
5351

54-
* `g++` 5.1 or later or `clang++` 3.5 or later
5552
* `python` 3 or 2.7
56-
* GNU `make` 3.81 or later
57-
* `cmake` 3.13.4 or later
58-
* `ninja`
59-
* `curl`
6053
* `git`
61-
* `ssl` which comes in `libssl-dev` or `openssl-devel`
54+
* A C compiler (when building for the host, `cc` is enough; cross-compiling may need additional compilers)
55+
* `curl` (not needed on Windows)
6256
* `pkg-config` if you are compiling on Linux and targeting Linux
57+
* `libiconv` (already included with glibc on Debian-based distros)
58+
59+
To build cargo, you'll also need OpenSSL (`libssl-dev` or `openssl-devel` on most Unix distros).
60+
61+
If building LLVM from source, you'll need additional tools:
62+
63+
* `g++`, `clang++`, or MSVC with versions listed on
64+
[LLVM's documentation](https://llvm.org/docs/GettingStarted.html#host-c-toolchain-both-compiler-and-standard-library)
65+
* `ninja`, or GNU `make` 3.81 or later (ninja is recommended, especially on Windows)
66+
* `cmake` 3.13.4 or later
67+
* `libstdc++-static` may be required on some Linux distributions such as Fedora and Ubuntu
68+
69+
On tier 1 or tier 2 with host tools platforms, you can also choose to download LLVM by setting `llvm.download-ci-llvm = true`.
70+
Otherwise, you'll need LLVM installed and `llvm-config` in your path.
71+
See [the rustc-dev-guide for more info][sysllvm].
72+
73+
[sysllvm]: https://rustc-dev-guide.rust-lang.org/building/new-target.html#using-pre-built-llvm
74+
75+
76+
### Building on a Unix-like system
6377

64-
2. Clone the [source] with `git`:
78+
1. Clone the [source] with `git`:
6579

6680
```sh
6781
git clone https://github.com/rust-lang/rust.git
@@ -70,38 +84,49 @@ by running it with the `--help` flag or reading the [rustc dev guide][rustcguide
7084

7185
[source]: https://github.com/rust-lang/rust
7286

73-
3. Configure the build settings:
87+
2. Configure the build settings:
7488

7589
The Rust build system uses a file named `config.toml` in the root of the
7690
source tree to determine various configuration settings for the build.
77-
Copy the default `config.toml.example` to `config.toml` to get started.
91+
Set up the defaults intended for distros to get started. You can see a full list of options
92+
in `config.toml.example`.
7893

7994
```sh
80-
cp config.toml.example config.toml
95+
printf 'profile = "user" \nchangelog-seen = 2 \n' > config.toml
8196
```
8297

8398
If you plan to use `x.py install` to create an installation, it is recommended
8499
that you set the `prefix` value in the `[install]` section to a directory.
85100

86-
Create an install directory if you are not installing in the default directory.
87-
88-
4. Build and install:
101+
3. Build and install:
89102

90103
```sh
91104
./x.py build && ./x.py install
92105
```
93106

94107
When complete, `./x.py install` will place several programs into
95108
`$PREFIX/bin`: `rustc`, the Rust compiler, and `rustdoc`, the
96-
API-documentation tool. This install does not include [Cargo],
97-
Rust's package manager. To build and install Cargo, you may
98-
run `./x.py install cargo` or set the `build.extended` key in
99-
`config.toml` to `true` to build and install all tools.
109+
API-documentation tool. If you've set `profile = "user"` or `build.extended = true`, it will
110+
also include [Cargo], Rust's package manager.
100111

101112
[Cargo]: https://github.com/rust-lang/cargo
102113

103114
### Building on Windows
104115

116+
On Windows, we suggest using [winget] to install dependencies by running the following in a terminal:
117+
118+
```powershell
119+
winget install -e Python.Python.3
120+
winget install -e Kitware.CMake
121+
winget install -e Git.Git
122+
```
123+
124+
Then edit your system's `PATH` variable and add: `C:\Program Files\CMake\bin`. See
125+
[this guide on editing the system `PATH`](https://www.java.com/en/download/help/path.html) from the
126+
Java documentation.
127+
128+
[winget]: https://github.com/microsoft/winget-cli
129+
105130
There are two prominent ABIs in use on Windows: the native (MSVC) ABI used by
106131
Visual Studio and the GNU ABI used by the GCC toolchain. Which version of Rust
107132
you need depends largely on what C/C++ libraries you want to interoperate with.
@@ -190,7 +215,7 @@ Windows build triples are:
190215
- `x86_64-pc-windows-msvc`
191216

192217
The build triple can be specified by either specifying `--build=<triple>` when
193-
invoking `x.py` commands, or by copying the `config.toml` file (as described
218+
invoking `x.py` commands, or by creating a `config.toml` file (as described
194219
in [Installing From Source](#installing-from-source)), and modifying the
195220
`build` option under the `[build]` section.
196221

@@ -204,9 +229,7 @@ configure script and makefile (the latter of which just invokes `x.py`).
204229
make && sudo make install
205230
```
206231

207-
When using the configure script, the generated `config.mk` file may override the
208-
`config.toml` file. To go back to the `config.toml` file, delete the generated
209-
`config.mk` file.
232+
`configure` generates a `config.toml` which can also be used with normal `x.py` invocations.
210233

211234
## Building Documentation
212235

@@ -227,41 +250,20 @@ precompiled "snapshot" version of itself (made in an earlier stage of
227250
development). As such, source builds require an Internet connection to
228251
fetch snapshots, and an OS that can execute the available snapshot binaries.
229252

230-
Snapshot binaries are currently built and tested on several platforms:
231-
232-
| Platform / Architecture | x86 | x86_64 |
233-
|---------------------------------------------|-----|--------|
234-
| Windows (7, 8, 10, ...) | ✓ | ✓ |
235-
| Linux (kernel 3.2, glibc 2.17 or later) | ✓ | ✓ |
236-
| macOS (10.7 Lion or later) | (\*) | ✓ |
237-
238-
(\*): Apple dropped support for running 32-bit binaries starting from macOS 10.15 and iOS 11.
239-
Due to this decision from Apple, the targets are no longer useful to our users.
240-
Please read [our blog post][macx32] for more info.
241-
242-
[macx32]: https://blog.rust-lang.org/2020/01/03/reducing-support-for-32-bit-apple-targets.html
253+
See https://doc.rust-lang.org/nightly/rustc/platform-support.html for a list of supported platforms.
254+
Only "host tools" platforms have a pre-compiled snapshot binary available; to compile for a platform
255+
without host tools you must cross-compile.
243256

244257
You may find that other platforms work, but these are our officially
245258
supported build environments that are most likely to work.
246259

247260
## Getting Help
248261

249-
The Rust community congregates in a few places:
250-
251-
* [Stack Overflow] - Direct questions about using the language.
252-
* [users.rust-lang.org] - General discussion and broader questions.
253-
* [/r/rust] - News and general discussion.
254-
255-
[Stack Overflow]: https://stackoverflow.com/questions/tagged/rust
256-
[/r/rust]: https://reddit.com/r/rust
257-
[users.rust-lang.org]: https://users.rust-lang.org/
262+
See https://www.rust-lang.org/community for a list of chat platforms and forums.
258263

259264
## Contributing
260265

261-
If you are interested in contributing to the Rust project, please take a look
262-
at the [Getting Started][gettingstarted] guide in the [rustc-dev-guide].
263-
264-
[rustc-dev-guide]: https://rustc-dev-guide.rust-lang.org
266+
See [CONTRIBUTING.md](CONTRIBUTING.md).
265267

266268
## License
267269

compiler/rustc_ast/src/ast.rs

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ impl Pat {
572572
PatKind::MacCall(mac) => TyKind::MacCall(mac.clone()),
573573
// `&mut? P` can be reinterpreted as `&mut? T` where `T` is `P` reparsed as a type.
574574
PatKind::Ref(pat, mutbl) => {
575-
pat.to_ty().map(|ty| TyKind::Rptr(None, MutTy { ty, mutbl: *mutbl }))?
575+
pat.to_ty().map(|ty| TyKind::Ref(None, MutTy { ty, mutbl: *mutbl }))?
576576
}
577577
// A slice/array pattern `[P]` can be reparsed as `[T]`, an unsized array,
578578
// when `P` can be reparsed as a type `T`.
@@ -1193,7 +1193,7 @@ impl Expr {
11931193
ExprKind::Paren(expr) => expr.to_ty().map(TyKind::Paren)?,
11941194

11951195
ExprKind::AddrOf(BorrowKind::Ref, mutbl, expr) => {
1196-
expr.to_ty().map(|ty| TyKind::Rptr(None, MutTy { ty, mutbl: *mutbl }))?
1196+
expr.to_ty().map(|ty| TyKind::Ref(None, MutTy { ty, mutbl: *mutbl }))?
11971197
}
11981198

11991199
ExprKind::Repeat(expr, expr_len) => {
@@ -2031,7 +2031,7 @@ impl Clone for Ty {
20312031
impl Ty {
20322032
pub fn peel_refs(&self) -> &Self {
20332033
let mut final_ty = self;
2034-
while let TyKind::Rptr(_, MutTy { ty, .. }) = &final_ty.kind {
2034+
while let TyKind::Ref(_, MutTy { ty, .. }) = &final_ty.kind {
20352035
final_ty = ty;
20362036
}
20372037
final_ty
@@ -2058,7 +2058,7 @@ pub enum TyKind {
20582058
/// A raw pointer (`*const T` or `*mut T`).
20592059
Ptr(MutTy),
20602060
/// A reference (`&'a T` or `&'a mut T`).
2061-
Rptr(Option<Lifetime>, MutTy),
2061+
Ref(Option<Lifetime>, MutTy),
20622062
/// A bare function (e.g., `fn(usize) -> bool`).
20632063
BareFn(P<BareFnTy>),
20642064
/// The never type (`!`).
@@ -2286,7 +2286,7 @@ impl Param {
22862286
if ident.name == kw::SelfLower {
22872287
return match self.ty.kind {
22882288
TyKind::ImplicitSelf => Some(respan(self.pat.span, SelfKind::Value(mutbl))),
2289-
TyKind::Rptr(lt, MutTy { ref ty, mutbl }) if ty.kind.is_implicit_self() => {
2289+
TyKind::Ref(lt, MutTy { ref ty, mutbl }) if ty.kind.is_implicit_self() => {
22902290
Some(respan(self.pat.span, SelfKind::Region(lt, mutbl)))
22912291
}
22922292
_ => Some(respan(
@@ -2319,7 +2319,7 @@ impl Param {
23192319
Mutability::Not,
23202320
P(Ty {
23212321
id: DUMMY_NODE_ID,
2322-
kind: TyKind::Rptr(lt, MutTy { ty: infer_ty, mutbl }),
2322+
kind: TyKind::Ref(lt, MutTy { ty: infer_ty, mutbl }),
23232323
span,
23242324
tokens: None,
23252325
}),
@@ -2743,8 +2743,19 @@ impl Item {
27432743
/// `extern` qualifier on a function item or function type.
27442744
#[derive(Clone, Copy, Encodable, Decodable, Debug)]
27452745
pub enum Extern {
2746+
/// No explicit extern keyword was used
2747+
///
2748+
/// E.g. `fn foo() {}`
27462749
None,
2750+
/// An explicit extern keyword was used, but with implicit ABI
2751+
///
2752+
/// E.g. `extern fn foo() {}`
2753+
///
2754+
/// This is just `extern "C"` (see `rustc_target::spec::abi::Abi::FALLBACK`)
27472755
Implicit(Span),
2756+
/// An explicit extern keyword was used with an explicit ABI
2757+
///
2758+
/// E.g. `extern "C" fn foo() {}`
27482759
Explicit(StrLit, Span),
27492760
}
27502761

@@ -2763,9 +2774,13 @@ impl Extern {
27632774
/// included in this struct (e.g., `async unsafe fn` or `const extern "C" fn`).
27642775
#[derive(Clone, Copy, Encodable, Decodable, Debug)]
27652776
pub struct FnHeader {
2777+
/// The `unsafe` keyword, if any
27662778
pub unsafety: Unsafe,
2779+
/// The `async` keyword, if any
27672780
pub asyncness: Async,
2781+
/// The `const` keyword, if any
27682782
pub constness: Const,
2783+
/// The `extern` keyword and corresponding ABI string, if any
27692784
pub ext: Extern,
27702785
}
27712786

compiler/rustc_ast/src/mut_visit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ pub fn noop_visit_ty<T: MutVisitor>(ty: &mut P<Ty>, vis: &mut T) {
459459
TyKind::Infer | TyKind::ImplicitSelf | TyKind::Err | TyKind::Never | TyKind::CVarArgs => {}
460460
TyKind::Slice(ty) => vis.visit_ty(ty),
461461
TyKind::Ptr(mt) => vis.visit_mt(mt),
462-
TyKind::Rptr(lt, mt) => {
462+
TyKind::Ref(lt, mt) => {
463463
visit_opt(lt, |lt| noop_visit_lifetime(lt, vis));
464464
vis.visit_mt(mt);
465465
}

compiler/rustc_ast/src/token.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,10 @@ impl Token {
379379
}
380380
}
381381

382+
pub fn is_range_separator(&self) -> bool {
383+
[DotDot, DotDotDot, DotDotEq].contains(&self.kind)
384+
}
385+
382386
pub fn is_op(&self) -> bool {
383387
match self.kind {
384388
Eq | Lt | Le | EqEq | Ne | Ge | Gt | AndAnd | OrOr | Not | Tilde | BinOp(_)

0 commit comments

Comments
 (0)