Skip to content

Commit eb2842d

Browse files
author
The rustc-josh-sync Cronjob Bot
committed
Merge ref 'e4fdb554ad2c' from rust-lang/rust
Pull recent changes from https://github.com/rust-lang/rust via Josh. Upstream ref: rust-lang/rust@e4fdb55 Filtered ref: rust-lang/stdarch@ae05da8 Upstream diff: rust-lang/rust@eda4fc7...e4fdb55 This merge was created using https://github.com/rust-lang/josh-sync.
2 parents e625d90 + e2d3405 commit eb2842d

22 files changed

Lines changed: 376 additions & 198 deletions

ci/sembr/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ struct Cli {
1515
/// Modify files that do not comply
1616
overwrite: bool,
1717
/// Applies to lines that are to be split
18-
#[arg(long, default_value_t = 100)]
18+
#[arg(long, default_value_t = 80)]
1919
line_length_limit: usize,
2020
}
2121

rust-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
c78a29473a68f07012904af11c92ecffa68fcc75
1+
562dee4820c458d823175268e41601d4c060588a

src/autodiff/installation.md

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,50 @@
11
# Installation
22

3-
In the near future, `std::autodiff` should become available in nightly builds for users. As a contributor however, you will still need to build rustc from source. Please be aware that the msvc target is not supported at the moment, all other tier 1 targets should work. Please open an issue if you encounter any problems on a supported tier 1 target, or if you successfully build this project on a tier2/tier3 target.
3+
In the near future, `std::autodiff` should become available for users via rustup. As a rustc/enzyme/autodiff contributor however, you will still need to build rustc from source.
4+
For the meantime, you can download up-to-date builds to enable `std::autodiff` on your latest nightly toolchain, if you are using either of:
5+
**Linux**, with `x86_64-unknown-linux-gnu` or `aarch64-unknown-linux-gnu`
6+
**Windows**, with `x86_64-llvm-mingw` or `aarch64-llvm-mingw`
7+
8+
You can also download slightly outdated builds for **Apple** (aarch64-apple), which should generally work for now.
9+
10+
If you need any other platform, you can build rustc including autodiff from source. Please open an issue if you want to help enabling automatic builds for your prefered target.
11+
12+
## Installation guide
13+
14+
If you want to use `std::autodiff` and don't plan to contribute PR's to the project, then we recommend to just use your existing nightly installation and download the missing component. In the future, rustup will be able to do it for you.
15+
For now, you'll have to manually download and copy it.
16+
17+
1) On our github repository, find the last merged PR: [`Repo`]
18+
2) Scroll down to the lower end of the PR, where you'll find a rust-bors message saying `Test successful` with a `CI` link.
19+
3) Click on the `CI` link, and grep for your target. E.g. `dist-x86_64-linux` or `dist-aarch64-llvm-mingw` and click `Load summary`.
20+
4) Under the `CI artifacts` section, find the `enzyme-nightly` artifact, download, and unpack it.
21+
5) Copy the artifact (libEnzyme-22.so for linux, libEnzyme-22.dylib for apple, etc.), which should be in a folder named `enzyme-preview`, to your rust toolchain directory. E.g. for linux: `cp ~/Downloads/enzyme-nightly-x86_64-unknown-linux-gnu/enzyme-preview/lib/rustlib/x86_64-unknown-linux-gnu/lib/libEnzyme-22.so ~/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib`
22+
23+
Apple support was temporarily reverted, due to downstream breakages. If you want to download autodiff for apple, please look at the artifacts from this [`run`].
24+
25+
## Installation guide for Nix user.
26+
27+
This setup was recommended by a nix and autodiff user. It uses [`Overlay`]. Please verify for yourself if you are comfortable using that repository.
28+
In that case you might use the following nix configuration to get a rustc that supports `std::autodiff`.
29+
```nix
30+
{
31+
enzymeLib = pkgs.fetchzip {
32+
url = "https://ci-artifacts.rust-lang.org/rustc-builds/ec818fda361ca216eb186f5cf45131bd9c776bb4/enzyme-nightly-x86_64-unknown-linux-gnu.tar.xz";
33+
sha256 = "sha256-Rnrop44vzS+qmYNaRoMNNMFyAc3YsMnwdNGYMXpZ5VY=";
34+
};
35+
36+
rustToolchain = pkgs.symlinkJoin {
37+
name = "rust-with-enzyme";
38+
paths = [pkgs.rust-bin.nightly.latest.default];
39+
nativeBuildInputs = [pkgs.makeWrapper];
40+
postBuild = ''
41+
libdir=$out/lib/rustlib/x86_64-unknown-linux-gnu/lib
42+
cp ${enzymeLib}/enzyme-preview/lib/rustlib/x86_64-unknown-linux-gnu/lib/libEnzyme-22.so $libdir/
43+
wrapProgram $out/bin/rustc --add-flags "--sysroot $out"
44+
'';
45+
};
46+
}
47+
```
448

549
## Build instructions
650

@@ -87,3 +131,6 @@ ninja
87131
```
88132
This will build Enzyme, and you can find it in `Enzyme/enzyme/build/lib/<LLD/Clang/LLVM/lib>Enzyme.so`. (Endings might differ based on your OS).
89133

134+
[`Repo`]: https://github.com/rust-lang/rust/
135+
[`run`]: https://github.com/rust-lang/rust/pull/153026#issuecomment-3950046599
136+
[`Overlay`]: https://github.com/oxalica/rust-overlay

src/backend/updating-llvm.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
# Updating LLVM
22

3-
<!-- date-check: Aug 2024 -->
43
Rust supports building against multiple LLVM versions:
54

65
* Tip-of-tree for the current LLVM development branch is usually supported within a few days.
76
PRs for such fixes are tagged with `llvm-main`.
87
* The latest released major version is always supported.
9-
* The one or two preceding major versions are usually supported.
8+
* The one or two preceding major versions are usually supported in the sense that they are expected
9+
to build successfully and pass most tests.
10+
However, fixes for miscompilations often do not get
11+
backported to past LLVM versions, so using rustc with older versions of LLVM comes with an
12+
increased risk of soundness bugs.
13+
We strongly recommend using the latest version of LLVM.
1014

1115
By default, Rust uses its own fork in the [rust-lang/llvm-project repository].
1216
This fork is based on a `release/$N.x` branch of the upstream project, where
@@ -86,7 +90,6 @@ An example PR: [#59089](https://github.com/rust-lang/rust/pull/59089)
8690

8791
## New LLVM Release Updates
8892

89-
<!-- date-check: Jul 2023 -->
9093

9194
Unlike bugfixes,
9295
updating to a new release of LLVM typically requires a lot more work.
@@ -167,12 +170,14 @@ so let's go through each in detail.
167170
You'll change at least
168171
`src/llvm-project` and will likely also change [`llvm-wrapper`] as well.
169172

170-
<!-- date-check: mar 2025 -->
173+
<!-- date-check: March 2026 -->
171174
> For prior art, here are some previous LLVM updates:
172175
> - [LLVM 17](https://github.com/rust-lang/rust/pull/115959)
173176
> - [LLVM 18](https://github.com/rust-lang/rust/pull/120055)
174177
> - [LLVM 19](https://github.com/rust-lang/rust/pull/127513)
175178
> - [LLVM 20](https://github.com/rust-lang/rust/pull/135763)
179+
> - [LLVM 21](https://github.com/rust-lang/rust/pull/143684)
180+
> - [LLVM 22](https://github.com/rust-lang/rust/pull/150722)
176181
177182
Note that sometimes it's easiest to land [`llvm-wrapper`] compatibility as a PR
178183
before actually updating `src/llvm-project`.
Lines changed: 73 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
# Member constraints
22

33
A member constraint `'m member of ['c_1..'c_N]` expresses that the
4-
region `'m` must be *equal* to some **choice regions** `'c_i` (for
5-
some `i`). These constraints cannot be expressed by users, but they
6-
arise from `impl Trait` due to its lifetime capture rules. Consider a
7-
function such as the following:
4+
region `'m` must be *equal* to some **choice regions** `'c_i` (for some `i`).
5+
These constraints cannot be expressed by users, but they
6+
arise from `impl Trait` due to its lifetime capture rules.
7+
Consider a function such as the following:
88

99
```rust,ignore
1010
fn make(a: &'a u32, b: &'b u32) -> impl Trait<'a, 'b> { .. }
1111
```
1212

1313
Here, the true return type (often called the "hidden type") is only
14-
permitted to capture the lifetimes `'a` or `'b`. You can kind of see
14+
permitted to capture the lifetimes `'a` or `'b`.
15+
You can kind of see
1516
this more clearly by desugaring that `impl Trait` return type into its
1617
more explicit form:
1718

@@ -23,16 +24,17 @@ fn make(a: &'a u32, b: &'b u32) -> MakeReturn<'a, 'b> { .. }
2324
Here, the idea is that the hidden type must be some type that could
2425
have been written in place of the `impl Trait<'x, 'y>` -- but clearly
2526
such a type can only reference the regions `'x` or `'y` (or
26-
`'static`!), as those are the only names in scope. This limitation is
27+
`'static`!), as those are the only names in scope.
28+
This limitation is
2729
then translated into a restriction to only access `'a` or `'b` because
2830
we are returning `MakeReturn<'a, 'b>`, where `'x` and `'y` have been
2931
replaced with `'a` and `'b` respectively.
3032

3133
## Detailed example
3234

3335
To help us explain member constraints in more detail, let's spell out
34-
the `make` example in a bit more detail. First off, let's assume that
35-
you have some dummy trait:
36+
the `make` example in a bit more detail.
37+
First off, let's assume that you have some dummy trait:
3638

3739
```rust,ignore
3840
trait Trait<'a, 'b> { }
@@ -49,8 +51,8 @@ fn make(a: &'a u32, b: &'b u32) -> MakeReturn<'a, 'b> {
4951
```
5052

5153
What happens in this case is that the return type will be `(&'0 u32, &'1 u32)`,
52-
where `'0` and `'1` are fresh region variables. We will have the following
53-
region constraints:
54+
where `'0` and `'1` are fresh region variables.
55+
We will have the following region constraints:
5456

5557
```txt
5658
'0 live at {L}
@@ -67,11 +69,11 @@ return tuple is constructed to where it is returned (in fact, `'0` and
6769
`'1` might have slightly different liveness sets, but that's not very
6870
interesting to the point we are illustrating here).
6971

70-
The `'a: '0` and `'b: '1` constraints arise from subtyping. When we
71-
construct the `(a, b)` value, it will be assigned type `(&'0 u32, &'1
72+
The `'a: '0` and `'b: '1` constraints arise from subtyping.
73+
When we construct the `(a, b)` value, it will be assigned type `(&'0 u32, &'1
7274
u32)` -- the region variables reflect that the lifetimes of these
73-
references could be made smaller. For this value to be created from
74-
`a` and `b`, however, we do require that:
75+
references could be made smaller.
76+
For this value to be created from `a` and `b`, however, we do require that:
7577

7678
```txt
7779
(&'a u32, &'b u32) <: (&'0 u32, &'1 u32)
@@ -82,35 +84,39 @@ which means in turn that `&'a u32 <: &'0 u32` and hence that `'a: '0`
8284

8385
Note that if we ignore member constraints, the value of `'0` would be
8486
inferred to some subset of the function body (from the liveness
85-
constraints, which we did not write explicitly). It would never become
87+
constraints, which we did not write explicitly).
88+
It would never become
8689
`'a`, because there is no need for it too -- we have a constraint that
87-
`'a: '0`, but that just puts a "cap" on how *large* `'0` can grow to
88-
become. Since we compute the *minimal* value that we can, we are happy
89-
to leave `'0` as being just equal to the liveness set. This is where
90-
member constraints come in.
90+
`'a: '0`, but that just puts a "cap" on how *large* `'0` can grow to become.
91+
Since we compute the *minimal* value that we can, we are happy
92+
to leave `'0` as being just equal to the liveness set.
93+
This is where member constraints come in.
9194

9295
## Choices are always lifetime parameters
9396

9497
At present, the "choice" regions from a member constraint are always lifetime
95-
parameters from the current function. As of <!-- date-check --> October 2021,
98+
parameters from the current function. As of <!-- date-check --> March 2026,
9699
this falls out from the placement of impl Trait, though in the future it may not
97-
be the case. We take some advantage of this fact, as it simplifies the current
98-
code. In particular, we don't have to consider a case like `'0 member of ['1,
100+
be the case.
101+
We take some advantage of this fact, as it simplifies the current code.
102+
In particular, we don't have to consider a case like `'0 member of ['1,
99103
'static]`, in which the value of both `'0` and `'1` are being inferred and hence
100-
changing. See [rust-lang/rust#61773][#61773] for more information.
104+
changing.
105+
See [rust-lang/rust#61773][#61773] for more information.
101106

102107
[#61773]: https://github.com/rust-lang/rust/issues/61773
103108

104109
## Applying member constraints
105110

106-
Member constraints are a bit more complex than other forms of
107-
constraints. This is because they have a "or" quality to them -- that
111+
Member constraints are a bit more complex than other forms of constraints.
112+
This is because they have a "or" quality to them -- that
108113
is, they describe multiple choices that we must select from. E.g., in
109114
our example constraint `'0 member of ['a, 'b, 'static]`, it might be
110-
that `'0` is equal to `'a`, `'b`, *or* `'static`. How can we pick the
111-
correct one? What we currently do is to look for a *minimal choice*
112-
-- if we find one, then we will grow `'0` to be equal to that minimal
113-
choice. To find that minimal choice, we take two factors into
115+
that `'0` is equal to `'a`, `'b`, *or* `'static`.
116+
How can we pick the correct one?
117+
What we currently do is to look for a *minimal choice*
118+
-- if we find one, then we will grow `'0` to be equal to that minimal choice.
119+
To find that minimal choice, we take two factors into
114120
consideration: lower and upper bounds.
115121

116122
### Lower bounds
@@ -121,30 +127,34 @@ apply member constraints, we've already *computed* the lower bounds of
121127
`'0` because we computed its minimal value (or at least, the lower
122128
bounds considering everything but member constraints).
123129

124-
Let `LB` be the current value of `'0`. We know then that `'0: LB` must
125-
hold, whatever the final value of `'0` is. Therefore, we can rule out
130+
Let `LB` be the current value of `'0`.
131+
We know then that `'0: LB` must hold, whatever the final value of `'0` is.
132+
Therefore, we can rule out
126133
any choice `'choice` where `'choice: LB` does not hold.
127134

128-
Unfortunately, in our example, this is not very helpful. The lower
129-
bound for `'0` will just be the liveness set `{L}`, and we know that
130-
all the lifetime parameters outlive that set. So we are left with the
131-
same set of choices here. (But in other examples, particularly those
135+
Unfortunately, in our example, this is not very helpful.
136+
The lower bound for `'0` will just be the liveness set `{L}`, and we know that
137+
all the lifetime parameters outlive that set.
138+
So we are left with the same set of choices here.
139+
(But in other examples, particularly those
132140
with different variance, lower bound constraints may be relevant.)
133141

134142
### Upper bounds
135143

136144
The *upper bounds* are those lifetimes that *must outlive* `'0` --
137145
i.e., that `'0` must be *smaller* than. In our example, this would be
138-
`'a`, because we have the constraint that `'a: '0`. In more complex
139-
examples, the chain may be more indirect.
146+
`'a`, because we have the constraint that `'a: '0`.
147+
In more complex examples, the chain may be more indirect.
140148

141149
We can use upper bounds to rule out members in a very similar way to
142-
lower bounds. If UB is some upper bound, then we know that `UB:
150+
lower bounds.
151+
If UB is some upper bound, then we know that `UB:
143152
'0` must hold, so we can rule out any choice `'choice` where `UB:
144153
'choice` does not hold.
145154

146155
In our example, we would be able to reduce our choice set from `['a,
147-
'b, 'static]` to just `['a]`. This is because `'0` has an upper bound
156+
'b, 'static]` to just `['a]`.
157+
This is because `'0` has an upper bound
148158
of `'a`, and neither `'a: 'b` nor `'a: 'static` is known to hold.
149159

150160
(For notes on how we collect upper bounds in the implementation, see
@@ -153,39 +163,45 @@ of `'a`, and neither `'a: 'b` nor `'a: 'static` is known to hold.
153163
### Minimal choice
154164

155165
After applying lower and upper bounds, we can still sometimes have
156-
multiple possibilities. For example, imagine a variant of our example
157-
using types with the opposite variance. In that case, we would have
158-
the constraint `'0: 'a` instead of `'a: '0`. Hence the current value
159-
of `'0` would be `{L, 'a}`. Using this as a lower bound, we would be
166+
multiple possibilities.
167+
For example, imagine a variant of our example
168+
using types with the opposite variance.
169+
In that case, we would have the constraint `'0: 'a` instead of `'a: '0`.
170+
Hence the current value of `'0` would be `{L, 'a}`.
171+
Using this as a lower bound, we would be
160172
able to narrow down the member choices to `['a, 'static]` because `'b:
161-
'a` is not known to hold (but `'a: 'a` and `'static: 'a` do hold). We
162-
would not have any upper bounds, so that would be our final set of choices.
173+
'a` is not known to hold (but `'a: 'a` and `'static: 'a` do hold).
174+
We would not have any upper bounds, so that would be our final set of choices.
163175

164176
In that case, we apply the **minimal choice** rule -- basically, if
165-
one of our choices if smaller than the others, we can use that. In
166-
this case, we would opt for `'a` (and not `'static`).
177+
one of our choices if smaller than the others, we can use that.
178+
In this case, we would opt for `'a` (and not `'static`).
167179

168180
This choice is consistent with the general 'flow' of region
169181
propagation, which always aims to compute a minimal value for the
170-
region being inferred. However, it is somewhat arbitrary.
182+
region being inferred.
183+
However, it is somewhat arbitrary.
171184

172185
<a id="collecting"></a>
173186

174187
### Collecting upper bounds in the implementation
175188

176189
In practice, computing upper bounds is a bit inconvenient, because our
177-
data structures are setup for the opposite. What we do is to compute
190+
data structures are setup for the opposite.
191+
What we do is to compute
178192
the **reverse SCC graph** (we do this lazily and cache the result) --
179-
that is, a graph where `'a: 'b` induces an edge `SCC('b) ->
180-
SCC('a)`. Like the normal SCC graph, this is a DAG. We can then do a
181-
depth-first search starting from `SCC('0)` in this graph. This will
182-
take us to all the SCCs that must outlive `'0`.
193+
that is, a graph where `'a: 'b` induces an edge `SCC('b) -> SCC('a)`.
194+
Like the normal SCC graph, this is a DAG.
195+
We can then do a depth-first search starting from `SCC('0)` in this graph.
196+
This will take us to all the SCCs that must outlive `'0`.
183197

184198
One wrinkle is that, as we walk the "upper bound" SCCs, their values
185-
will not yet have been fully computed. However, we **have** already
199+
will not yet have been fully computed.
200+
However, we **have** already
186201
applied their liveness constraints, so we have some information about
187-
their value. In particular, for any regions representing lifetime
202+
their value.
203+
In particular, for any regions representing lifetime
188204
parameters, their value will contain themselves (i.e., the initial
189-
value for `'a` includes `'a` and the value for `'b` contains `'b`). So
190-
we can collect all of the lifetime parameters that are reachable,
205+
value for `'a` includes `'a` and the value for `'b` contains `'b`).
206+
So we can collect all of the lifetime parameters that are reachable,
191207
which is precisely what we are interested in.

src/building/how-to-build-and-run.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ Also, using `x` rather than `x.py` is recommended as:
110110
Notice that this is not absolute.
111111
For instance, using Nushell in VSCode on Win10,
112112
typing `x` or `./x` still opens `x.py` in an editor rather than invoking the program.
113-
:)
114113

115114
In the rest of this guide, we use `x` rather than `x.py` directly.
116115
The following command:

src/conventions.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ if foo {
139139
}
140140
```
141141

142+
If you want to leave a note in the codebase, use `// FIXME` instead.
143+
142144
<a id="cio"></a>
143145

144146
## Using crates from crates.io

src/diagnostics/error-codes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Note that not all _historical_ (no longer emitted) error codes have explanations
1010
The explanations are written in Markdown (see the [CommonMark Spec] for
1111
specifics around syntax), and all of them are linked in the [`rustc_error_codes`] crate.
1212
Please read [RFC 1567] for details on how to format and write long error codes.
13-
As of <!-- date-check --> February 2023, there is an
13+
As of <!-- date-check --> March 2026, there is an
1414
effort[^new-explanations] to replace this largely outdated RFC with a new more flexible standard.
1515

1616
Error explanations should expand on the error message and provide details about

0 commit comments

Comments
 (0)