Merge from rust-lang/rust

This commit is contained in:
Laurențiu Nicola 2025-02-24 09:42:57 +02:00
commit caeaa140d3
4 changed files with 36 additions and 3 deletions

View File

@ -75,6 +75,7 @@
- [Prologue](./building/bootstrapping/intro.md) - [Prologue](./building/bootstrapping/intro.md)
- [What Bootstrapping does](./building/bootstrapping/what-bootstrapping-does.md) - [What Bootstrapping does](./building/bootstrapping/what-bootstrapping-does.md)
- [How Bootstrap does it](./building/bootstrapping/how-bootstrap-does-it.md) - [How Bootstrap does it](./building/bootstrapping/how-bootstrap-does-it.md)
- [Writing tools in Bootstrap](./building/bootstrapping/writing-tools-in-bootstrap.md)
- [Debugging bootstrap](./building/bootstrapping/debugging-bootstrap.md) - [Debugging bootstrap](./building/bootstrapping/debugging-bootstrap.md)
# High-level Compiler Architecture # High-level Compiler Architecture

View File

@ -0,0 +1,23 @@
# Writing tools in Bootstrap
There are three types of tools you can write in bootstrap:
- **`Mode::ToolBootstrap`**
Use this for tools that dont need anything from the in-tree compiler and can run with the stage0 `rustc`.
The output is placed in the "stage0-bootstrap-tools" directory. This mode is for general-purpose tools built
entirely with the stage0 compiler, including target libraries and only works for stage 0.
- **`Mode::ToolStd`**
Use this for tools that rely on the locally built std. The output goes into the "stageN-tools" directory.
This mode is rarely used, mainly for `compiletest` which requires `libtest`.
- **`Mode::ToolRustc`**
Use this for tools that depend on both the locally built `rustc` and the target `std`. This is more complex than
the other modes because the tool must be built with the same compiler used for `rustc` and placed in the "stageN-tools"
directory. When you choose `Mode::ToolRustc`, `ToolBuild` implementation takes care of this automatically.
If you need to use the builders compiler for something specific, you can get it from `ToolBuildResult`, which is
returned by the tool's [`Step`].
Regardless of the tool type you must return `ToolBuildResult` from the tools [`Step`] implementation and use `ToolBuild` inside it.
[`Step`]: https://doc.rust-lang.org/nightly/nightly-rustc/bootstrap/core/builder/trait.Step.html

View File

@ -154,6 +154,16 @@ You can run `./x setup editor` and select `helix`, which will prompt you to
create `languages.toml` with the recommended configuration for Helix. The create `languages.toml` with the recommended configuration for Helix. The
recommended settings live at [`src/etc/rust_analyzer_helix.toml`]. recommended settings live at [`src/etc/rust_analyzer_helix.toml`].
### Zed
Zed comes with built-in LSP and rust-analyzer support.
It can be configured through `.zed/settings.json`, as described
[here](https://zed.dev/docs/configuring-languages). Selecting `zed`
in `./x setup editor` will prompt you to create a `.zed/settings.json`
file which will configure Zed with the recommended configuration. The
recommended `rust-analyzer` settings live
at [`src/etc/rust_analyzer_zed.json`].
## Check, check, and check again ## Check, check, and check again
When doing simple refactoring, it can be useful to run `./x check` When doing simple refactoring, it can be useful to run `./x check`
@ -381,4 +391,5 @@ load this completion.
[`src/etc/rust_analyzer_settings.json`]: https://github.com/rust-lang/rust/blob/master/src/etc/rust_analyzer_settings.json [`src/etc/rust_analyzer_settings.json`]: https://github.com/rust-lang/rust/blob/master/src/etc/rust_analyzer_settings.json
[`src/etc/rust_analyzer_eglot.el`]: https://github.com/rust-lang/rust/blob/master/src/etc/rust_analyzer_eglot.el [`src/etc/rust_analyzer_eglot.el`]: https://github.com/rust-lang/rust/blob/master/src/etc/rust_analyzer_eglot.el
[`src/etc/rust_analyzer_helix.toml`]: https://github.com/rust-lang/rust/blob/master/src/etc/rust_analyzer_helix.toml [`src/etc/rust_analyzer_helix.toml`]: https://github.com/rust-lang/rust/blob/master/src/etc/rust_analyzer_helix.toml
[`src/etc/rust_analyzer_zed.json`]: https://github.com/rust-lang/rust/blob/master/src/etc/rust_analyzer_zed.json
[`src/etc/pre-push.sh`]: https://github.com/rust-lang/rust/blob/master/src/etc/pre-push.sh [`src/etc/pre-push.sh`]: https://github.com/rust-lang/rust/blob/master/src/etc/pre-push.sh

View File

@ -167,9 +167,7 @@ a new unstable feature:
1. Prevent usage of the new feature unless the feature gate is set. 1. Prevent usage of the new feature unless the feature gate is set.
You can check it in most places in the compiler using the You can check it in most places in the compiler using the
expression `tcx.features().$feature_name` (or expression `tcx.features().$feature_name()`
`sess.features_untracked().$feature_name` if the
tcx is unavailable)
If the feature gate is not set, you should either maintain If the feature gate is not set, you should either maintain
the pre-feature behavior or raise an error, depending on the pre-feature behavior or raise an error, depending on