Skip to content

Commit 8766bbd

Browse files
committed
Auto merge of #106111 - matthiaskrgr:rollup-nnpoe5h, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - #105465 (Improve top-level docs) - #105872 (Suggest remove last method call when type coerce with expected type) - #106032 (std: only use LFS function on glibc) - #106078 (Provide more context on FileCheck failures) - #106100 (Codegen test for derived `<` on trivial newtype [TEST ONLY]) - #106109 (rustdoc: make line number CSS for doc comment and scraped the same) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 5e8bab9 + 750bf73 commit 8766bbd

File tree

21 files changed

+281
-120
lines changed

21 files changed

+281
-120
lines changed

CONTRIBUTING.md

+4-3
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

README.md

+55-54
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,7 @@ standard library, and documentation.
66
[Rust]: https://www.rust-lang.org
77

88
**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
9+
If you wish to _contribute_ to the compiler, you should read [CONTRIBUTING.md](CONTRIBUTING.md) instead.
1410

1511
## Quick Start
1612

@@ -48,20 +44,37 @@ by running it with the `--help` flag or reading the [rustc dev guide][rustcguide
4844
[gettingstarted]: https://rustc-dev-guide.rust-lang.org/getting-started.html
4945
[rustcguidebuild]: https://rustc-dev-guide.rust-lang.org/building/how-to-build-and-run.html
5046

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

54-
* `g++` 5.1 or later or `clang++` 3.5 or later
5551
* `python` 3 or 2.7
56-
* GNU `make` 3.81 or later
57-
* `cmake` 3.13.4 or later
58-
* `ninja`
59-
* `curl`
6052
* `git`
61-
* `ssl` which comes in `libssl-dev` or `openssl-devel`
53+
* A C compiler (when building for the host, `cc` is enough; cross-compiling may need additional compilers)
54+
* `curl` (not needed on Windows)
6255
* `pkg-config` if you are compiling on Linux and targeting Linux
56+
* `libiconv` (already included with glibc on Debian-based distros)
57+
58+
To build cargo, you'll also need OpenSSL (`libssl-dev` or `openssl-devel` on most Unix distros).
59+
60+
If building LLVM from source, you'll need additional tools:
61+
62+
* `g++`, `clang++`, or MSVC with versions listed on
63+
[LLVM's documentation](https://llvm.org/docs/GettingStarted.html#host-c-toolchain-both-compiler-and-standard-library)
64+
* `ninja`, or GNU `make` 3.81 or later (ninja is recommended, especially on Windows)
65+
* `cmake` 3.13.4 or later
66+
* `libstdc++-static` may be required on some Linux distributions such as Fedora and Ubuntu
6367

64-
2. Clone the [source] with `git`:
68+
On tier 1 or tier 2 with host tools platforms, you can also choose to download LLVM by setting `llvm.download-ci-llvm = true`.
69+
Otherwise, you'll need LLVM installed and `llvm-config` in your path.
70+
See [the rustc-dev-guide for more info][sysllvm].
71+
72+
[sysllvm]: https://rustc-dev-guide.rust-lang.org/building/new-target.html#using-pre-built-llvm
73+
74+
75+
### Building on a Unix-like system
76+
77+
1. Clone the [source] with `git`:
6578

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

7184
[source]: https://github.com/rust-lang/rust
7285

73-
3. Configure the build settings:
86+
2. Configure the build settings:
7487

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

7993
```sh
80-
cp config.toml.example config.toml
94+
printf 'profile = "user" \nchangelog-seen = 2 \n' > config.toml
8195
```
8296

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

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

90102
```sh
91103
./x.py build && ./x.py install
92104
```
93105

94106
When complete, `./x.py install` will place several programs into
95107
`$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.
108+
API-documentation tool. If you've set `profile = "user"` or `build.extended = true`, it will
109+
also include [Cargo], Rust's package manager.
100110

101111
[Cargo]: https://github.com/rust-lang/cargo
102112

103113
### Building on Windows
104114

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

192216
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
217+
invoking `x.py` commands, or by creating a `config.toml` file (as described
194218
in [Installing From Source](#installing-from-source)), and modifying the
195219
`build` option under the `[build]` section.
196220

@@ -204,9 +228,7 @@ configure script and makefile (the latter of which just invokes `x.py`).
204228
make && sudo make install
205229
```
206230

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.
231+
`configure` generates a `config.toml` which can also be used with normal `x.py` invocations.
210232

211233
## Building Documentation
212234

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

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
252+
See https://doc.rust-lang.org/nightly/rustc/platform-support.html for a list of supported platforms.
253+
Only "host tools" platforms have a pre-compiled snapshot binary available; to compile for a platform
254+
without host tools you must cross-compile.
243255

244256
You may find that other platforms work, but these are our officially
245257
supported build environments that are most likely to work.
246258

247259
## Getting Help
248260

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/
261+
See https://www.rust-lang.org/community for a list of chat platforms and forums.
258262

259263
## Contributing
260264

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
265+
See [CONTRIBUTING.md](CONTRIBUTING.md).
265266

266267
## License
267268

compiler/rustc_hir_typeck/src/demand.rs

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
3838

3939
// Use `||` to give these suggestions a precedence
4040
let _ = self.suggest_missing_parentheses(err, expr)
41+
|| self.suggest_remove_last_method_call(err, expr, expected)
4142
|| self.suggest_associated_const(err, expr, expected)
4243
|| self.suggest_deref_ref_or_into(err, expr, expected, expr_ty, expected_ty_expr)
4344
|| self.suggest_option_to_bool(err, expr, expr_ty, expected)

compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs

+25
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,31 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
329329
}
330330
}
331331

332+
pub fn suggest_remove_last_method_call(
333+
&self,
334+
err: &mut Diagnostic,
335+
expr: &hir::Expr<'tcx>,
336+
expected: Ty<'tcx>,
337+
) -> bool {
338+
if let hir::ExprKind::MethodCall(hir::PathSegment { ident: method, .. }, recv_expr, &[], _) = expr.kind &&
339+
let Some(recv_ty) = self.typeck_results.borrow().expr_ty_opt(recv_expr) &&
340+
self.can_coerce(recv_ty, expected) {
341+
let span = if let Some(recv_span) = recv_expr.span.find_ancestor_inside(expr.span) {
342+
expr.span.with_lo(recv_span.hi())
343+
} else {
344+
expr.span.with_lo(method.span.lo() - rustc_span::BytePos(1))
345+
};
346+
err.span_suggestion_verbose(
347+
span,
348+
"try removing the method call",
349+
"",
350+
Applicability::MachineApplicable,
351+
);
352+
return true;
353+
}
354+
false
355+
}
356+
332357
pub fn suggest_deref_ref_or_into(
333358
&self,
334359
err: &mut Diagnostic,

library/std/src/sys/unix/fs.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1754,11 +1754,11 @@ mod remove_dir_impl {
17541754
use crate::sys::{cvt, cvt_r};
17551755

17561756
#[cfg(not(any(
1757-
target_os = "linux",
1757+
all(target_os = "linux", target_env = "gnu"),
17581758
all(target_os = "macos", not(target_arch = "aarch64"))
17591759
)))]
17601760
use libc::{fdopendir, openat, unlinkat};
1761-
#[cfg(target_os = "linux")]
1761+
#[cfg(all(target_os = "linux", target_env = "gnu"))]
17621762
use libc::{fdopendir, openat64 as openat, unlinkat};
17631763
#[cfg(all(target_os = "macos", not(target_arch = "aarch64")))]
17641764
use macos_weak::{fdopendir, openat, unlinkat};

library/std/src/sys/unix/kernel_copy.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ use crate::ptr;
6161
use crate::sync::atomic::{AtomicBool, AtomicU8, Ordering};
6262
use crate::sys::cvt;
6363
use crate::sys::weak::syscall;
64-
#[cfg(not(target_os = "linux"))]
64+
#[cfg(not(all(target_os = "linux", target_env = "gnu")))]
6565
use libc::sendfile as sendfile64;
66-
#[cfg(target_os = "linux")]
66+
#[cfg(all(target_os = "linux", target_env = "gnu"))]
6767
use libc::sendfile64;
6868
use libc::{EBADF, EINVAL, ENOSYS, EOPNOTSUPP, EOVERFLOW, EPERM, EXDEV};
6969

library/std/src/sys/unix/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@ pub unsafe fn init(argc: isize, argv: *const *const u8, sigpipe: u8) {
9595
)))]
9696
'poll: {
9797
use crate::sys::os::errno;
98-
#[cfg(not(target_os = "linux"))]
98+
#[cfg(not(all(target_os = "linux", target_env = "gnu")))]
9999
use libc::open as open64;
100-
#[cfg(target_os = "linux")]
100+
#[cfg(all(target_os = "linux", target_env = "gnu"))]
101101
use libc::open64;
102102
let pfds: &mut [_] = &mut [
103103
libc::pollfd { fd: 0, events: 0, revents: 0 },
@@ -143,9 +143,9 @@ pub unsafe fn init(argc: isize, argv: *const *const u8, sigpipe: u8) {
143143
)))]
144144
{
145145
use crate::sys::os::errno;
146-
#[cfg(not(target_os = "linux"))]
146+
#[cfg(not(all(target_os = "linux", target_env = "gnu")))]
147147
use libc::open as open64;
148-
#[cfg(target_os = "linux")]
148+
#[cfg(all(target_os = "linux", target_env = "gnu"))]
149149
use libc::open64;
150150
for fd in 0..3 {
151151
if libc::fcntl(fd, libc::F_GETFD) == -1 && errno() == libc::EBADF {

library/std/src/sys/unix/stack_overflow.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ mod imp {
4545
use crate::thread;
4646

4747
use libc::MAP_FAILED;
48-
#[cfg(not(target_os = "linux"))]
48+
#[cfg(not(all(target_os = "linux", target_env = "gnu")))]
4949
use libc::{mmap as mmap64, munmap};
50-
#[cfg(target_os = "linux")]
50+
#[cfg(all(target_os = "linux", target_env = "gnu"))]
5151
use libc::{mmap64, munmap};
5252
use libc::{sigaction, sighandler_t, SA_ONSTACK, SA_SIGINFO, SIGBUS, SIG_DFL};
5353
use libc::{sigaltstack, SIGSTKSZ, SS_DISABLE};

library/std/src/sys/unix/thread.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -653,9 +653,9 @@ pub mod guard {
653653
))]
654654
#[cfg_attr(test, allow(dead_code))]
655655
pub mod guard {
656-
#[cfg(not(target_os = "linux"))]
656+
#[cfg(not(all(target_os = "linux", target_env = "gnu")))]
657657
use libc::{mmap as mmap64, mprotect};
658-
#[cfg(target_os = "linux")]
658+
#[cfg(all(target_os = "linux", target_env = "gnu"))]
659659
use libc::{mmap64, mprotect};
660660
use libc::{MAP_ANON, MAP_FAILED, MAP_FIXED, MAP_PRIVATE, PROT_NONE, PROT_READ, PROT_WRITE};
661661

src/bootstrap/README.md

+2-8
Original file line numberDiff line numberDiff line change
@@ -80,18 +80,12 @@ The script accepts commands, flags, and arguments to determine what to do:
8080

8181
## Configuring rustbuild
8282

83-
There are currently two methods for configuring the rustbuild build system.
84-
85-
First, rustbuild offers a TOML-based configuration system with a `config.toml`
83+
rustbuild offers a TOML-based configuration system with a `config.toml`
8684
file. An example of this configuration can be found at `config.toml.example`,
8785
and the configuration file can also be passed as `--config path/to/config.toml`
8886
if the build system is being invoked manually (via the python script).
8987

90-
Next, the `./configure` options serialized in `config.mk` will be
91-
parsed and read. That is, if any `./configure` options are passed, they'll be
92-
handled naturally. `./configure` should almost never be used for local
93-
installations, and is primarily useful for CI. Prefer to customize behavior
94-
using `config.toml`.
88+
You can generate a config.toml using `./configure` options if you want to automate creating the file without having to edit it.
9589

9690
Finally, rustbuild makes use of the [cc-rs crate] which has [its own
9791
method][env-vars] of configuring C compilers and C flags via environment

src/bootstrap/config.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,7 @@ pub enum DryRun {
4949

5050
/// Global configuration for the entire build and/or bootstrap.
5151
///
52-
/// This structure is derived from a combination of both `config.toml` and
53-
/// `config.mk`. As of the time of this writing it's unlikely that `config.toml`
54-
/// is used all that much, so this is primarily filled out by `config.mk` which
55-
/// is generated from `./configure`.
52+
/// This structure is parsed from `config.toml`, and some of the fields are inferred from `git` or build-time parameters.
5653
///
5754
/// Note that this structure is not decoded directly into, but rather it is
5855
/// filled out from the decoded forms of the structs below. For documentation

0 commit comments

Comments
 (0)