Compare commits
31 Commits
f35336f50d
...
7aa34a045d
| Author | SHA1 | Date |
|---|---|---|
|
|
7aa34a045d | |
|
|
eb4eba8ab2 | |
|
|
6fe303f431 | |
|
|
beb25e1390 | |
|
|
c7e38e9640 | |
|
|
5ad366e50d | |
|
|
183107472f | |
|
|
ef25866b8f | |
|
|
784f90ee2f | |
|
|
fa8dce1efb | |
|
|
f80902e3ae | |
|
|
8152a0dea4 | |
|
|
3f559ff34a | |
|
|
1bbe997711 | |
|
|
882699e328 | |
|
|
4c6d66ccb0 | |
|
|
4233695fea | |
|
|
33eaf36815 | |
|
|
980acc5eee | |
|
|
e0a39188f1 | |
|
|
9d7ba8573d | |
|
|
c963b4ad93 | |
|
|
a02af2f135 | |
|
|
4185dca095 | |
|
|
a2c80e6e23 | |
|
|
7b921990fc | |
|
|
2536baab6d | |
|
|
6c99b7501a | |
|
|
32824bfe35 | |
|
|
c63baadda5 | |
|
|
e4ee951653 |
|
|
@ -54,7 +54,8 @@
|
|||
- [Walkthrough: a typical contribution](./walkthrough.md)
|
||||
- [Implementing new language features](./implementing_new_features.md)
|
||||
- [Stability attributes](./stability.md)
|
||||
- [Stabilizing Features](./stabilization_guide.md)
|
||||
- [Stabilizing language features](./stabilization_guide.md)
|
||||
- [Stabilization report template](./stabilization_report_template.md)
|
||||
- [Feature Gates](./feature-gates.md)
|
||||
- [Coding conventions](./conventions.md)
|
||||
- [Procedures for breaking changes](./bug-fix-procedure.md)
|
||||
|
|
@ -101,6 +102,8 @@
|
|||
- [The `rustdoc` test suite](./rustdoc-internals/rustdoc-test-suite.md)
|
||||
- [The `rustdoc-gui` test suite](./rustdoc-internals/rustdoc-gui-test-suite.md)
|
||||
- [The `rustdoc-json` test suite](./rustdoc-internals/rustdoc-json-test-suite.md)
|
||||
- [GPU offload internals](./offload/internals.md)
|
||||
- [Installation](./offload/installation.md)
|
||||
- [Autodiff internals](./autodiff/internals.md)
|
||||
- [Installation](./autodiff/installation.md)
|
||||
- [How to debug](./autodiff/debugging.md)
|
||||
|
|
@ -121,8 +124,9 @@
|
|||
- [Feature gate checking](./feature-gate-ck.md)
|
||||
- [Lang Items](./lang-items.md)
|
||||
- [The HIR (High-level IR)](./hir.md)
|
||||
- [Lowering AST to HIR](./ast-lowering.md)
|
||||
- [Debugging](./hir-debugging.md)
|
||||
- [Lowering AST to HIR](./hir/lowering.md)
|
||||
- [Ambig/Unambig Types and Consts](./hir/ambig-unambig-ty-and-consts.md)
|
||||
- [Debugging](./hir/debugging.md)
|
||||
- [The THIR (Typed High-level IR)](./thir.md)
|
||||
- [The MIR (Mid-level IR)](./mir/index.md)
|
||||
- [MIR construction](./mir/construction.md)
|
||||
|
|
|
|||
|
|
@ -174,8 +174,8 @@ compiler, you can use it instead of the JSON file for both arguments.
|
|||
## Promoting a target from tier 2 (target) to tier 2 (host)
|
||||
|
||||
There are two levels of tier 2 targets:
|
||||
a) Targets that are only cross-compiled (`rustup target add`)
|
||||
b) Targets that [have a native toolchain][tier2-native] (`rustup toolchain install`)
|
||||
- Targets that are only cross-compiled (`rustup target add`)
|
||||
- Targets that [have a native toolchain][tier2-native] (`rustup toolchain install`)
|
||||
|
||||
[tier2-native]: https://doc.rust-lang.org/nightly/rustc/target-tier-policy.html#tier-2-with-host-tools
|
||||
|
||||
|
|
|
|||
|
|
@ -553,7 +553,7 @@ compiler](#linting-early-in-the-compiler).
|
|||
|
||||
|
||||
[AST nodes]: the-parser.md
|
||||
[AST lowering]: ast-lowering.md
|
||||
[AST lowering]: ./hir/lowering.md
|
||||
[HIR nodes]: hir.md
|
||||
[MIR nodes]: mir/index.md
|
||||
[macro expansion]: macro-expansion.md
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
The HIR – "High-Level Intermediate Representation" – is the primary IR used
|
||||
in most of rustc. It is a compiler-friendly representation of the abstract
|
||||
syntax tree (AST) that is generated after parsing, macro expansion, and name
|
||||
resolution (see [Lowering](./ast-lowering.html) for how the HIR is created).
|
||||
resolution (see [Lowering](./hir/lowering.md) for how the HIR is created).
|
||||
Many parts of HIR resemble Rust surface syntax quite closely, with
|
||||
the exception that some of Rust's expression forms have been desugared away.
|
||||
For example, `for` loops are converted into a `loop` and do not appear in
|
||||
|
|
|
|||
|
|
@ -0,0 +1,63 @@
|
|||
# Ambig/Unambig Types and Consts
|
||||
|
||||
Types and Consts args in the HIR can be in two kinds of positions ambiguous (ambig) or unambiguous (unambig). Ambig positions are where
|
||||
it would be valid to parse either a type or a const, unambig positions are where only one kind would be valid to
|
||||
parse.
|
||||
|
||||
```rust
|
||||
fn func<T, const N: usize>(arg: T) {
|
||||
// ^ Unambig type position
|
||||
let a: _ = arg;
|
||||
// ^ Unambig type position
|
||||
|
||||
func::<T, N>(arg);
|
||||
// ^ ^
|
||||
// ^^^^ Ambig position
|
||||
|
||||
let _: [u8; 10];
|
||||
// ^^ ^^ Unambig const position
|
||||
// ^^ Unambig type position
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
Most types/consts in ambig positions are able to be disambiguated as either a type or const during parsing. Single segment paths are always represented as types in the AST but may get resolved to a const parameter during name resolution, then lowered to a const argument during ast-lowering. The only generic arguments which remain ambiguous after lowering are inferred generic arguments (`_`) in path segments. For example, in `Foo<_>` it is not clear whether the `_` argument is an inferred type argument, or an inferred const argument.
|
||||
|
||||
In unambig positions, inferred arguments are represented with [`hir::TyKind::Infer`][ty_infer] or [`hir::ConstArgKind::Infer`][const_infer] depending on whether it is a type or const position respectively.
|
||||
In ambig positions, inferred arguments are represented with `hir::GenericArg::Infer`.
|
||||
|
||||
A naive implementation of this would result in there being potentially 5 places where you might think an inferred type/const could be found in the HIR from looking at the structure of the HIR:
|
||||
1. In unambig type position as a `hir::TyKind::Infer`
|
||||
2. In unambig const arg position as a `hir::ConstArgKind::Infer`
|
||||
3. In an ambig position as a [`GenericArg::Type(TyKind::Infer)`][generic_arg_ty]
|
||||
4. In an ambig position as a [`GenericArg::Const(ConstArgKind::Infer)`][generic_arg_const]
|
||||
5. In an ambig position as a [`GenericArg::Infer`][generic_arg_infer]
|
||||
|
||||
Note that places 3 and 4 would never actually be possible to encounter as we always lower to `GenericArg::Infer` in generic arg position.
|
||||
|
||||
This has a few failure modes:
|
||||
- People may write visitors which check for `GenericArg::Infer` but forget to check for `hir::TyKind/ConstArgKind::Infer`, only handling infers in ambig positions by accident.
|
||||
- People may write visitors which check for `hir::TyKind/ConstArgKind::Infer` but forget to check for `GenericArg::Infer`, only handling infers in unambig positions by accident.
|
||||
- People may write visitors which check for `GenerArg::Type/Const(TyKind/ConstArgKind::Infer)` and `GenerigArg::Infer`, not realising that we never represent inferred types/consts in ambig positions as a `GenericArg::Type/Const`.
|
||||
- People may write visitors which check for *only* `TyKind::Infer` and not `ConstArgKind::Infer` forgetting that there are also inferred const arguments (and vice versa).
|
||||
|
||||
To make writing HIR visitors less error prone when caring about inferred types/consts we have a relatively complex system:
|
||||
|
||||
1. We have different types in the compiler for when a type or const is in an unambig or ambig position, `hir::Ty<AmbigArg>` and `hir::Ty<()>`. [`AmbigArg`][ambig_arg] is an uninhabited type which we use in the `Infer` variant of `TyKind` and `ConstArgKind` to selectively "disable" it if we are in an ambig position.
|
||||
|
||||
2. The [`visit_ty`][visit_ty] and [`visit_const_arg`][visit_const_arg] methods on HIR visitors only accept the ambig position versions of types/consts. Unambig types/consts are implicitly converted to ambig types/consts during the visiting process, with the `Infer` variant handled by a dedicated [`visit_infer`][visit_infer] method.
|
||||
|
||||
This has a number of benefits:
|
||||
- It's clear that `GenericArg::Type/Const` cannot represent inferred type/const arguments
|
||||
- Implementors of `visit_ty` and `visit_const_arg` will never encounter inferred types/consts making it impossible to write a visitor that seems to work right but handles edge cases wrong
|
||||
- The `visit_infer` method handles *all* cases of inferred type/consts in the HIR making it easy for visitors to handle inferred type/consts in one dedicated place and not forget cases
|
||||
|
||||
[ty_infer]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/hir/enum.TyKind.html#variant.Infer
|
||||
[const_infer]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/hir/enum.ConstArgKind.html#variant.Infer
|
||||
[generic_arg_ty]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/hir/enum.GenericArg.html#variant.Type
|
||||
[generic_arg_const]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/hir/enum.GenericArg.html#variant.Const
|
||||
[generic_arg_infer]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/hir/enum.GenericArg.html#variant.Infer
|
||||
[ambig_arg]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/hir/enum.AmbigArg.html
|
||||
[visit_ty]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/intravisit/trait.Visitor.html#method.visit_ty
|
||||
[visit_const_arg]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/intravisit/trait.Visitor.html#method.visit_const_arg
|
||||
[visit_infer]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/intravisit/trait.Visitor.html#method.visit_infer
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
# AST lowering
|
||||
|
||||
The AST lowering step converts AST to [HIR](hir.html).
|
||||
The AST lowering step converts AST to [HIR](../hir.md).
|
||||
This means many structures are removed if they are irrelevant
|
||||
for type analysis or similar syntax agnostic analyses. Examples
|
||||
of such structures include but are not limited to
|
||||
|
|
@ -206,3 +206,42 @@ tests/ui/feature-gates/ --bless`.
|
|||
[here]: ./stabilization_guide.md
|
||||
[tracking issue]: #tracking-issues
|
||||
[add-feature-gate]: ./feature-gates.md#adding-a-feature-gate
|
||||
|
||||
## Call for testing
|
||||
|
||||
Once the implementation is complete, the feature will be available to nightly users, but not yet part of stable Rust. This is a good time to write a blog post on [the main Rust blog][rust-blog] and issue a **Call for Testing**.
|
||||
|
||||
Some example Call for Testing blog posts:
|
||||
|
||||
1. [The push for GATs stabilization](https://blog.rust-lang.org/2021/08/03/GATs-stabilization-push/)
|
||||
2. [Changes to `impl Trait` in Rust 2024](https://blog.rust-lang.org/2024/09/05/impl-trait-capture-rules.html)
|
||||
3. [Async Closures MVP: Call for Testing!](https://blog.rust-lang.org/inside-rust/2024/08/09/async-closures-call-for-testing/)
|
||||
|
||||
Alternatively, [*This Week in Rust*][twir] has a [call-for-testing section][twir-cft]. Example:
|
||||
|
||||
- [Call for testing on boolean literals as cfg predicates](https://github.com/rust-lang/rust/issues/131204#issuecomment-2569314526).
|
||||
|
||||
Which option to choose might depend on how significant the language change is, though note that [*This Week in Rust*][twir]'s Call for Testing section might be less visible than a dedicated post on the main Rust blog.
|
||||
|
||||
## Affiliated work
|
||||
|
||||
Once the feature is supported by rustc, there is other associated work that needs to be done to give users a complete experience. Think of it as the *language toolchain* developer experience, which doesn't only comprise of the language or compiler in isolation.
|
||||
|
||||
- Documenting the language feature in the [Rust Reference][reference].
|
||||
- (If applicable) Extending [`rustfmt`] to format any new syntax.
|
||||
- (If applicable) Extending [`rust-analyzer`]. This can depend on the nature of the language feature, as some features don't need to be blocked on *full* support.
|
||||
- A blocking concern is when a language feature degrades the user experience simply by existing before its support is implemented in [`rust-analyzer`].
|
||||
- Example blocking concern: new syntax that [`rust-analyzer`] can't parse -> bogus diagnostics, type inference changes -> bogus diagnostics.
|
||||
|
||||
## Stabilization
|
||||
|
||||
The final step in the feature lifecycle is [stabilization][stab], which is when the feature becomes available to all Rust users. At this point, backwards incompatible changes are no longer permitted (modulo soundness bugs and inference changes; see the lang team's [defined semver policies](https://rust-lang.github.io/rfcs/1122-language-semver.html) for full details). To learn more about stabilization, see the [stabilization guide][stab].
|
||||
|
||||
|
||||
[stab]: ./stabilization_guide.md
|
||||
[rust-blog]: https://github.com/rust-lang/blog.rust-lang.org/
|
||||
[twir]: https://github.com/rust-lang/this-week-in-rust
|
||||
[twir-cft]: https://this-week-in-rust.org/blog/2025/01/22/this-week-in-rust-583/#calls-for-testing
|
||||
[`rustfmt`]: https://github.com/rust-lang/rustfmt
|
||||
[`rust-analyzer`]: https://github.com/rust-lang/rust-analyzer
|
||||
[reference]: https://github.com/rust-lang/reference
|
||||
|
|
|
|||
|
|
@ -0,0 +1,71 @@
|
|||
# Installation
|
||||
|
||||
In the future, `std::offload` should become available in nightly builds for users. For now, everyone still needs to build rustc from source.
|
||||
|
||||
## Build instructions
|
||||
|
||||
First you need to clone and configure the Rust repository:
|
||||
```bash
|
||||
git clone --depth=1 git@github.com:rust-lang/rust.git
|
||||
cd rust
|
||||
./configure --enable-llvm-link-shared --release-channel=nightly --enable-llvm-assertions --enable-offload --enable-enzyme --enable-clang --enable-lld --enable-option-checking --enable-ninja --disable-docs
|
||||
```
|
||||
|
||||
Afterwards you can build rustc using:
|
||||
```bash
|
||||
./x.py build --stage 1 library
|
||||
```
|
||||
|
||||
Afterwards rustc toolchain link will allow you to use it through cargo:
|
||||
```
|
||||
rustup toolchain link offload build/host/stage1
|
||||
rustup toolchain install nightly # enables -Z unstable-options
|
||||
```
|
||||
|
||||
|
||||
|
||||
## Build instruction for LLVM itself
|
||||
```bash
|
||||
git clone --depth=1 git@github.com:llvm/llvm-project.git
|
||||
cd llvm-project
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -G Ninja ../llvm -DLLVM_TARGETS_TO_BUILD="host,AMDGPU,NVPTX" -DLLVM_ENABLE_ASSERTIONS=ON -DLLVM_ENABLE_PROJECTS="clang;lld" -DLLVM_ENABLE_RUNTIMES="offload,openmp" -DLLVM_ENABLE_PLUGINS=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=.
|
||||
ninja
|
||||
ninja install
|
||||
```
|
||||
This gives you a working LLVM build.
|
||||
|
||||
|
||||
## Testing
|
||||
run
|
||||
```
|
||||
./x.py test --stage 1 tests/codegen/gpu_offload
|
||||
```
|
||||
|
||||
## Usage
|
||||
It is important to use a clang compiler build on the same llvm as rustc. Just calling clang without the full path will likely use your system clang, which probably will be incompatible.
|
||||
```
|
||||
/absolute/path/to/rust/build/x86_64-unknown-linux-gnu/stage1/bin/rustc --edition=2024 --crate-type cdylib src/main.rs --emit=llvm-ir -O -C lto=fat -Cpanic=abort -Zoffload=Enable
|
||||
/absolute/path/to/rust/build/x86_64-unknown-linux-gnu/llvm/bin/clang++ -fopenmp --offload-arch=native -g -O3 main.ll -o main -save-temps
|
||||
LIBOMPTARGET_INFO=-1 ./main
|
||||
```
|
||||
The first step will generate a `main.ll` file, which has enough instructions to cause the offload runtime to move data to and from a gpu.
|
||||
The second step will use clang as the compilation driver to compile our IR file down to a working binary. Only a very small Rust subset will work out of the box here, unless
|
||||
you use features like build-std, which are not covered by this guide. Look at the codegen test to get a feeling for how to write a working example.
|
||||
In the last step you can run your binary, if all went well you will see a data transfer being reported:
|
||||
```
|
||||
omptarget device 0 info: Entering OpenMP data region with being_mapper at unknown:0:0 with 1 arguments:
|
||||
omptarget device 0 info: tofrom(unknown)[1024]
|
||||
omptarget device 0 info: Creating new map entry with HstPtrBase=0x00007fffffff9540, HstPtrBegin=0x00007fffffff9540, TgtAllocBegin=0x0000155547200000, TgtPtrBegin=0x0000155547200000, Size=1024, DynRefCount=1, HoldRefCount=0, Name=unknown
|
||||
omptarget device 0 info: Copying data from host to device, HstPtr=0x00007fffffff9540, TgtPtr=0x0000155547200000, Size=1024, Name=unknown
|
||||
omptarget device 0 info: OpenMP Host-Device pointer mappings after block at unknown:0:0:
|
||||
omptarget device 0 info: Host Ptr Target Ptr Size (B) DynRefCount HoldRefCount Declaration
|
||||
omptarget device 0 info: 0x00007fffffff9540 0x0000155547200000 1024 1 0 unknown at unknown:0:0
|
||||
// some other output
|
||||
omptarget device 0 info: Exiting OpenMP data region with end_mapper at unknown:0:0 with 1 arguments:
|
||||
omptarget device 0 info: tofrom(unknown)[1024]
|
||||
omptarget device 0 info: Mapping exists with HstPtrBegin=0x00007fffffff9540, TgtPtrBegin=0x0000155547200000, Size=1024, DynRefCount=0 (decremented, delayed deletion), HoldRefCount=0
|
||||
omptarget device 0 info: Copying data from device to host, TgtPtr=0x0000155547200000, HstPtr=0x00007fffffff9540, Size=1024, Name=unknown
|
||||
omptarget device 0 info: Removing map entry with HstPtrBegin=0x00007fffffff9540, TgtPtrBegin=0x0000155547200000, Size=1024, Name=unknown
|
||||
```
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
# std::offload
|
||||
|
||||
This module is under active development. Once upstream, it should allow Rust developers to run Rust code on GPUs.
|
||||
We aim to develop a `rusty` GPU programming interface, which is safe, convenient and sufficiently fast by default.
|
||||
This includes automatic data movement to and from the GPU, in a efficient way. We will (later)
|
||||
also offer more advanced, possibly unsafe, interfaces which allow a higher degree of control.
|
||||
|
||||
The implementation is based on LLVM's "offload" project, which is already used by OpenMP to run Fortran or C++ code on GPUs.
|
||||
While the project is under development, users will need to call other compilers like clang to finish the compilation process.
|
||||
|
|
@ -410,7 +410,7 @@ For more details on bootstrapping, see
|
|||
- Guide: [The HIR](hir.md)
|
||||
- Guide: [Identifiers in the HIR](hir.md#identifiers-in-the-hir)
|
||||
- Guide: [The `HIR` Map](hir.md#the-hir-map)
|
||||
- Guide: [Lowering `AST` to `HIR`](ast-lowering.md)
|
||||
- Guide: [Lowering `AST` to `HIR`](./hir/lowering.md)
|
||||
- How to view `HIR` representation for your code `cargo rustc -- -Z unpretty=hir-tree`
|
||||
- Rustc `HIR` definition: [`rustc_hir`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/index.html)
|
||||
- Main entry point: **TODO**
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ This is a guide for how to profile rustc with [perf](https://perf.wiki.kernel.or
|
|||
- Get a clean checkout of rust-lang/master, or whatever it is you want
|
||||
to profile.
|
||||
- Set the following settings in your `bootstrap.toml`:
|
||||
- `debuginfo-level = 1` - enables line debuginfo
|
||||
- `jemalloc = false` - lets you do memory use profiling with valgrind
|
||||
- `rust.debuginfo-level = 1` - enables line debuginfo
|
||||
- `rust.jemalloc = false` - lets you do memory use profiling with valgrind
|
||||
- leave everything else the defaults
|
||||
- Run `./x build` to get a full build
|
||||
- Make a rustup toolchain pointing to that result
|
||||
|
|
|
|||
|
|
@ -43,55 +43,25 @@ has completed. Meanwhile, we can proceed to the next step.
|
|||
|
||||
## Write a stabilization report
|
||||
|
||||
Find the tracking issue of the feature, and create a short
|
||||
stabilization report. Essentially this would be a brief summary
|
||||
of the feature plus some links to test cases showing it works
|
||||
as expected, along with a list of edge cases that came up
|
||||
and were considered. This is a minimal "due diligence" that
|
||||
we do before stabilizing.
|
||||
Author a stabilization report using the [template found in this repository][srt].
|
||||
|
||||
The report should contain:
|
||||
Stabilization reports summarize:
|
||||
|
||||
- A summary, showing examples (e.g. code snippets) what is
|
||||
enabled by this feature.
|
||||
- Links to test cases in our test suite regarding this feature
|
||||
and describe the feature's behavior on encountering edge cases.
|
||||
- Links to the documentations (the PRs we have made in the
|
||||
previous steps).
|
||||
- Any other relevant information.
|
||||
- The resolutions of any unresolved questions if the stabilization
|
||||
is for an RFC.
|
||||
- The main design decisions and deviations since the RFC was accepted, particularly decisions that were FCP'd or otherwise accepted by the language team.
|
||||
- Quite often, the final stabilized language feature can have significant design deviations from the original RFC text.
|
||||
- The work that has been done since the RFC was accepted, acknowledging the main contributors that helped drive the language feature forward.
|
||||
|
||||
Examples of stabilization reports can be found in
|
||||
[rust-lang/rust#44494][report1] and [rust-lang/rust#28237][report2] (these links
|
||||
will bring you directly to the comment containing the stabilization report).
|
||||
The [*Stabilization Template*][srt] includes a series of questions that aim to surface interconnections between this feature and the various Rust teams (lang, types, etc) and also to identify items that are commonly overlooked.
|
||||
|
||||
[report1]: https://github.com/rust-lang/rust/issues/44494#issuecomment-360191474
|
||||
[report2]: https://github.com/rust-lang/rust/issues/28237#issuecomment-363374130
|
||||
[srt]: ./stabilization_report_template.md
|
||||
|
||||
## FCP
|
||||
The stabilization report is typically posted as the main comment on the stabilization PR (see the next section).
|
||||
|
||||
If any member of the team responsible for tracking this
|
||||
feature agrees with stabilizing this feature, they will
|
||||
start the FCP (final-comment-period) process by commenting
|
||||
|
||||
```text
|
||||
@rfcbot fcp merge
|
||||
```
|
||||
|
||||
The rest of the team members will review the proposal. If the final
|
||||
decision is to stabilize, we proceed to do the actual code modification.
|
||||
|
||||
## Stabilization PR
|
||||
## Stabilization PR for a language feature
|
||||
|
||||
*This is for stabilizing language features. If you are stabilizing a library
|
||||
feature, see [the stabilization chapter of the std dev guide][std-guide-stabilization] instead.*
|
||||
|
||||
Once we have decided to stabilize a feature, we need to have
|
||||
a PR that actually makes that stabilization happen. These kinds
|
||||
of PRs are a great way to get involved in Rust, as they take
|
||||
you on a little tour through the source code.
|
||||
|
||||
Here is a general guide to how to stabilize a feature --
|
||||
every feature is different, of course, so some features may
|
||||
require steps beyond what this guide talks about.
|
||||
|
|
@ -151,8 +121,7 @@ same `compiler/rustc_ast_passes/src/feature_gate.rs`.
|
|||
For example, you might see code like this:
|
||||
|
||||
```rust,ignore
|
||||
gate_feature_post!(&self, pub_restricted, span,
|
||||
"`pub(restricted)` syntax is experimental");
|
||||
gate_all!(pub_restricted, "`pub(restricted)` syntax is experimental");
|
||||
```
|
||||
|
||||
This `gate_feature_post!` macro prints an error if the
|
||||
|
|
@ -162,7 +131,7 @@ now that `#[pub_restricted]` is stable.
|
|||
For more subtle features, you may find code like this:
|
||||
|
||||
```rust,ignore
|
||||
if self.tcx.sess.features.borrow().pub_restricted { /* XXX */ }
|
||||
if self.tcx.features().async_fn_in_dyn_trait() { /* XXX */ }
|
||||
```
|
||||
|
||||
This `pub_restricted` field (obviously named after the feature)
|
||||
|
|
@ -194,3 +163,25 @@ if something { /* XXX */ }
|
|||
[Rust by Example]: https://github.com/rust-lang/rust-by-example
|
||||
[`Unstable Book`]: https://doc.rust-lang.org/unstable-book/index.html
|
||||
[`src/doc/unstable-book`]: https://github.com/rust-lang/rust/tree/master/src/doc/unstable-book
|
||||
|
||||
## Team nominations
|
||||
|
||||
After the stabilization PR is opened with the stabilization report, wait a bit for potential immediate comments. When such immediate comments "simmer down" and you feel the PR is ready for consideration by the lang team, you can [nominate the PR](https://lang-team.rust-lang.org/how_to/nominate.html) to get it on the list for discussion in the next meeting. You should also cc the other interacting teams when applicable to review the language feature being stabilized and the stabilization report:
|
||||
|
||||
* `@rust-lang/types`, to look for type system interactions
|
||||
* `@rust-lang/compiler`, to review implementation robustness
|
||||
* `@rust-lang/opsem`, if this feature interacts with unsafe code and can create undefined behavior
|
||||
* `@rust-lang/libs-api`, if there are additions to the standard library that affects standard library API or their guarantees
|
||||
|
||||
If you are not an organization member, you can simply ask your assigned reviewer to cc the relevant teams on your behalf.
|
||||
|
||||
## FCP proposed on the PR
|
||||
|
||||
Finally, some member of the team responsible for tracking this feature agrees with stabilizing this feature, will
|
||||
start the FCP (final-comment-period) process by commenting
|
||||
|
||||
```text
|
||||
@rfcbot fcp merge
|
||||
```
|
||||
|
||||
The rest of the team members will review the proposal. If the final decision is to stabilize, the PR will be reviewed by the compiler team like any other PR.
|
||||
|
|
|
|||
|
|
@ -0,0 +1,105 @@
|
|||
# Stabilization report template
|
||||
|
||||
> **What is this?**
|
||||
>
|
||||
> This is a template to use for [stabilization reports](./stabilization_guide.md) of **language features**. It consists of a series of questions that aim to provide the information most commonly needed and to help reviewers be more likely to identify potential problems up front. Not all parts of the template will apply to all stabilizations. Feel free to put N/A if a question doesn't seem to apply to your case.
|
||||
>
|
||||
> You can copy the following template after the separator and edit it as Markdown, replacing the *TODO* placeholders with answers.
|
||||
|
||||
---
|
||||
|
||||
> ## General design
|
||||
|
||||
> ### What is the RFC for this feature and what changes have occurred to the user-facing design since the RFC was finalized?
|
||||
|
||||
*TODO*
|
||||
|
||||
> ### What behavior are we committing to that has been controversial? Summarize the major arguments pro/con.
|
||||
|
||||
*TODO*
|
||||
|
||||
> ### Are there extensions to this feature that remain unstable? How do we know that we are not accidentally committing to those?
|
||||
|
||||
*TODO*
|
||||
|
||||
> ## Has a Call for Testing period been conducted? If so, what feedback was received?
|
||||
>
|
||||
> Does any OSS nightly users use this feature? For instance, a useful indication might be "search <grep.app> for `#![feature(FEATURE_NAME)]` and had `N` results".
|
||||
|
||||
*TODO*
|
||||
|
||||
> ## Implementation quality
|
||||
|
||||
*TODO*
|
||||
|
||||
> ### Summarize the major parts of the implementation and provide links into the code (or to PRs)
|
||||
>
|
||||
> An example for async closures: <https://rustc-dev-guide.rust-lang.org/coroutine-closures.html>.
|
||||
|
||||
*TODO*
|
||||
|
||||
> ### Summarize existing test coverage of this feature
|
||||
>
|
||||
> Consider what the "edges" of this feature are. We're particularly interested in seeing tests that assure us about exactly what nearby things we're not stabilizing.
|
||||
>
|
||||
> Within each test, include a comment at the top describing the purpose of the test and what set of invariants it intends to demonstrate. This is a great help to those reviewing the tests at stabilization time.
|
||||
>
|
||||
> - What does the test coverage landscape for this feature look like?
|
||||
> - Tests for compiler errors when you use the feature wrongly or make mistakes?
|
||||
> - Tests for the feature itself:
|
||||
> - Limits of the feature (so failing compilation)
|
||||
> - Exercises of edge cases of the feature
|
||||
> - Tests that checks the feature works as expected (where applicable, `//@ run-pass`).
|
||||
> - Are there any intentional gaps in test coverage?
|
||||
>
|
||||
> Link to test folders or individual tests (ui/codegen/assembly/run-make tests, etc.).
|
||||
|
||||
*TODO*
|
||||
|
||||
> ### What outstanding bugs in the issue tracker involve this feature? Are they stabilization-blocking?
|
||||
|
||||
*TODO*
|
||||
|
||||
> ### What FIXMEs are still in the code for that feature and why is it ok to leave them there?
|
||||
|
||||
*TODO*
|
||||
|
||||
> ### Summarize contributors to the feature by name for recognition and assuredness that people involved in the feature agree with stabilization
|
||||
|
||||
*TODO*
|
||||
|
||||
> ### Which tools need to be adjusted to support this feature. Has this work been done?
|
||||
>
|
||||
> Consider rustdoc, clippy, rust-analyzer, rustfmt, rustup, docs.rs.
|
||||
|
||||
*TODO*
|
||||
|
||||
> ## Type system and execution rules
|
||||
|
||||
> ### What compilation-time checks are done that are needed to prevent undefined behavior?
|
||||
>
|
||||
> (Be sure to link to tests demonstrating that these tests are being done.)
|
||||
|
||||
*TODO*
|
||||
|
||||
> ### Does the feature's implementation need checks to prevent UB or is it sound by default and needs opt in in places to perform the dangerous/unsafe operations? If it is not sound by default, what is the rationale?
|
||||
|
||||
*TODO*
|
||||
|
||||
> ### Can users use this feature to introduce undefined behavior, or use this feature to break the abstraction of Rust and expose the underlying assembly-level implementation? (Describe.)
|
||||
|
||||
*TODO*
|
||||
|
||||
> ### What updates are needed to the reference/specification? (link to PRs when they exist)
|
||||
|
||||
*TODO*
|
||||
|
||||
> ## Common interactions
|
||||
|
||||
> ### Does this feature introduce new expressions and can they produce temporaries? What are the lifetimes of those temporaries?
|
||||
|
||||
*TODO*
|
||||
|
||||
> ### What other unstable features may be exposed by this feature?
|
||||
|
||||
*TODO*
|
||||
Loading…
Reference in New Issue