jfrick commited on
Commit
3f8a1ac
·
verified ·
1 Parent(s): 9efda7e

Batched collector checkpoint

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. changes/20261028T105419Z/rust-lang--rust-part009-00012.jsonl.gz +3 -0
  2. patches/20261028T105419Z/rust-lang--rust-part009/0023d942d9035a1cc7a3c920766561696c06f2be.patch +815 -0
  3. patches/20261028T105419Z/rust-lang--rust-part009/0cc88b4a48aeb75a31c28ba341c851d43d6e7e09.patch +24 -0
  4. patches/20261028T105419Z/rust-lang--rust-part009/0dfb098f3aeecbe38c2566ca090193280e7349e7.patch +1741 -0
  5. patches/20261028T105419Z/rust-lang--rust-part009/12a11b5722e5e6517d09ebc43747a495e7f9fd9c.patch +7 -0
  6. patches/20261028T105419Z/rust-lang--rust-part009/141d9b7eab729c024a36bc9a16c810a5acf8cb37.patch +145 -0
  7. patches/20261028T105419Z/rust-lang--rust-part009/1483f9b6e80530193d7b3b94b154a33b446643cb.patch +305 -0
  8. patches/20261028T105419Z/rust-lang--rust-part009/1ad04856b8374eb74cb8d98d90ae67da05fc5978.patch +15 -0
  9. patches/20261028T105419Z/rust-lang--rust-part009/1c4440205607cd18ccfb30abe065bf0f62b5dd18.patch +98 -0
  10. patches/20261028T105419Z/rust-lang--rust-part009/1d7375898dacaaeed8046891066b0e2b58f488c4.patch +68 -0
  11. patches/20261028T105419Z/rust-lang--rust-part009/2039641f6574ca041cc1fb66cf67e4610c8ca98d.patch +32 -0
  12. patches/20261028T105419Z/rust-lang--rust-part009/2060175f5af18b4100acf5995979f4bfb31a000c.patch +0 -0
  13. patches/20261028T105419Z/rust-lang--rust-part009/21228c2dfa1a8afda35130d0fd59979ed6c34937.patch +37 -0
  14. patches/20261028T105419Z/rust-lang--rust-part009/27ee86c0606742c491037219354eacdd7b0bdcc0.patch +15 -0
  15. patches/20261028T105419Z/rust-lang--rust-part009/27f7c65c12d5629df79d121b6242a1a8e8dd8320.patch +15 -0
  16. patches/20261028T105419Z/rust-lang--rust-part009/2a534f5f34829daed828deb0a3106159bb249ab9.patch +130 -0
  17. patches/20261028T105419Z/rust-lang--rust-part009/2da32405305a277a14178b259604f518ce31276a.patch +81 -0
  18. patches/20261028T105419Z/rust-lang--rust-part009/38359d0c24e9e582594d142a5561082362e8744d.patch +59 -0
  19. patches/20261028T105419Z/rust-lang--rust-part009/3a91281217abd4c0e3d4a3de0f1e598c5bef31a3.patch +70 -0
  20. patches/20261028T105419Z/rust-lang--rust-part009/41258df4130f7c8eaab4d3177d156b1661587456.patch +486 -0
  21. patches/20261028T105419Z/rust-lang--rust-part009/45f215f136e00d8a74c69afde2f71be3f16837cf.patch +1678 -0
  22. patches/20261028T105419Z/rust-lang--rust-part009/4a1c2491ff2853a51d7b6aef065fcf7426086d83.patch +347 -0
  23. patches/20261028T105419Z/rust-lang--rust-part009/4a6a067d7950c7eaebb111196e99f935cc0475bd.patch +22 -0
  24. patches/20261028T105419Z/rust-lang--rust-part009/51f306c0e5fcb3a08a97592b1dcab49cf4b64c81.patch +68 -0
  25. patches/20261028T105419Z/rust-lang--rust-part009/52b03b32d115af35abb8945bf6103f26e7ffc169.patch +165 -0
  26. patches/20261028T105419Z/rust-lang--rust-part009/5321a4f40c957cf3587c055e77461febc2ebc865.patch +461 -0
  27. patches/20261028T105419Z/rust-lang--rust-part009/5a41279a06746a114695e96e9d6e1d561e37516d.patch +13 -0
  28. patches/20261028T105419Z/rust-lang--rust-part009/5c8d4746317b634a361daba38e24514f0bfc569d.patch +37 -0
  29. patches/20261028T105419Z/rust-lang--rust-part009/5e8508c0f02f55084f7d616a90b5d2fee42933bf.patch +54 -0
  30. patches/20261028T105419Z/rust-lang--rust-part009/5f96a1cac7a6c204f76559bbba7ffedc1a696b80.patch +74 -0
  31. patches/20261028T105419Z/rust-lang--rust-part009/60be5628af1f9202097d63613e9c68f1f5990378.patch +45 -0
  32. patches/20261028T105419Z/rust-lang--rust-part009/6146d3aacc810466c9f367d7da467067a465a1ed.patch +30 -0
  33. patches/20261028T105419Z/rust-lang--rust-part009/614d9ea42ce84b46371e653f882496877ce277b4.patch +97 -0
  34. patches/20261028T105419Z/rust-lang--rust-part009/61dec2208f5d0a6ea9aa22f19c2f1c14584c8daf.patch +12 -0
  35. patches/20261028T105419Z/rust-lang--rust-part009/61f12cc266bc3581360d66cd55d7f27bf3479fec.patch +18 -0
  36. patches/20261028T105419Z/rust-lang--rust-part009/6508e60c9139ac2ccf98f812709f324ec5c4f521.patch +13 -0
  37. patches/20261028T105419Z/rust-lang--rust-part009/6b1b19c41d3d184814233bcda6bf863440408331.patch +35 -0
  38. patches/20261028T105419Z/rust-lang--rust-part009/6c317cc6df2f2d90baaaa8fdf6f6b542b0f7d620.patch +291 -0
  39. patches/20261028T105419Z/rust-lang--rust-part009/6d74441f2887f645b83dcd97f01471f2bfd49a72.patch +172 -0
  40. patches/20261028T105419Z/rust-lang--rust-part009/7876a7b6f1b50204bbde12770df4d7fc02dd14ed.patch +283 -0
  41. patches/20261028T105419Z/rust-lang--rust-part009/799c6d0902f86e9f3356ad5fe78883e05c066701.patch +89 -0
  42. patches/20261028T105419Z/rust-lang--rust-part009/7b98255ea37f2557b1e79c1729b86fcdd5122ee3.patch +18 -0
  43. patches/20261028T105419Z/rust-lang--rust-part009/7f0581d42e299ea0824c13338832daa20d442e62.patch +348 -0
  44. patches/20261028T105419Z/rust-lang--rust-part009/7f0cd463543d4cc9213517619dd8f784e87896f7.patch +564 -0
  45. patches/20261028T105419Z/rust-lang--rust-part009/84eb2cf29b4891230b4d6faffa4225600f81b584.patch +564 -0
  46. patches/20261028T105419Z/rust-lang--rust-part009/8517e0f05f445518a924e4c93a390c4ac532e1f5.patch +17 -0
  47. patches/20261028T105419Z/rust-lang--rust-part009/85eaa63195a932c731059139342153c1a55a3ddd.patch +68 -0
  48. patches/20261028T105419Z/rust-lang--rust-part009/862ae981f33f053b6e4b3df9582e519bb7a1e541.patch +32 -0
  49. patches/20261028T105419Z/rust-lang--rust-part009/892c6bb8e88536aafabe1d4734073b82c15da566.patch +1882 -0
  50. patches/20261028T105419Z/rust-lang--rust-part009/9670dfaf1574b3417e0404af4524c686d6be7aef.patch +24 -0
changes/20261028T105419Z/rust-lang--rust-part009-00012.jsonl.gz ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2313cbaf8d309c37465d9cc26cef25d561d182d4762495b58aff997c5b1912ee
3
+ size 5678088
patches/20261028T105419Z/rust-lang--rust-part009/0023d942d9035a1cc7a3c920766561696c06f2be.patch ADDED
@@ -0,0 +1,815 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ diff --git a/src/doc/rustc-dev-guide/README.md b/src/doc/rustc-dev-guide/README.md
2
+ index 21e6832633d15848fe7820a2653583b0e5c474fd..86aba86ab8ed9140f13c14e94eb5bafc3823d89d 100644
3
+ --- a/src/doc/rustc-dev-guide/README.md
4
+ +++ b/src/doc/rustc-dev-guide/README.md
5
+ @@ -81,7 +81,7 @@ The build files are found in the `book/html` directory.
6
+
7
+ See the guide itself for instructions on [writing new docs].
8
+
9
+ -[writing new docs]: src/contributing.md#contributing-to-rustc-dev-guide
10
+ +[writing new docs]: src/contributing-to-guide.md
11
+
12
+ ## Maintaining the guide
13
+
14
+ diff --git a/src/doc/rustc-dev-guide/src/SUMMARY.md b/src/doc/rustc-dev-guide/src/SUMMARY.md
15
+ index 8e9b3accb2481c55ee5eae5efed1a33bf96013c1..2f778d34c22c8f85fa04790ab866aa4d98d2d160 100644
16
+ --- a/src/doc/rustc-dev-guide/src/SUMMARY.md
17
+ +++ b/src/doc/rustc-dev-guide/src/SUMMARY.md
18
+ @@ -51,6 +51,7 @@
19
+ # Contributing to Rust
20
+
21
+ - [Contribution procedures](./contributing.md)
22
+ +- [Writing rustc-dev-guide documentation](./contributing-to-guide.md)
23
+ - [About the compiler team](./compiler-team.md)
24
+ - [Using Git](./git.md)
25
+ - [Mastering @rustbot](./rustbot.md)
26
+ diff --git a/src/doc/rustc-dev-guide/src/about-this-guide.md b/src/doc/rustc-dev-guide/src/about-this-guide.md
27
+ index d12d1a14c5b42185944db802d590ee1817e1e088..8928bbaa44aad9edb4f7a4ac63335827d04cdd3c 100644
28
+ --- a/src/doc/rustc-dev-guide/src/about-this-guide.md
29
+ +++ b/src/doc/rustc-dev-guide/src/about-this-guide.md
30
+ @@ -35,7 +35,7 @@ There are several parts to this guide:
31
+ There are a few of these with different information, including a glossary.
32
+
33
+ [p1]: ./building/how-to-build-and-run.md
34
+ -[p2]: ./contributing.md
35
+ +[p2]: ./getting-started.md
36
+ [p3]: ./building/bootstrapping/intro.md
37
+ [p4]: ./part-2-intro.md
38
+ [p5]: ./part-3-intro.md
39
+ @@ -61,7 +61,7 @@ Even better, open a PR with a correction!
40
+ If you do contribute to the guide,
41
+ please see the corresponding [subsection on writing documentation in this guide].
42
+
43
+ -[subsection on writing documentation in this guide]: contributing.md#contributing-to-rustc-dev-guide
44
+ +[subsection on writing documentation in this guide]: contributing-to-guide.md
45
+
46
+ > “‘All conditioned things are impermanent’ —
47
+ > when one sees this with wisdom, one turns away from suffering.”
48
+ diff --git a/src/doc/rustc-dev-guide/src/building/compiler-documenting.md b/src/doc/rustc-dev-guide/src/building/compiler-documenting.md
49
+ index 026a42907493f14f5e99ae931098a28cdce9e4bf..2be8f053a9fbc1503c7d6709a96cd30864068939 100644
50
+ --- a/src/doc/rustc-dev-guide/src/building/compiler-documenting.md
51
+ +++ b/src/doc/rustc-dev-guide/src/building/compiler-documenting.md
52
+ @@ -48,3 +48,36 @@ like the standard library (std) or the compiler (rustc).
53
+ NOTE: The documentation for the compiler is found at [this link].
54
+
55
+ [this link]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/
56
+ +
57
+ +## Contributing documentation
58
+ +
59
+ +Documentation improvements are very welcome.
60
+ +The source of `doc.rust-lang.org`
61
+ +is located in [`src/doc`] in the tree, and standard API documentation is generated
62
+ +from the source code itself (e.g. [`library/std/src/lib.rs`][std-root]). Documentation pull requests
63
+ +function in the same way as other pull requests.
64
+ +
65
+ +[`src/doc`]: https://github.com/rust-lang/rust/tree/HEAD/src/doc
66
+ +[std-root]: https://github.com/rust-lang/rust/blob/HEAD/library/std/src/lib.rs#L1
67
+ +
68
+ +To find documentation-related issues, use the [A-docs label].
69
+ +
70
+ +You can find documentation style guidelines in [RFC 1574].
71
+ +
72
+ +To build the standard library documentation, use `x doc --stage 1 library --open`.
73
+ +To build the documentation for a book (e.g. the unstable book), use `x doc src/doc/unstable-book`.
74
+ +Results should appear in `build/host/doc`, as well as automatically open in your default browser.
75
+ +See [Building Documentation](#building-documentation) for more
76
+ +information.
77
+ +
78
+ +You can also use `rustdoc` directly to check small fixes.
79
+ +For example, `rustdoc src/doc/reference.md` will render reference to `doc/reference.html`.
80
+ +The CSS might be messed up, but you can verify that the HTML is right.
81
+ +
82
+ +Please notice that we don't accept typography/spellcheck fixes to **internal documentation**
83
+ +as it's usually not worth the churn or the review time.
84
+ +Examples of internal documentation are code comments and rustc API docs.
85
+ +However, feel free to fix those if accompanied by other improvements in the same PR.
86
+ +
87
+ +[A-docs label]: https://github.com/rust-lang/rust/issues?q=is%3Aopen%20is%3Aissue%20label%3AA-docs
88
+ +[RFC 1574]: https://github.com/rust-lang/rfcs/blob/master/text/1574-more-api-documentation-conventions.md#appendix-a-full-conventions-text
89
+ diff --git a/src/doc/rustc-dev-guide/src/contributing-to-guide.md b/src/doc/rustc-dev-guide/src/contributing-to-guide.md
90
+ new file mode 100644
91
+ index 0000000000000000000000000000000000000000..43b9d5868b029adf9400f018b3d8a44e827c6eff
92
+ --- /dev/null
93
+ +++ b/src/doc/rustc-dev-guide/src/contributing-to-guide.md
94
+ @@ -0,0 +1,82 @@
95
+ +# Writing rustc-dev-guide documentation
96
+ +
97
+ +Contributions to the [rustc-dev-guide] are always welcome, and can be made directly at
98
+ +[the rust-lang/rustc-dev-guide repo][rdgrepo].
99
+ +The issue tracker in that repo is also a great way to find things that need doing.
100
+ +There are issues for beginners and advanced compiler devs alike!
101
+ +
102
+ +Just a few things to keep in mind:
103
+ +
104
+ +[rustc API docs]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle
105
+ +
106
+ +- When writing about a particular part of the compiler's code, we
107
+ + recommend that you link to the relevant parts of the [rustc API docs].
108
+ +
109
+ +- Use sentence case for chapter and section titles.
110
+ +
111
+ +- Use dashes (`-`) to separate words in file names.
112
+ +
113
+ +- Links within the guide should use `.md` relative links, not `.html` links.
114
+ + CI will enforce this.
115
+ +
116
+ +- Please try to avoid overly long lines and use semantic line breaks (where you break the line after each sentence).
117
+ + This makes it easier to review diffs, since they avoid reflowing other unrelated prose.
118
+ + There is no strict limit on line lengths;
119
+ + let the sentence or part of the sentence flow to its proper end on the same line.
120
+ +
121
+ + You can use a tool in ci/sembr to help with this.
122
+ + Its help output can be seen with this command:
123
+ +
124
+ + ```console
125
+ + cargo run --manifest-path ci/sembr/Cargo.toml -- --help
126
+ + ```
127
+ +
128
+ +- When contributing text to the guide, please contextualize the information with some time period
129
+ + and/or a reason so that the reader knows how much to trust the information.
130
+ + Aim to provide a reasonable amount of context, and consider including:
131
+ +
132
+ + - A reason for why the text may be out of date other than "change",
133
+ + as change is a constant across the project.
134
+ +
135
+ + - The date the comment was added, e.g. instead of writing _"Currently, ..."_
136
+ + or _"As of now, ..."_, consider adding the date, in one of the following formats:
137
+ + - Jan 2021
138
+ + - January 2021
139
+ + - jan 2021
140
+ + - january 2021
141
+ +
142
+ + There is a CI action (in `.github/workflows/date-check.yml`)
143
+ + that generates a monthly report showing those that are over 6 months old
144
+ + ([example](https://github.com/rust-lang/rustc-dev-guide/issues/2052)).
145
+ +
146
+ + For the action to pick the date, add a special annotation before specifying the date:
147
+ +
148
+ + ```md
149
+ + <!-- date-check --> Jul 2026
150
+ + ```
151
+ +
152
+ + Example:
153
+ +
154
+ + ```md
155
+ + As of <!-- date-check --> Jul 2026, the foo did the bar.
156
+ + ```
157
+ +
158
+ + For cases where the date should not be part of the visible rendered output,
159
+ + use the following instead:
160
+ +
161
+ + ```md
162
+ + <!-- date-check: Jul 2026 -->
163
+ + ```
164
+ +
165
+ + - A link to a relevant WG, tracking issue, `rustc` rustdoc page, or similar, that may provide
166
+ + further explanation for the change process or a way to verify that the information is not
167
+ + outdated.
168
+ +
169
+ +## ⚠️ Note: Where to contribute `rustc-dev-guide` changes
170
+ +
171
+ +For detailed information about where to contribute rustc-dev-guide changes and the benefits of doing so,
172
+ +see [the rustc-dev-guide team documentation].
173
+ +
174
+ +[rustc-dev-guide]: https://rustc-dev-guide.rust-lang.org/
175
+ +[rdgrepo]: https://github.com/rust-lang/rustc-dev-guide
176
+ +[the rustc-dev-guide team documentation]: https://forge.rust-lang.org/rustc-dev-guide/index.html#where-to-contribute-rustc-dev-guide-changes
177
+ diff --git a/src/doc/rustc-dev-guide/src/contributing.md b/src/doc/rustc-dev-guide/src/contributing.md
178
+ index f8fadc8910dd3290e304409d543f97845cea39af..09ac149b705c42de9cafca989bf33dc30b164a8b 100644
179
+ --- a/src/doc/rustc-dev-guide/src/contributing.md
180
+ +++ b/src/doc/rustc-dev-guide/src/contributing.md
181
+ @@ -31,121 +31,76 @@ Trait in return position**.
182
+ Opening an issue is as easy as following [this link][create an issue] and filling out the fields
183
+ in the appropriate provided template.
184
+
185
+ -## Bug fixes or "normal" code changes
186
+ -
187
+ -For most PRs, no special procedures are needed.
188
+ -You can just [open a PR], and it will be reviewed, approved, and merged.
189
+ -This includes most bug fixes, refactorings, and other user-invisible changes.
190
+ -The next few sections talk about exceptions to this rule.
191
+ -
192
+ -Also, note that it is perfectly acceptable to open WIP PRs or GitHub [Draft PRs].
193
+ -Some people prefer to do this so they can get feedback along the
194
+ -way or share their code with a collaborator.
195
+ -Others do this so they can utilize
196
+ -the CI to build and test their PR (e.g. when developing on a slow machine).
197
+ -
198
+ -[open a PR]: #pull-requests
199
+ -[Draft PRs]: https://github.blog/2019-02-14-introducing-draft-pull-requests/
200
+ -
201
+ -## New features
202
+ -
203
+ -Rust has strong backwards-compatibility guarantees.
204
+ -Thus, new features can't just be implemented directly in stable Rust.
205
+ -Instead, we have 3 release channels: stable, beta, and nightly.
206
+ -See [The Rust Book] for more details on Rust’s train release model.
207
+ +[search existing issues]: https://github.com/rust-lang/rust/issues?q=is%3Aissue
208
+ +[create an issue]: https://github.com/rust-lang/rust/issues/new/choose
209
+
210
+ -- **Stable**: this is the latest stable release for general usage.
211
+ -- **Beta**: this is the next release (will be stable within 6 weeks).
212
+ -- **Nightly**: follows the `main` branch of the repo.
213
+ - This is the only channel where unstable features are intended to be used,
214
+ - which happens via opt-in feature gates.
215
+ +## PRs and review
216
+
217
+ -See [this chapter on implementing new features](./implementing-new-features.md) for more
218
+ -information.
219
+ +### Opening a PR
220
+
221
+ -[The Rust Book]: https://doc.rust-lang.org/book/appendix-07-nightly-rust.html
222
+ +You are now ready to file a pull request (PR)?
223
+ +Great!
224
+ +Here are a few points you should be aware of.
225
+
226
+ -### Breaking changes
227
+ +All pull requests should be filed against the `main` branch,
228
+ +unless you know for sure that you should target a different branch.
229
+
230
+ -Breaking changes have a [dedicated section][Breaking Changes] in the dev-guide.
231
+ +Run some style checks before you submit the PR:
232
+
233
+ -### Major changes
234
+ + ./x test tidy --bless
235
+
236
+ -See ["What proposal approval do I need?"](https://forge.rust-lang.org/compiler/proposals-and-stabilization.html#what-proposalapproval-do-i-need)
237
+ -For a definition of the terms there, see
238
+ -["Proposals"](https://forge.rust-lang.org/compiler/proposals-and-stabilization.html#proposals).
239
+ +We recommend to make this check before every pull request (and every new commit in a pull request);
240
+ +you can add [git hooks] before every push to make sure you never forget to make this check.
241
+ +The CI will also run tidy and will fail if tidy fails.
242
+
243
+ -**When in doubt, ask [on Zulip].
244
+ -It would be a shame to put a lot of work into a PR that ends up not getting merged!**
245
+ +Rust follows a _no merge-commit policy_,
246
+ +meaning that when you encounter merge conflicts,
247
+ +you are expected to always rebase instead of merging.
248
+ +For example,
249
+ +always use rebase when bringing the latest changes from the `main` branch to your feature branch.
250
+ +If your PR contains merge commits, it will get marked as `has-merge-commits`.
251
+ +Once you have removed the merge commits, e.g., through an interactive rebase, you
252
+ +should remove the label again:
253
+
254
+ -[on Zulip]: https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler
255
+ + @rustbot label -has-merge-commits
256
+
257
+ -### Performance
258
+ +See [this chapter][labeling] for more details.
259
+
260
+ -Compiler performance is important.
261
+ -We have put a lot of effort over the last few years into [gradually improving it][perfdash].
262
+ +If you encounter merge conflicts or when a reviewer asks you to perform some
263
+ +changes, your PR will get marked as `S-waiting-on-author`.
264
+ +When you resolve them, you should use `@rustbot` to mark it as `S-waiting-on-review`:
265
+
266
+ -[perfdash]: https://perf.rust-lang.org/dashboard.html
267
+ + @rustbot ready
268
+
269
+ -If you suspect that your change may cause a performance regression (or
270
+ -improvement), you can request a "perf run" (and your reviewer may also request one
271
+ -before approving).
272
+ -This is yet another bot that will compile a collection of
273
+ -benchmarks on a compiler with your changes.
274
+ -The numbers are reported
275
+ -[here][perf], and you can see a comparison of your changes against the latest `main`.
276
+ +GitHub allows [closing issues using keywords][closing-keywords].
277
+ +This feature should be used to keep the issue tracker tidy.
278
+ +However, it is generally preferred
279
+ +to put the "closes #123" text in the PR description rather than the commit message;
280
+ +particularly during rebasing, citing the issue number in the commit can "spam"
281
+ +the issue in question.
282
+
283
+ -> For an introduction to the performance of Rust code in general
284
+ -> which would also be useful in rustc development, see [The Rust Performance Book].
285
+ +However, if your PR fixes a stable-to-beta or stable-to-stable regression and has
286
+ +been accepted for a beta and/or stable backport (i.e., it is marked `beta-accepted`
287
+ +and/or `stable-accepted`), please do *not* use any such keywords since we don't
288
+ +want the corresponding issue to get auto-closed once the fix lands on `main`.
289
+ +Please update the PR description while still mentioning the issue somewhere.
290
+ +For example, you could write `Fixes (after beta backport) #NNN.`.
291
+
292
+ -[perf]: https://perf.rust-lang.org
293
+ -[The Rust Performance Book]: https://nnethercote.github.io/perf-book/
294
+ +As for further actions, please keep a sharp look-out for a PR whose title begins with
295
+ +`[beta]` or `[stable]` and which backports the PR in question.
296
+ +When that one gets merged, the relevant issue can be closed.
297
+ +The closing comment should mention all PRs that were involved.
298
+ +If you don't have the permissions to close the issue, please
299
+ +leave a comment on the original PR asking the reviewer to close it for you.
300
+
301
+ -## Pull requests
302
+ +[labeling]: ./rustbot.md#issue-relabeling
303
+ +[closing-keywords]: https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue
304
+
305
+ -Pull requests (or PRs for short) are the primary mechanism we use to change Rust.
306
+ -GitHub itself has some [great documentation][about-pull-requests] on using the Pull Request feature.
307
+ -We use the ["fork and pull" model][development-models],
308
+ -where contributors push changes to their personal fork and create pull requests to
309
+ -bring those changes into the source repository.
310
+ -We have [a chapter](git.md) on how to use Git when contributing to Rust.
311
+ +### r?
312
+
313
+ -> **Advice for potentially large, complex, cross-cutting and/or very domain-specific changes**
314
+ ->
315
+ -> The compiler reviewers on rotation usually each have areas of the compiler that they know well,
316
+ -> but also have areas that they are not very familiar with. If your PR contains changes that are
317
+ -> large, complex, cross-cutting and/or highly domain-specific, it becomes very difficult to find a
318
+ -> suitable reviewer who is comfortable in reviewing all of the changes in such a PR. This is also
319
+ -> true if the changes are not only compiler-specific but also contain changes which fall under the
320
+ -> purview of reviewers from other teams, like the standard library team. [There's a bot][triagebot]
321
+ -> which notifies the relevant teams and pings people who have set up specific alerts based on the
322
+ -> files modified.
323
+ ->
324
+ -> Before making such changes, you are strongly encouraged to **discuss your proposed changes with
325
+ -> the compiler team beforehand** (and with other teams that the changes would require approval
326
+ -> from), and work with the compiler team to see if we can help you **break down a large potentially
327
+ -> unreviewable PR into a series of smaller more individually reviewable PRs**.
328
+ ->
329
+ -> You can communicate with the compiler team by creating a [#t-compiler thread on Zulip][t-compiler]
330
+ -> to discuss your proposed changes.
331
+ ->
332
+ -> Communicating with the compiler team beforehand helps in several ways:
333
+ ->
334
+ -> 1. It increases the likelihood of your PRs being reviewed in a timely manner.
335
+ -> - We can help you identify suitable reviewers *before* you open actual PRs, or help find
336
+ -> advisors and liaisons to help you navigate the change procedures, or help with running
337
+ -> try-jobs, perf runs and crater runs as suitable.
338
+ -> 2. It helps the compiler team track your changes.
339
+ -> 3. The compiler team can perform vibe checks on your changes early and often, to see if the
340
+ -> direction of the changes align with what the compiler team prefers to see.
341
+ -> 4. Helps to avoid situations where you may have invested significant time and effort into large
342
+ -> changes that the compiler team might not be willing to accept, or finding out very late that the
343
+ -> changes are in a direction that the compiler team disagrees with.
344
+ -
345
+ -[about-pull-requests]: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests
346
+ -[development-models]: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/getting-started/about-collaborative-development-models#fork-and-pull-model
347
+ -[t-compiler]: https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler
348
+ -[triagebot]: https://github.com/rust-lang/rust/blob/HEAD/triagebot.toml
349
+ +Your PR will be automatically assigned a reviewer.
350
+ +You can override the reviewer using `r? @username`.
351
+ +See [PR assignment](https://forge.rust-lang.org/triagebot/pr-assignment.html#usage) for details.
352
+
353
+ ### Keeping your branch up-to-date
354
+
355
+ @@ -166,12 +121,6 @@ See [keeping things up to date](git.md#keeping-things-up-to-date) for detailed i
356
+
357
+ After rebasing, it's recommended to [run the relevant tests locally](tests/intro.md) to catch any issues before CI runs.
358
+
359
+ -### r?
360
+ -
361
+ -Your PR will be automatically assigned a reviewer.
362
+ -You can override the reviewer using `r? @username`.
363
+ -See [PR assignment](https://forge.rust-lang.org/triagebot/pr-assignment.html#usage) for details.
364
+ -
365
+ ### Waiting for reviews
366
+
367
+ > NOTE
368
+ @@ -261,67 +210,7 @@ Also, note that PRs are never merged by hand.
369
+ [@rustbot]: https://github.com/rustbot
370
+ [@bors]: https://github.com/rust-lang/bors
371
+
372
+ -### Opening a PR
373
+ -
374
+ -You are now ready to file a pull request (PR)?
375
+ -Great!
376
+ -Here are a few points you should be aware of.
377
+ -
378
+ -All pull requests should be filed against the `main` branch,
379
+ -unless you know for sure that you should target a different branch.
380
+ -
381
+ -Run some style checks before you submit the PR:
382
+ -
383
+ - ./x test tidy --bless
384
+ -
385
+ -We recommend to make this check before every pull request (and every new commit in a pull request);
386
+ -you can add [git hooks] before every push to make sure you never forget to make this check.
387
+ -The CI will also run tidy and will fail if tidy fails.
388
+ -
389
+ -Rust follows a _no merge-commit policy_,
390
+ -meaning that when you encounter merge conflicts,
391
+ -you are expected to always rebase instead of merging.
392
+ -For example,
393
+ -always use rebase when bringing the latest changes from the `main` branch to your feature branch.
394
+ -If your PR contains merge commits, it will get marked as `has-merge-commits`.
395
+ -Once you have removed the merge commits, e.g., through an interactive rebase, you
396
+ -should remove the label again:
397
+ -
398
+ - @rustbot label -has-merge-commits
399
+ -
400
+ -See [this chapter][labeling] for more details.
401
+ -
402
+ -If you encounter merge conflicts or when a reviewer asks you to perform some
403
+ -changes, your PR will get marked as `S-waiting-on-author`.
404
+ -When you resolve them, you should use `@rustbot` to mark it as `S-waiting-on-review`:
405
+ -
406
+ - @rustbot ready
407
+ -
408
+ -GitHub allows [closing issues using keywords][closing-keywords].
409
+ -This feature should be used to keep the issue tracker tidy.
410
+ -However, it is generally preferred
411
+ -to put the "closes #123" text in the PR description rather than the commit message;
412
+ -particularly during rebasing, citing the issue number in the commit can "spam"
413
+ -the issue in question.
414
+ -
415
+ -However, if your PR fixes a stable-to-beta or stable-to-stable regression and has
416
+ -been accepted for a beta and/or stable backport (i.e., it is marked `beta-accepted`
417
+ -and/or `stable-accepted`), please do *not* use any such keywords since we don't
418
+ -want the corresponding issue to get auto-closed once the fix lands on `main`.
419
+ -Please update the PR description while still mentioning the issue somewhere.
420
+ -For example, you could write `Fixes (after beta backport) #NNN.`.
421
+ -
422
+ -As for further actions, please keep a sharp look-out for a PR whose title begins with
423
+ -`[beta]` or `[stable]` and which backports the PR in question.
424
+ -When that one gets merged, the relevant issue can be closed.
425
+ -The closing comment should mention all PRs that were involved.
426
+ -If you don't have the permissions to close the issue, please
427
+ -leave a comment on the original PR asking the reviewer to close it for you.
428
+ -
429
+ -[labeling]: ./rustbot.md#issue-relabeling
430
+ -[closing-keywords]: https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue
431
+ -
432
+ -### Reverting a PR
433
+ +## Reverting a PR
434
+
435
+ See ["Reverts"](https://forge.rust-lang.org/compiler/reviews.html#reverts) on Forge.
436
+
437
+ @@ -330,149 +219,53 @@ problematic code, as shown in [#128271][#128271].
438
+ For MIR optimizations, we can also use the `-Zunsound-mir-opt` option to gate the mir-opt, as shown
439
+ in [#132356][#132356].
440
+
441
+ -[revert policy]: https://forge.rust-lang.org/compiler/reviews.html?highlight=revert#reverts
442
+ [#128271]: https://github.com/rust-lang/rust/pull/128271
443
+ [#132356]: https://github.com/rust-lang/rust/pull/132356
444
+
445
+ -## External dependencies
446
+ -
447
+ -This section has moved to ["Using External Repositories"](./external-repos.md).
448
+ -
449
+ -## Writing documentation
450
+ -
451
+ -Documentation improvements are very welcome.
452
+ -The source of `doc.rust-lang.org`
453
+ -is located in [`src/doc`] in the tree, and standard API documentation is generated
454
+ -from the source code itself (e.g. [`library/std/src/lib.rs`][std-root]). Documentation pull requests
455
+ -function in the same way as other pull requests.
456
+ -
457
+ -[`src/doc`]: https://github.com/rust-lang/rust/tree/HEAD/src/doc
458
+ -[std-root]: https://github.com/rust-lang/rust/blob/HEAD/library/std/src/lib.rs#L1
459
+ -
460
+ -To find documentation-related issues, use the [A-docs label].
461
+ -
462
+ -You can find documentation style guidelines in [RFC 1574].
463
+ -
464
+ -To build the standard library documentation, use `x doc --stage 1 library --open`.
465
+ -To build the documentation for a book (e.g. the unstable book), use `x doc src/doc/unstable-book`.
466
+ -Results should appear in `build/host/doc`, as well as automatically open in your default browser.
467
+ -See [Building Documentation](./building/compiler-documenting.md#building-documentation) for more
468
+ -information.
469
+ -
470
+ -You can also use `rustdoc` directly to check small fixes.
471
+ -For example, `rustdoc src/doc/reference.md` will render reference to `doc/reference.html`.
472
+ -The CSS might be messed up, but you can verify that the HTML is right.
473
+ -
474
+ -Please notice that we don't accept typography/spellcheck fixes to **internal documentation**
475
+ -as it's usually not worth the churn or the review time.
476
+ -Examples of internal documentation are code comments and rustc API docs.
477
+ -However, feel free to fix those if accompanied by other improvements in the same PR.
478
+ -
479
+ -### Contributing to rustc-dev-guide
480
+ -
481
+ -Contributions to the [rustc-dev-guide] are always welcome, and can be made directly at
482
+ -[the rust-lang/rustc-dev-guide repo][rdgrepo].
483
+ -The issue tracker in that repo is also a great way to find things that need doing.
484
+ -There are issues for beginners and advanced compiler devs alike!
485
+ -
486
+ -Just a few things to keep in mind:
487
+ -
488
+ -[rustc API docs]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle
489
+ -
490
+ -- When writing about a particular part of the compiler's code, we
491
+ - recommend that you link to the relevant parts of the [rustc API docs].
492
+ -
493
+ -- Use sentence case for chapter and sections titles.
494
+ -
495
+ -- Use dashes (`-`) to separate words in file names.
496
+ -
497
+ -- Links within the guide should use `.md` relative links, not `.html` links.
498
+ - CI will enforce this.
499
+ -
500
+ -- Please try to avoid overly long lines and use semantic line breaks (where you break the line after each sentence).
501
+ - This makes it easier to review diffs, since they avoid reflowing other unrelated prose.
502
+ - There is no strict limit on line lengths;
503
+ - let the sentence or part of the sentence flow to its proper end on the same line.
504
+ -
505
+ - You can use a tool in ci/sembr to help with this.
506
+ - Its help output can be seen with this command:
507
+ -
508
+ - ```console
509
+ - cargo run --manifest-path ci/sembr/Cargo.toml -- --help
510
+ - ```
511
+ -
512
+ -- When contributing text to the guide, please contextualize the information with some time period
513
+ - and/or a reason so that the reader knows how much to trust the information.
514
+ - Aim to provide a reasonable amount of context, and consider including:
515
+ -
516
+ - - A reason for why the text may be out of date other than "change",
517
+ - as change is a constant across the project.
518
+ +[Breaking Changes]: bug-fix-procedure.md
519
+ +[compiler test suite]: tests/intro.md
520
+ +[merge queue]: https://bors.rust-lang.org/queue/rust
521
+ +[git hooks]: https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks
522
+
523
+ - - The date the comment was added, e.g. instead of writing _"Currently, ..."_
524
+ - or _"As of now, ..."_, consider adding the date, in one of the following formats:
525
+ - - Jan 2021
526
+ - - January 2021
527
+ - - jan 2021
528
+ - - january 2021
529
+ +## Other procedures
530
+
531
+ - There is a CI action (in `.github/workflows/date-check.yml`)
532
+ - that generates a monthly report showing those that are over 6 months old
533
+ - ([example](https://github.com/rust-lang/rustc-dev-guide/issues/2052)).
534
+ +Other contribution procedures are documented with the parts of the guide that own them:
535
+
536
+ - For the action to pick the date, add a special annotation before specifying the date:
537
+ +<a id="bug-fixes-or-normal-code-changes"></a>
538
+ +<a id="pull-requests"></a>
539
+
540
+ - ```md
541
+ - <!-- date-check --> Jul 2026
542
+ - ```
543
+ +- For routine changes or large, cross-cutting pull requests, see [normal code changes](getting-started.md#bug-fixes-or-normal-code-changes) and [pull request guidance](getting-started.md#pull-requests).
544
+
545
+ - Example:
546
+ +<a id="new-features"></a>
547
+ +<a id="breaking-changes"></a>
548
+ +<a id="major-changes"></a>
549
+
550
+ - ```md
551
+ - As of <!-- date-check --> Jul 2026, the foo did the bar.
552
+ - ```
553
+ +- For new features, major changes, and breaking changes, see [Implementing new language features](implementing-new-features.md) and [Procedures for breaking changes](bug-fix-procedure.md).
554
+
555
+ - For cases where the date should not be part of the visible rendered output,
556
+ - use the following instead:
557
+ +<a id="performance"></a>
558
+
559
+ - ```md
560
+ - <!-- date-check: Jul 2026 -->
561
+ - ```
562
+ +- For performance-sensitive changes, see [Performance testing](tests/perf.md#performance-considerations).
563
+
564
+ - - A link to a relevant WG, tracking issue, `rustc` rustdoc page, or similar, that may provide
565
+ - further explanation for the change process or a way to verify that the information is not
566
+ - outdated.
567
+ +<a id="writing-documentation"></a>
568
+
569
+ -#### ⚠️ Note: Where to contribute `rustc-dev-guide` changes
570
+ +- For compiler documentation, see [Contributing documentation](building/compiler-documenting.md#contributing-documentation).
571
+
572
+ -For detailed information about where to contribute rustc-dev-guide changes and the benefits of doing so,
573
+ -see [the rustc-dev-guide team documentation].
574
+ +<a id="issue-triage"></a>
575
+
576
+ -[the rustc-dev-guide team documentation]: https://forge.rust-lang.org/rustc-dev-guide/index.html#where-to-contribute-rustc-dev-guide-changes
577
+ +- For issue triage, see [Issue triage](getting-started.md#issue-triage).
578
+
579
+ -## Issue triage
580
+ +<a id="llm-guidance"></a>
581
+
582
+ -Please see <https://forge.rust-lang.org/release/issue-triaging.html>.
583
+ +- For guidance on LLM usage, see [Running LLMs](llm-guidance.md).
584
+
585
+ -## LLM policy
586
+ +<a id="contributing-to-rustc-dev-guide"></a>
587
+
588
+ -See [Forge][LLM policy].
589
+ +- For changes to this guide itself, see [Writing rustc-dev-guide documentation](contributing-to-guide.md).
590
+
591
+ -[LLM policy]: https://forge.rust-lang.org/policies/llm-usage.html
592
+ +<a id="external-dependencies"></a>
593
+
594
+ -## Helpful links and information
595
+ +- For external dependencies, see [Using external repositories](external-repos.md).
596
+
597
+ -This section has moved to the ["About this guide"] chapter.
598
+ +<a id="helpful-links-and-information"></a>
599
+
600
+ -["About this guide"]: about-this-guide.md#other-places-to-find-information
601
+ -[search existing issues]: https://github.com/rust-lang/rust/issues?q=is%3Aissue
602
+ -[Breaking Changes]: bug-fix-procedure.md
603
+ -[triagebot.toml config file]: https://github.com/rust-lang/rust/blob/HEAD/triagebot.toml
604
+ -[rust-lang teams database]: https://github.com/rust-lang/team/tree/HEAD/teams
605
+ -[compiler test suite]: tests/intro.md
606
+ -[merge queue]: https://bors.rust-lang.org/queue/rust
607
+ -[git hooks]: https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks
608
+ -[A-docs label]: https://github.com/rust-lang/rust/issues?q=is%3Aopen%20is%3Aissue%20label%3AA-docs
609
+ -[RFC 1574]: https://github.com/rust-lang/rfcs/blob/master/text/1574-more-api-documentation-conventions.md#appendix-a-full-conventions-text
610
+ -[rustc-dev-guide]: https://rustc-dev-guide.rust-lang.org/
611
+ -[rdgrepo]: https://github.com/rust-lang/rustc-dev-guide
612
+ -[create an issue]: https://github.com/rust-lang/rust/issues/new/choose
613
+ +- For further resources, see [About this guide](about-this-guide.md#other-places-to-find-information).
614
+ diff --git a/src/doc/rustc-dev-guide/src/getting-started.md b/src/doc/rustc-dev-guide/src/getting-started.md
615
+ index 9481e378ee5a004314eafc377bcf01558373ac9c..77b04e683c86d41431f04e525f999b334a2b4dcf 100644
616
+ --- a/src/doc/rustc-dev-guide/src/getting-started.md
617
+ +++ b/src/doc/rustc-dev-guide/src/getting-started.md
618
+ @@ -57,7 +57,7 @@ Not all important or beginner work has issue labels.
619
+ See below for how to find work that isn't labelled.
620
+
621
+ [help-wanted-search]: https://github.com/rust-lang/rust/issues?q=is%3Aopen%20is%3Aissue%20org%3Arust-lang%20no%3Aassignee%20label%3AE-easy%2CE-medium%2CE-help-wanted%2CE-mentor%20-label%3AS-blocked%20-linked%3Apr
622
+ -[Triage]: ./contributing.md#issue-triage
623
+ +[Triage]: https://forge.rust-lang.org/release/issue-triaging.html
624
+
625
+ ### Recurring work
626
+
627
+ @@ -116,9 +116,71 @@ See [Forge](https://forge.rust-lang.org/how-to-start-contributing.html#how-to-st
628
+
629
+ See ["How to build and run the compiler"](./building/how-to-build-and-run.md).
630
+
631
+ -## Contributor Procedures
632
+ -
633
+ -This section has moved to the ["Contribution Procedures"](./contributing.md) chapter.
634
+ +## Bug fixes or "normal" code changes
635
+ +
636
+ +For most PRs, no special procedures are needed.
637
+ +You can just [open a PR], and it will be reviewed, approved, and merged.
638
+ +This includes most bug fixes, refactorings, and other user-invisible changes.
639
+ +The next few sections talk about exceptions to this rule.
640
+ +
641
+ +Also, note that it is perfectly acceptable to open WIP PRs or GitHub [Draft PRs].
642
+ +Some people prefer to do this so they can get feedback along the
643
+ +way or share their code with a collaborator.
644
+ +Others do this so they can utilize
645
+ +the CI to build and test their PR (e.g. when developing on a slow machine).
646
+ +
647
+ +[open a PR]: git.md#opening-a-pr
648
+ +[Draft PRs]: https://github.blog/2019-02-14-introducing-draft-pull-requests/
649
+ +
650
+ +## Pull requests
651
+ +
652
+ +Pull requests (or PRs for short) are the primary mechanism we use to change Rust.
653
+ +GitHub itself has some [great documentation][about-pull-requests] on using the Pull Request feature.
654
+ +We use the ["fork and pull" model][development-models],
655
+ +where contributors push changes to their personal fork and create pull requests to
656
+ +bring those changes into the source repository.
657
+ +We have [a chapter](git.md) on how to use Git when contributing to Rust.
658
+ +
659
+ +> **Advice for potentially large, complex, cross-cutting and/or very domain-specific changes**
660
+ +>
661
+ +> The compiler reviewers on rotation usually each have areas of the compiler that they know well,
662
+ +> but also have areas that they are not very familiar with. If your PR contains changes that are
663
+ +> large, complex, cross-cutting and/or highly domain-specific, it becomes very difficult to find a
664
+ +> suitable reviewer who is comfortable in reviewing all of the changes in such a PR. This is also
665
+ +> true if the changes are not only compiler-specific but also contain changes which fall under the
666
+ +> purview of reviewers from other teams, like the standard library team. [There's a bot][triagebot]
667
+ +> which notifies the relevant teams and pings people who have set up specific alerts based on the
668
+ +> files modified.
669
+ +>
670
+ +> Before making such changes, you are strongly encouraged to **discuss your proposed changes with
671
+ +> the compiler team beforehand** (and with other teams that the changes would require approval
672
+ +> from), and work with the compiler team to see if we can help you **break down a large potentially
673
+ +> unreviewable PR into a series of smaller more individually reviewable PRs**.
674
+ +>
675
+ +> You can communicate with the compiler team by creating a [#t-compiler thread on Zulip][t-compiler]
676
+ +> to discuss your proposed changes.
677
+ +>
678
+ +> Communicating with the compiler team beforehand helps in several ways:
679
+ +>
680
+ +> 1. It increases the likelihood of your PRs being reviewed in a timely manner.
681
+ +> - We can help you identify suitable reviewers *before* you open actual PRs, or help find
682
+ +> advisors and liaisons to help you navigate the change procedures, or help with running
683
+ +> try-jobs, perf runs and crater runs as suitable.
684
+ +> 2. It helps the compiler team track your changes.
685
+ +> 3. The compiler team can perform vibe checks on your changes early and often, to see if the
686
+ +> direction of the changes align with what the compiler team prefers to see.
687
+ +> 4. Helps to avoid situations where you may have invested significant time and effort into large
688
+ +> changes that the compiler team might not be willing to accept, or finding out very late that the
689
+ +> changes are in a direction that the compiler team disagrees with.
690
+ +
691
+ +[about-pull-requests]: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests
692
+ +[development-models]: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/getting-started/about-collaborative-development-models#fork-and-pull-model
693
+ +[t-compiler]: https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler
694
+ +[triagebot]: https://github.com/rust-lang/rust/blob/HEAD/triagebot.toml
695
+ +
696
+ +## Issue triage
697
+ +
698
+ +Please see <https://forge.rust-lang.org/release/issue-triaging.html>.
699
+
700
+ ## Other Resources
701
+
702
+ diff --git a/src/doc/rustc-dev-guide/src/implementing-new-features.md b/src/doc/rustc-dev-guide/src/implementing-new-features.md
703
+ index 2ff9d6a62e2867eca5699d4d1e201732705227f8..947dd9d36d0e51f9a5a3984141fd7e43c86eb53e 100644
704
+ --- a/src/doc/rustc-dev-guide/src/implementing-new-features.md
705
+ +++ b/src/doc/rustc-dev-guide/src/implementing-new-features.md
706
+ @@ -12,6 +12,38 @@ See also [the Rust Language Design Team's procedures][lang-propose] for proposin
707
+ [a different process]: ./stability.md
708
+ [lang-propose]: https://lang-team.rust-lang.org/how_to/propose.html
709
+
710
+ +## New features
711
+ +
712
+ +Rust has strong backwards-compatibility guarantees.
713
+ +Thus, new features can't just be implemented directly in stable Rust.
714
+ +Instead, we have 3 release channels: stable, beta, and nightly.
715
+ +See [The Rust Book] for more details on Rust’s train release model.
716
+ +
717
+ +- **Stable**: this is the latest stable release for general usage.
718
+ +- **Beta**: this is the next release (will be stable within 6 weeks).
719
+ +- **Nightly**: follows the `main` branch of the repo.
720
+ + This is the only channel where unstable features are intended to be used,
721
+ + which happens via opt-in feature gates.
722
+ +
723
+ +[The Rust Book]: https://doc.rust-lang.org/book/appendix-07-nightly-rust.html
724
+ +
725
+ +### Breaking changes
726
+ +
727
+ +Breaking changes have a [dedicated section][Breaking Changes] in the dev-guide.
728
+ +
729
+ +### Major changes
730
+ +
731
+ +See ["What proposal approval do I need?"](https://forge.rust-lang.org/compiler/proposals-and-stabilization.html#what-proposalapproval-do-i-need)
732
+ +For a definition of the terms there, see
733
+ +["Proposals"](https://forge.rust-lang.org/compiler/proposals-and-stabilization.html#proposals).
734
+ +
735
+ +**When in doubt, ask [on Zulip].
736
+ +It would be a shame to put a lot of work into a PR that ends up not getting merged!**
737
+ +
738
+ +[on Zulip]: https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler
739
+ +
740
+ +[Breaking Changes]: bug-fix-procedure.md
741
+ +
742
+ ## The @rfcbot FCP process
743
+
744
+ When the change is small, uncontroversial, non-breaking,
745
+ @@ -226,7 +258,6 @@ The below steps needs to be followed in order to implement a new unstable featur
746
+ [stability in code]: #stability-in-code
747
+ [here]: ./stabilization-guide.md
748
+ [tracking issue]: #tracking-issues
749
+ -[add-feature-gate]: ./feature-gates.md#adding-a-feature-gate
750
+ [guidance for compiler flags]: https://forge.rust-lang.org/compiler/proposals-and-stabilization.html?highlight=unstable%20flag#compiler-flags
751
+ [`UnstableOptions`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_session/options/struct.UnstableOptions.html
752
+
753
+ diff --git a/src/doc/rustc-dev-guide/src/llm-guidance/writing.md b/src/doc/rustc-dev-guide/src/llm-guidance/writing.md
754
+ index 3cbdf3d2b849c4ad18e32742bbba1d181c080b4a..44685ba77f1d679c73cbebe21b5a6c4e41ae221c 100644
755
+ --- a/src/doc/rustc-dev-guide/src/llm-guidance/writing.md
756
+ +++ b/src/doc/rustc-dev-guide/src/llm-guidance/writing.md
757
+ @@ -63,7 +63,7 @@ For example:
758
+
759
+ - Search for related issues and PRs.
760
+ - Find relevant code, tests, git history, and Zulip discussion.
761
+ -- If this is a cross-cutting change, consult the "cross-cutting" section of [the contributing docs](../contributing.md#pull-requests).
762
+ +- If this is a cross-cutting change, consult the [pull request guidance](../getting-started.md#pull-requests).
763
+ - [Make the smallest change that fixes the problem][small-cls].
764
+ Do not combine it with unrelated refactors or cleanups.
765
+
766
+ @@ -81,7 +81,7 @@ You may use an LLM for generating the instructions for that tool, but you should
767
+
768
+ Consider [performance] as you write.
769
+
770
+ -[performance]: ../contributing.md#performance
771
+ +[performance]: ../tests/perf.md#performance-considerations
772
+
773
+ Think before adding dependencies;
774
+ consult our [guidance for new dependencies][crates-io].
775
+ @@ -176,3 +176,9 @@ We don't care which model you used, but we do care whether you used the LLM to i
776
+ > 🤖 Generated with Claude Code
777
+
778
+ > `Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>`
779
+ +
780
+ +## LLM policy
781
+ +
782
+ +See [Forge][LLM policy].
783
+ +
784
+ +[LLM policy]: https://forge.rust-lang.org/policies/llm-usage.html
785
+ diff --git a/src/doc/rustc-dev-guide/src/tests/perf.md b/src/doc/rustc-dev-guide/src/tests/perf.md
786
+ index 567b2d7a97e4808455c39a8ea66b044fb9693684..50825a706cbe64dc66390df62cd97beaabb0a34d 100644
787
+ --- a/src/doc/rustc-dev-guide/src/tests/perf.md
788
+ +++ b/src/doc/rustc-dev-guide/src/tests/perf.md
789
+ @@ -1,5 +1,26 @@
790
+ # Performance testing
791
+
792
+ +## Performance considerations
793
+ +
794
+ +Compiler performance is important.
795
+ +We have put a lot of effort over the last few years into [gradually improving it][perfdash].
796
+ +
797
+ +[perfdash]: https://perf.rust-lang.org/dashboard.html
798
+ +
799
+ +If you suspect that your change may cause a performance regression (or
800
+ +improvement), you can request a "perf run" (and your reviewer may also request one
801
+ +before approving).
802
+ +This is yet another bot that will compile a collection of
803
+ +benchmarks on a compiler with your changes.
804
+ +The numbers are reported
805
+ +[here][perf], and you can see a comparison of your changes against the latest `main`.
806
+ +
807
+ +> For an introduction to the performance of Rust code in general
808
+ +> which would also be useful in rustc development, see [The Rust Performance Book].
809
+ +
810
+ +[perf]: https://perf.rust-lang.org
811
+ +[The Rust Performance Book]: https://nnethercote.github.io/perf-book/
812
+ +
813
+ ## rustc-perf
814
+
815
+ A lot of work is put into improving the performance of the compiler and
patches/20261028T105419Z/rust-lang--rust-part009/0cc88b4a48aeb75a31c28ba341c851d43d6e7e09.patch ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ diff --git a/compiler/rustc_infer/src/infer/mod.rs b/compiler/rustc_infer/src/infer/mod.rs
2
+ index b25736112027ca85c860e04421e477c143f8fa9c..6f5d3bb75ebe46604fe1774c151d9ea166faa352 100644
3
+ --- a/compiler/rustc_infer/src/infer/mod.rs
4
+ +++ b/compiler/rustc_infer/src/infer/mod.rs
5
+ @@ -91,7 +91,7 @@ pub(crate) type UnificationTable<'a, 'tcx, T> = ut::UnificationTable<
6
+
7
+ /// This type contains all the things within [`InferCtxt`] that sit within a
8
+ /// [`RefCell`] and are involved with taking/rolling back snapshots. Snapshot
9
+ -/// operations are hot enough that we want only one call to
10
+ +/// operations are hot enough that we want only one call to
11
+ /// [`RefCell::borrow_mut`] per call to [`InferCtxt::start_snapshot`] and
12
+ /// [`InferCtxt::rollback_to`].
13
+ #[derive(Clone)]
14
+ @@ -104,8 +104,8 @@ pub struct InferCtxtInner<'tcx> {
15
+ projection_cache: traits::ProjectionCacheStorage<'tcx>,
16
+
17
+ /// Primary map of inference variables to the types that they currently
18
+ - /// represent.
19
+ - ///
20
+ + /// represent.
21
+ + ///
22
+ /// We instantiate [`UnificationTable`] with `bounds<Ty>` because the types
23
+ /// that might instantiate a general type variable have an order,
24
+ /// represented by its upper and lower bounds.
patches/20261028T105419Z/rust-lang--rust-part009/0dfb098f3aeecbe38c2566ca090193280e7349e7.patch ADDED
@@ -0,0 +1,1741 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ diff --git a/RELEASES.md b/RELEASES.md
2
+ index f2d74f2e7f1f04a39239db4cd83fa7a616268407..34984a29eff5192fa9605a52ebd93dd9407f4f26 100644
3
+ --- a/RELEASES.md
4
+ +++ b/RELEASES.md
5
+ @@ -1,3 +1,10 @@
6
+ +Version 1.98.1 (2026-09-03)
7
+ +===========================
8
+ +
9
+ +<a id="1.98.1"></a>
10
+ +
11
+ +* [rustc: fix miscompilation in generating vtables](https://github.com/rust-lang/rust/issues/161441)
12
+ +
13
+ Version 1.98.0 (2026-08-20)
14
+ ==========================
15
+
16
+ diff --git a/compiler/rustc_attr_ir/src/attribute_docs.rs b/compiler/rustc_attr_ir/src/attribute_docs.rs
17
+ new file mode 100644
18
+ index 0000000000000000000000000000000000000000..4d40cd6d52f16ab35bb6f9d1230f3bbe7a2b4ce6
19
+ --- /dev/null
20
+ +++ b/compiler/rustc_attr_ir/src/attribute_docs.rs
21
+ @@ -0,0 +1,225 @@
22
+ +macro_rules! include_example {
23
+ + ($name:literal) => {
24
+ + concat!(
25
+ + "```rust,compile_fail\n",
26
+ + include_str!(concat!("../../../tests/ui/attributes/doc_examples/", $name, ".rs")),
27
+ + "```\n",
28
+ + "produces:\n",
29
+ + " ```text\n",
30
+ + include_str!(concat!("../../../tests/ui/attributes/doc_examples/", $name, ".stderr")),
31
+ + "```\n",
32
+ + )
33
+ + };
34
+ +}
35
+ +
36
+ +#[cfg_attr(not(bootstrap), doc(attribute = "rustc_dump_clauses"))]
37
+ +/// Dumps the list of [`ty::Clause`]s as computed by the [`clauses_of`] query.
38
+ +///
39
+ +/// See [`AttributeKind::RustcDumpClauses`] for the internal representation of this attribute.
40
+ +///
41
+ +/// # Example
42
+ +///
43
+ +#[doc = include_example!("rustc_dump_clauses")]
44
+ +///
45
+ +/// # Example: super trait bounds are not elaborated
46
+ +///
47
+ +#[doc = include_example!("rustc_dump_clauses_super_trait")]
48
+ +///
49
+ +/// [`clauses_of`]: ../rustc_middle/ty/struct.TyCtxt.html#method.clauses_of
50
+ +/// [`ty::Clause`]: ../rustc_middle/ty/struct.Clause.html
51
+ +const _: () = ();
52
+ +
53
+ +#[doc(attribute = "rustc_dump_def_parents")]
54
+ +/// Dumps the parents of the annotated item and of any anonymous constants contained within it.
55
+ +///
56
+ +/// See also [`opt_parent`](../rustc_middle/ty/struct.TyCtxt.html#method.opt_parent).
57
+ +///
58
+ +/// See [`AttributeKind::RustcDumpDefParents`] for the internal representation of this attribute.
59
+ +///
60
+ +/// # Example
61
+ +///
62
+ +#[doc = include_example!("rustc_dump_def_parents")]
63
+ +const _: () = ();
64
+ +
65
+ +#[doc(attribute = "rustc_dump_def_path")]
66
+ +/// Dumps the def path of the annotated item.
67
+ +///
68
+ +/// See also [`def_path_str`] and [`def_path_str_with_args`].
69
+ +///
70
+ +/// See [`AttributeKind::RustcDumpDefPath`] for the internal representation of this attribute.
71
+ +///
72
+ +/// # Example
73
+ +///
74
+ +#[doc = include_example!("rustc_dump_def_path")]
75
+ +///
76
+ +/// [`def_path_str`]: ../rustc_middle/ty/struct.TyCtxt.html#method.def_path_str
77
+ +/// [`def_path_str_with_args`]: ../rustc_middle/ty/struct.TyCtxt.html#method.def_path_str_with_args
78
+ +const _: () = ();
79
+ +
80
+ +#[doc(attribute = "rustc_dump_generics")]
81
+ +/// Dumps the generics of the annotated item.
82
+ +///
83
+ +/// See [`generics_of`] and [`ty::Generics`] for what "generics" means here.
84
+ +///
85
+ +/// See [`AttributeKind::RustcDumpGenerics`] for the internal representation of this attribute.
86
+ +///
87
+ +/// # Example
88
+ +///
89
+ +#[doc = include_example!("rustc_dump_generics")]
90
+ +///
91
+ +/// [`generics_of`]: ../rustc_middle/ty/struct.TyCtxt.html#method.generics_of
92
+ +/// [`ty::Generics`]: ../rustc_middle/ty/struct.Generics.html
93
+ +const _: () = ();
94
+ +
95
+ +#[doc(attribute = "rustc_dump_hidden_type_of_opaques")]
96
+ +/// Dumps the hidden types of the opaque items in this crate.
97
+ +///
98
+ +/// This ends up calling the [`type_of`] query, which, for opaque types, reveals their hidden types.
99
+ +///
100
+ +/// See [`AttributeKind::RustcDumpHiddenTypeOfOpaques`] for the internal representation of this attribute.
101
+ +///
102
+ +/// # Example
103
+ +///
104
+ +#[doc = include_example!("rustc_dump_hidden_type_of_opaques")]
105
+ +///
106
+ +/// [`type_of`]: ../rustc_middle/ty/struct.TyCtxt.html#method.type_of
107
+ +const _: () = ();
108
+ +
109
+ +#[doc(attribute = "rustc_dump_inferred_outlives")]
110
+ +/// Dumps the inferred outlives-clauses of the annotated item.
111
+ +///
112
+ +/// See also the [`inferred_outlives_of`] query.
113
+ +///
114
+ +/// See [`AttributeKind::RustcDumpInferredOutlives`] for the internal representation of this attribute.
115
+ +///
116
+ +/// # Example
117
+ +///
118
+ +#[doc = include_example!("rustc_dump_inferred_outlives")]
119
+ +///
120
+ +/// [`inferred_outlives_of`]: ../rustc_middle/ty/struct.TyCtxt.html#method.inferred_outlives_of
121
+ +const _: () = ();
122
+ +
123
+ +#[doc(attribute = "rustc_dump_item_bounds")]
124
+ +/// Dumps the item bounds of the annotated item.
125
+ +///
126
+ +/// This ends up calling the [`item_bounds`] query and prints the [`ty::Clause`] of the item.
127
+ +///
128
+ +/// See [`AttributeKind::RustcDumpItemBounds`] for the internal representation of this attribute.
129
+ +///
130
+ +/// # Example
131
+ +///
132
+ +#[doc = include_example!("rustc_dump_item_bounds")]
133
+ +///
134
+ +/// [`item_bounds`]: ../rustc_middle/ty/struct.TyCtxt.html#method.item_bounds
135
+ +/// [`ty::Clause`]: ../rustc_middle/ty/struct.Clause.html
136
+ +const _: () = ();
137
+ +
138
+ +#[doc(attribute = "rustc_dump_layout")]
139
+ +/// Dumps the layout of the annotated item.
140
+ +///
141
+ +/// This ends up calling the [`layout_of`] query to get the [`Layout`] of the annotated item. If used
142
+ +/// with the `debug` modifier, it will print the entirety of `Layout`. Other modifiers will print
143
+ +/// only parts of it.
144
+ +///
145
+ +/// See [`AttributeKind::RustcDumpLayout`] for the internal representation of this attribute.
146
+ +///
147
+ +/// # Example: `debug`
148
+ +///
149
+ +#[doc = include_example!("rustc_dump_layout_debug")]
150
+ +///
151
+ +/// # Example: `largest_niche`
152
+ +///
153
+ +#[doc = include_example!("rustc_dump_layout_largest_niche")]
154
+ +///
155
+ +/// # Example: `size`
156
+ +///
157
+ +#[doc = include_example!("rustc_dump_layout_size")]
158
+ +///
159
+ +/// # Example: `align`
160
+ +///
161
+ +#[doc = include_example!("rustc_dump_layout_align")]
162
+ +///
163
+ +/// # Example: `backend_repr`
164
+ +///
165
+ +#[doc = include_example!("rustc_dump_layout_backend_repr")]
166
+ +///
167
+ +/// # Example: `homogeneous_aggregate`
168
+ +///
169
+ +#[doc = include_example!("rustc_dump_layout_homogeneous_aggregate")]
170
+ +///
171
+ +/// [`layout_of`]: ../rustc_middle/ty/struct.TyCtxt.html#method.layout_of
172
+ +/// [`Layout`]: rustc_abi::Layout
173
+ +const _: () = ();
174
+ +
175
+ +#[doc(attribute = "rustc_dump_object_lifetime_defaults")]
176
+ +/// Dumps the trait object lifetime defaults induced by the type parameters of the annotated item.
177
+ +///
178
+ +/// It will dump this information separately for each type parameter of the annotated item.
179
+ +///
180
+ +/// See also the [`object_lifetime_default`] query.
181
+ +///
182
+ +/// See [`AttributeKind::RustcDumpObjectLifetimeDefaults`] for the internal representation of this attribute.
183
+ +///
184
+ +/// # Example
185
+ +///
186
+ +#[doc = include_example!("rustc_dump_object_lifetime_defaults")]
187
+ +///
188
+ +/// [`object_lifetime_default`]: ../rustc_middle/ty/struct.TyCtxt.html#method.object_lifetime_default
189
+ +const _: () = ();
190
+ +
191
+ +#[doc(attribute = "rustc_dump_symbol_name")]
192
+ +/// Dumps the symbol name of the annotated item, also demangling it if necessary.
193
+ +///
194
+ +/// See also the [`symbol_name`] query.
195
+ +///
196
+ +/// See [`AttributeKind::RustcDumpSymbolName`] for the internal representation of this attribute.
197
+ +///
198
+ +/// # Example
199
+ +///
200
+ +#[doc = include_example!("rustc_dump_symbol_name")]
201
+ +///
202
+ +/// [`symbol_name`]: ../rustc_middle/ty/struct.TyCtxt.html#method.symbol_name
203
+ +const _: () = ();
204
+ +
205
+ +#[doc(attribute = "rustc_dump_variances")]
206
+ +/// Dumps the variances of the annotated item.
207
+ +///
208
+ +/// See also the [`variances_of`] query and [`ty::Variance`].
209
+ +///
210
+ +/// See [`AttributeKind::RustcDumpVariances`] for the internal representation of this attribute.
211
+ +///
212
+ +/// # Example
213
+ +///
214
+ +#[doc = include_example!("rustc_dump_variances")]
215
+ +///
216
+ +/// [`variances_of`]: ../rustc_middle/ty/struct.TyCtxt.html#method.variances_of
217
+ +/// [`ty::Variance`]: ../rustc_middle/ty/enum.Variance.html
218
+ +const _: () = ();
219
+ +
220
+ +#[doc(attribute = "rustc_dump_variances_of_opaques")]
221
+ +/// Dumps the variances of opaque types in this crate.
222
+ +///
223
+ +/// See also the [`variances_of`] query.
224
+ +///
225
+ +/// See [`AttributeKind::RustcDumpVariancesOfOpaques`] for the internal representation of this attribute.
226
+ +///
227
+ +/// # Example
228
+ +///
229
+ +#[doc = include_example!("rustc_dump_variances_of_opaques")]
230
+ +///
231
+ +/// [`variances_of`]: ../rustc_middle/ty/struct.TyCtxt.html#method.variances_of
232
+ +const _: () = ();
233
+ +
234
+ +#[doc(attribute = "rustc_dump_vtable")]
235
+ +/// Dumps the virtual method table ("vtable") of the annotated item.
236
+ +///
237
+ +/// See also the [`vtable_entries`] query.
238
+ +///
239
+ +/// See [`AttributeKind::RustcDumpVtable`] for the internal representation of this attribute.
240
+ +///
241
+ +/// # Example
242
+ +///
243
+ +#[doc = include_example!("rustc_dump_vtable")]
244
+ +///
245
+ +/// [`vtable_entries`]: ../rustc_middle/ty/struct.TyCtxt.html#method.vtable_entries
246
+ +const _: () = ();
247
+ diff --git a/compiler/rustc_attr_ir/src/data_structures.rs b/compiler/rustc_attr_ir/src/data_structures.rs
248
+ index 164efb04e1fe3018dc5513814786d8c73fe0ee65..beb4ba8fabef7c2d6a64c2f55cda84493cff3d36 100644
249
+ --- a/compiler/rustc_attr_ir/src/data_structures.rs
250
+ +++ b/compiler/rustc_attr_ir/src/data_structures.rs
251
+ @@ -1219,46 +1219,46 @@ pub enum AttributeKind {
252
+ /// Represents `#[rustc_dummy]`.
253
+ RustcDummy,
254
+
255
+ - /// Represents `#[rustc_dump_clauses]`
256
+ + /// Represents the [`rustc_dump_clauses`](./attribute.rustc_dump_clauses.html) attribute.
257
+ RustcDumpClauses,
258
+
259
+ - /// Represents `#[rustc_dump_def_parents]`
260
+ + /// Represents the [`rustc_dump_def_parents`](./attribute.rustc_dump_def_parents.html) attribute.
261
+ RustcDumpDefParents,
262
+
263
+ - /// Represents `#[rustc_dump_def_path]`
264
+ + /// Represents the [`rustc_dump_def_path`](./attribute.rustc_dump_def_path.html) attribute.
265
+ RustcDumpDefPath(Span),
266
+
267
+ - /// Represents `#[rustc_dump_generics]`
268
+ + /// Represents the [`rustc_dump_generics`](./attribute.rustc_dump_generics.html) attribute.
269
+ RustcDumpGenerics,
270
+
271
+ - /// Represents `#[rustc_dump_hidden_type_of_opaques]`
272
+ + /// Represents the [`rustc_dump_hidden_type_of_opaques`](./attribute.rustc_dump_hidden_type_of_opaques.html) attribute.
273
+ RustcDumpHiddenTypeOfOpaques,
274
+
275
+ - /// Represents `#[rustc_dump_inferred_outlives]`
276
+ + /// Represents the [`rustc_dump_inferred_outlives`](./attribute.rustc_dump_inferred_outlives.html) attribute.
277
+ RustcDumpInferredOutlives,
278
+
279
+ - /// Represents `#[rustc_dump_item_bounds]`
280
+ + /// Represents the [`rustc_dump_item_bounds`](./attribute.rustc_dump_item_bounds.html) attribute.
281
+ RustcDumpItemBounds,
282
+
283
+ - /// Represents `#[rustc_dump_layout]`
284
+ + /// Represents the [`rustc_dump_layout`](./attribute.rustc_dump_layout.html) attribute.
285
+ RustcDumpLayout(ThinVec<RustcDumpLayoutKind>),
286
+
287
+ - /// Represents `#[rustc_dump_object_lifetime_defaults]`.
288
+ + /// Represents the [`rustc_dump_object_lifetime_defaults`](./attribute.rustc_dump_object_lifetime_defaults.html) attribute.
289
+ RustcDumpObjectLifetimeDefaults,
290
+
291
+ - /// Represents `#[rustc_dump_symbol_name]`
292
+ + /// Represents the [`rustc_dump_symbol_name`](./attribute.rustc_dump_symbol_name.html) attribute.
293
+ RustcDumpSymbolName(Span),
294
+
295
+ /// Represents `#[rustc_dump_user_args]`
296
+ RustcDumpUserArgs,
297
+
298
+ - /// Represents `#[rustc_dump_variances]`
299
+ + /// Represents the [`rustc_dump_variances`](./attribute.rustc_dump_variances.html) attribute.
300
+ RustcDumpVariances,
301
+
302
+ - /// Represents `#[rustc_dump_variances_of_opaques]`
303
+ + /// Represents the [`rustc_dump_variances_of_opaques`](./attribute.rustc_dump_variances_of_opaques.html) attribute.
304
+ RustcDumpVariancesOfOpaques,
305
+
306
+ - /// Represents `#[rustc_dump_vtable]`
307
+ + /// Represents the [`rustc_dump_vtable`](./attribute.rustc_dump_vtable.html) attribute.
308
+ RustcDumpVtable(Span),
309
+
310
+ /// Represents `#[rustc_dyn_incompatible_trait]`.
311
+ diff --git a/compiler/rustc_attr_ir/src/lib.rs b/compiler/rustc_attr_ir/src/lib.rs
312
+ index 0b142ca92df6bddce9716f329a67347db316d194..f835e257762a9dbd1bc70c1cf3f06a9bc43ce31f 100644
313
+ --- a/compiler/rustc_attr_ir/src/lib.rs
314
+ +++ b/compiler/rustc_attr_ir/src/lib.rs
315
+ @@ -4,11 +4,13 @@
316
+ //! see [rustc_attr_parsing](../rustc_attr_parsing/index.html).
317
+
318
+ // tidy-alphabetical-start
319
+ +#![expect(internal_features, reason = "rustdoc_internals, for documenting attributes")]
320
+ #![feature(const_default)]
321
+ #![feature(const_trait_impl)]
322
+ #![feature(default_field_values)]
323
+ #![feature(derive_const)]
324
+ #![feature(exhaustive_patterns)]
325
+ +#![feature(rustdoc_internals)]
326
+ #![feature(variant_count)]
327
+ #![recursion_limit = "256"]
328
+ // tidy-alphabetical-end
329
+ @@ -143,3 +145,5 @@ macro_rules! find_attr {
330
+ }
331
+ }};
332
+ }
333
+ +
334
+ +include!("attribute_docs.rs");
335
+ diff --git a/compiler/rustc_borrowck/src/region_infer/mod.rs b/compiler/rustc_borrowck/src/region_infer/mod.rs
336
+ index d86ba5d462de17a903f1004438f92ce039a8cd76..19aa4081bfc88f9e74e43e8eda402be55f82eb04 100644
337
+ --- a/compiler/rustc_borrowck/src/region_infer/mod.rs
338
+ +++ b/compiler/rustc_borrowck/src/region_infer/mod.rs
339
+ @@ -347,7 +347,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
340
+ outlives_constraints,
341
+ scc_annotations,
342
+ type_tests,
343
+ - mut liveness_constraints,
344
+ + liveness_constraints,
345
+ universe_causes,
346
+ placeholder_indices,
347
+ } = lowered_constraints;
348
+ @@ -376,9 +376,6 @@ impl<'tcx> RegionInferenceContext<'tcx> {
349
+ match definition.origin {
350
+ // For each free, universally quantified region X:
351
+ NllRegionVariableOrigin::FreeRegion => {
352
+ - // Add all nodes in the CFG to liveness constraints
353
+ - liveness_constraints.add_all_points(region);
354
+ -
355
+ // Add `end(X)` into the set for X.
356
+ scc_values.add_free_region(scc, region);
357
+ }
358
+ @@ -396,8 +393,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
359
+ // has them, setting `scc_values[scc(region)] |= liveness_constraints[region]`.
360
+ //
361
+ // These values will later be propagated during [`Self::propagate_constraints()`].
362
+ - // The values include any live-at-all-points constraints added above
363
+ - // for free regions.
364
+ + // The values include any live-at-all-points constraints added previously in `liveness::generate`.
365
+ if let Some(liveness) = liveness_constraints.point_liveness(region) {
366
+ scc_values.merge_liveness(scc, liveness)
367
+ }
368
+ diff --git a/compiler/rustc_borrowck/src/type_check/liveness/mod.rs b/compiler/rustc_borrowck/src/type_check/liveness/mod.rs
369
+ index 22d8ababcdfd52e6edd62ed53ebc889b2baee208..fd8502773c51e6bb78deaa349944d7cee88ea69a 100644
370
+ --- a/compiler/rustc_borrowck/src/type_check/liveness/mod.rs
371
+ +++ b/compiler/rustc_borrowck/src/type_check/liveness/mod.rs
372
+ @@ -34,6 +34,11 @@ pub(super) fn generate<'tcx>(
373
+ debug!("liveness::generate");
374
+ let _timer = typeck.tcx().prof.generic_activity("borrowck_liveness");
375
+
376
+ + // Universal regions are live at every point.
377
+ + for region in typeck.universal_regions.universal_regions_iter() {
378
+ + typeck.constraints.liveness_constraints.add_all_points(region);
379
+ + }
380
+ +
381
+ let mut free_regions = regions_that_outlive_free_regions(
382
+ typeck.infcx.num_region_vars(),
383
+ &typeck.universal_regions,
384
+ diff --git a/compiler/rustc_infer/src/infer/mod.rs b/compiler/rustc_infer/src/infer/mod.rs
385
+ index a49a4355b66b16a2c118dd1cdf4ff143ccd2f624..6f5d3bb75ebe46604fe1774c151d9ea166faa352 100644
386
+ --- a/compiler/rustc_infer/src/infer/mod.rs
387
+ +++ b/compiler/rustc_infer/src/infer/mod.rs
388
+ @@ -89,10 +89,11 @@ pub(crate) type UnificationTable<'a, 'tcx, T> = ut::UnificationTable<
389
+ ut::InPlace<T, &'a mut ut::UnificationStorage<T>, &'a mut InferCtxtUndoLogs<'tcx>>,
390
+ >;
391
+
392
+ -/// This type contains all the things within `InferCtxt` that sit within a
393
+ -/// `RefCell` and are involved with taking/rolling back snapshots. Snapshot
394
+ -/// operations are hot enough that we want only one call to `borrow_mut` per
395
+ -/// call to `start_snapshot` and `rollback_to`.
396
+ +/// This type contains all the things within [`InferCtxt`] that sit within a
397
+ +/// [`RefCell`] and are involved with taking/rolling back snapshots. Snapshot
398
+ +/// operations are hot enough that we want only one call to
399
+ +/// [`RefCell::borrow_mut`] per call to [`InferCtxt::start_snapshot`] and
400
+ +/// [`InferCtxt::rollback_to`].
401
+ #[derive(Clone)]
402
+ pub struct InferCtxtInner<'tcx> {
403
+ undo_log: InferCtxtUndoLogs<'tcx>,
404
+ @@ -102,7 +103,10 @@ pub struct InferCtxtInner<'tcx> {
405
+ /// This cache is snapshotted along with the infcx.
406
+ projection_cache: traits::ProjectionCacheStorage<'tcx>,
407
+
408
+ - /// We instantiate `UnificationTable` with `bounds<Ty>` because the types
409
+ + /// Primary map of inference variables to the types that they currently
410
+ + /// represent.
411
+ + ///
412
+ + /// We instantiate [`UnificationTable`] with `bounds<Ty>` because the types
413
+ /// that might instantiate a general type variable have an order,
414
+ /// represented by its upper and lower bounds.
415
+ type_variable_storage: type_variable::TypeVariableStorage<'tcx>,
416
+ diff --git a/library/std/src/sys/thread/unix.rs b/library/std/src/sys/thread/unix.rs
417
+ index 1d87e2095f134bbc7fc141658ddcb195099d7344..b7908dea2b5deda94bca109deb29d0c2d1f1ff2a 100644
418
+ --- a/library/std/src/sys/thread/unix.rs
419
+ +++ b/library/std/src/sys/thread/unix.rs
420
+ @@ -67,7 +67,7 @@ impl Thread {
421
+ assert_eq!(
422
+ libc::pthread_attr_setstacksize(
423
+ attr.get(),
424
+ - cmp::max(stack, min_stack_size(attr.as_ptr()))
425
+ + cmp::max(stack, min_stack_size(attr.get()))
426
+ ),
427
+ 0
428
+ );
429
+ diff --git a/src/bootstrap/src/bin/rustdoc.rs b/src/bootstrap/src/bin/rustdoc.rs
430
+ index da80d7cd8c5994418136aecd86b1f8b674b47741..d18ca77fc7e1468c82332831ecfafd81294138da 100644
431
+ --- a/src/bootstrap/src/bin/rustdoc.rs
432
+ +++ b/src/bootstrap/src/bin/rustdoc.rs
433
+ @@ -72,11 +72,9 @@ fn main() {
434
+ .arg("-Zcrate-attr=doc(rust_logo)")
435
+ .arg("-Zcrate-attr=doc(html_root_url = \"https://doc.rust-lang.org/nightly/nightly-rustc/\")");
436
+
437
+ - // rustc_proc_macro is another build of library/proc_macro which already enables this
438
+ - // feature
439
+ - if crate_name != "rustc_proc_macro" {
440
+ - cmd.arg("-Zcrate-attr=feature(rustdoc_internals)");
441
+ - }
442
+ + // Some crates already have this feature enabled
443
+ + cmd.arg("-Zcrate-attr=feature(rustdoc_internals)");
444
+ + cmd.arg("-Aduplicate-features");
445
+ }
446
+ }
447
+
448
+ diff --git a/src/etc/lldb_batchmode/common.py b/src/etc/lldb_batchmode/common.py
449
+ index 56933b4de87b3b98cf64899951a2bfd3c9bcf34c..b85ef47ba3cedb9c66d61049247402a58f7dc95e 100644
450
+ --- a/src/etc/lldb_batchmode/common.py
451
+ +++ b/src/etc/lldb_batchmode/common.py
452
+ @@ -572,6 +572,12 @@ generated for this test yet, consider using the `--bless` option."
453
+ f.write(x)
454
+ f.write("\n")
455
+
456
+ + def print_json(self, metadata: BlessMetadata):
457
+ + """Prints `self` to `stdout` in json format with no formatting. This output is identicall to
458
+ + what would be saved via `TargetData.save_blessing`"""
459
+ + self.bless_metadata = metadata
460
+ + print(json.dumps(clean_nones(asdict(self))))
461
+ +
462
+
463
+ def clean_nones(value):
464
+ """
465
+ diff --git a/src/etc/lldb_batchmode/runner.py b/src/etc/lldb_batchmode/runner.py
466
+ index a396f7c1f504b49b8dc927459978d3f0e54a2793..2db1f6793d4f3ee1cf3edeaec02a479fc9987a55 100644
467
+ --- a/src/etc/lldb_batchmode/runner.py
468
+ +++ b/src/etc/lldb_batchmode/runner.py
469
+ @@ -301,14 +301,35 @@ def main():
470
+ # this point are either from the `bless` not working properly, or some other issue with
471
+ # the test itself. In either case, we probably don't want to update the test data until
472
+ # those are resolved.
473
+ - # Only runs if the test contains a repr command, as we don't want to create an input
474
+ - # file for a test that won't ever use it.
475
+ +
476
+ + # If we're running CI though, the runner may be on a target that the PR author doesn't
477
+ + # have access to. In such cases, we want to dump the json output so they can "manually
478
+ + # bless" when necessary.
479
+ + if (
480
+ + not all_ok
481
+ + and (is_ci := os.environ.get("CI")) is not None
482
+ + and is_ci == "true"
483
+ + ):
484
+ + from lldb_providers import FEATURE_FLAGS
485
+ +
486
+ + path = os.path.relpath(os.environ["LLDB_BATCHMODE_INPUT_DATA_PATH"])
487
+ +
488
+ + print(f"[repr] If you do not have access to this target, you can manually update \
489
+ +the test data by overwriting the data in {path} with the following:")
490
+ +
491
+ + INPUT_DATA.print_json(
492
+ + BlessMetadata(
493
+ + sys.version, debugger.GetVersionString(), str(FEATURE_FLAGS)
494
+ + )
495
+ + )
496
+
497
+ if not tested_all_types() or not tested_all_variables():
498
+ debugger.HandleCommand("quit 1")
499
+ elif BLESS:
500
+ from lldb_providers import FEATURE_FLAGS
501
+
502
+ + # Only runs if the test contains a repr command, as we don't want to create an input
503
+ + # file for a test that won't ever use it.
504
+ INPUT_DATA.save_blessing(
505
+ BlessMetadata(
506
+ sys.version, debugger.GetVersionString(), str(FEATURE_FLAGS)
507
+ diff --git a/tests/ui/attributes/doc_examples/README.md b/tests/ui/attributes/doc_examples/README.md
508
+ new file mode 100644
509
+ index 0000000000000000000000000000000000000000..38a76752d91a7379ae81b7101bc9c868e7126129
510
+ --- /dev/null
511
+ +++ b/tests/ui/attributes/doc_examples/README.md
512
+ @@ -0,0 +1 @@
513
+ +These UI tests and their stderr are `include_str`'d into compiler/rustc_attr_ir/src/attribute_docs.rs.
514
+ diff --git a/tests/ui/attributes/doc_examples/rustc_dump_clauses.rs b/tests/ui/attributes/doc_examples/rustc_dump_clauses.rs
515
+ new file mode 100644
516
+ index 0000000000000000000000000000000000000000..fb4a2ceb8bbd709de92b30949434e9f5d011b0c3
517
+ --- /dev/null
518
+ +++ b/tests/ui/attributes/doc_examples/rustc_dump_clauses.rs
519
+ @@ -0,0 +1,25 @@
520
+ +//@ dont-require-annotations: ERROR
521
+ +//@ compile-flags: --crate-type lib -Z ui-testing=no
522
+ +//@ normalize-stderr: "DefId\((\d+):(\d+)" -> "DefId(..:.."
523
+ +//@ normalize-stderr: "\[[A-Fa-f0-9]{4}\]" -> "[....]"
524
+ +
525
+ +#![feature(negative_impls)]
526
+ +#![feature(rustc_attrs)]
527
+ +
528
+ +#[rustc_dump_clauses]
529
+ +fn function<T: Send>(_t: T) {}
530
+ +
531
+ +#[rustc_dump_clauses]
532
+ +trait Trait: Sync {
533
+ + #[rustc_dump_clauses]
534
+ + type Assoc;
535
+ +}
536
+ +
537
+ +#[rustc_dump_clauses]
538
+ +struct X<'a, T: ?Sized, I: Iterator> {
539
+ + x: &'a T,
540
+ + y: &'a I::Item,
541
+ +}
542
+ +
543
+ +#[rustc_dump_clauses]
544
+ +impl<T: ?Sized, I> !Sync for X<'_, T, I> {}
545
+ diff --git a/tests/ui/attributes/doc_examples/rustc_dump_clauses.stderr b/tests/ui/attributes/doc_examples/rustc_dump_clauses.stderr
546
+ new file mode 100644
547
+ index 0000000000000000000000000000000000000000..d381e6ebd745f02cf52f6ff6826b928722344d38
548
+ --- /dev/null
549
+ +++ b/tests/ui/attributes/doc_examples/rustc_dump_clauses.stderr
550
+ @@ -0,0 +1,52 @@
551
+ +error: rustc_dump_clauses
552
+ + --> $DIR/rustc_dump_clauses.rs:10:1
553
+ + |
554
+ +10 | fn function<T: Send>(_t: T) {}
555
+ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
556
+ + |
557
+ + = note: Binder { value: TraitClause(<T as std::marker::Sized>, polarity:Positive), bound_vars: [] }
558
+ + = note: Binder { value: TraitClause(<T as std::marker::Send>, polarity:Positive), bound_vars: [] }
559
+ +
560
+ +error: rustc_dump_clauses
561
+ + --> $DIR/rustc_dump_clauses.rs:13:1
562
+ + |
563
+ +13 | trait Trait: Sync {
564
+ + | ^^^^^^^^^^^^^^^^^
565
+ + |
566
+ + = note: Binder { value: TraitClause(<Self as std::marker::MetaSized>, polarity:Positive), bound_vars: [] }
567
+ + = note: Binder { value: TraitClause(<Self as std::marker::Sync>, polarity:Positive), bound_vars: [] }
568
+ + = note: Binder { value: TraitClause(<Self as Trait>, polarity:Positive), bound_vars: [] }
569
+ +
570
+ +error: rustc_dump_clauses
571
+ + --> $DIR/rustc_dump_clauses.rs:19:1
572
+ + |
573
+ +19 | struct X<'a, T: ?Sized, I: Iterator> {
574
+ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
575
+ + |
576
+ + = note: Binder { value: TraitClause(<T as std::marker::MetaSized>, polarity:Positive), bound_vars: [] }
577
+ + = note: Binder { value: TraitClause(<I as std::marker::Sized>, polarity:Positive), bound_vars: [] }
578
+ + = note: Binder { value: TraitClause(<I as std::iter::Iterator>, polarity:Positive), bound_vars: [] }
579
+ + = note: Binder { value: OutlivesClause(T/#1, 'a/#0), bound_vars: [] }
580
+ + = note: Binder { value: OutlivesClause(Alias(No, Alias { kind: Projection { def_id: DefId(..:.. ~ core[....]::iter::traits::iterator::Iterator::Item) }, args: [I/#2], .. }), 'a/#0), bound_vars: [] }
581
+ +
582
+ +error: rustc_dump_clauses
583
+ + --> $DIR/rustc_dump_clauses.rs:25:1
584
+ + |
585
+ +25 | impl<T: ?Sized, I> !Sync for X<'_, T, I> {}
586
+ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
587
+ + |
588
+ + = note: Binder { value: TraitClause(<T as std::marker::MetaSized>, polarity:Positive), bound_vars: [] }
589
+ + = note: Binder { value: TraitClause(<I as std::marker::Sized>, polarity:Positive), bound_vars: [] }
590
+ +
591
+ +error: rustc_dump_clauses
592
+ + --> $DIR/rustc_dump_clauses.rs:15:5
593
+ + |
594
+ +15 | type Assoc;
595
+ + | ^^^^^^^^^^
596
+ + |
597
+ + = note: Binder { value: TraitClause(<Self as std::marker::MetaSized>, polarity:Positive), bound_vars: [] }
598
+ + = note: Binder { value: TraitClause(<Self as std::marker::Sync>, polarity:Positive), bound_vars: [] }
599
+ + = note: Binder { value: TraitClause(<Self as Trait>, polarity:Positive), bound_vars: [] }
600
+ +
601
+ +error: aborting due to 5 previous errors
602
+ +
603
+ diff --git a/tests/ui/attributes/doc_examples/rustc_dump_clauses_super_trait.rs b/tests/ui/attributes/doc_examples/rustc_dump_clauses_super_trait.rs
604
+ new file mode 100644
605
+ index 0000000000000000000000000000000000000000..d9f4b94f8d5de8662984235ca1c81298dc6231d8
606
+ --- /dev/null
607
+ +++ b/tests/ui/attributes/doc_examples/rustc_dump_clauses_super_trait.rs
608
+ @@ -0,0 +1,9 @@
609
+ +//@ dont-require-annotations: ERROR
610
+ +//@ compile-flags: --crate-type lib -Z ui-testing=no
611
+ +
612
+ +#![feature(rustc_attrs)]
613
+ +
614
+ +#[rustc_dump_clauses]
615
+ +fn foo<T: Copy>(t: &T) -> T {
616
+ + *t
617
+ +}
618
+ diff --git a/tests/ui/attributes/doc_examples/rustc_dump_clauses_super_trait.stderr b/tests/ui/attributes/doc_examples/rustc_dump_clauses_super_trait.stderr
619
+ new file mode 100644
620
+ index 0000000000000000000000000000000000000000..d110ea484a6f8e0b9b0304a6cb3e2cd72e6ec120
621
+ --- /dev/null
622
+ +++ b/tests/ui/attributes/doc_examples/rustc_dump_clauses_super_trait.stderr
623
+ @@ -0,0 +1,11 @@
624
+ +error: rustc_dump_clauses
625
+ + --> $DIR/rustc_dump_clauses_super_trait.rs:7:1
626
+ + |
627
+ +7 | fn foo<T: Copy>(t: &T) -> T {
628
+ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
629
+ + |
630
+ + = note: Binder { value: TraitClause(<T as std::marker::Sized>, polarity:Positive), bound_vars: [] }
631
+ + = note: Binder { value: TraitClause(<T as std::marker::Copy>, polarity:Positive), bound_vars: [] }
632
+ +
633
+ +error: aborting due to 1 previous error
634
+ +
635
+ diff --git a/tests/ui/attributes/doc_examples/rustc_dump_def_parents.rs b/tests/ui/attributes/doc_examples/rustc_dump_def_parents.rs
636
+ new file mode 100644
637
+ index 0000000000000000000000000000000000000000..92bd53c473da9cee913fd1a3e531cfe7ebf1c24f
638
+ --- /dev/null
639
+ +++ b/tests/ui/attributes/doc_examples/rustc_dump_def_parents.rs
640
+ @@ -0,0 +1,20 @@
641
+ +//@ dont-require-annotations: ERROR
642
+ +//@ compile-flags: --crate-type lib -Z ui-testing=no
643
+ +
644
+ +#![feature(rustc_attrs)]
645
+ +
646
+ +fn parent() {
647
+ + #[rustc_dump_def_parents]
648
+ + fn child() {}
649
+ +}
650
+ +
651
+ +struct Struct<const N: usize>;
652
+ +
653
+ +const CONST: Struct<42> = Struct::<
654
+ + {
655
+ + #[rustc_dump_def_parents]
656
+ + fn baby() {}
657
+ +
658
+ + 42
659
+ + },
660
+ +>;
661
+ diff --git a/tests/ui/attributes/doc_examples/rustc_dump_def_parents.stderr b/tests/ui/attributes/doc_examples/rustc_dump_def_parents.stderr
662
+ new file mode 100644
663
+ index 0000000000000000000000000000000000000000..ffeb7119986317440aff129b8cefb8c51c322fed
664
+ --- /dev/null
665
+ +++ b/tests/ui/attributes/doc_examples/rustc_dump_def_parents.stderr
666
+ @@ -0,0 +1,57 @@
667
+ +error: rustc_dump_def_parents: DefId(0:4 ~ rustc_dump_def_parents[9c2e]::parent::child)
668
+ + --> $DIR/rustc_dump_def_parents.rs:8:5
669
+ + |
670
+ + 8 | fn child() {}
671
+ + | ^^^^^^^^^^
672
+ + |
673
+ +note: DefId(0:3 ~ rustc_dump_def_parents[9c2e]::parent)
674
+ + --> $DIR/rustc_dump_def_parents.rs:6:1
675
+ + |
676
+ + 6 | fn parent() {
677
+ + | ^^^^^^^^^^^
678
+ +note: DefId(0:0 ~ rustc_dump_def_parents[9c2e])
679
+ + --> $DIR/rustc_dump_def_parents.rs:4:1
680
+ + |
681
+ + 4 | / #![feature(rustc_attrs)]
682
+ + 5 | |
683
+ + 6 | | fn parent() {
684
+ + 7 | | #[rustc_dump_def_parents]
685
+ +... |
686
+ +19 | | },
687
+ +20 | | >;
688
+ + | |__^
689
+ +
690
+ +error: rustc_dump_def_parents: DefId(0:11 ~ rustc_dump_def_parents[9c2e]::CONST::{constant#1}::baby)
691
+ + --> $DIR/rustc_dump_def_parents.rs:16:9
692
+ + |
693
+ +16 | fn baby() {}
694
+ + | ^^^^^^^^^
695
+ + |
696
+ +note: DefId(0:10 ~ rustc_dump_def_parents[9c2e]::CONST::{constant#1})
697
+ + --> $DIR/rustc_dump_def_parents.rs:14:5
698
+ + |
699
+ +14 | / {
700
+ +15 | | #[rustc_dump_def_parents]
701
+ +16 | | fn baby() {}
702
+ +... |
703
+ +19 | | },
704
+ + | |_____^
705
+ +note: DefId(0:8 ~ rustc_dump_def_parents[9c2e]::CONST)
706
+ + --> $DIR/rustc_dump_def_parents.rs:13:1
707
+ + |
708
+ +13 | const CONST: Struct<42> = Struct::<
709
+ + | ^^^^^^^^^^^^^^^^^^^^^^^
710
+ +note: DefId(0:0 ~ rustc_dump_def_parents[9c2e])
711
+ + --> $DIR/rustc_dump_def_parents.rs:4:1
712
+ + |
713
+ + 4 | / #![feature(rustc_attrs)]
714
+ + 5 | |
715
+ + 6 | | fn parent() {
716
+ + 7 | | #[rustc_dump_def_parents]
717
+ +... |
718
+ +19 | | },
719
+ +20 | | >;
720
+ + | |__^
721
+ +
722
+ +error: aborting due to 2 previous errors
723
+ +
724
+ diff --git a/tests/ui/attributes/doc_examples/rustc_dump_def_path.rs b/tests/ui/attributes/doc_examples/rustc_dump_def_path.rs
725
+ new file mode 100644
726
+ index 0000000000000000000000000000000000000000..00181bce7d445b65b0c233f9f5a47beadbc9290b
727
+ --- /dev/null
728
+ +++ b/tests/ui/attributes/doc_examples/rustc_dump_def_path.rs
729
+ @@ -0,0 +1,24 @@
730
+ +//@ dont-require-annotations: ERROR
731
+ +//@ compile-flags: --crate-type lib -Z ui-testing=no
732
+ +//@ build-fail
733
+ +
734
+ +#![feature(rustc_attrs)]
735
+ +
736
+ +#[rustc_dump_def_path]
737
+ +fn main() {
738
+ + || {
739
+ + unsafe extern "C" {
740
+ + #[rustc_dump_def_path]
741
+ + static Foo: u8;
742
+ + }
743
+ + };
744
+ +}
745
+ +
746
+ +mod a {
747
+ + mod b {
748
+ + mod c {
749
+ + #[rustc_dump_def_path]
750
+ + fn d() {}
751
+ + }
752
+ + }
753
+ +}
754
+ diff --git a/tests/ui/attributes/doc_examples/rustc_dump_def_path.stderr b/tests/ui/attributes/doc_examples/rustc_dump_def_path.stderr
755
+ new file mode 100644
756
+ index 0000000000000000000000000000000000000000..f7cd75eecd927125fb235657e5d994e911feb642
757
+ --- /dev/null
758
+ +++ b/tests/ui/attributes/doc_examples/rustc_dump_def_path.stderr
759
+ @@ -0,0 +1,20 @@
760
+ +error: def-path(main)
761
+ + --> $DIR/rustc_dump_def_path.rs:7:1
762
+ + |
763
+ +7 | #[rustc_dump_def_path]
764
+ + | ^^^^^^^^^^^^^^^^^^^^^^
765
+ +
766
+ +error: def-path(a::b::c::d)
767
+ + --> $DIR/rustc_dump_def_path.rs:20:13
768
+ + |
769
+ +20 | #[rustc_dump_def_path]
770
+ + | ^^^^^^^^^^^^^^^^^^^^^^
771
+ +
772
+ +error: def-path(main::{closure#0}::Foo)
773
+ + --> $DIR/rustc_dump_def_path.rs:11:13
774
+ + |
775
+ +11 | #[rustc_dump_def_path]
776
+ + | ^^^^^^^^^^^^^^^^^^^^^^
777
+ +
778
+ +error: aborting due to 3 previous errors
779
+ +
780
+ diff --git a/tests/ui/attributes/doc_examples/rustc_dump_generics.rs b/tests/ui/attributes/doc_examples/rustc_dump_generics.rs
781
+ new file mode 100644
782
+ index 0000000000000000000000000000000000000000..9b95354309d00887051b5deec075e78b52f8675c
783
+ --- /dev/null
784
+ +++ b/tests/ui/attributes/doc_examples/rustc_dump_generics.rs
785
+ @@ -0,0 +1,11 @@
786
+ +//@ dont-require-annotations: ERROR
787
+ +//@ compile-flags: --crate-type lib -Z ui-testing=no
788
+ +//@ normalize-stderr: "DefId\((\d+):(\d+)" -> "DefId(..:.."
789
+ +//@ normalize-stderr: "\[[A-Fa-f0-9]{4}\]" -> "[....]"
790
+ +
791
+ +#![feature(rustc_attrs)]
792
+ +
793
+ +#[rustc_dump_generics]
794
+ +struct Struct<'lifetime, const CONST: usize, GENERIC> {
795
+ + stuff: &'lifetime [GENERIC; CONST],
796
+ +}
797
+ diff --git a/tests/ui/attributes/doc_examples/rustc_dump_generics.stderr b/tests/ui/attributes/doc_examples/rustc_dump_generics.stderr
798
+ new file mode 100644
799
+ index 0000000000000000000000000000000000000000..b6b2eacb2c1379f3f0a5333c1e165445af090abe
800
+ --- /dev/null
801
+ +++ b/tests/ui/attributes/doc_examples/rustc_dump_generics.stderr
802
+ @@ -0,0 +1,61 @@
803
+ +error: rustc_dump_generics: DefId(..:.. ~ rustc_dump_generics[....]::Struct)
804
+ + --> $DIR/rustc_dump_generics.rs:9:1
805
+ + |
806
+ +9 | struct Struct<'lifetime, const CONST: usize, GENERIC> {
807
+ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
808
+ + |
809
+ +note: Generics {
810
+ + parent: None,
811
+ + parent_count: 0,
812
+ + own_params: [
813
+ + GenericParamDef {
814
+ + name: "'lifetime",
815
+ + def_id: DefId(..:.. ~ rustc_dump_generics[....]::Struct::'lifetime),
816
+ + index: 0,
817
+ + pure_wrt_drop: false,
818
+ + kind: Lifetime,
819
+ + },
820
+ + GenericParamDef {
821
+ + name: "CONST",
822
+ + def_id: DefId(..:.. ~ rustc_dump_generics[....]::Struct::CONST),
823
+ + index: 1,
824
+ + pure_wrt_drop: false,
825
+ + kind: Const {
826
+ + has_default: false,
827
+ + },
828
+ + },
829
+ + GenericParamDef {
830
+ + name: "GENERIC",
831
+ + def_id: DefId(..:.. ~ rustc_dump_generics[....]::Struct::GENERIC),
832
+ + index: 2,
833
+ + pure_wrt_drop: false,
834
+ + kind: Type {
835
+ + has_default: false,
836
+ + synthetic: false,
837
+ + },
838
+ + },
839
+ + ],
840
+ + param_def_id_to_index: [
841
+ + (
842
+ + DefId(..:.. ~ rustc_dump_generics[....]::Struct::'lifetime),
843
+ + 0,
844
+ + ),
845
+ + (
846
+ + DefId(..:.. ~ rustc_dump_generics[....]::Struct::CONST),
847
+ + 1,
848
+ + ),
849
+ + (
850
+ + DefId(..:.. ~ rustc_dump_generics[....]::Struct::GENERIC),
851
+ + 2,
852
+ + ),
853
+ + ],
854
+ + has_self: false,
855
+ + has_late_bound_regions: None,
856
+ + }
857
+ + --> $DIR/rustc_dump_generics.rs:9:1
858
+ + |
859
+ +9 | struct Struct<'lifetime, const CONST: usize, GENERIC> {
860
+ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
861
+ +
862
+ +error: aborting due to 1 previous error
863
+ +
864
+ diff --git a/tests/ui/attributes/doc_examples/rustc_dump_hidden_type_of_opaques.rs b/tests/ui/attributes/doc_examples/rustc_dump_hidden_type_of_opaques.rs
865
+ new file mode 100644
866
+ index 0000000000000000000000000000000000000000..fbd21351f5379e0a571246094eed7aebe878f111
867
+ --- /dev/null
868
+ +++ b/tests/ui/attributes/doc_examples/rustc_dump_hidden_type_of_opaques.rs
869
+ @@ -0,0 +1,13 @@
870
+ +//@ dont-require-annotations: ERROR
871
+ +//@ compile-flags: --crate-type lib -Z ui-testing=no -Z verbose-internals
872
+ +
873
+ +#![feature(rustc_attrs)]
874
+ +#![rustc_dump_hidden_type_of_opaques]
875
+ +
876
+ +trait Foo {
877
+ + fn hello(&self) -> impl Sized;
878
+ +}
879
+ +
880
+ +fn hello<'s, T: Foo>(x: &'s T) -> impl Sized + use<'s, T> {
881
+ + x.hello()
882
+ +}
883
+ diff --git a/tests/ui/attributes/doc_examples/rustc_dump_hidden_type_of_opaques.stderr b/tests/ui/attributes/doc_examples/rustc_dump_hidden_type_of_opaques.stderr
884
+ new file mode 100644
885
+ index 0000000000000000000000000000000000000000..a92efaf30859a407b19ac3660cf0ac7ded1472b2
886
+ --- /dev/null
887
+ +++ b/tests/ui/attributes/doc_examples/rustc_dump_hidden_type_of_opaques.stderr
888
+ @@ -0,0 +1,8 @@
889
+ +error: <T as Foo>::hello::{anon_assoc#0}<'s/#1>
890
+ + --> $DIR/rustc_dump_hidden_type_of_opaques.rs:11:35
891
+ + |
892
+ +11 | fn hello<'s, T: Foo>(x: &'s T) -> impl Sized + use<'s, T> {
893
+ + | ^^^^^^^^^^^^^^^^^^^^^^^
894
+ +
895
+ +error: aborting due to 1 previous error
896
+ +
897
+ diff --git a/tests/ui/attributes/doc_examples/rustc_dump_inferred_outlives.rs b/tests/ui/attributes/doc_examples/rustc_dump_inferred_outlives.rs
898
+ new file mode 100644
899
+ index 0000000000000000000000000000000000000000..7d5e51f65ab38890bf3aab6c867c71371d2f4037
900
+ --- /dev/null
901
+ +++ b/tests/ui/attributes/doc_examples/rustc_dump_inferred_outlives.rs
902
+ @@ -0,0 +1,19 @@
903
+ +//@ dont-require-annotations: ERROR
904
+ +//@ compile-flags: --crate-type lib -Z ui-testing=no
905
+ +
906
+ +#![feature(rustc_attrs)]
907
+ +
908
+ +trait Trait<'x, T>
909
+ +where
910
+ + T: 'x,
911
+ +{
912
+ + type Type;
913
+ +}
914
+ +
915
+ +#[rustc_dump_inferred_outlives]
916
+ +struct Foo<'a, A, B>
917
+ +where
918
+ + A: Trait<'a, B>,
919
+ +{
920
+ + foo: <A as Trait<'a, B>>::Type,
921
+ +}
922
+ diff --git a/tests/ui/attributes/doc_examples/rustc_dump_inferred_outlives.stderr b/tests/ui/attributes/doc_examples/rustc_dump_inferred_outlives.stderr
923
+ new file mode 100644
924
+ index 0000000000000000000000000000000000000000..6c07c38d0384aa787fb9a55e3989cbcea9c23901
925
+ --- /dev/null
926
+ +++ b/tests/ui/attributes/doc_examples/rustc_dump_inferred_outlives.stderr
927
+ @@ -0,0 +1,10 @@
928
+ +error: rustc_dump_inferred_outlives
929
+ + --> $DIR/rustc_dump_inferred_outlives.rs:14:1
930
+ + |
931
+ +14 | struct Foo<'a, A, B>
932
+ + | ^^^^^^^^^^^^^^^^^^^^
933
+ + |
934
+ + = note: B: 'a
935
+ +
936
+ +error: aborting due to 1 previous error
937
+ +
938
+ diff --git a/tests/ui/attributes/doc_examples/rustc_dump_item_bounds.rs b/tests/ui/attributes/doc_examples/rustc_dump_item_bounds.rs
939
+ new file mode 100644
940
+ index 0000000000000000000000000000000000000000..8eb5fd003c3e21d3a35a52af92aa9d509a37372f
941
+ --- /dev/null
942
+ +++ b/tests/ui/attributes/doc_examples/rustc_dump_item_bounds.rs
943
+ @@ -0,0 +1,9 @@
944
+ +//@ dont-require-annotations: ERROR
945
+ +//@ compile-flags: --crate-type lib -Z ui-testing=no
946
+ +
947
+ +#![feature(rustc_attrs)]
948
+ +
949
+ +trait Trait<T> {
950
+ + #[rustc_dump_item_bounds]
951
+ + type Assoc: PartialEq<String>;
952
+ +}
953
+ diff --git a/tests/ui/attributes/doc_examples/rustc_dump_item_bounds.stderr b/tests/ui/attributes/doc_examples/rustc_dump_item_bounds.stderr
954
+ new file mode 100644
955
+ index 0000000000000000000000000000000000000000..be7850111c429e9395fe70f7b5f269c199cadff3
956
+ --- /dev/null
957
+ +++ b/tests/ui/attributes/doc_examples/rustc_dump_item_bounds.stderr
958
+ @@ -0,0 +1,11 @@
959
+ +error: rustc_dump_item_bounds
960
+ + --> $DIR/rustc_dump_item_bounds.rs:8:5
961
+ + |
962
+ +8 | type Assoc: PartialEq<String>;
963
+ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
964
+ + |
965
+ + = note: Binder { value: TraitClause(<<Self as Trait<T>>::Assoc as std::cmp::PartialEq<std::string::String>>, polarity:Positive), bound_vars: [] }
966
+ + = note: Binder { value: TraitClause(<<Self as Trait<T>>::Assoc as std::marker::Sized>, polarity:Positive), bound_vars: [] }
967
+ +
968
+ +error: aborting due to 1 previous error
969
+ +
970
+ diff --git a/tests/ui/attributes/doc_examples/rustc_dump_layout_align.rs b/tests/ui/attributes/doc_examples/rustc_dump_layout_align.rs
971
+ new file mode 100644
972
+ index 0000000000000000000000000000000000000000..103a8924cba4e9244cf0aafa668ded618e7bb25e
973
+ --- /dev/null
974
+ +++ b/tests/ui/attributes/doc_examples/rustc_dump_layout_align.rs
975
+ @@ -0,0 +1,10 @@
976
+ +//@ dont-require-annotations: ERROR
977
+ +//@ compile-flags: --crate-type lib -Z ui-testing=no
978
+ +
979
+ +#![feature(rustc_attrs)]
980
+ +
981
+ +#[rustc_dump_layout(align)]
982
+ +enum Enum {
983
+ + Bytes([u8; 4]),
984
+ + Int(u32),
985
+ +}
986
+ diff --git a/tests/ui/attributes/doc_examples/rustc_dump_layout_align.stderr b/tests/ui/attributes/doc_examples/rustc_dump_layout_align.stderr
987
+ new file mode 100644
988
+ index 0000000000000000000000000000000000000000..d7fb8b5c969190e51fda42a3cdad773a587b9978
989
+ --- /dev/null
990
+ +++ b/tests/ui/attributes/doc_examples/rustc_dump_layout_align.stderr
991
+ @@ -0,0 +1,8 @@
992
+ +error: align: Align(4 bytes)
993
+ + --> $DIR/rustc_dump_layout_align.rs:7:1
994
+ + |
995
+ +7 | enum Enum {
996
+ + | ^^^^^^^^^
997
+ +
998
+ +error: aborting due to 1 previous error
999
+ +
1000
+ diff --git a/tests/ui/attributes/doc_examples/rustc_dump_layout_backend_repr.rs b/tests/ui/attributes/doc_examples/rustc_dump_layout_backend_repr.rs
1001
+ new file mode 100644
1002
+ index 0000000000000000000000000000000000000000..844a7bc072ff9c92b8b7c9b68ec56cb1ba300a45
1003
+ --- /dev/null
1004
+ +++ b/tests/ui/attributes/doc_examples/rustc_dump_layout_backend_repr.rs
1005
+ @@ -0,0 +1,8 @@
1006
+ +//@ dont-require-annotations: ERROR
1007
+ +//@ compile-flags: --crate-type lib -Z ui-testing=no
1008
+ +
1009
+ +#![feature(rustc_attrs)]
1010
+ +#![feature(portable_simd)]
1011
+ +
1012
+ +#[rustc_dump_layout(backend_repr)]
1013
+ +type Simd = std::simd::u32x4;
1014
+ diff --git a/tests/ui/attributes/doc_examples/rustc_dump_layout_backend_repr.stderr b/tests/ui/attributes/doc_examples/rustc_dump_layout_backend_repr.stderr
1015
+ new file mode 100644
1016
+ index 0000000000000000000000000000000000000000..5afc9709cb24ec719375723cea533e8c26dbae88
1017
+ --- /dev/null
1018
+ +++ b/tests/ui/attributes/doc_examples/rustc_dump_layout_backend_repr.stderr
1019
+ @@ -0,0 +1,8 @@
1020
+ +error: backend_repr: SimdVector { element: u32 is .., count: BackendLaneCount(4) }
1021
+ + --> $DIR/rustc_dump_layout_backend_repr.rs:8:1
1022
+ + |
1023
+ +8 | type Simd = std::simd::u32x4;
1024
+ + | ^^^^^^^^^
1025
+ +
1026
+ +error: aborting due to 1 previous error
1027
+ +
1028
+ diff --git a/tests/ui/attributes/doc_examples/rustc_dump_layout_debug.rs b/tests/ui/attributes/doc_examples/rustc_dump_layout_debug.rs
1029
+ new file mode 100644
1030
+ index 0000000000000000000000000000000000000000..41544d99cf10d90e9aa987f3828402f854c37e71
1031
+ --- /dev/null
1032
+ +++ b/tests/ui/attributes/doc_examples/rustc_dump_layout_debug.rs
1033
+ @@ -0,0 +1,11 @@
1034
+ +//@ dont-require-annotations: ERROR
1035
+ +//@ compile-flags: --crate-type lib -Z ui-testing=no
1036
+ +//@ normalize-stderr: "randomization_seed: \d+" -> "randomization_seed: $$SEED"
1037
+ +
1038
+ +#![feature(rustc_attrs)]
1039
+ +
1040
+ +#[rustc_dump_layout(debug)]
1041
+ +pub union Union {
1042
+ + Float: f32,
1043
+ + Int: u32,
1044
+ +}
1045
+ diff --git a/tests/ui/attributes/doc_examples/rustc_dump_layout_debug.stderr b/tests/ui/attributes/doc_examples/rustc_dump_layout_debug.stderr
1046
+ new file mode 100644
1047
+ index 0000000000000000000000000000000000000000..1918a3696a4e18a3d6ee57340d00bf6b86439c76
1048
+ --- /dev/null
1049
+ +++ b/tests/ui/attributes/doc_examples/rustc_dump_layout_debug.stderr
1050
+ @@ -0,0 +1,27 @@
1051
+ +error: layout_of(Union) = Layout {
1052
+ + size: Size(4 bytes),
1053
+ + align: AbiAlign {
1054
+ + abi: Align(4 bytes),
1055
+ + },
1056
+ + backend_repr: Memory {
1057
+ + sized: true,
1058
+ + },
1059
+ + fields: Union(
1060
+ + 2,
1061
+ + ),
1062
+ + largest_niche: None,
1063
+ + uninhabited: false,
1064
+ + variants: Single {
1065
+ + index: 0,
1066
+ + },
1067
+ + max_repr_align: None,
1068
+ + unadjusted_abi_align: Align(4 bytes),
1069
+ + randomization_seed: $SEED,
1070
+ + }
1071
+ + --> $DIR/rustc_dump_layout_debug.rs:8:1
1072
+ + |
1073
+ +8 | pub union Union {
1074
+ + | ^^^^^^^^^^^^^^^
1075
+ +
1076
+ +error: aborting due to 1 previous error
1077
+ +
1078
+ diff --git a/tests/ui/attributes/doc_examples/rustc_dump_layout_homogeneous_aggregate.rs b/tests/ui/attributes/doc_examples/rustc_dump_layout_homogeneous_aggregate.rs
1079
+ new file mode 100644
1080
+ index 0000000000000000000000000000000000000000..4888f1896f79e649e07c47262693bab8c3cc1fdd
1081
+ --- /dev/null
1082
+ +++ b/tests/ui/attributes/doc_examples/rustc_dump_layout_homogeneous_aggregate.rs
1083
+ @@ -0,0 +1,11 @@
1084
+ +//@ dont-require-annotations: ERROR
1085
+ +//@ compile-flags: --crate-type lib -Z ui-testing=no
1086
+ +
1087
+ +#![feature(rustc_attrs)]
1088
+ +
1089
+ +#[rustc_dump_layout(homogeneous_aggregate)]
1090
+ +#[repr(C)]
1091
+ +struct Struct {
1092
+ + field: [u8; 32],
1093
+ + unit: (),
1094
+ +}
1095
+ diff --git a/tests/ui/attributes/doc_examples/rustc_dump_layout_homogeneous_aggregate.stderr b/tests/ui/attributes/doc_examples/rustc_dump_layout_homogeneous_aggregate.stderr
1096
+ new file mode 100644
1097
+ index 0000000000000000000000000000000000000000..2241adaef234303b9e34d000442a04885a760980
1098
+ --- /dev/null
1099
+ +++ b/tests/ui/attributes/doc_examples/rustc_dump_layout_homogeneous_aggregate.stderr
1100
+ @@ -0,0 +1,8 @@
1101
+ +error: homogeneous_aggregate: Ok(Homogeneous(Reg { kind: Integer, size: Size(1 bytes) }))
1102
+ + --> $DIR/rustc_dump_layout_homogeneous_aggregate.rs:8:1
1103
+ + |
1104
+ +8 | struct Struct {
1105
+ + | ^^^^^^^^^^^^^
1106
+ +
1107
+ +error: aborting due to 1 previous error
1108
+ +
1109
+ diff --git a/tests/ui/attributes/doc_examples/rustc_dump_layout_largest_niche.rs b/tests/ui/attributes/doc_examples/rustc_dump_layout_largest_niche.rs
1110
+ new file mode 100644
1111
+ index 0000000000000000000000000000000000000000..3a8f93fb76347262d028c2ac3e4569f29369d505
1112
+ --- /dev/null
1113
+ +++ b/tests/ui/attributes/doc_examples/rustc_dump_layout_largest_niche.rs
1114
+ @@ -0,0 +1,7 @@
1115
+ +//@ dont-require-annotations: ERROR
1116
+ +//@ compile-flags: --crate-type lib -Z ui-testing=no
1117
+ +
1118
+ +#![feature(rustc_attrs)]
1119
+ +
1120
+ +#[rustc_dump_layout(largest_niche)]
1121
+ +type Alias = Option<char>;
1122
+ diff --git a/tests/ui/attributes/doc_examples/rustc_dump_layout_largest_niche.stderr b/tests/ui/attributes/doc_examples/rustc_dump_layout_largest_niche.stderr
1123
+ new file mode 100644
1124
+ index 0000000000000000000000000000000000000000..f0be65ffe82d71b1cf8e8f88423356161b031a4d
1125
+ --- /dev/null
1126
+ +++ b/tests/ui/attributes/doc_examples/rustc_dump_layout_largest_niche.stderr
1127
+ @@ -0,0 +1,8 @@
1128
+ +error: largest_niche: Some(Niche { offset: Size(0 bytes), value: u32, valid_range: (..=1114111) | (4294967295..) })
1129
+ + --> $DIR/rustc_dump_layout_largest_niche.rs:7:1
1130
+ + |
1131
+ +7 | type Alias = Option<char>;
1132
+ + | ^^^^^^^^^^
1133
+ +
1134
+ +error: aborting due to 1 previous error
1135
+ +
1136
+ diff --git a/tests/ui/attributes/doc_examples/rustc_dump_layout_size.rs b/tests/ui/attributes/doc_examples/rustc_dump_layout_size.rs
1137
+ new file mode 100644
1138
+ index 0000000000000000000000000000000000000000..ad0ef8a668ca348a059e88d268ad909221cb476a
1139
+ --- /dev/null
1140
+ +++ b/tests/ui/attributes/doc_examples/rustc_dump_layout_size.rs
1141
+ @@ -0,0 +1,7 @@
1142
+ +//@ dont-require-annotations: ERROR
1143
+ +//@ compile-flags: --crate-type lib -Z ui-testing=no
1144
+ +
1145
+ +#![feature(rustc_attrs)]
1146
+ +
1147
+ +#[rustc_dump_layout(size)]
1148
+ +type ID = std::any::TypeId;
1149
+ diff --git a/tests/ui/attributes/doc_examples/rustc_dump_layout_size.stderr b/tests/ui/attributes/doc_examples/rustc_dump_layout_size.stderr
1150
+ new file mode 100644
1151
+ index 0000000000000000000000000000000000000000..065fcb833280f05a3a06e9f936ebddd4446f70c6
1152
+ --- /dev/null
1153
+ +++ b/tests/ui/attributes/doc_examples/rustc_dump_layout_size.stderr
1154
+ @@ -0,0 +1,8 @@
1155
+ +error: size: Size(16 bytes)
1156
+ + --> $DIR/rustc_dump_layout_size.rs:7:1
1157
+ + |
1158
+ +7 | type ID = std::any::TypeId;
1159
+ + | ^^^^^^^
1160
+ +
1161
+ +error: aborting due to 1 previous error
1162
+ +
1163
+ diff --git a/tests/ui/attributes/doc_examples/rustc_dump_object_lifetime_defaults.rs b/tests/ui/attributes/doc_examples/rustc_dump_object_lifetime_defaults.rs
1164
+ new file mode 100644
1165
+ index 0000000000000000000000000000000000000000..720e8076e6a4ca8094fd4abb3a0e9def02c95354
1166
+ --- /dev/null
1167
+ +++ b/tests/ui/attributes/doc_examples/rustc_dump_object_lifetime_defaults.rs
1168
+ @@ -0,0 +1,7 @@
1169
+ +//@ dont-require-annotations: ERROR
1170
+ +//@ compile-flags: --crate-type lib -Z ui-testing=no
1171
+ +
1172
+ +#![feature(rustc_attrs)]
1173
+ +
1174
+ +#[rustc_dump_object_lifetime_defaults]
1175
+ +struct Ref<'a, T: 'a>(&'a T);
1176
+ diff --git a/tests/ui/attributes/doc_examples/rustc_dump_object_lifetime_defaults.stderr b/tests/ui/attributes/doc_examples/rustc_dump_object_lifetime_defaults.stderr
1177
+ new file mode 100644
1178
+ index 0000000000000000000000000000000000000000..5aea8daba3f084fe5676964794f26ed83f892aa7
1179
+ --- /dev/null
1180
+ +++ b/tests/ui/attributes/doc_examples/rustc_dump_object_lifetime_defaults.stderr
1181
+ @@ -0,0 +1,8 @@
1182
+ +error: 'a
1183
+ + --> $DIR/rustc_dump_object_lifetime_defaults.rs:7:16
1184
+ + |
1185
+ +7 | struct Ref<'a, T: 'a>(&'a T);
1186
+ + | ^
1187
+ +
1188
+ +error: aborting due to 1 previous error
1189
+ +
1190
+ diff --git a/tests/ui/attributes/doc_examples/rustc_dump_symbol_name.rs b/tests/ui/attributes/doc_examples/rustc_dump_symbol_name.rs
1191
+ new file mode 100644
1192
+ index 0000000000000000000000000000000000000000..7c5750d1936db8a52cfaf74a4e6bf921a46eb7c6
1193
+ --- /dev/null
1194
+ +++ b/tests/ui/attributes/doc_examples/rustc_dump_symbol_name.rs
1195
+ @@ -0,0 +1,17 @@
1196
+ +//@ dont-require-annotations: ERROR
1197
+ +//@ compile-flags: --crate-type lib -Z ui-testing=no
1198
+ +//@ build-fail
1199
+ +
1200
+ +#![feature(rustc_attrs)]
1201
+ +
1202
+ +#[rustc_dump_symbol_name]
1203
+ +fn mangled() {}
1204
+ +
1205
+ +#[rustc_dump_symbol_name]
1206
+ +#[unsafe(no_mangle)]
1207
+ +fn no_mangle() {}
1208
+ +
1209
+ +unsafe extern "C" {
1210
+ + #[rustc_dump_symbol_name]
1211
+ + fn abort();
1212
+ +}
1213
+ diff --git a/tests/ui/attributes/doc_examples/rustc_dump_symbol_name.stderr b/tests/ui/attributes/doc_examples/rustc_dump_symbol_name.stderr
1214
+ new file mode 100644
1215
+ index 0000000000000000000000000000000000000000..a1d298909fae6837985e9d15cb371a9e4bdb8b97
1216
+ --- /dev/null
1217
+ +++ b/tests/ui/attributes/doc_examples/rustc_dump_symbol_name.stderr
1218
+ @@ -0,0 +1,32 @@
1219
+ +error: symbol-name(_RNvCsCRATE_HASH_22rustc_dump_symbol_name7mangled)
1220
+ + --> $DIR/rustc_dump_symbol_name.rs:7:1
1221
+ + |
1222
+ +7 | #[rustc_dump_symbol_name]
1223
+ + | ^^^^^^^^^^^^^^^^^^^^^^^^^
1224
+ +
1225
+ +error: demangling(rustc_dump_symbol_name[6981ee133444a33d]::mangled)
1226
+ + --> $DIR/rustc_dump_symbol_name.rs:7:1
1227
+ + |
1228
+ +7 | #[rustc_dump_symbol_name]
1229
+ + | ^^^^^^^^^^^^^^^^^^^^^^^^^
1230
+ +
1231
+ +error: demangling-alt(rustc_dump_symbol_name::mangled)
1232
+ + --> $DIR/rustc_dump_symbol_name.rs:7:1
1233
+ + |
1234
+ +7 | #[rustc_dump_symbol_name]
1235
+ + | ^^^^^^^^^^^^^^^^^^^^^^^^^
1236
+ +
1237
+ +error: symbol-name(no_mangle)
1238
+ + --> $DIR/rustc_dump_symbol_name.rs:10:1
1239
+ + |
1240
+ +10 | #[rustc_dump_symbol_name]
1241
+ + | ^^^^^^^^^^^^^^^^^^^^^^^^^
1242
+ +
1243
+ +error: symbol-name(abort)
1244
+ + --> $DIR/rustc_dump_symbol_name.rs:15:5
1245
+ + |
1246
+ +15 | #[rustc_dump_symbol_name]
1247
+ + | ^^^^^^^^^^^^^^^^^^^^^^^^^
1248
+ +
1249
+ +error: aborting due to 5 previous errors
1250
+ +
1251
+ diff --git a/tests/ui/attributes/doc_examples/rustc_dump_variances.rs b/tests/ui/attributes/doc_examples/rustc_dump_variances.rs
1252
+ new file mode 100644
1253
+ index 0000000000000000000000000000000000000000..37a4c9a7894355b9c425274b06efe6a6f7503835
1254
+ --- /dev/null
1255
+ +++ b/tests/ui/attributes/doc_examples/rustc_dump_variances.rs
1256
+ @@ -0,0 +1,24 @@
1257
+ +//@ dont-require-annotations: ERROR
1258
+ +//@ compile-flags: --crate-type lib -Z ui-testing=no
1259
+ +
1260
+ +#![feature(rustc_attrs)]
1261
+ +
1262
+ +#[rustc_dump_variances]
1263
+ +struct Ref<'a, T> {
1264
+ + r: &'a T,
1265
+ +}
1266
+ +
1267
+ +#[rustc_dump_variances]
1268
+ +struct RefMut<'a, T> {
1269
+ + r: &'a mut T,
1270
+ +}
1271
+ +
1272
+ +#[rustc_dump_variances]
1273
+ +struct CellRef<'a, T> {
1274
+ + r: &'a core::cell::UnsafeCell<T>,
1275
+ +}
1276
+ +
1277
+ +#[rustc_dump_variances]
1278
+ +fn x<T, U>(_t: T) -> U {
1279
+ + todo!()
1280
+ +}
1281
+ diff --git a/tests/ui/attributes/doc_examples/rustc_dump_variances.stderr b/tests/ui/attributes/doc_examples/rustc_dump_variances.stderr
1282
+ new file mode 100644
1283
+ index 0000000000000000000000000000000000000000..4680ca94b5ec806f05e403bd65566340ba57c497
1284
+ --- /dev/null
1285
+ +++ b/tests/ui/attributes/doc_examples/rustc_dump_variances.stderr
1286
+ @@ -0,0 +1,26 @@
1287
+ +error: ['a: +, T: +]
1288
+ + --> $DIR/rustc_dump_variances.rs:7:1
1289
+ + |
1290
+ +7 | struct Ref<'a, T> {
1291
+ + | ^^^^^^^^^^^^^^^^^
1292
+ +
1293
+ +error: ['a: +, T: o]
1294
+ + --> $DIR/rustc_dump_variances.rs:12:1
1295
+ + |
1296
+ +12 | struct RefMut<'a, T> {
1297
+ + | ^^^^^^^^^^^^^^^^^^^^
1298
+ +
1299
+ +error: ['a: +, T: o]
1300
+ + --> $DIR/rustc_dump_variances.rs:17:1
1301
+ + |
1302
+ +17 | struct CellRef<'a, T> {
1303
+ + | ^^^^^^^^^^^^^^^^^^^^^
1304
+ +
1305
+ +error: [T: -, U: +]
1306
+ + --> $DIR/rustc_dump_variances.rs:22:1
1307
+ + |
1308
+ +22 | fn x<T, U>(_t: T) -> U {
1309
+ + | ^^^^^^^^^^^^^^^^^^^^^^
1310
+ +
1311
+ +error: aborting due to 4 previous errors
1312
+ +
1313
+ diff --git a/tests/ui/attributes/doc_examples/rustc_dump_variances_of_opaques.rs b/tests/ui/attributes/doc_examples/rustc_dump_variances_of_opaques.rs
1314
+ new file mode 100644
1315
+ index 0000000000000000000000000000000000000000..924cd923733de2e8ec6d741f2bca74c0056b0ead
1316
+ --- /dev/null
1317
+ +++ b/tests/ui/attributes/doc_examples/rustc_dump_variances_of_opaques.rs
1318
+ @@ -0,0 +1,16 @@
1319
+ +//@ dont-require-annotations: ERROR
1320
+ +//@ compile-flags: --crate-type lib -Z ui-testing=no
1321
+ +
1322
+ +#![feature(rustc_attrs)]
1323
+ +#![rustc_dump_variances_of_opaques]
1324
+ +
1325
+ +trait Captures<'a> {}
1326
+ +impl<T> Captures<'_> for T {}
1327
+ +
1328
+ +fn not_captured_early<'a: 'a>() -> impl Sized {}
1329
+ +
1330
+ +fn captured_early<'a: 'a>() -> impl Sized + Captures<'a> {}
1331
+ +
1332
+ +fn not_captured_late<'a>(_: &'a ()) -> impl Sized {}
1333
+ +
1334
+ +fn captured_late<'a>(_: &'a ()) -> impl Sized + Captures<'a> {}
1335
+ diff --git a/tests/ui/attributes/doc_examples/rustc_dump_variances_of_opaques.stderr b/tests/ui/attributes/doc_examples/rustc_dump_variances_of_opaques.stderr
1336
+ new file mode 100644
1337
+ index 0000000000000000000000000000000000000000..2c89b9473bd2960d97cccf4432ae6086bde9bfaa
1338
+ --- /dev/null
1339
+ +++ b/tests/ui/attributes/doc_examples/rustc_dump_variances_of_opaques.stderr
1340
+ @@ -0,0 +1,26 @@
1341
+ +error: ['a: *]
1342
+ + --> $DIR/rustc_dump_variances_of_opaques.rs:10:36
1343
+ + |
1344
+ +10 | fn not_captured_early<'a: 'a>() -> impl Sized {}
1345
+ + | ^^^^^^^^^^
1346
+ +
1347
+ +error: ['a: *, 'a: o]
1348
+ + --> $DIR/rustc_dump_variances_of_opaques.rs:12:32
1349
+ + |
1350
+ +12 | fn captured_early<'a: 'a>() -> impl Sized + Captures<'a> {}
1351
+ + | ^^^^^^^^^^^^^^^^^^^^^^^^^
1352
+ +
1353
+ +error: []
1354
+ + --> $DIR/rustc_dump_variances_of_opaques.rs:14:40
1355
+ + |
1356
+ +14 | fn not_captured_late<'a>(_: &'a ()) -> impl Sized {}
1357
+ + | ^^^^^^^^^^
1358
+ +
1359
+ +error: ['a: o]
1360
+ + --> $DIR/rustc_dump_variances_of_opaques.rs:16:36
1361
+ + |
1362
+ +16 | fn captured_late<'a>(_: &'a ()) -> impl Sized + Captures<'a> {}
1363
+ + | ^^^^^^^^^^^^^^^^^^^^^^^^^
1364
+ +
1365
+ +error: aborting due to 4 previous errors
1366
+ +
1367
+ diff --git a/tests/ui/attributes/doc_examples/rustc_dump_vtable.rs b/tests/ui/attributes/doc_examples/rustc_dump_vtable.rs
1368
+ new file mode 100644
1369
+ index 0000000000000000000000000000000000000000..e061406858d2379d189d3dd334e0ce36de1233ad
1370
+ --- /dev/null
1371
+ +++ b/tests/ui/attributes/doc_examples/rustc_dump_vtable.rs
1372
+ @@ -0,0 +1,20 @@
1373
+ +//@ dont-require-annotations: ERROR
1374
+ +//@ compile-flags: --crate-type lib -Z ui-testing=no
1375
+ +
1376
+ +#![feature(rustc_attrs)]
1377
+ +
1378
+ +#[rustc_dump_vtable]
1379
+ +type X = dyn Send;
1380
+ +
1381
+ +#[rustc_dump_vtable]
1382
+ +type Y = dyn core::any::Any;
1383
+ +
1384
+ +struct C;
1385
+ +
1386
+ +#[rustc_dump_vtable]
1387
+ +impl Iterator for C {
1388
+ + type Item = ();
1389
+ + fn next(&mut self) -> Option<Self::Item> {
1390
+ + Some(())
1391
+ + }
1392
+ +}
1393
+ diff --git a/tests/ui/attributes/doc_examples/rustc_dump_vtable.stderr b/tests/ui/attributes/doc_examples/rustc_dump_vtable.stderr
1394
+ new file mode 100644
1395
+ index 0000000000000000000000000000000000000000..32c43b71b9aada47b65e821b4e55fea12823eb27
1396
+ --- /dev/null
1397
+ +++ b/tests/ui/attributes/doc_examples/rustc_dump_vtable.stderr
1398
+ @@ -0,0 +1,37 @@
1399
+ +error: vtable entries: [
1400
+ + MetadataDropInPlace,
1401
+ + MetadataSize,
1402
+ + MetadataAlign,
1403
+ + ]
1404
+ + --> $DIR/rustc_dump_vtable.rs:7:1
1405
+ + |
1406
+ +7 | type X = dyn Send;
1407
+ + | ^^^^^^
1408
+ +
1409
+ +error: vtable entries: [
1410
+ + MetadataDropInPlace,
1411
+ + MetadataSize,
1412
+ + MetadataAlign,
1413
+ + Method(<dyn Any as Any>::type_id - shim(reify)),
1414
+ + ]
1415
+ + --> $DIR/rustc_dump_vtable.rs:10:1
1416
+ + |
1417
+ +10 | type Y = dyn core::any::Any;
1418
+ + | ^^^^^^
1419
+ +
1420
+ +error: vtable entries: [
1421
+ + MetadataDropInPlace,
1422
+ + MetadataSize,
1423
+ + MetadataAlign,
1424
+ + Method(<C as Iterator>::next),
1425
+ + Method(<C as Iterator>::size_hint),
1426
+ + Method(<C as Iterator>::advance_by),
1427
+ + Method(<C as Iterator>::nth),
1428
+ + ]
1429
+ + --> $DIR/rustc_dump_vtable.rs:15:1
1430
+ + |
1431
+ +15 | impl Iterator for C {
1432
+ + | ^^^^^^^^^^^^^^^^^^^
1433
+ +
1434
+ +error: aborting due to 3 previous errors
1435
+ +
1436
+ diff --git a/tests/ui/attributes/dump-clauses.rs b/tests/ui/attributes/dump-clauses.rs
1437
+ deleted file mode 100644
1438
+ index 7191fe3f57acf7dccd0535786dbc60710172546a..0000000000000000000000000000000000000000
1439
+ --- a/tests/ui/attributes/dump-clauses.rs
1440
+ +++ /dev/null
1441
+ @@ -1,20 +0,0 @@
1442
+ -//@ normalize-stderr: "DefId\(.+?\)" -> "DefId(..)"
1443
+ -
1444
+ -#![feature(rustc_attrs)]
1445
+ -
1446
+ -#[rustc_dump_clauses]
1447
+ -trait Trait<T>: Iterator<Item: Copy>
1448
+ -//~^ ERROR rustc_dump_clauses
1449
+ -where
1450
+ - String: From<T>
1451
+ -{
1452
+ - #[rustc_dump_clauses]
1453
+ - #[rustc_dump_item_bounds]
1454
+ - type Assoc<P: Eq>: std::ops::Deref<Target = ()>
1455
+ - //~^ ERROR rustc_dump_clauses
1456
+ - //~| ERROR rustc_dump_item_bounds
1457
+ - where
1458
+ - Self::Assoc<()>: Copy;
1459
+ -}
1460
+ -
1461
+ -fn main() {}
1462
+ diff --git a/tests/ui/attributes/dump-clauses.stderr b/tests/ui/attributes/dump-clauses.stderr
1463
+ deleted file mode 100644
1464
+ index 93d2057d88cd5931aef904254c6f47ee254025fe..0000000000000000000000000000000000000000
1465
+ --- a/tests/ui/attributes/dump-clauses.stderr
1466
+ +++ /dev/null
1467
+ @@ -1,41 +0,0 @@
1468
+ -error: rustc_dump_clauses
1469
+ - --> $DIR/dump-clauses.rs:6:1
1470
+ - |
1471
+ -LL | trait Trait<T>: Iterator<Item: Copy>
1472
+ - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1473
+ - |
1474
+ - = note: Binder { value: TraitClause(<Self as std::marker::MetaSized>, polarity:Positive), bound_vars: [] }
1475
+ - = note: Binder { value: TraitClause(<Self as std::iter::Iterator>, polarity:Positive), bound_vars: [] }
1476
+ - = note: Binder { value: TraitClause(<<Self as std::iter::Iterator>::Item as std::marker::Copy>, polarity:Positive), bound_vars: [] }
1477
+ - = note: Binder { value: TraitClause(<T as std::marker::Sized>, polarity:Positive), bound_vars: [] }
1478
+ - = note: Binder { value: TraitClause(<std::string::String as std::convert::From<T>>, polarity:Positive), bound_vars: [] }
1479
+ - = note: Binder { value: TraitClause(<Self as Trait<T>>, polarity:Positive), bound_vars: [] }
1480
+ -
1481
+ -error: rustc_dump_clauses
1482
+ - --> $DIR/dump-clauses.rs:13:5
1483
+ - |
1484
+ -LL | type Assoc<P: Eq>: std::ops::Deref<Target = ()>
1485
+ - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1486
+ - |
1487
+ - = note: Binder { value: TraitClause(<Self as std::marker::MetaSized>, polarity:Positive), bound_vars: [] }
1488
+ - = note: Binder { value: TraitClause(<Self as std::iter::Iterator>, polarity:Positive), bound_vars: [] }
1489
+ - = note: Binder { value: TraitClause(<<Self as std::iter::Iterator>::Item as std::marker::Copy>, polarity:Positive), bound_vars: [] }
1490
+ - = note: Binder { value: TraitClause(<T as std::marker::Sized>, polarity:Positive), bound_vars: [] }
1491
+ - = note: Binder { value: TraitClause(<std::string::String as std::convert::From<T>>, polarity:Positive), bound_vars: [] }
1492
+ - = note: Binder { value: TraitClause(<Self as Trait<T>>, polarity:Positive), bound_vars: [] }
1493
+ - = note: Binder { value: TraitClause(<P as std::marker::Sized>, polarity:Positive), bound_vars: [] }
1494
+ - = note: Binder { value: TraitClause(<P as std::cmp::Eq>, polarity:Positive), bound_vars: [] }
1495
+ - = note: Binder { value: TraitClause(<<Self as Trait<T>>::Assoc<()> as std::marker::Copy>, polarity:Positive), bound_vars: [] }
1496
+ -
1497
+ -error: rustc_dump_item_bounds
1498
+ - --> $DIR/dump-clauses.rs:13:5
1499
+ - |
1500
+ -LL | type Assoc<P: Eq>: std::ops::Deref<Target = ()>
1501
+ - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1502
+ - |
1503
+ - = note: Binder { value: ProjectionClause(Alias { kind: ProjectionTy { def_id: DefId(..) }, args: [Alias(No, Alias { kind: Projection { def_id: DefId(..) }, args: [Self/#0, T/#1, P/#2], .. })], .. }, Term::Ty(())), bound_vars: [] }
1504
+ - = note: Binder { value: TraitClause(<<Self as Trait<T>>::Assoc<P> as std::ops::Deref>, polarity:Positive), bound_vars: [] }
1505
+ - = note: Binder { value: TraitClause(<<Self as Trait<T>>::Assoc<P> as std::marker::Sized>, polarity:Positive), bound_vars: [] }
1506
+ -
1507
+ -error: aborting due to 3 previous errors
1508
+ -
1509
+ diff --git a/tests/ui/nll/polonius/boring-local-drop-liveness.nll.stderr b/tests/ui/nll/polonius/boring-local-drop-liveness.nll.stderr
1510
+ new file mode 100644
1511
+ index 0000000000000000000000000000000000000000..1618679c8b2d4f91191761b19edcb3718ae08cfa
1512
+ --- /dev/null
1513
+ +++ b/tests/ui/nll/polonius/boring-local-drop-liveness.nll.stderr
1514
+ @@ -0,0 +1,32 @@
1515
+ +error[E0506]: cannot assign to `*x` because it is borrowed
1516
+ + --> $DIR/boring-local-drop-liveness.rs:28:5
1517
+ + |
1518
+ +LL | fn assigning_under_a_live_destructor<'a>(
1519
+ + | -- lifetime `'a` defined here
1520
+ +...
1521
+ +LL | *slot = Some(d.0);
1522
+ + | ----------------- assignment requires that `*x` is borrowed for `'a`
1523
+ +LL | d = D(&*x);
1524
+ + | --- `*x` is borrowed here
1525
+ +LL | *x = String::new();
1526
+ + | ^^ `*x` is assigned to here but it was already borrowed
1527
+ +
1528
+ +error[E0597]: `local` does not live long enough
1529
+ + --> $DIR/boring-local-drop-liveness.rs:35:11
1530
+ + |
1531
+ +LL | fn dropping_under_a_live_destructor<'a>(x: &'a String, slot: &mut Option<&'a String>) {
1532
+ + | -- lifetime `'a` defined here
1533
+ +LL | let mut d = D(x);
1534
+ +LL | *slot = Some(d.0);
1535
+ + | ----------------- assignment requires that `local` is borrowed for `'a`
1536
+ +LL | let local = String::from("gone");
1537
+ + | ----- binding `local` declared here
1538
+ +LL | d = D(&local);
1539
+ + | ^^^^^^ borrowed value does not live long enough
1540
+ +LL | }
1541
+ + | - `local` dropped here while still borrowed
1542
+ +
1543
+ +error: aborting due to 2 previous errors
1544
+ +
1545
+ +Some errors have detailed explanations: E0506, E0597.
1546
+ +For more information about an error, try `rustc --explain E0506`.
1547
+ diff --git a/tests/ui/nll/polonius/boring-local-drop-liveness.polonius_next.stderr b/tests/ui/nll/polonius/boring-local-drop-liveness.polonius_next.stderr
1548
+ new file mode 100644
1549
+ index 0000000000000000000000000000000000000000..1618679c8b2d4f91191761b19edcb3718ae08cfa
1550
+ --- /dev/null
1551
+ +++ b/tests/ui/nll/polonius/boring-local-drop-liveness.polonius_next.stderr
1552
+ @@ -0,0 +1,32 @@
1553
+ +error[E0506]: cannot assign to `*x` because it is borrowed
1554
+ + --> $DIR/boring-local-drop-liveness.rs:28:5
1555
+ + |
1556
+ +LL | fn assigning_under_a_live_destructor<'a>(
1557
+ + | -- lifetime `'a` defined here
1558
+ +...
1559
+ +LL | *slot = Some(d.0);
1560
+ + | ----------------- assignment requires that `*x` is borrowed for `'a`
1561
+ +LL | d = D(&*x);
1562
+ + | --- `*x` is borrowed here
1563
+ +LL | *x = String::new();
1564
+ + | ^^ `*x` is assigned to here but it was already borrowed
1565
+ +
1566
+ +error[E0597]: `local` does not live long enough
1567
+ + --> $DIR/boring-local-drop-liveness.rs:35:11
1568
+ + |
1569
+ +LL | fn dropping_under_a_live_destructor<'a>(x: &'a String, slot: &mut Option<&'a String>) {
1570
+ + | -- lifetime `'a` defined here
1571
+ +LL | let mut d = D(x);
1572
+ +LL | *slot = Some(d.0);
1573
+ + | ----------------- assignment requires that `local` is borrowed for `'a`
1574
+ +LL | let local = String::from("gone");
1575
+ + | ----- binding `local` declared here
1576
+ +LL | d = D(&local);
1577
+ + | ^^^^^^ borrowed value does not live long enough
1578
+ +LL | }
1579
+ + | - `local` dropped here while still borrowed
1580
+ +
1581
+ +error: aborting due to 2 previous errors
1582
+ +
1583
+ +Some errors have detailed explanations: E0506, E0597.
1584
+ +For more information about an error, try `rustc --explain E0506`.
1585
+ diff --git a/tests/ui/nll/polonius/boring-local-drop-liveness.rs b/tests/ui/nll/polonius/boring-local-drop-liveness.rs
1586
+ new file mode 100644
1587
+ index 0000000000000000000000000000000000000000..d473a2faeb5c51ca7d651528520fcf345479a036
1588
+ --- /dev/null
1589
+ +++ b/tests/ui/nll/polonius/boring-local-drop-liveness.rs
1590
+ @@ -0,0 +1,38 @@
1591
+ +// Polonius requires liveness for some locals that NLL leaves "boring": locals
1592
+ +// containing some region that outlives a universal region but is not universal itself.
1593
+ +//
1594
+ +// This test checks that we correctly compute liveness for NLL-boring locals that
1595
+ +// are live only because of their drop.
1596
+ +
1597
+ +//@ ignore-compare-mode-polonius (explicit revisions)
1598
+ +//@ revisions: nll polonius_next
1599
+ +//@ [nll] compile-flags: -Zpolonius=off
1600
+ +//@ [polonius_next] compile-flags: -Zpolonius=next
1601
+ +
1602
+ +struct D<'a>(&'a String);
1603
+ +
1604
+ +impl<'a> Drop for D<'a> {
1605
+ + fn drop(&mut self) {
1606
+ + println!("{}", self.0);
1607
+ + }
1608
+ +}
1609
+ +
1610
+ +fn assigning_under_a_live_destructor<'a>(
1611
+ + x: &'a mut String,
1612
+ + slot: &mut Option<&'a String>,
1613
+ + y: &'a String,
1614
+ +) {
1615
+ + let mut d = D(y);
1616
+ + *slot = Some(d.0);
1617
+ + d = D(&*x);
1618
+ + *x = String::new(); //~ ERROR cannot assign to `*x` because it is borrowed
1619
+ +}
1620
+ +
1621
+ +fn dropping_under_a_live_destructor<'a>(x: &'a String, slot: &mut Option<&'a String>) {
1622
+ + let mut d = D(x);
1623
+ + *slot = Some(d.0);
1624
+ + let local = String::from("gone");
1625
+ + d = D(&local); //~ ERROR `local` does not live long enough
1626
+ +}
1627
+ +
1628
+ +fn main() {}
1629
+ diff --git a/tests/ui/nll/polonius/boring-local-liveness.nll.stderr b/tests/ui/nll/polonius/boring-local-liveness.nll.stderr
1630
+ new file mode 100644
1631
+ index 0000000000000000000000000000000000000000..5d5c46a97e9466604261dff6a0c8a9ad3a3fb3f4
1632
+ --- /dev/null
1633
+ +++ b/tests/ui/nll/polonius/boring-local-liveness.nll.stderr
1634
+ @@ -0,0 +1,30 @@
1635
+ +error[E0506]: cannot assign to `*x` because it is borrowed
1636
+ + --> $DIR/boring-local-liveness.rs:22:5
1637
+ + |
1638
+ +LL | fn assigning_into_a_slot<'a>(x: &'a mut u32, slot: &mut Option<D<'a>>) {
1639
+ + | -- lifetime `'a` defined here
1640
+ +LL | let r: &'a u32 = &*x;
1641
+ + | ------- --- `*x` is borrowed here
1642
+ + | |
1643
+ + | type annotation requires that `*x` is borrowed for `'a`
1644
+ +LL | *slot = Some(D(r));
1645
+ +LL | *x = 1;
1646
+ + | ^^^^^^ `*x` is assigned to here but it was already borrowed
1647
+ +
1648
+ +error[E0506]: cannot assign to `*x` because it is borrowed
1649
+ + --> $DIR/boring-local-liveness.rs:32:5
1650
+ + |
1651
+ +LL | fn clearing_the_slot_does_not_release_it<'a>(x: &'a mut u32, slot: &mut Option<D<'a>>) {
1652
+ + | -- lifetime `'a` defined here
1653
+ +LL | {
1654
+ +LL | let r: &'a u32 = &*x;
1655
+ + | ------- --- `*x` is borrowed here
1656
+ + | |
1657
+ + | type annotation requires that `*x` is borrowed for `'a`
1658
+ +...
1659
+ +LL | *x = 1;
1660
+ + | ^^^^^^ `*x` is assigned to here but it was already borrowed
1661
+ +
1662
+ +error: aborting due to 2 previous errors
1663
+ +
1664
+ +For more information about this error, try `rustc --explain E0506`.
1665
+ diff --git a/tests/ui/nll/polonius/boring-local-liveness.polonius_next.stderr b/tests/ui/nll/polonius/boring-local-liveness.polonius_next.stderr
1666
+ new file mode 100644
1667
+ index 0000000000000000000000000000000000000000..5d5c46a97e9466604261dff6a0c8a9ad3a3fb3f4
1668
+ --- /dev/null
1669
+ +++ b/tests/ui/nll/polonius/boring-local-liveness.polonius_next.stderr
1670
+ @@ -0,0 +1,30 @@
1671
+ +error[E0506]: cannot assign to `*x` because it is borrowed
1672
+ + --> $DIR/boring-local-liveness.rs:22:5
1673
+ + |
1674
+ +LL | fn assigning_into_a_slot<'a>(x: &'a mut u32, slot: &mut Option<D<'a>>) {
1675
+ + | -- lifetime `'a` defined here
1676
+ +LL | let r: &'a u32 = &*x;
1677
+ + | ------- --- `*x` is borrowed here
1678
+ + | |
1679
+ + | type annotation requires that `*x` is borrowed for `'a`
1680
+ +LL | *slot = Some(D(r));
1681
+ +LL | *x = 1;
1682
+ + | ^^^^^^ `*x` is assigned to here but it was already borrowed
1683
+ +
1684
+ +error[E0506]: cannot assign to `*x` because it is borrowed
1685
+ + --> $DIR/boring-local-liveness.rs:32:5
1686
+ + |
1687
+ +LL | fn clearing_the_slot_does_not_release_it<'a>(x: &'a mut u32, slot: &mut Option<D<'a>>) {
1688
+ + | -- lifetime `'a` defined here
1689
+ +LL | {
1690
+ +LL | let r: &'a u32 = &*x;
1691
+ + | ------- --- `*x` is borrowed here
1692
+ + | |
1693
+ + | type annotation requires that `*x` is borrowed for `'a`
1694
+ +...
1695
+ +LL | *x = 1;
1696
+ + | ^^^^^^ `*x` is assigned to here but it was already borrowed
1697
+ +
1698
+ +error: aborting due to 2 previous errors
1699
+ +
1700
+ +For more information about this error, try `rustc --explain E0506`.
1701
+ diff --git a/tests/ui/nll/polonius/boring-local-liveness.rs b/tests/ui/nll/polonius/boring-local-liveness.rs
1702
+ new file mode 100644
1703
+ index 0000000000000000000000000000000000000000..86ddcfc6b01191b29c4efa54908cbd1d9dce11a4
1704
+ --- /dev/null
1705
+ +++ b/tests/ui/nll/polonius/boring-local-liveness.rs
1706
+ @@ -0,0 +1,35 @@
1707
+ +// Polonius requires liveness for some locals that NLL leaves "boring": locals
1708
+ +// containing some region that outlives a universal region but is not universal itself.
1709
+ +//
1710
+ +// This test checks that we correctly compute liveness for NLL-boring locals that
1711
+ +// are live because of a use.
1712
+ +
1713
+ +//@ ignore-compare-mode-polonius (explicit revisions)
1714
+ +//@ revisions: nll polonius_next
1715
+ +//@ [nll] compile-flags: -Zpolonius=off
1716
+ +//@ [polonius_next] compile-flags: -Zpolonius=next
1717
+ +
1718
+ +struct D<'a>(&'a u32);
1719
+ +
1720
+ +impl<'a> Drop for D<'a> {
1721
+ + fn drop(&mut self) {}
1722
+ +}
1723
+ +
1724
+ +// The loan of `*x` flows into `slot`'s region, which outlives `'a` and so is boring to NLLs.
1725
+ +fn assigning_into_a_slot<'a>(x: &'a mut u32, slot: &mut Option<D<'a>>) {
1726
+ + let r: &'a u32 = &*x;
1727
+ + *slot = Some(D(r));
1728
+ + *x = 1; //~ ERROR cannot assign to `*x` because it is borrowed
1729
+ +}
1730
+ +
1731
+ +// The same, with the borrow confined to an inner scope and the slot cleared afterwards.
1732
+ +fn clearing_the_slot_does_not_release_it<'a>(x: &'a mut u32, slot: &mut Option<D<'a>>) {
1733
+ + {
1734
+ + let r: &'a u32 = &*x;
1735
+ + *slot = Some(D(r));
1736
+ + }
1737
+ + *slot = None;
1738
+ + *x = 1; //~ ERROR cannot assign to `*x` because it is borrowed
1739
+ +}
1740
+ +
1741
+ +fn main() {}
patches/20261028T105419Z/rust-lang--rust-part009/12a11b5722e5e6517d09ebc43747a495e7f9fd9c.patch ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ diff --git a/library/compiler-builtins/rust-version b/library/compiler-builtins/rust-version
2
+ index 9ff8b0c27d19c6e07364db9545279749231a7f0c..6c07d50b9c4b33feccea2fc775573987febee815 100644
3
+ --- a/library/compiler-builtins/rust-version
4
+ +++ b/library/compiler-builtins/rust-version
5
+ @@ -1 +1 @@
6
+ -f7d782a3be46d6bb4b9792fe69a61db389ba1769
7
+ +45f215f136e00d8a74c69afde2f71be3f16837cf
patches/20261028T105419Z/rust-lang--rust-part009/141d9b7eab729c024a36bc9a16c810a5acf8cb37.patch ADDED
@@ -0,0 +1,145 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ diff --git a/compiler/rustc_borrowck/src/universal_regions.rs b/compiler/rustc_borrowck/src/universal_regions.rs
2
+ index d693061e8fa433e18d5ab6f479be885eb73f39e2..fbde85ef6aec458239c09362cff7eddd1f90f570 100644
3
+ --- a/compiler/rustc_borrowck/src/universal_regions.rs
4
+ +++ b/compiler/rustc_borrowck/src/universal_regions.rs
5
+ @@ -21,19 +21,16 @@ use rustc_hir::attrs::lang_items::LangItem;
6
+ use rustc_hir::def::DefKind;
7
+ use rustc_hir::def_id::{DefId, LocalDefId};
8
+ use rustc_index::IndexVec;
9
+ -use rustc_infer::infer::{NllRegionVariableOrigin, TyCtxtInferExt};
10
+ -use rustc_infer::traits::ObligationCause;
11
+ +use rustc_infer::infer::NllRegionVariableOrigin;
12
+ use rustc_macros::extension;
13
+ use rustc_middle::mir::RETURN_PLACE;
14
+ use rustc_middle::ty::print::with_no_trimmed_paths;
15
+ use rustc_middle::ty::{
16
+ self, BoundVariableKind, GenericArgs, GenericArgsRef, InlineConstArgs, InlineConstArgsParts,
17
+ - List, RegionExt, RegionVid, Ty, TyCtxt, TypeFoldable, TypeVisitableExt, TypingMode,
18
+ - fold_regions,
19
+ + List, RegionExt, RegionVid, Ty, TyCtxt, TypeFoldable, TypeVisitableExt, fold_regions,
20
+ };
21
+ use rustc_middle::{bug, span_bug};
22
+ use rustc_span::{ErrorGuaranteed, kw, sym};
23
+ -use rustc_trait_selection::traits::ObligationCtxt;
24
+ use tracing::{debug, instrument};
25
+
26
+ use crate::BorrowckInferCtxt;
27
+ @@ -136,32 +133,22 @@ pub(crate) enum DefiningTy<'tcx> {
28
+ GlobalAsm(DefId),
29
+ }
30
+
31
+ -fn normalized_type_of<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Ty<'tcx> {
32
+ - let ty = tcx.type_of(def_id).instantiate_identity();
33
+ - if !tcx.next_trait_solver_globally() {
34
+ - return ty.skip_normalization();
35
+ - }
36
+ -
37
+ - let typing_mode = if tcx.use_typing_mode_post_typeck_until_borrowck() {
38
+ - TypingMode::borrowck(tcx, def_id)
39
+ - } else {
40
+ - TypingMode::analysis_in_body(tcx, def_id)
41
+ - };
42
+ - let infcx = tcx.infer_ctxt().build(typing_mode);
43
+ - let ocx = ObligationCtxt::new(&infcx);
44
+ - let span = tcx.def_span(def_id);
45
+ - let cause = ObligationCause::misc(span, def_id);
46
+ - ocx.deeply_normalize(&cause, tcx.param_env(def_id), ty).unwrap()
47
+ -}
48
+ -
49
+ impl<'tcx> DefiningTy<'tcx> {
50
+ #[instrument(level = "debug", skip(tcx), ret)]
51
+ pub(crate) fn new(tcx: TyCtxt<'tcx>, body_def_id: LocalDefId) -> DefiningTy<'tcx> {
52
+ match tcx.hir_body_owner_kind(body_def_id) {
53
+ BodyOwnerKind::Closure | BodyOwnerKind::Fn => {
54
+ - // Normalize after instantiation so coroutine yield/resume
55
+ - // types in the args are rigid under the next solver.
56
+ - let defining_ty = normalized_type_of(tcx, body_def_id);
57
+ + let defining_ty =
58
+ + tcx.type_of(body_def_id).instantiate_identity().skip_normalization();
59
+ + let defining_ty = if tcx.next_trait_solver_globally() {
60
+ + // Closure types come from HIR typeck results, where they were already
61
+ + // normalized during writeback. Wrapping them in an `EarlyBinder`
62
+ + // conservatively makes aliases non-rigid, so restore their rigidness
63
+ + // instead of normalizing them again during borrowck.
64
+ + ty::set_aliases_to_rigid(tcx, defining_ty)
65
+ + } else {
66
+ + defining_ty
67
+ + };
68
+ match *defining_ty.kind() {
69
+ ty::Closure(def_id, args) => DefiningTy::Closure(def_id, args),
70
+ ty::Coroutine(def_id, args) => DefiningTy::Coroutine(def_id, args),
71
+ diff --git a/compiler/rustc_mir_build/src/builder/mod.rs b/compiler/rustc_mir_build/src/builder/mod.rs
72
+ index 7701206ad03b74e4d80e458d37da9acbc92d1a38..60b8cf3f78a06142fbade7cd4f0b29778e97df56 100644
73
+ --- a/compiler/rustc_mir_build/src/builder/mod.rs
74
+ +++ b/compiler/rustc_mir_build/src/builder/mod.rs
75
+ @@ -33,7 +33,6 @@ use rustc_hir::{self as hir, BindingMode, ByRef, HirId, ItemLocalId, Node, find_
76
+ use rustc_index::bit_set::GrowableBitSet;
77
+ use rustc_index::{Idx, IndexSlice, IndexVec};
78
+ use rustc_infer::infer::{InferCtxt, TyCtxtInferExt};
79
+ -use rustc_infer::traits::ObligationCause;
80
+ use rustc_middle::hir::place::PlaceBase as HirPlaceBase;
81
+ use rustc_middle::middle::region;
82
+ use rustc_middle::mir::*;
83
+ @@ -41,7 +40,6 @@ use rustc_middle::thir::{self, ExprId, LocalVarId, Param, ParamId, PatKind, Thir
84
+ use rustc_middle::ty::{self, ScalarInt, Ty, TyCtxt, TypeVisitableExt, TypingMode};
85
+ use rustc_middle::{bug, span_bug};
86
+ use rustc_span::{Span, Symbol};
87
+ -use rustc_trait_selection::traits::ObligationCtxt;
88
+
89
+ use crate::builder::expr::as_place::PlaceBuilder;
90
+ use crate::builder::scope::LintLevel;
91
+ @@ -508,7 +506,17 @@ fn construct_fn<'tcx>(
92
+
93
+ let infcx = tcx.infer_ctxt().build(typing_mode);
94
+
95
+ - let coroutine = match normalized_type_of(&infcx, fn_def).kind() {
96
+ + let defining_ty = tcx.type_of(fn_def).instantiate_identity().skip_normalization();
97
+ + let defining_ty = if infcx.next_trait_solver() {
98
+ + // Closure types come from HIR typeck results, where they were already
99
+ + // normalized during writeback. Wrapping them in an `EarlyBinder`
100
+ + // conservatively makes aliases non-rigid, so restore their rigidness
101
+ + // instead of normalizing them again during MIR build.
102
+ + ty::set_aliases_to_rigid(tcx, defining_ty)
103
+ + } else {
104
+ + defining_ty
105
+ + };
106
+ + let coroutine = match defining_ty.kind() {
107
+ ty::Coroutine(_, args) => Some(Box::new(CoroutineInfo::initial(
108
+ tcx.coroutine_kind(fn_def).unwrap(),
109
+ args.as_coroutine().yield_ty(),
110
+ @@ -566,18 +574,6 @@ fn construct_fn<'tcx>(
111
+ body
112
+ }
113
+
114
+ -fn normalized_type_of<'tcx>(infcx: &InferCtxt<'tcx>, def_id: LocalDefId) -> Ty<'tcx> {
115
+ - let tcx = infcx.tcx;
116
+ - let ty = tcx.type_of(def_id).instantiate_identity();
117
+ - if !infcx.next_trait_solver() {
118
+ - return ty.skip_normalization();
119
+ - }
120
+ -
121
+ - let ocx = ObligationCtxt::new(infcx);
122
+ - let cause = ObligationCause::misc(tcx.def_span(def_id), def_id);
123
+ - ocx.deeply_normalize(&cause, tcx.param_env(def_id), ty).unwrap()
124
+ -}
125
+ -
126
+ fn construct_const<'a, 'tcx>(
127
+ tcx: TyCtxt<'tcx>,
128
+ def: LocalDefId,
129
+ diff --git a/compiler/rustc_type_ir/src/ty_kind.rs b/compiler/rustc_type_ir/src/ty_kind.rs
130
+ index 94e6be03c766f7d5d38687fa09a456197d366cc2..0a9eaf360e3efa99f0cf79a269c8ec5d3e211fb7 100644
131
+ --- a/compiler/rustc_type_ir/src/ty_kind.rs
132
+ +++ b/compiler/rustc_type_ir/src/ty_kind.rs
133
+ @@ -112,6 +112,12 @@ impl<I: Interner> AliasTyKind<I> {
134
+ /// with `IsRigid::Yes`. At this point we no longer have to try and renormalize this alias
135
+ /// later on.
136
+ ///
137
+ +/// Rigidness becomes outdated when the surrounding typing mode or param env changes,
138
+ +/// because further normalization might be possible.
139
+ +/// We should also note that rigidness can be shared within some typing mode groups
140
+ +/// if the param env is the same, e.g., `Typeck/PostTypeckUntilBorrowck` and
141
+ +/// `PostAnalysis/Codegen`.
142
+ +///
143
+ /// FIXME(#155345): Alias handling is currently still in flux for the new trait
144
+ /// solver and this is currently somewhat messy. Please reach out on
145
+ /// #t-types/trait-system-refactor-initiative if you encounter this and it isn't
patches/20261028T105419Z/rust-lang--rust-part009/1483f9b6e80530193d7b3b94b154a33b446643cb.patch ADDED
@@ -0,0 +1,305 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ diff --git a/compiler/rustc_macros/src/diagnostics/utils.rs b/compiler/rustc_macros/src/diagnostics/utils.rs
2
+ index 3cace48e3fb27229f3ae05996a866ac49423f471..b030f0e07b2d65db68cc7b2f8680d0d2c71be01b 100644
3
+ --- a/compiler/rustc_macros/src/diagnostics/utils.rs
4
+ +++ b/compiler/rustc_macros/src/diagnostics/utils.rs
5
+ @@ -13,7 +13,6 @@ use syn::spanned::Spanned;
6
+ use syn::{Attribute, Field, LitStr, Meta, Path, Token, Type, TypeTuple, parenthesized};
7
+ use synstructure::{BindingInfo, VariantInfo};
8
+
9
+ -use super::error::invalid_attr;
10
+ use crate::diagnostics::error::{
11
+ DiagnosticDeriveError, span_err, throw_invalid_attr, throw_span_err,
12
+ };
13
+ @@ -542,16 +541,6 @@ impl SuggestionKind {
14
+ }
15
+ }
16
+ }
17
+ -
18
+ - fn from_suffix(s: &str) -> Option<Self> {
19
+ - match s {
20
+ - "" => Some(SuggestionKind::Normal),
21
+ - "_short" => Some(SuggestionKind::Short),
22
+ - "_hidden" => Some(SuggestionKind::Hidden),
23
+ - "_verbose" => Some(SuggestionKind::Verbose),
24
+ - _ => None,
25
+ - }
26
+ - }
27
+ }
28
+
29
+ /// Types of subdiagnostics that can be created using attributes
30
+ @@ -569,7 +558,7 @@ pub(super) enum SubdiagnosticKind {
31
+ HelpOnce,
32
+ /// `#[warning(...)]`
33
+ Warn,
34
+ - /// `#[suggestion{,_short,_hidden,_verbose}]`
35
+ + /// `#[suggestion(..)]`
36
+ Suggestion {
37
+ suggestion_kind: SuggestionKind,
38
+ applicability: SpannedOption<Applicability>,
39
+ @@ -580,7 +569,7 @@ pub(super) enum SubdiagnosticKind {
40
+ /// `let __formatted_code = /* whatever */;`
41
+ code_init: TokenStream,
42
+ },
43
+ - /// `#[multipart_suggestion{,_short,_hidden,_verbose}]`
44
+ + /// `#[multipart_suggestion(..)]`
45
+ MultipartSuggestion {
46
+ suggestion_kind: SuggestionKind,
47
+ applicability: SpannedOption<Applicability>,
48
+ @@ -618,44 +607,18 @@ impl SubdiagnosticVariant {
49
+ "help" => SubdiagnosticKind::Help,
50
+ "help_once" => SubdiagnosticKind::HelpOnce,
51
+ "warning" => SubdiagnosticKind::Warn,
52
+ + "suggestion" => SubdiagnosticKind::Suggestion {
53
+ + suggestion_kind: SuggestionKind::Normal,
54
+ + applicability: None,
55
+ + code_field: new_code_ident(),
56
+ + code_init: TokenStream::new(),
57
+ + },
58
+ + "multipart_suggestion" => SubdiagnosticKind::MultipartSuggestion {
59
+ + suggestion_kind: SuggestionKind::Normal,
60
+ + applicability: None,
61
+ + },
62
+ _ => {
63
+ - // Recover old `#[(multipart_)suggestion_*]` syntaxes
64
+ - // FIXME(#100717): remove
65
+ - if let Some(suggestion_kind) =
66
+ - name.strip_prefix("suggestion").and_then(SuggestionKind::from_suffix)
67
+ - {
68
+ - if suggestion_kind != SuggestionKind::Normal {
69
+ - invalid_attr(attr)
70
+ - .help(format!(
71
+ - r#"Use `#[suggestion(..., style = "{suggestion_kind}")]` instead"#
72
+ - ))
73
+ - .emit();
74
+ - }
75
+ -
76
+ - SubdiagnosticKind::Suggestion {
77
+ - suggestion_kind: SuggestionKind::Normal,
78
+ - applicability: None,
79
+ - code_field: new_code_ident(),
80
+ - code_init: TokenStream::new(),
81
+ - }
82
+ - } else if let Some(suggestion_kind) =
83
+ - name.strip_prefix("multipart_suggestion").and_then(SuggestionKind::from_suffix)
84
+ - {
85
+ - if suggestion_kind != SuggestionKind::Normal {
86
+ - invalid_attr(attr)
87
+ - .help(format!(
88
+ - r#"Use `#[multipart_suggestion(..., style = "{suggestion_kind}")]` instead"#
89
+ - ))
90
+ - .emit();
91
+ - }
92
+ -
93
+ - SubdiagnosticKind::MultipartSuggestion {
94
+ - suggestion_kind: SuggestionKind::Normal,
95
+ - applicability: None,
96
+ - }
97
+ - } else {
98
+ - throw_invalid_attr!(attr);
99
+ - }
100
+ + throw_invalid_attr!(attr);
101
+ }
102
+ };
103
+
104
+ diff --git a/compiler/rustc_macros/src/lib.rs b/compiler/rustc_macros/src/lib.rs
105
+ index ec7495f95ac3aaabf294ce2c653d79c601c2ac84..f632862dc46274f5ff359f26b61a10c3eb0e35eb 100644
106
+ --- a/compiler/rustc_macros/src/lib.rs
107
+ +++ b/compiler/rustc_macros/src/lib.rs
108
+ @@ -191,10 +191,7 @@ decl_derive!(
109
+ primary_span,
110
+ label,
111
+ subdiagnostic,
112
+ - suggestion,
113
+ - suggestion_short,
114
+ - suggestion_hidden,
115
+ - suggestion_verbose)] =>
116
+ + suggestion)] =>
117
+ #[doc = "See <https://rustc-dev-guide.rust-lang.org/diagnostics/diagnostic-structs.html#derivediagnostic>"]
118
+ diagnostics::diagnostic_derive
119
+ );
120
+ @@ -209,12 +206,7 @@ decl_derive!(
121
+ warning,
122
+ subdiagnostic,
123
+ suggestion,
124
+ - suggestion_short,
125
+ - suggestion_hidden,
126
+ - suggestion_verbose,
127
+ multipart_suggestion,
128
+ - multipart_suggestion_short,
129
+ - multipart_suggestion_hidden,
130
+ // field attributes
131
+ primary_span,
132
+ suggestion_part,
133
+ diff --git a/src/doc/rustc-dev-guide/src/diagnostics/diagnostic-structs.md b/src/doc/rustc-dev-guide/src/diagnostics/diagnostic-structs.md
134
+ index 6a450909eb8a427331093d07ac84965db93b56df..d5a218dfa87c08a7983f1e1f3eba0083cd6a21b9 100644
135
+ --- a/src/doc/rustc-dev-guide/src/diagnostics/diagnostic-structs.md
136
+ +++ b/src/doc/rustc-dev-guide/src/diagnostics/diagnostic-structs.md
137
+ @@ -152,7 +152,7 @@ tcx.dcx().emit_err(FieldAlreadyDeclared {
138
+ - _Applied to struct or struct fields of type `Span`, `Option<()>`, `bool`, or `()`._
139
+ - Adds a warning subdiagnostic.
140
+ - Value is the warning's message.
141
+ -- `#[suggestion{,_hidden,_short,_verbose}("message", code = "...", applicability = "...")]`
142
+ +- `#[suggestion("message", code = "...", applicability = "...", style = "...")]`
143
+ (_Optional_)
144
+ - _Applied to `(Span, MachineApplicability)` or `Span` fields._
145
+ - Adds a suggestion subdiagnostic.
146
+ @@ -165,6 +165,9 @@ tcx.dcx().emit_err(FieldAlreadyDeclared {
147
+ - `applicability = "..."` (_Optional_)
148
+ - String which must be one of `machine-applicable`, `maybe-incorrect`,
149
+ `has-placeholders` or `unspecified`.
150
+ + - `style = "..."` (_Optional_)
151
+ + - Value is the style of the suggestion.
152
+ + - String which must be one of `normal`, `short`, `hidden`, `verbose` or `tool-only`.
153
+ - `#[subdiagnostic]`
154
+ - _Applied to a type that implements `Subdiagnostic` (from `#[derive(Subdiagnostic)]`)._
155
+ - Adds the subdiagnostic represented by the subdiagnostic struct.
156
+ @@ -209,7 +212,7 @@ Each `Subdiagnostic` should have one attribute applied to the struct or each var
157
+ - `#[note(..)]` for defining a note
158
+ - `#[help(..)]` for defining a help
159
+ - `#[warning(..)]` for defining a warning
160
+ -- `#[suggestion{,_hidden,_short,_verbose}(..)]` for defining a suggestion
161
+ +- `#[suggestion(..)]` for defining a suggestion
162
+
163
+ All of the above must provide a diagnostic message as the first positional argument.
164
+ See [translation documentation](./translation.md) to learn more about how
165
+ @@ -305,7 +308,7 @@ Additionally, subdiagnostics can access arguments from the main diagnostic with
166
+ - Message (_Mandatory_)
167
+ - The diagnostic message that will be shown to the user.
168
+ - See [translation documentation](./translation.md).
169
+ -- `#[suggestion{,_hidden,_short,_verbose}("message", code = "...", applicability = "...")]`
170
+ +- `#[suggestion("message", code = "...", applicability = "...", style = "...")]`
171
+ - _Applied to struct or enum variant.
172
+ Mutually exclusive with struct/enum variant attributes._
173
+ - _Mandatory_
174
+ @@ -324,13 +327,22 @@ Additionally, subdiagnostics can access arguments from the main diagnostic with
175
+ - `maybe-incorrect`
176
+ - `has-placeholders`
177
+ - `unspecified`
178
+ -- `#[multipart_suggestion{,_hidden,_short,_verbose}("message", applicability = "...")]`
179
+ + - `style = "..."` (_Optional_)
180
+ + - Value is the style of the suggestion.
181
+ + - String which must be one of:
182
+ + - `normal` (the default)
183
+ + - `short`
184
+ + - `hidden`
185
+ + - `verbose`
186
+ + - `tool-only`
187
+ +- `#[multipart_suggestion("message", applicability = "...", style = "...")]`
188
+ - _Applied to struct or enum variant.
189
+ Mutually exclusive with struct/enum variant attributes._
190
+ - _Mandatory_
191
+ - Defines the type to be representing a multipart suggestion.
192
+ - Message (_Mandatory_): see `#[suggestion]`
193
+ - `applicability = "..."` (_Optional_): see `#[suggestion]`
194
+ + - `style = "..."` (_Optional_): see `#[suggestion]`
195
+ - `#[primary_span]` (_Mandatory_ for labels and suggestions; _optional_ otherwise; not applicable
196
+ to multipart suggestions)
197
+ - _Applied to `Span` fields._
198
+ diff --git a/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive-inline.rs b/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive-inline.rs
199
+ index 1bec8ac03c981b5f58a74a8181f62d9d746e9df0..1d60b3e0733ecc226afe2f352a439e960f7a61e8 100644
200
+ --- a/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive-inline.rs
201
+ +++ b/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive-inline.rs
202
+ @@ -746,7 +746,8 @@ struct SuggestionStyleTwice {
203
+
204
+ #[derive(Subdiagnostic)]
205
+ #[suggestion_hidden("example message", code = "")]
206
+ -//~^ ERROR #[suggestion_hidden(...)]` is not a valid attribute
207
+ +//~^ ERROR cannot find attribute `suggestion_hidden` in this scope
208
+ +//~| ERROR derive(Diagnostic): `#[suggestion_hidden(...)]` is not a valid attribute
209
+ struct SuggestionStyleOldSyntax {
210
+ #[primary_span]
211
+ sub: Span,
212
+ @@ -754,7 +755,8 @@ struct SuggestionStyleOldSyntax {
213
+
214
+ #[derive(Subdiagnostic)]
215
+ #[suggestion_hidden("example message", code = "", style = "normal")]
216
+ -//~^ ERROR #[suggestion_hidden(...)]` is not a valid attribute
217
+ +//~^ ERROR cannot find attribute `suggestion_hidden` in this scope
218
+ +//~| ERROR derive(Diagnostic): `#[suggestion_hidden(...)]` is not a valid attribute
219
+ struct SuggestionStyleOldAndNewSyntax {
220
+ #[primary_span]
221
+ sub: Span,
222
+ diff --git a/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive-inline.stderr b/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive-inline.stderr
223
+ index cf3c9dd9ce10d52661b1ab68046f7132eba3e6dc..23999437d28768318293bb0e9caea5e50e5796c0 100644
224
+ --- a/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive-inline.stderr
225
+ +++ b/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive-inline.stderr
226
+ @@ -439,19 +439,15 @@ error: derive(Diagnostic): `#[suggestion_hidden(...)]` is not a valid attribute
227
+ |
228
+ LL | #[suggestion_hidden("example message", code = "")]
229
+ | ^
230
+ - |
231
+ - = help: Use `#[suggestion(..., style = "hidden")]` instead
232
+
233
+ error: derive(Diagnostic): `#[suggestion_hidden(...)]` is not a valid attribute
234
+ - --> $DIR/subdiagnostic-derive-inline.rs:756:1
235
+ + --> $DIR/subdiagnostic-derive-inline.rs:757:1
236
+ |
237
+ LL | #[suggestion_hidden("example message", code = "", style = "normal")]
238
+ | ^
239
+ - |
240
+ - = help: Use `#[suggestion(..., style = "hidden")]` instead
241
+
242
+ error: derive(Diagnostic): invalid suggestion style
243
+ - --> $DIR/subdiagnostic-derive-inline.rs:764:52
244
+ + --> $DIR/subdiagnostic-derive-inline.rs:766:52
245
+ |
246
+ LL | #[suggestion("example message", code = "", style = "foo")]
247
+ | ^^^^^
248
+ @@ -459,25 +455,25 @@ LL | #[suggestion("example message", code = "", style = "foo")]
249
+ = help: valid styles are `normal`, `short`, `hidden`, `verbose` and `tool-only`
250
+
251
+ error: expected string literal
252
+ - --> $DIR/subdiagnostic-derive-inline.rs:772:52
253
+ + --> $DIR/subdiagnostic-derive-inline.rs:774:52
254
+ |
255
+ LL | #[suggestion("example message", code = "", style = 42)]
256
+ | ^^
257
+
258
+ error: expected `=`
259
+ - --> $DIR/subdiagnostic-derive-inline.rs:780:49
260
+ + --> $DIR/subdiagnostic-derive-inline.rs:782:49
261
+ |
262
+ LL | #[suggestion("example message", code = "", style)]
263
+ | ^
264
+
265
+ error: expected `=`
266
+ - --> $DIR/subdiagnostic-derive-inline.rs:788:49
267
+ + --> $DIR/subdiagnostic-derive-inline.rs:790:49
268
+ |
269
+ LL | #[suggestion("example message", code = "", style("foo"))]
270
+ | ^
271
+
272
+ error: derive(Diagnostic): `#[primary_span]` is not a valid attribute
273
+ - --> $DIR/subdiagnostic-derive-inline.rs:799:5
274
+ + --> $DIR/subdiagnostic-derive-inline.rs:801:5
275
+ |
276
+ LL | #[primary_span]
277
+ | ^
278
+ @@ -486,7 +482,7 @@ LL | #[primary_span]
279
+ = help: to create a suggestion with multiple spans, use `#[multipart_suggestion]` instead
280
+
281
+ error: derive(Diagnostic): suggestion without `#[primary_span]` field
282
+ - --> $DIR/subdiagnostic-derive-inline.rs:796:1
283
+ + --> $DIR/subdiagnostic-derive-inline.rs:798:1
284
+ |
285
+ LL | #[suggestion("example message", code = "")]
286
+ | ^
287
+ @@ -545,5 +541,17 @@ error: cannot find attribute `bar` in this scope
288
+ LL | #[bar("...")]
289
+ | ^^^
290
+
291
+ -error: aborting due to 82 previous errors
292
+ +error: cannot find attribute `suggestion_hidden` in this scope
293
+ + --> $DIR/subdiagnostic-derive-inline.rs:748:3
294
+ + |
295
+ +LL | #[suggestion_hidden("example message", code = "")]
296
+ + | ^^^^^^^^^^^^^^^^^
297
+ +
298
+ +error: cannot find attribute `suggestion_hidden` in this scope
299
+ + --> $DIR/subdiagnostic-derive-inline.rs:757:3
300
+ + |
301
+ +LL | #[suggestion_hidden("example message", code = "", style = "normal")]
302
+ + | ^^^^^^^^^^^^^^^^^
303
+ +
304
+ +error: aborting due to 84 previous errors
305
+
patches/20261028T105419Z/rust-lang--rust-part009/1ad04856b8374eb74cb8d98d90ae67da05fc5978.patch ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ diff --git a/RELEASES.md b/RELEASES.md
2
+ index f2d74f2e7f1f04a39239db4cd83fa7a616268407..34984a29eff5192fa9605a52ebd93dd9407f4f26 100644
3
+ --- a/RELEASES.md
4
+ +++ b/RELEASES.md
5
+ @@ -1,3 +1,10 @@
6
+ +Version 1.98.1 (2026-09-03)
7
+ +===========================
8
+ +
9
+ +<a id="1.98.1"></a>
10
+ +
11
+ +* [rustc: fix miscompilation in generating vtables](https://github.com/rust-lang/rust/issues/161441)
12
+ +
13
+ Version 1.98.0 (2026-08-20)
14
+ ==========================
15
+
patches/20261028T105419Z/rust-lang--rust-part009/1c4440205607cd18ccfb30abe065bf0f62b5dd18.patch ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ diff --git a/compiler/rustc_codegen_llvm/src/coverageinfo/llvm_cov.rs b/compiler/rustc_codegen_llvm/src/coverageinfo/llvm_cov.rs
2
+ index a58202834cfa53da1defb308d4752b291fa0f7c5..93d0b09578315d06f99044cac41e5480a89b6743 100644
3
+ --- a/compiler/rustc_codegen_llvm/src/coverageinfo/llvm_cov.rs
4
+ +++ b/compiler/rustc_codegen_llvm/src/coverageinfo/llvm_cov.rs
5
+ @@ -64,7 +64,7 @@ pub(crate) fn write_filenames_to_buffer(filenames: &[impl AsRef<str>]) -> Vec<u8
6
+ ///
7
+ /// Each field name has a `_regions` suffix for improved readability after
8
+ /// exhaustive destructing, which ensures that all region types are handled.
9
+ -#[derive(Clone, Debug, Default)]
10
+ +#[derive(Debug, Default)]
11
+ pub(crate) struct Regions {
12
+ pub(crate) code_regions: Vec<ffi::CodeRegion>,
13
+ pub(crate) expansion_regions: Vec<ffi::ExpansionRegion>,
14
+ diff --git a/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs b/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs
15
+ index 18818fd1a56c078d8b7227a88bf47950ab114725..e9543ebeecf99ee6a2274080b3620d73c4144539 100644
16
+ --- a/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs
17
+ +++ b/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs
18
+ @@ -74,7 +74,7 @@ pub(crate) fn finalize(cx: &mut CodegenCx<'_, '_>) {
19
+ unused::prepare_covfun_records_for_unused_functions(cx, &mut covfun_records);
20
+ }
21
+
22
+ - // If there are no covfun records for this CGU, don't generate a covmap record.
23
+ + // If there are no covfun records for this CGU, don't emit a covmap record.
24
+ // Emitting a covmap record without any covfun records causes `llvm-cov` to
25
+ // fail when generating coverage reports, and if there are no covfun records
26
+ // then the covmap record isn't useful anyway.
27
+ @@ -89,13 +89,13 @@ pub(crate) fn finalize(cx: &mut CodegenCx<'_, '_>) {
28
+ GlobalFileTable::build(tcx, covfun_records.iter().flat_map(|c| c.all_source_files()));
29
+
30
+ for covfun in &covfun_records {
31
+ - covfun::generate_covfun_record(cx, &global_file_table, covfun)
32
+ + covfun::emit_covfun_record(cx, &global_file_table, covfun);
33
+ }
34
+
35
+ - // Generate the coverage map header, which contains the filenames used by
36
+ + // Emit the coverage map header, which contains the filenames used by
37
+ // this CGU's coverage mappings, and store it in a well-known global.
38
+ // (This is skipped if we returned early due to having no covfun records.)
39
+ - generate_covmap_record(cx, covmap_version, &global_file_table.filenames_buffer);
40
+ + emit_covmap_record(cx, covmap_version, &global_file_table.filenames_buffer);
41
+ }
42
+
43
+ /// Maps "global" (per-CGU) file ID numbers to their underlying source file paths.
44
+ @@ -218,10 +218,10 @@ impl VirtualFileMapping {
45
+ }
46
+ }
47
+
48
+ -/// Generates the contents of the covmap record for this CGU, which mostly
49
+ -/// consists of a header and a list of filenames. The record is then stored
50
+ +/// Generates and emits the covmap record for this CGU, which mostly
51
+ +/// consists of a header and a list of filenames. The record is emitted
52
+ /// as a global variable in the `__llvm_covmap` section.
53
+ -fn generate_covmap_record<'ll>(
54
+ +fn emit_covmap_record<'ll>(
55
+ cx: &mut CodegenCx<'ll, '_>,
56
+ version: CovmapVersion,
57
+ filenames_buffer: &[u8],
58
+ diff --git a/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen/covfun.rs b/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen/covfun.rs
59
+ index 28985448fd1c195f63fe8029de262de9d8f9a2e5..b83570911c3a03e97c607568dc501442d2e6b4da 100644
60
+ --- a/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen/covfun.rs
61
+ +++ b/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen/covfun.rs
62
+ @@ -77,15 +77,15 @@ pub(crate) fn prepare_covfun_record<'tcx>(
63
+ Some(covfun)
64
+ }
65
+
66
+ -pub(crate) fn counter_for_term(term: CovTerm) -> ffi::Counter {
67
+ - use ffi::Counter;
68
+ +fn counter_for_term(term: CovTerm) -> ffi::Counter {
69
+ match term {
70
+ - CovTerm::Zero => Counter::ZERO,
71
+ - CovTerm::Counter(id) => {
72
+ - Counter { kind: ffi::CounterKind::CounterValueReference, id: CounterId::as_u32(id) }
73
+ - }
74
+ + CovTerm::Zero => ffi::Counter::ZERO,
75
+ + CovTerm::Counter(id) => ffi::Counter {
76
+ + kind: ffi::CounterKind::CounterValueReference,
77
+ + id: CounterId::as_u32(id),
78
+ + },
79
+ CovTerm::Expression(id) => {
80
+ - Counter { kind: ffi::CounterKind::Expression, id: ExpressionId::as_u32(id) }
81
+ + ffi::Counter { kind: ffi::CounterKind::Expression, id: ExpressionId::as_u32(id) }
82
+ }
83
+ }
84
+ }
85
+ @@ -174,10 +174,10 @@ fn fill_region_tables<'tcx>(
86
+ }
87
+ }
88
+
89
+ -/// Generates the contents of the covfun record for this function, which
90
+ -/// contains the function's coverage mapping data. The record is then stored
91
+ +/// Generates and emits the covfun record for this function, which
92
+ +/// contains the function's coverage mapping data. The record is emitted
93
+ /// as a global variable in the `__llvm_covfun` section.
94
+ -pub(crate) fn generate_covfun_record<'tcx>(
95
+ +pub(crate) fn emit_covfun_record<'tcx>(
96
+ cx: &mut CodegenCx<'_, 'tcx>,
97
+ global_file_table: &GlobalFileTable,
98
+ covfun: &CovfunRecord<'tcx>,
patches/20261028T105419Z/rust-lang--rust-part009/1d7375898dacaaeed8046891066b0e2b58f488c4.patch ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ diff --git a/compiler/rustc_codegen_llvm/src/diagnostics.rs b/compiler/rustc_codegen_llvm/src/diagnostics.rs
2
+ index 54f8ffbb881da29b549ed0dfc09febaea079f606..fb43b36fe39b908ddb2bc021bd124692676cac82 100644
3
+ --- a/compiler/rustc_codegen_llvm/src/diagnostics.rs
4
+ +++ b/compiler/rustc_codegen_llvm/src/diagnostics.rs
5
+ @@ -1,4 +1,4 @@
6
+ -use std::ffi::CString;
7
+ +use std::ffi::{CString, c_uint};
8
+ use std::path::Path;
9
+
10
+ use rustc_data_structures::small_c_str::SmallCStr;
11
+ @@ -265,3 +265,15 @@ pub(crate) struct IntrinsicWrongArch<'a> {
12
+ pub(crate) struct UnknownLlvmTargetFeaturePrefix<'a> {
13
+ pub feature: &'a str,
14
+ }
15
+ +
16
+ +#[derive(Diagnostic)]
17
+ +#[diag(
18
+ + "LLVM version mismatch: this compiler was built for LLVM {$expected_version}, but LLVM {$llvm_major}.{$llvm_minor}.{$llvm_patch} was found{$dll_loc}"
19
+ +)]
20
+ +pub(crate) struct LlvmVersionMismatch<'a> {
21
+ + pub expected_version: c_uint,
22
+ + pub llvm_major: c_uint,
23
+ + pub llvm_minor: c_uint,
24
+ + pub llvm_patch: c_uint,
25
+ + pub dll_loc: &'a str,
26
+ +}
27
+ diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs
28
+ index 9819699ca5228c8e79a10d4e0aacb0ab57674cec..82ddcca3e15305e8a49fae4a444c437a4b9acb68 100644
29
+ --- a/compiler/rustc_codegen_llvm/src/llvm_util.rs
30
+ +++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs
31
+ @@ -56,20 +56,17 @@ unsafe fn configure_llvm(sess: &Session) {
32
+ llvm::LLVMGetVersion(&mut llvm_major, &mut llvm_minor, &mut llvm_patch);
33
+ let expected_version = llvm::LLVMRustVersionMajor();
34
+ if llvm_major != expected_version {
35
+ - panic!(
36
+ - concat!(
37
+ - "LLVM version mismatch: this compiler was built for LLVM {}, ",
38
+ - "but LLVM {}.{}.{} was found{}"
39
+ - ),
40
+ + sess.dcx().emit_fatal(diagnostics::LlvmVersionMismatch {
41
+ expected_version,
42
+ llvm_major,
43
+ llvm_minor,
44
+ llvm_patch,
45
+ - match rustc_session::filesearch::dll_path(llvm::LLVMGetVersion as *mut _) {
46
+ + dll_loc: &match rustc_session::filesearch::dll_path(llvm::LLVMGetVersion as *mut _)
47
+ + {
48
+ Ok(path) => format!(" at {}", path.display()),
49
+ Err(_) => String::new(),
50
+ - }
51
+ - );
52
+ + },
53
+ + })
54
+ }
55
+ }
56
+
57
+ diff --git a/compiler/rustc_macros/src/diagnostics/message.rs b/compiler/rustc_macros/src/diagnostics/message.rs
58
+ index 63561e409b0ae60acd1dce4b1770859ca2399b35..8eff9a4fa9e8a5d9bb10565cc3f49aec9410ce2d 100644
59
+ --- a/compiler/rustc_macros/src/diagnostics/message.rs
60
+ +++ b/compiler/rustc_macros/src/diagnostics/message.rs
61
+ @@ -133,6 +133,7 @@ const ALLOWED_CAPITALIZED_WORDS: &[&str] = &[
62
+ "Cargo",
63
+ "Ferris",
64
+ "GCC",
65
+ + "LLVM",
66
+ "MIR",
67
+ "NaNs",
68
+ "OK",
patches/20261028T105419Z/rust-lang--rust-part009/2039641f6574ca041cc1fb66cf67e4610c8ca98d.patch ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ diff --git a/compiler/rustc_infer/src/infer/mod.rs b/compiler/rustc_infer/src/infer/mod.rs
2
+ index a49a4355b66b16a2c118dd1cdf4ff143ccd2f624..b25736112027ca85c860e04421e477c143f8fa9c 100644
3
+ --- a/compiler/rustc_infer/src/infer/mod.rs
4
+ +++ b/compiler/rustc_infer/src/infer/mod.rs
5
+ @@ -89,10 +89,11 @@ pub(crate) type UnificationTable<'a, 'tcx, T> = ut::UnificationTable<
6
+ ut::InPlace<T, &'a mut ut::UnificationStorage<T>, &'a mut InferCtxtUndoLogs<'tcx>>,
7
+ >;
8
+
9
+ -/// This type contains all the things within `InferCtxt` that sit within a
10
+ -/// `RefCell` and are involved with taking/rolling back snapshots. Snapshot
11
+ -/// operations are hot enough that we want only one call to `borrow_mut` per
12
+ -/// call to `start_snapshot` and `rollback_to`.
13
+ +/// This type contains all the things within [`InferCtxt`] that sit within a
14
+ +/// [`RefCell`] and are involved with taking/rolling back snapshots. Snapshot
15
+ +/// operations are hot enough that we want only one call to
16
+ +/// [`RefCell::borrow_mut`] per call to [`InferCtxt::start_snapshot`] and
17
+ +/// [`InferCtxt::rollback_to`].
18
+ #[derive(Clone)]
19
+ pub struct InferCtxtInner<'tcx> {
20
+ undo_log: InferCtxtUndoLogs<'tcx>,
21
+ @@ -102,7 +103,10 @@ pub struct InferCtxtInner<'tcx> {
22
+ /// This cache is snapshotted along with the infcx.
23
+ projection_cache: traits::ProjectionCacheStorage<'tcx>,
24
+
25
+ - /// We instantiate `UnificationTable` with `bounds<Ty>` because the types
26
+ + /// Primary map of inference variables to the types that they currently
27
+ + /// represent.
28
+ + ///
29
+ + /// We instantiate [`UnificationTable`] with `bounds<Ty>` because the types
30
+ /// that might instantiate a general type variable have an order,
31
+ /// represented by its upper and lower bounds.
32
+ type_variable_storage: type_variable::TypeVariableStorage<'tcx>,
patches/20261028T105419Z/rust-lang--rust-part009/2060175f5af18b4100acf5995979f4bfb31a000c.patch ADDED
The diff for this file is too large to render. See raw diff
 
patches/20261028T105419Z/rust-lang--rust-part009/21228c2dfa1a8afda35130d0fd59979ed6c34937.patch ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/suggest.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/suggest.rs
2
+ index db852701051cf7dcb4b719b95157cb31a2c6b5e3..577571196a239d5e406fe9bf132eefce0be19ee7 100644
3
+ --- a/compiler/rustc_trait_selection/src/error_reporting/infer/suggest.rs
4
+ +++ b/compiler/rustc_trait_selection/src/error_reporting/infer/suggest.rs
5
+ @@ -521,7 +521,9 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
6
+ let found_sig =
7
+ self.normalize_fn_sig(self.tcx.fn_sig(*did2).instantiate(self.tcx, args2));
8
+
9
+ - if self.same_type_modulo_infer(expected_sig, found_sig) {
10
+ + let expected_sig_anon = self.tcx.anonymize_bound_vars(expected_sig);
11
+ + let found_sig_anon = self.tcx.anonymize_bound_vars(found_sig);
12
+ + if self.same_type_modulo_infer(expected_sig_anon, found_sig_anon) {
13
+ diag.subdiagnostic(FnUniqTypes);
14
+ }
15
+
16
+ diff --git a/tests/ui/fn/fn-item-type-note-late-bound-145558.rs b/tests/ui/fn/fn-item-type-note-late-bound-145558.rs
17
+ index 2463e2ba7067540ecdca1c53da14eb24be3717fb..3e8fc0e8b14a72480eda08d258faf534df537da0 100644
18
+ --- a/tests/ui/fn/fn-item-type-note-late-bound-145558.rs
19
+ +++ b/tests/ui/fn/fn-item-type-note-late-bound-145558.rs
20
+ @@ -16,4 +16,5 @@ fn main() {
21
+ map.push(f1);
22
+ map.push(f2);
23
+ //~^ ERROR mismatched types
24
+ + //~| NOTE different fn items have unique types
25
+ }
26
+ diff --git a/tests/ui/fn/fn-item-type-note-late-bound-145558.stderr b/tests/ui/fn/fn-item-type-note-late-bound-145558.stderr
27
+ index 31d773c7e4a797ea0b21f9f5908046203e246d03..bf0a1c3316e57ae8b8a66d5b12c6eb4a3fceb117 100644
28
+ --- a/tests/ui/fn/fn-item-type-note-late-bound-145558.stderr
29
+ +++ b/tests/ui/fn/fn-item-type-note-late-bound-145558.stderr
30
+ @@ -12,6 +12,7 @@ LL | map.push(f2);
31
+ |
32
+ = note: expected fn item `for<'a> fn(&'a A) {f1}`
33
+ found fn item `for<'a> fn(&'a A) {f2}`
34
+ + = note: different fn items have unique types, even if their signatures are the same
35
+ note: method defined here
36
+ --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
37
+
patches/20261028T105419Z/rust-lang--rust-part009/27ee86c0606742c491037219354eacdd7b0bdcc0.patch ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ diff --git a/RELEASES.md b/RELEASES.md
2
+ index f2d74f2e7f1f04a39239db4cd83fa7a616268407..34984a29eff5192fa9605a52ebd93dd9407f4f26 100644
3
+ --- a/RELEASES.md
4
+ +++ b/RELEASES.md
5
+ @@ -1,3 +1,10 @@
6
+ +Version 1.98.1 (2026-09-03)
7
+ +===========================
8
+ +
9
+ +<a id="1.98.1"></a>
10
+ +
11
+ +* [rustc: fix miscompilation in generating vtables](https://github.com/rust-lang/rust/issues/161441)
12
+ +
13
+ Version 1.98.0 (2026-08-20)
14
+ ==========================
15
+
patches/20261028T105419Z/rust-lang--rust-part009/27f7c65c12d5629df79d121b6242a1a8e8dd8320.patch ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ diff --git a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
2
+ index 6fd78c6bde4bec32ffde93be87fcf54750e686a3..e77d63d91703bbf7c66f000d101dfd4f1e037304 100644
3
+ --- a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
4
+ +++ b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
5
+ @@ -66,10 +66,8 @@ using namespace llvm;
6
+
7
+ static codegen::RegisterCodeGenFlags CGF;
8
+
9
+ -typedef struct LLVMOpaquePass *LLVMPassRef;
10
+ typedef struct LLVMOpaqueTargetMachine *LLVMTargetMachineRef;
11
+
12
+ -DEFINE_STDCXX_CONVERSION_FUNCTIONS(Pass, LLVMPassRef)
13
+ DEFINE_STDCXX_CONVERSION_FUNCTIONS(TargetMachine, LLVMTargetMachineRef)
14
+
15
+ extern "C" void LLVMRustTimeTraceProfilerInitialize() {
patches/20261028T105419Z/rust-lang--rust-part009/2a534f5f34829daed828deb0a3106159bb249ab9.patch ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ diff --git a/compiler/rustc_attr_parsing/src/attributes/doc.rs b/compiler/rustc_attr_parsing/src/attributes/doc.rs
2
+ index e315d6abea395c41df106f7d85fbdc838a411539..6cce64d700a63d432893450470a2d41b25a22e1b 100644
3
+ --- a/compiler/rustc_attr_parsing/src/attributes/doc.rs
4
+ +++ b/compiler/rustc_attr_parsing/src/attributes/doc.rs
5
+ @@ -43,7 +43,7 @@ fn check_keyword(cx: &mut AcceptContext<'_, '_>, keyword: Symbol, span: Span) ->
6
+
7
+ fn check_attribute(cx: &mut AcceptContext<'_, '_>, attribute: Symbol, span: Span) -> bool {
8
+ // FIXME: This should support attributes with namespace like `diagnostic::do_not_recommend`.
9
+ - if rustc_feature::BUILTIN_ATTRIBUTE_MAP.contains(&attribute) {
10
+ + if rustc_feature::BUILTIN_ATTRIBUTE_SET.contains(&attribute) {
11
+ return true;
12
+ }
13
+ cx.emit_err(DocAttributeNotAttribute { span, attribute });
14
+ diff --git a/compiler/rustc_attr_parsing/src/interface.rs b/compiler/rustc_attr_parsing/src/interface.rs
15
+ index aef7dd48ec664f5e63b840cd7f898e42623b84e6..240f437828259b5b4db1ad1041172b0453bdb5fa 100644
16
+ --- a/compiler/rustc_attr_parsing/src/interface.rs
17
+ +++ b/compiler/rustc_attr_parsing/src/interface.rs
18
+ @@ -10,7 +10,7 @@ use rustc_attr_ir::target::Target;
19
+ use rustc_attr_ir::{AttrArgs, AttrItem, AttrPath, Attribute, AttributeKind, HashIgnoredAttrId};
20
+ use rustc_data_structures::sync::{DynSend, DynSync};
21
+ use rustc_errors::{Diag, DiagCtxtHandle, Diagnostic, Level, MultiSpan};
22
+ -use rustc_feature::{BUILTIN_ATTRIBUTE_MAP, Features};
23
+ +use rustc_feature::{BUILTIN_ATTRIBUTE_SET, Features};
24
+ use rustc_lint_defs::{LintId, RegisteredTools};
25
+ use rustc_session::Session;
26
+ use rustc_span::{DUMMY_SP, ErrorGuaranteed, Span, Symbol, sym};
27
+ @@ -376,7 +376,7 @@ impl<'sess> AttributeParser<'sess> {
28
+ );
29
+ self.check_attribute_stability(&attr_path, attr_span, accept.stability);
30
+ if let [part] = parts.as_slice() {
31
+ - debug_assert!(BUILTIN_ATTRIBUTE_MAP.contains(part));
32
+ + debug_assert!(BUILTIN_ATTRIBUTE_SET.contains(part));
33
+ }
34
+
35
+ let Some(args) = ArgParser::from_attr_args(
36
+ diff --git a/compiler/rustc_attr_parsing/src/validate_attr.rs b/compiler/rustc_attr_parsing/src/validate_attr.rs
37
+ index f225458ebc0e63b086e9032e4838e1245ecd903a..4719ee5103877423c29bd7aa7c9ab6c9004b0d60 100644
38
+ --- a/compiler/rustc_attr_parsing/src/validate_attr.rs
39
+ +++ b/compiler/rustc_attr_parsing/src/validate_attr.rs
40
+ @@ -11,7 +11,7 @@ use rustc_ast::{
41
+ };
42
+ use rustc_attr_ir::AttrPath;
43
+ use rustc_errors::{Applicability, Diagnostic, PResult};
44
+ -use rustc_feature::BUILTIN_ATTRIBUTE_MAP;
45
+ +use rustc_feature::BUILTIN_ATTRIBUTE_SET;
46
+ use rustc_lint_defs::builtin::ILL_FORMED_ATTRIBUTE_INPUT;
47
+ use rustc_parse::parse_in;
48
+ use rustc_session::diagnostics::report_lit_error;
49
+ @@ -27,7 +27,7 @@ pub fn check_attr(psess: &ParseSess, attr: &Attribute) {
50
+ AttrKind::Synthetic(CfgTrace(_) | CfgAttrTrace(_)) | AttrKind::DocComment(..) => return,
51
+ }
52
+
53
+ - let builtin_attr_info = attr.name().and_then(|name| BUILTIN_ATTRIBUTE_MAP.get(&name));
54
+ + let builtin_attr_info = attr.name().and_then(|name| BUILTIN_ATTRIBUTE_SET.get(&name));
55
+
56
+ // Check input tokens for built-in and key-value attributes.
57
+ if let Some(name) = builtin_attr_info {
58
+ diff --git a/compiler/rustc_feature/src/builtin_attrs.rs b/compiler/rustc_feature/src/builtin_attrs.rs
59
+ index cc5b8ff2238eaab16b76dbc876c23650b0b35672..7403a0eb0adbd4f5469461e8b7f0f29fae5ed513 100644
60
+ --- a/compiler/rustc_feature/src/builtin_attrs.rs
61
+ +++ b/compiler/rustc_feature/src/builtin_attrs.rs
62
+ @@ -417,15 +417,15 @@ pub static BUILTIN_ATTRIBUTES: &[Symbol] = &[
63
+ ];
64
+
65
+ pub fn is_builtin_attr_name(name: Symbol) -> bool {
66
+ - BUILTIN_ATTRIBUTE_MAP.get(&name).is_some()
67
+ + BUILTIN_ATTRIBUTE_SET.contains(&name)
68
+ }
69
+
70
+ -pub static BUILTIN_ATTRIBUTE_MAP: LazyLock<FxHashSet<Symbol>> = LazyLock::new(|| {
71
+ - let mut map = FxHashSet::default();
72
+ +pub static BUILTIN_ATTRIBUTE_SET: LazyLock<FxHashSet<Symbol>> = LazyLock::new(|| {
73
+ + let mut set = FxHashSet::default();
74
+ for attr in BUILTIN_ATTRIBUTES.iter() {
75
+ - if !map.insert(*attr) {
76
+ + if !set.insert(*attr) {
77
+ panic!("duplicate builtin attribute `{}`", attr);
78
+ }
79
+ }
80
+ - map
81
+ + set
82
+ });
83
+ diff --git a/compiler/rustc_feature/src/lib.rs b/compiler/rustc_feature/src/lib.rs
84
+ index 859b2025619e45a52426ecdba213ab985fdc7a06..a3821ab940b15e6f80ae68c36ff28a4fd582ff41 100644
85
+ --- a/compiler/rustc_feature/src/lib.rs
86
+ +++ b/compiler/rustc_feature/src/lib.rs
87
+ @@ -129,7 +129,7 @@ pub fn find_feature_issue(feature: Symbol, issue: GateIssue) -> Option<NonZero<u
88
+
89
+ pub use accepted::ACCEPTED_LANG_FEATURES;
90
+ pub use builtin_attrs::{
91
+ - AttributeStability, BUILTIN_ATTRIBUTE_MAP, BUILTIN_ATTRIBUTES, GatedCfg, find_gated_cfg,
92
+ + AttributeStability, BUILTIN_ATTRIBUTE_SET, BUILTIN_ATTRIBUTES, GatedCfg, find_gated_cfg,
93
+ is_builtin_attr_name,
94
+ };
95
+ pub use removed::REMOVED_LANG_FEATURES;
96
+ diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs
97
+ index c3d19542c1645aaf3aaad4ae4b9d612a903620ea..2db25a7a30f624a8b34398dd9a3f8742cdb3ab49 100644
98
+ --- a/compiler/rustc_passes/src/check_attr.rs
99
+ +++ b/compiler/rustc_passes/src/check_attr.rs
100
+ @@ -13,7 +13,7 @@ use rustc_ast::{AttrStyle, MetaItemKind, ast};
101
+ use rustc_attr_parsing::AttributeParser;
102
+ use rustc_data_structures::thin_vec::ThinVec;
103
+ use rustc_errors::{DiagCtxtHandle, IntoDiagArg, MultiSpan, msg};
104
+ -use rustc_feature::BUILTIN_ATTRIBUTE_MAP;
105
+ +use rustc_feature::BUILTIN_ATTRIBUTE_SET;
106
+ use rustc_hir::attrs::diagnostic::Directive;
107
+ use rustc_hir::attrs::lang_items::LangItem;
108
+ use rustc_hir::attrs::{
109
+ @@ -146,7 +146,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
110
+ [sym::allow | sym::expect | sym::warn | sym::deny | sym::forbid, ..] => {}
111
+
112
+ [name, rest @ ..] => {
113
+ - if let Some(_) = BUILTIN_ATTRIBUTE_MAP.get(name) {
114
+ + if BUILTIN_ATTRIBUTE_SET.contains(name) {
115
+ if rest.len() > 0
116
+ && AttributeParser::is_parsed_attribute(slice::from_ref(name))
117
+ {
118
+ diff --git a/src/doc/rustc-dev-guide/src/feature-gate-check.md b/src/doc/rustc-dev-guide/src/feature-gate-check.md
119
+ index 0b4fc0cd680c067430639735c130fc2551737801..7726122b02f3886c9a1819408d132b15f313e388 100644
120
+ --- a/src/doc/rustc-dev-guide/src/feature-gate-check.md
121
+ +++ b/src/doc/rustc-dev-guide/src/feature-gate-check.md
122
+ @@ -100,7 +100,7 @@ Beyond syntax, rustc also gates attributes and `cfg` options.
123
+
124
+ ### Built-in attributes
125
+
126
+ -- [`rustc_ast_passes::check_attribute`] inspects attributes against `BUILTIN_ATTRIBUTE_MAP`.
127
+ +- [`rustc_ast_passes::check_attribute`] inspects attributes against `BUILTIN_ATTRIBUTE_SET`.
128
+ - If the attribute is `AttributeGate::Gated` and the feature isn’t enabled,
129
+ `feature_err` is emitted.
130
+
patches/20261028T105419Z/rust-lang--rust-part009/2da32405305a277a14178b259604f518ce31276a.patch ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs
2
+ index 1210a3ef57e328eee13e40c3757af5c086b9b1d8..35449284b5093e33196389aec832abf2ecc37caa 100644
3
+ --- a/compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs
4
+ +++ b/compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs
5
+ @@ -1374,7 +1374,12 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
6
+ (ty::Alias(kind1, alias1), ty::Alias(kind2, alias2)) if kind1 == kind2 => {
7
+ let mut values = (DiagStyledString::new(), DiagStyledString::new());
8
+ match (alias1.kind, alias2.kind) {
9
+ - (ty::Projection { def_id: def_id1 }, ty::Projection { def_id: def_id2 }) => {
10
+ + (ty::Projection { def_id: def_id1 }, ty::Projection { def_id: def_id2 })
11
+ + // RPITIT projections use anonymous associated type and have no item name,
12
+ + // so it will be ICE from call of `tcx.item_name(def_id)` below, issue #161915.
13
+ + if !self.tcx.is_impl_trait_in_trait(def_id1)
14
+ + && !self.tcx.is_impl_trait_in_trait(def_id2) =>
15
+ + {
16
+ // `<Type as Trait>::Name<args>`
17
+ values.0.push_normal("<");
18
+ values.1.push_normal("<");
19
+ diff --git a/tests/ui/impl-trait/in-trait/rpitit-mismatch-missing-item-name-issue-161915.rs b/tests/ui/impl-trait/in-trait/rpitit-mismatch-missing-item-name-issue-161915.rs
20
+ new file mode 100644
21
+ index 0000000000000000000000000000000000000000..2f28b14d746774defca7ec054d4d79cfc0df3d69
22
+ --- /dev/null
23
+ +++ b/tests/ui/impl-trait/in-trait/rpitit-mismatch-missing-item-name-issue-161915.rs
24
+ @@ -0,0 +1,17 @@
25
+ +//! Regression test for <https://github.com/rust-lang/rust/issues/161915>.
26
+ +//! Mismatched RPITIT projections should produce E0308 instead of an ICE.
27
+ +
28
+ +trait Parameter {
29
+ + fn create() -> impl Form;
30
+ +}
31
+ +
32
+ +trait Form {}
33
+ +
34
+ +fn forms_at_phase<T: Parameter, U: Parameter>() -> impl Form {
35
+ + match true {
36
+ + true => T::create(),
37
+ + false => U::create(), //~ ERROR `match` arms have incompatible types
38
+ + }
39
+ +}
40
+ +
41
+ +fn main() {}
42
+ diff --git a/tests/ui/impl-trait/in-trait/rpitit-mismatch-missing-item-name-issue-161915.stderr b/tests/ui/impl-trait/in-trait/rpitit-mismatch-missing-item-name-issue-161915.stderr
43
+ new file mode 100644
44
+ index 0000000000000000000000000000000000000000..7b8f6e438c456b06c65d5d4a67399265eed753f8
45
+ --- /dev/null
46
+ +++ b/tests/ui/impl-trait/in-trait/rpitit-mismatch-missing-item-name-issue-161915.stderr
47
+ @@ -0,0 +1,34 @@
48
+ +error[E0308]: `match` arms have incompatible types
49
+ + --> $DIR/rpitit-mismatch-missing-item-name-issue-161915.rs:13:18
50
+ + |
51
+ +LL | fn forms_at_phase<T: Parameter, U: Parameter>() -> impl Form {
52
+ + | - - found type parameter
53
+ + | |
54
+ + | expected type parameter
55
+ +LL | / match true {
56
+ +LL | | true => T::create(),
57
+ + | | ----------- this is found to be of type `impl Form`
58
+ +LL | | false => U::create(),
59
+ + | | ^^^^^^^^^^^ expected type parameter `T`, found type parameter `U`
60
+ +LL | | }
61
+ + | |_____- `match` arms have incompatible types
62
+ + |
63
+ + = note: expected associated type `impl Form` (type parameter `T`)
64
+ + found associated type `impl Form` (type parameter `U`)
65
+ + = note: a type parameter was expected, but a different one was found; you might be missing a type parameter or trait bound
66
+ + = note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters
67
+ + = note: an associated type was expected, but a different one was found
68
+ +help: you could change the return type to be a boxed trait object
69
+ + |
70
+ +LL - fn forms_at_phase<T: Parameter, U: Parameter>() -> impl Form {
71
+ +LL + fn forms_at_phase<T: Parameter, U: Parameter>() -> Box<dyn Form> {
72
+ + |
73
+ +help: if you change the return type to expect trait objects, box the returned expressions
74
+ + |
75
+ +LL ~ true => Box::new(T::create()),
76
+ +LL ~ false => Box::new(U::create()),
77
+ + |
78
+ +
79
+ +error: aborting due to 1 previous error
80
+ +
81
+ +For more information about this error, try `rustc --explain E0308`.
patches/20261028T105419Z/rust-lang--rust-part009/38359d0c24e9e582594d142a5561082362e8744d.patch ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ diff --git a/src/etc/lldb_batchmode/common.py b/src/etc/lldb_batchmode/common.py
2
+ index 56933b4de87b3b98cf64899951a2bfd3c9bcf34c..b85ef47ba3cedb9c66d61049247402a58f7dc95e 100644
3
+ --- a/src/etc/lldb_batchmode/common.py
4
+ +++ b/src/etc/lldb_batchmode/common.py
5
+ @@ -572,6 +572,12 @@ generated for this test yet, consider using the `--bless` option."
6
+ f.write(x)
7
+ f.write("\n")
8
+
9
+ + def print_json(self, metadata: BlessMetadata):
10
+ + """Prints `self` to `stdout` in json format with no formatting. This output is identicall to
11
+ + what would be saved via `TargetData.save_blessing`"""
12
+ + self.bless_metadata = metadata
13
+ + print(json.dumps(clean_nones(asdict(self))))
14
+ +
15
+
16
+ def clean_nones(value):
17
+ """
18
+ diff --git a/src/etc/lldb_batchmode/runner.py b/src/etc/lldb_batchmode/runner.py
19
+ index a396f7c1f504b49b8dc927459978d3f0e54a2793..2db1f6793d4f3ee1cf3edeaec02a479fc9987a55 100644
20
+ --- a/src/etc/lldb_batchmode/runner.py
21
+ +++ b/src/etc/lldb_batchmode/runner.py
22
+ @@ -301,14 +301,35 @@ def main():
23
+ # this point are either from the `bless` not working properly, or some other issue with
24
+ # the test itself. In either case, we probably don't want to update the test data until
25
+ # those are resolved.
26
+ - # Only runs if the test contains a repr command, as we don't want to create an input
27
+ - # file for a test that won't ever use it.
28
+ +
29
+ + # If we're running CI though, the runner may be on a target that the PR author doesn't
30
+ + # have access to. In such cases, we want to dump the json output so they can "manually
31
+ + # bless" when necessary.
32
+ + if (
33
+ + not all_ok
34
+ + and (is_ci := os.environ.get("CI")) is not None
35
+ + and is_ci == "true"
36
+ + ):
37
+ + from lldb_providers import FEATURE_FLAGS
38
+ +
39
+ + path = os.path.relpath(os.environ["LLDB_BATCHMODE_INPUT_DATA_PATH"])
40
+ +
41
+ + print(f"[repr] If you do not have access to this target, you can manually update \
42
+ +the test data by overwriting the data in {path} with the following:")
43
+ +
44
+ + INPUT_DATA.print_json(
45
+ + BlessMetadata(
46
+ + sys.version, debugger.GetVersionString(), str(FEATURE_FLAGS)
47
+ + )
48
+ + )
49
+
50
+ if not tested_all_types() or not tested_all_variables():
51
+ debugger.HandleCommand("quit 1")
52
+ elif BLESS:
53
+ from lldb_providers import FEATURE_FLAGS
54
+
55
+ + # Only runs if the test contains a repr command, as we don't want to create an input
56
+ + # file for a test that won't ever use it.
57
+ INPUT_DATA.save_blessing(
58
+ BlessMetadata(
59
+ sys.version, debugger.GetVersionString(), str(FEATURE_FLAGS)
patches/20261028T105419Z/rust-lang--rust-part009/3a91281217abd4c0e3d4a3de0f1e598c5bef31a3.patch ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ diff --git a/src/bootstrap/src/core/build_steps/llvm.rs b/src/bootstrap/src/core/build_steps/llvm.rs
2
+ index a1cba8fde74bf0100a38b78865ab82752ce91dde..a9fec79765ef192d34d20f524e7736c73b24493f 100644
3
+ --- a/src/bootstrap/src/core/build_steps/llvm.rs
4
+ +++ b/src/bootstrap/src/core/build_steps/llvm.rs
5
+ @@ -151,13 +151,7 @@ impl LdFlags {
6
+ ///
7
+ /// Calling this function should never attempt to checkout the LLVM submodule.
8
+ pub fn prebuilt_llvm_output(builder: &Builder<'_>, target: TargetSelection) -> Option<LlvmOutput> {
9
+ - // Try to download LLVM from CI, if possible
10
+ - let llvm_ci = builder.ensure(LlvmFromCi { target });
11
+ - if let Some(llvm) = llvm_ci {
12
+ - return Some(llvm.output);
13
+ - }
14
+ -
15
+ - // If it is not available, use an externally provided LLVM
16
+ + // Use an externally provided LLVM, if available
17
+ if let Some(config) = builder.config.target_config.get(&target)
18
+ && let Some(ref s) = config.llvm_config
19
+ {
20
+ @@ -178,6 +172,12 @@ pub fn prebuilt_llvm_output(builder: &Builder<'_>, target: TargetSelection) -> O
21
+ });
22
+ }
23
+
24
+ + // If external LLVM is not configured, try to download LLVM from CI, if possible
25
+ + let llvm_ci = builder.ensure(LlvmFromCi { target });
26
+ + if let Some(llvm) = llvm_ci {
27
+ + return Some(llvm.output);
28
+ + }
29
+ +
30
+ // If LLVM is not available from CI nor externally, it is still possible that it was already
31
+ // built locally before. In that case we still treat it as prebuilt config.
32
+ match get_locally_built_llvm_build_status(builder, target) {
33
+ @@ -256,21 +256,6 @@ fn llvm_output_dir(builder: &Builder<'_>, target: TargetSelection) -> PathBuf {
34
+ }
35
+
36
+ fn try_download_ci_llvm(builder: &Builder<'_>, target: TargetSelection) -> Option<DownloadedLlvm> {
37
+ - if builder.config.llvm_ci_mode.requests_download_from_ci()
38
+ - && let Some(config) = builder.config.target_config.get(&target)
39
+ - {
40
+ - if config.llvm_config.is_some() {
41
+ - panic!(
42
+ - "Cannot configure `llvm-config` for {target} when using `llvm.download-ci-llvm`",
43
+ - );
44
+ - }
45
+ - if config.llvm_filecheck.is_some() {
46
+ - panic!(
47
+ - "Cannot configure `llvm-filecheck` for {target} when using `llvm.download-ci-llvm`"
48
+ - );
49
+ - }
50
+ - }
51
+ -
52
+ match builder.config.llvm_ci_mode {
53
+ LlvmCiMode::BuildLocally => return None,
54
+ LlvmCiMode::Download => {}
55
+ diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs
56
+ index a513c45bce9b12505e355b013d0b694aa7ddd0aa..f87e0780ce49c4314303d00a7c28c2166f6c0e21 100644
57
+ --- a/src/bootstrap/src/core/config/config.rs
58
+ +++ b/src/bootstrap/src/core/config/config.rs
59
+ @@ -1008,6 +1008,11 @@ impl Config {
60
+ target.llvm_has_rust_patches = Some(patches);
61
+ }
62
+ if let Some(ref s) = target_llvm_filecheck {
63
+ + if target_llvm_config.is_none() {
64
+ + panic!(
65
+ + "You must also configure `llvm-config` when setting `llvm-filecheck` for target {triple}",
66
+ + );
67
+ + }
68
+ target.llvm_filecheck = Some(src.join(s));
69
+ }
70
+ target.llvm_libunwind = target_llvm_libunwind.as_ref().map(|v| {
patches/20261028T105419Z/rust-lang--rust-part009/41258df4130f7c8eaab4d3177d156b1661587456.patch ADDED
@@ -0,0 +1,486 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ diff --git a/tests/rustdoc-html/async/async-move-doctest.rs b/tests/rustdoc-ui/doctest/async-move-doctest.rs
2
+ similarity index 77%
3
+ rename from tests/rustdoc-html/async/async-move-doctest.rs
4
+ rename to tests/rustdoc-ui/doctest/async-move-doctest.rs
5
+ index e18ec353533dff0de54dcdecaf5c9b29cfa73165..f491a9a04f851a50850e60d734a34e7599af2c6f 100644
6
+ --- a/tests/rustdoc-html/async/async-move-doctest.rs
7
+ +++ b/tests/rustdoc-ui/doctest/async-move-doctest.rs
8
+ @@ -1,5 +1,7 @@
9
+ //@ compile-flags:--test
10
+ +//@ normalize-stdout: "finished in \d+\.\d+s" -> "finished in $$TIME"
11
+ //@ edition:2018
12
+ +//@ check-pass
13
+
14
+ // Prior to setting the default edition for the doctest pre-parser,
15
+ // this doctest would fail due to a fatal parsing error.
16
+ diff --git a/tests/rustdoc-ui/doctest/async-move-doctest.stdout b/tests/rustdoc-ui/doctest/async-move-doctest.stdout
17
+ new file mode 100644
18
+ index 0000000000000000000000000000000000000000..4790438d4602f63d2d7baecab8cb41092bd10753
19
+ --- /dev/null
20
+ +++ b/tests/rustdoc-ui/doctest/async-move-doctest.stdout
21
+ @@ -0,0 +1,6 @@
22
+ +
23
+ +running 1 test
24
+ +test $DIR/async-move-doctest.rs - (line 10) ... ok
25
+ +
26
+ +test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME
27
+ +
28
+ diff --git a/tests/rustdoc-html/comment-in-doctest.rs b/tests/rustdoc-ui/doctest/comment-in-doctest.rs
29
+ similarity index 89%
30
+ rename from tests/rustdoc-html/comment-in-doctest.rs
31
+ rename to tests/rustdoc-ui/doctest/comment-in-doctest.rs
32
+ index e580aa2bb72c677d37f94979adc788bd9bd9c401..2caec5db9c92087968bd66b738564588940d7528 100644
33
+ --- a/tests/rustdoc-html/comment-in-doctest.rs
34
+ +++ b/tests/rustdoc-ui/doctest/comment-in-doctest.rs
35
+ @@ -1,4 +1,6 @@
36
+ //@ compile-flags:--test
37
+ +//@ normalize-stdout: "finished in \d+\.\d+s" -> "finished in $$TIME"
38
+ +//@ check-pass
39
+
40
+ // comments, both doc comments and regular ones, used to trick rustdoc's doctest parser into
41
+ // thinking that everything after it was part of the regular program. combined with the librustc_ast
42
+ diff --git a/tests/rustdoc-ui/doctest/comment-in-doctest.stdout b/tests/rustdoc-ui/doctest/comment-in-doctest.stdout
43
+ new file mode 100644
44
+ index 0000000000000000000000000000000000000000..5cb97c53f37fd484c32b07b6f289525a1509db4f
45
+ --- /dev/null
46
+ +++ b/tests/rustdoc-ui/doctest/comment-in-doctest.stdout
47
+ @@ -0,0 +1,6 @@
48
+ +
49
+ +running 1 test
50
+ +test $DIR/comment-in-doctest.rs - (line 12) ... ok
51
+ +
52
+ +test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME
53
+ +
54
+ diff --git a/tests/rustdoc-html/demo-allocator-54478.rs b/tests/rustdoc-ui/doctest/demo-allocator-54478.rs
55
+ similarity index 93%
56
+ rename from tests/rustdoc-html/demo-allocator-54478.rs
57
+ rename to tests/rustdoc-ui/doctest/demo-allocator-54478.rs
58
+ index 80acfc0ff58a17b18bcb20af027be6bea973b5f6..073d83e11120e9b96b179518db936ddb10d57a36 100644
59
+ --- a/tests/rustdoc-html/demo-allocator-54478.rs
60
+ +++ b/tests/rustdoc-ui/doctest/demo-allocator-54478.rs
61
+ @@ -1,4 +1,9 @@
62
+ // https://github.com/rust-lang/rust/issues/54478
63
+ +
64
+ +//@ compile-flags:--test
65
+ +//@ normalize-stdout: "finished in \d+\.\d+s" -> "finished in $$TIME"
66
+ +//@ check-pass
67
+ +
68
+ #![crate_name="foo"]
69
+
70
+ // Issue #54478: regression test showing that we can demonstrate
71
+ @@ -15,8 +20,6 @@
72
+ // decided to change `rustdoc` to behave more like the compiler's
73
+ // default setting, by leaving off `-C prefer-dynamic`.
74
+
75
+ -//@ compile-flags:--test
76
+ -
77
+ //! This is a doc comment
78
+ //!
79
+ //! ```rust
80
+ diff --git a/tests/rustdoc-ui/doctest/demo-allocator-54478.stdout b/tests/rustdoc-ui/doctest/demo-allocator-54478.stdout
81
+ new file mode 100644
82
+ index 0000000000000000000000000000000000000000..f32d9a5b7d932d83a200eb2a76264359f9e11188
83
+ --- /dev/null
84
+ +++ b/tests/rustdoc-ui/doctest/demo-allocator-54478.stdout
85
+ @@ -0,0 +1,6 @@
86
+ +
87
+ +running 1 test
88
+ +test $DIR/demo-allocator-54478.rs - (line 25) ... ok
89
+ +
90
+ +test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME
91
+ +
92
+ diff --git a/tests/rustdoc-html/doc-cfg/doc-cfg-target-feature.rs b/tests/rustdoc-ui/doctest/doc-cfg-target-feature.rs
93
+ similarity index 78%
94
+ rename from tests/rustdoc-html/doc-cfg/doc-cfg-target-feature.rs
95
+ rename to tests/rustdoc-ui/doctest/doc-cfg-target-feature.rs
96
+ index b66e86e36af8b61869f04bb4b98309813eea0d0c..99a133a6829c53942ed7e3e09d1345beacefb9f8 100644
97
+ --- a/tests/rustdoc-html/doc-cfg/doc-cfg-target-feature.rs
98
+ +++ b/tests/rustdoc-ui/doctest/doc-cfg-target-feature.rs
99
+ @@ -1,6 +1,7 @@
100
+ //@ only-x86_64
101
+ +//@ normalize-stdout: "finished in \d+\.\d+s" -> "finished in $$TIME"
102
+ //@ compile-flags:--test
103
+ -//@ should-fail
104
+ +//@ failure-status: 101
105
+
106
+ // #49723: rustdoc didn't add target features when extracting or running doctests
107
+
108
+ diff --git a/tests/rustdoc-ui/doctest/doc-cfg-target-feature.stdout b/tests/rustdoc-ui/doctest/doc-cfg-target-feature.stdout
109
+ new file mode 100644
110
+ index 0000000000000000000000000000000000000000..d71b1032e60ec92b321b866890d46809503a9b2a
111
+ --- /dev/null
112
+ +++ b/tests/rustdoc-ui/doctest/doc-cfg-target-feature.stdout
113
+ @@ -0,0 +1,39 @@
114
+ +
115
+ +running 1 test
116
+ +test $DIR/doc-cfg-target-feature.rs - foo (line 14) ... FAILED
117
+ +
118
+ +failures:
119
+ +
120
+ +---- $DIR/doc-cfg-target-feature.rs - foo (line 14) stdout ----
121
+ +warning: the feature `cfg_target_feature` has been stable since 1.27.0 and no longer requires an attribute to enable
122
+ + --> $DIR/doc-cfg-target-feature.rs:14:12
123
+ + |
124
+ +LL | #![feature(cfg_target_feature)]
125
+ + | ^^^^^^^^^^^^^^^^^^
126
+ + |
127
+ + = note: `#[warn(stable_features)]` on by default
128
+ +
129
+ +warning: 1 warning emitted
130
+ +
131
+ +Test executable failed (exit status: 101).
132
+ +
133
+ +stderr:
134
+ +
135
+ +thread 'main' ($TID) panicked at $DIR/doc-cfg-target-feature.rs:7:1:
136
+ +assertion failed: false
137
+ +stack backtrace:
138
+ + 0: __rustc::rust_begin_unwind
139
+ + 1: core::panicking::panic_fmt
140
+ + 2: core::panicking::panic
141
+ + 3: rust_out::main::_doctest_main__home_imperio_rust_rust_tests_rustdoc_ui_doctest_doc_cfg_target_feature_rs_14_0
142
+ + 4: rust_out::main
143
+ + 5: <fn() as core::ops::function::FnOnce<()>>::call_once
144
+ +note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
145
+ +
146
+ +
147
+ +
148
+ +failures:
149
+ + $DIR/doc-cfg-target-feature.rs - foo (line 14)
150
+ +
151
+ +test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME
152
+ +
153
+ diff --git a/tests/rustdoc-html/doc-test-attr-18199.rs b/tests/rustdoc-ui/doctest/doc-test-attr-18199.rs
154
+ similarity index 74%
155
+ rename from tests/rustdoc-html/doc-test-attr-18199.rs
156
+ rename to tests/rustdoc-ui/doctest/doc-test-attr-18199.rs
157
+ index 64016e32eeeb113c0a638d32f175b7310a753544..8350f244fccac32f0ee72ac465bcfb7aafcbfeab 100644
158
+ --- a/tests/rustdoc-html/doc-test-attr-18199.rs
159
+ +++ b/tests/rustdoc-ui/doctest/doc-test-attr-18199.rs
160
+ @@ -1,6 +1,9 @@
161
+ -//@ compile-flags:--test
162
+ // https://github.com/rust-lang/rust/issues/18199
163
+
164
+ +//@ compile-flags:--test
165
+ +//@ normalize-stdout: "finished in \d+\.\d+s" -> "finished in $$TIME"
166
+ +//@ check-pass
167
+ +
168
+ #![doc(test(attr(feature(staged_api))))]
169
+
170
+ /// ```
171
+ diff --git a/tests/rustdoc-ui/doctest/doc-test-attr-18199.stdout b/tests/rustdoc-ui/doctest/doc-test-attr-18199.stdout
172
+ new file mode 100644
173
+ index 0000000000000000000000000000000000000000..a182a3b911af6ce36f1ba52ed27576255545c486
174
+ --- /dev/null
175
+ +++ b/tests/rustdoc-ui/doctest/doc-test-attr-18199.stdout
176
+ @@ -0,0 +1,6 @@
177
+ +
178
+ +running 1 test
179
+ +test $DIR/doc-test-attr-18199.rs - foo (line 9) ... ok
180
+ +
181
+ +test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME
182
+ +
183
+ diff --git a/tests/rustdoc-html/edition-doctest.rs b/tests/rustdoc-ui/doctest/edition-doctest.rs
184
+ similarity index 87%
185
+ rename from tests/rustdoc-html/edition-doctest.rs
186
+ rename to tests/rustdoc-ui/doctest/edition-doctest.rs
187
+ index f43c074f806bd82570a7971559422deb3d2b5ab1..066475dae7bf061b402a4877a7732fdf87f78910 100644
188
+ --- a/tests/rustdoc-html/edition-doctest.rs
189
+ +++ b/tests/rustdoc-ui/doctest/edition-doctest.rs
190
+ @@ -1,4 +1,6 @@
191
+ -//@ compile-flags:--test
192
+ +//@ compile-flags:--test --test-args=--test-threads=1
193
+ +//@ normalize-stdout: "finished in \d+\.\d+s" -> "finished in $$TIME"
194
+ +//@ check-pass
195
+
196
+ /// ```rust,edition2018
197
+ /// #![feature(try_blocks)]
198
+ diff --git a/tests/rustdoc-ui/doctest/edition-doctest.stdout b/tests/rustdoc-ui/doctest/edition-doctest.stdout
199
+ new file mode 100644
200
+ index 0000000000000000000000000000000000000000..40d0df0575a76991989f41303e439d1b3b7f50c8
201
+ --- /dev/null
202
+ +++ b/tests/rustdoc-ui/doctest/edition-doctest.stdout
203
+ @@ -0,0 +1,7 @@
204
+ +
205
+ +running 2 tests
206
+ +test $DIR/edition-doctest.rs - foo (line 24) - compile fail ... ok
207
+ +test $DIR/edition-doctest.rs - foo (line 5) ... ok
208
+ +
209
+ +test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME
210
+ +
211
+ diff --git a/tests/rustdoc-html/edition-flag.rs b/tests/rustdoc-ui/doctest/edition-flag.rs
212
+ similarity index 63%
213
+ rename from tests/rustdoc-html/edition-flag.rs
214
+ rename to tests/rustdoc-ui/doctest/edition-flag.rs
215
+ index c57c8d50b23570589816ed7f21701e8b255c26c0..51235634dbf4a174d194d0aff6e94a4d8d5b7ffa 100644
216
+ --- a/tests/rustdoc-html/edition-flag.rs
217
+ +++ b/tests/rustdoc-ui/doctest/edition-flag.rs
218
+ @@ -1,5 +1,7 @@
219
+ //@ compile-flags:--test
220
+ //@ edition:2018
221
+ +//@ normalize-stdout: "finished in \d+\.\d+s" -> "finished in $$TIME"
222
+ +//@ check-pass
223
+
224
+ /// ```rust
225
+ /// fn main() {
226
+ diff --git a/tests/rustdoc-ui/doctest/edition-flag.stdout b/tests/rustdoc-ui/doctest/edition-flag.stdout
227
+ new file mode 100644
228
+ index 0000000000000000000000000000000000000000..4833a6dcf9adfd9d67ac1ee11c34685cd59a0e2f
229
+ --- /dev/null
230
+ +++ b/tests/rustdoc-ui/doctest/edition-flag.stdout
231
+ @@ -0,0 +1,6 @@
232
+ +
233
+ +running 1 test
234
+ +test $DIR/edition-flag.rs - main (line 6) ... ok
235
+ +
236
+ +test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME
237
+ +
238
+ diff --git a/tests/rustdoc-html/force-target-feature.rs b/tests/rustdoc-ui/doctest/force-target-feature.rs
239
+ similarity index 64%
240
+ rename from tests/rustdoc-html/force-target-feature.rs
241
+ rename to tests/rustdoc-ui/doctest/force-target-feature.rs
242
+ index fa71bbeea2747f7a2951dd7d96fab34a4744ce18..c3f97981470743b72361f3da7e2e1118e4a1d326 100644
243
+ --- a/tests/rustdoc-html/force-target-feature.rs
244
+ +++ b/tests/rustdoc-ui/doctest/force-target-feature.rs
245
+ @@ -1,6 +1,9 @@
246
+ //@ only-x86_64
247
+ //@ compile-flags:--test -C target-feature=+avx
248
+ -//@ should-fail
249
+ +//@ normalize-stdout: "finished in \d+\.\d+s" -> "finished in $$TIME"
250
+ +//@ failure-status: 101
251
+ +
252
+ +#![feature(doc_cfg)]
253
+
254
+ /// (written on a spider's web) Some Struct
255
+ ///
256
+ diff --git a/tests/rustdoc-ui/doctest/force-target-feature.stdout b/tests/rustdoc-ui/doctest/force-target-feature.stdout
257
+ new file mode 100644
258
+ index 0000000000000000000000000000000000000000..861a742075623fa17464f03c3b032a54354d3edb
259
+ --- /dev/null
260
+ +++ b/tests/rustdoc-ui/doctest/force-target-feature.stdout
261
+ @@ -0,0 +1,27 @@
262
+ +
263
+ +running 1 test
264
+ +test $DIR/force-target-feature.rs - SomeStruct (line 10) ... FAILED
265
+ +
266
+ +failures:
267
+ +
268
+ +---- $DIR/force-target-feature.rs - SomeStruct (line 10) stdout ----
269
+ +Test executable failed (exit status: 101).
270
+ +
271
+ +stderr:
272
+ +
273
+ +thread 'main' ($TID) panicked at $DIR/force-target-feature.rs:3:1:
274
+ +oh no
275
+ +stack backtrace:
276
+ + 0: std::panicking::begin_panic::<&str>
277
+ + 1: rust_out::main::_doctest_main__home_imperio_rust_rust_tests_rustdoc_ui_doctest_force_target_feature_rs_10_0
278
+ + 2: rust_out::main
279
+ + 3: <fn() as core::ops::function::FnOnce<()>>::call_once
280
+ +note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
281
+ +
282
+ +
283
+ +
284
+ +failures:
285
+ + $DIR/force-target-feature.rs - SomeStruct (line 10)
286
+ +
287
+ +test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME
288
+ +
289
+ diff --git a/tests/rustdoc-html/ice-type-error-19181.rs b/tests/rustdoc-ui/doctest/ice-type-error-19181.rs
290
+ similarity index 65%
291
+ rename from tests/rustdoc-html/ice-type-error-19181.rs
292
+ rename to tests/rustdoc-ui/doctest/ice-type-error-19181.rs
293
+ index 02c64047622220093c917d3ea1ab62448cf61049..accb9e2cab1f4658c4797eb219a7ddfd41320428 100644
294
+ --- a/tests/rustdoc-html/ice-type-error-19181.rs
295
+ +++ b/tests/rustdoc-ui/doctest/ice-type-error-19181.rs
296
+ @@ -1,4 +1,7 @@
297
+ //@ compile-flags:--test
298
+ +//@ normalize-stdout: "finished in \d+\.\d+s" -> "finished in $$TIME"
299
+ +//@ check-pass
300
+ +
301
+ // https://github.com/rust-lang/rust/issues/19181
302
+
303
+ // rustdoc should not panic when target crate has compilation errors
304
+ diff --git a/tests/rustdoc-ui/doctest/ice-type-error-19181.stdout b/tests/rustdoc-ui/doctest/ice-type-error-19181.stdout
305
+ new file mode 100644
306
+ index 0000000000000000000000000000000000000000..7326c0a25a069340ea659b1382b6271d853bcc72
307
+ --- /dev/null
308
+ +++ b/tests/rustdoc-ui/doctest/ice-type-error-19181.stdout
309
+ @@ -0,0 +1,5 @@
310
+ +
311
+ +running 0 tests
312
+ +
313
+ +test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME
314
+ +
315
+ diff --git a/tests/rustdoc-html/no-run-still-checks-lints.rs b/tests/rustdoc-ui/doctest/no-run-still-checks-lints.rs
316
+ similarity index 55%
317
+ rename from tests/rustdoc-html/no-run-still-checks-lints.rs
318
+ rename to tests/rustdoc-ui/doctest/no-run-still-checks-lints.rs
319
+ index 73e311b72d5e5a69593733d43dc470224fc2f3c7..cae6331f4723df420358cd805cdd5277aaa29a7e 100644
320
+ --- a/tests/rustdoc-html/no-run-still-checks-lints.rs
321
+ +++ b/tests/rustdoc-ui/doctest/no-run-still-checks-lints.rs
322
+ @@ -1,5 +1,6 @@
323
+ //@ compile-flags:--test
324
+ -//@ should-fail
325
+ +//@ failure-status: 101
326
+ +//@ normalize-stdout: "finished in \d+\.\d+s" -> "finished in $$TIME"
327
+
328
+ #![doc(test(attr(deny(warnings))))]
329
+
330
+ diff --git a/tests/rustdoc-ui/doctest/no-run-still-checks-lints.stdout b/tests/rustdoc-ui/doctest/no-run-still-checks-lints.stdout
331
+ new file mode 100644
332
+ index 0000000000000000000000000000000000000000..86d1b4d3094b65b938680eebf15836f0c1c04121
333
+ --- /dev/null
334
+ +++ b/tests/rustdoc-ui/doctest/no-run-still-checks-lints.stdout
335
+ @@ -0,0 +1,29 @@
336
+ +
337
+ +running 1 test
338
+ +test $DIR/no-run-still-checks-lints.rs - foo (line 7) - compile ... FAILED
339
+ +
340
+ +failures:
341
+ +
342
+ +---- $DIR/no-run-still-checks-lints.rs - foo (line 7) stdout ----
343
+ +error: unused variable: `a`
344
+ + --> $DIR/no-run-still-checks-lints.rs:8:5
345
+ + |
346
+ +LL | let a = 3;
347
+ + | ^ help: if this is intentional, prefix it with an underscore: `_a`
348
+ + |
349
+ +note: the lint level is defined here
350
+ + --> $DIR/no-run-still-checks-lints.rs:6:9
351
+ + |
352
+ +LL | #![deny(warnings)]
353
+ + | ^^^^^^^^
354
+ + = note: `#[deny(unused_variables)]` implied by `#[deny(warnings)]`
355
+ +
356
+ +error: aborting due to 1 previous error
357
+ +
358
+ +Couldn't compile the test.
359
+ +
360
+ +failures:
361
+ + $DIR/no-run-still-checks-lints.rs - foo (line 7)
362
+ +
363
+ +test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME
364
+ +
365
+ diff --git a/tests/rustdoc-html/process-termination.rs b/tests/rustdoc-ui/doctest/process-termination.rs
366
+ similarity index 80%
367
+ rename from tests/rustdoc-html/process-termination.rs
368
+ rename to tests/rustdoc-ui/doctest/process-termination.rs
369
+ index 73a86e57424a2b703a64af655595c7f4c3074678..02ac594b3f0d41b4a4272ffc895b93bac8035979 100644
370
+ --- a/tests/rustdoc-html/process-termination.rs
371
+ +++ b/tests/rustdoc-ui/doctest/process-termination.rs
372
+ @@ -1,4 +1,6 @@
373
+ -//@ compile-flags:--test
374
+ +//@ compile-flags:--test --test-args=--test-threads=1
375
+ +//@ normalize-stdout: "finished in \d+\.\d+s" -> "finished in $$TIME"
376
+ +//@ check-pass
377
+
378
+ /// A check of using various process termination strategies
379
+ ///
380
+ diff --git a/tests/rustdoc-ui/doctest/process-termination.stdout b/tests/rustdoc-ui/doctest/process-termination.stdout
381
+ new file mode 100644
382
+ index 0000000000000000000000000000000000000000..3e15b9a5df80aa3edb60edef2eb11ea0551e3c5d
383
+ --- /dev/null
384
+ +++ b/tests/rustdoc-ui/doctest/process-termination.stdout
385
+ @@ -0,0 +1,8 @@
386
+ +
387
+ +running 3 tests
388
+ +test $DIR/process-termination.rs - check_process_termination (line 16) ... ok
389
+ +test $DIR/process-termination.rs - check_process_termination (line 22) ... ok
390
+ +test $DIR/process-termination.rs - check_process_termination (line 9) ... ok
391
+ +
392
+ +test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME
393
+ +
394
+ diff --git a/tests/rustdoc-html/sanitizer-option.rs b/tests/rustdoc-ui/doctest/sanitizer-option.rs
395
+ similarity index 86%
396
+ rename from tests/rustdoc-html/sanitizer-option.rs
397
+ rename to tests/rustdoc-ui/doctest/sanitizer-option.rs
398
+ index 7b0038138f09f724392de792e678ea3a52961fe7..5f29f1b8bac7e432c46c0ce8c74eef583961f252 100644
399
+ --- a/tests/rustdoc-html/sanitizer-option.rs
400
+ +++ b/tests/rustdoc-ui/doctest/sanitizer-option.rs
401
+ @@ -1,7 +1,9 @@
402
+ //@ needs-sanitizer-support
403
+ //@ needs-sanitizer-address
404
+ //@ compile-flags: --test -Z sanitizer=address -C unsafe-allow-abi-mismatch=sanitizer
405
+ -//
406
+ +//@ normalize-stdout: "finished in \d+\.\d+s" -> "finished in $$TIME"
407
+ +//@ check-pass
408
+ +
409
+ // #43031: Verify that rustdoc passes `-Z` options to rustc. Use an extern
410
+ // function that is provided by the sanitizer runtime, if flag is not passed
411
+ // correctly, then linking will fail.
412
+ diff --git a/tests/rustdoc-html/test_option_check/test.rs b/tests/rustdoc-ui/doctest/test-option-check-2.rs
413
+ similarity index 54%
414
+ rename from tests/rustdoc-html/test_option_check/test.rs
415
+ rename to tests/rustdoc-ui/doctest/test-option-check-2.rs
416
+ index af7a5827690f08d766d96feea35a99443cbbd03f..2e74da1eca794ce348c023ef575b9bfa2e639713 100644
417
+ --- a/tests/rustdoc-html/test_option_check/test.rs
418
+ +++ b/tests/rustdoc-ui/doctest/test-option-check-2.rs
419
+ @@ -1,6 +1,9 @@
420
+ -//@ compile-flags: --test
421
+ +//@ compile-flags: --test --test-args=--test-threads=1
422
+ //@ check-test-line-numbers-match
423
+ +//@ normalize-stdout: "finished in \d+\.\d+s" -> "finished in $$TIME"
424
+ +//@ check-pass
425
+
426
+ +#[path = "test-option-check.rs"]
427
+ pub mod bar;
428
+
429
+ /// This is a Foo;
430
+ diff --git a/tests/rustdoc-ui/doctest/test-option-check-2.stdout b/tests/rustdoc-ui/doctest/test-option-check-2.stdout
431
+ new file mode 100644
432
+ index 0000000000000000000000000000000000000000..ab2db4938dfab3f93eb686fdebb59f2990483632
433
+ --- /dev/null
434
+ +++ b/tests/rustdoc-ui/doctest/test-option-check-2.stdout
435
+ @@ -0,0 +1,8 @@
436
+ +
437
+ +running 3 tests
438
+ +test $DIR/test-option-check-2.rs - Bar (line 18) ... ok
439
+ +test $DIR/test-option-check-2.rs - Foo (line 11) ... ok
440
+ +test $DIR/test-option-check.rs - bar::foooo (line 8) ... ok
441
+ +
442
+ +test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME
443
+ +
444
+ diff --git a/tests/rustdoc-html/test_option_check/bar.rs b/tests/rustdoc-ui/doctest/test-option-check.rs
445
+ similarity index 65%
446
+ rename from tests/rustdoc-html/test_option_check/bar.rs
447
+ rename to tests/rustdoc-ui/doctest/test-option-check.rs
448
+ index 7c2309a79d4b919f01ec8e75f6ac5c255c5b0c42..e5d3350e3f9813d96e4a3ac4efb0954573284d31 100644
449
+ --- a/tests/rustdoc-html/test_option_check/bar.rs
450
+ +++ b/tests/rustdoc-ui/doctest/test-option-check.rs
451
+ @@ -1,5 +1,7 @@
452
+ //@ compile-flags: --test
453
+ //@ check-test-line-numbers-match
454
+ +//@ normalize-stdout: "finished in \d+\.\d+s" -> "finished in $$TIME"
455
+ +//@ check-pass
456
+
457
+ /// This looks like another awesome test!
458
+ ///
459
+ diff --git a/tests/rustdoc-ui/doctest/test-option-check.stdout b/tests/rustdoc-ui/doctest/test-option-check.stdout
460
+ new file mode 100644
461
+ index 0000000000000000000000000000000000000000..38f949612a47a165db2e806a696a37c9be360e1d
462
+ --- /dev/null
463
+ +++ b/tests/rustdoc-ui/doctest/test-option-check.stdout
464
+ @@ -0,0 +1,6 @@
465
+ +
466
+ +running 1 test
467
+ +test $DIR/test-option-check.rs - foooo (line 8) ... ok
468
+ +
469
+ +test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME
470
+ +
471
+ diff --git a/tests/rustdoc-ui/lints/renamed-lint-still-applies.rs b/tests/rustdoc-ui/lints/renamed-lint-still-applies.rs
472
+ deleted file mode 100644
473
+ index a4d3a4b497117b80948337551fbfa18348c4bda8..0000000000000000000000000000000000000000
474
+ --- a/tests/rustdoc-ui/lints/renamed-lint-still-applies.rs
475
+ +++ /dev/null
476
+ @@ -1,10 +0,0 @@
477
+ -// compile-args: --crate-type lib
478
+ -#![deny(broken_intra_doc_links)]
479
+ -//~^ WARNING renamed to `rustdoc::broken_intra_doc_links`
480
+ -//! [x]
481
+ -//~^ ERROR unresolved link
482
+ -
483
+ -#![deny(rustdoc::non_autolinks)]
484
+ -//~^ WARNING renamed to `rustdoc::bare_urls`
485
+ -//! http://example.com
486
+ -//~^ ERROR not a hyperlink
patches/20261028T105419Z/rust-lang--rust-part009/45f215f136e00d8a74c69afde2f71be3f16837cf.patch ADDED
@@ -0,0 +1,1678 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ diff --git a/compiler/rustc_borrowck/src/universal_regions.rs b/compiler/rustc_borrowck/src/universal_regions.rs
2
+ index d693061e8fa433e18d5ab6f479be885eb73f39e2..fbde85ef6aec458239c09362cff7eddd1f90f570 100644
3
+ --- a/compiler/rustc_borrowck/src/universal_regions.rs
4
+ +++ b/compiler/rustc_borrowck/src/universal_regions.rs
5
+ @@ -21,19 +21,16 @@ use rustc_hir::attrs::lang_items::LangItem;
6
+ use rustc_hir::def::DefKind;
7
+ use rustc_hir::def_id::{DefId, LocalDefId};
8
+ use rustc_index::IndexVec;
9
+ -use rustc_infer::infer::{NllRegionVariableOrigin, TyCtxtInferExt};
10
+ -use rustc_infer::traits::ObligationCause;
11
+ +use rustc_infer::infer::NllRegionVariableOrigin;
12
+ use rustc_macros::extension;
13
+ use rustc_middle::mir::RETURN_PLACE;
14
+ use rustc_middle::ty::print::with_no_trimmed_paths;
15
+ use rustc_middle::ty::{
16
+ self, BoundVariableKind, GenericArgs, GenericArgsRef, InlineConstArgs, InlineConstArgsParts,
17
+ - List, RegionExt, RegionVid, Ty, TyCtxt, TypeFoldable, TypeVisitableExt, TypingMode,
18
+ - fold_regions,
19
+ + List, RegionExt, RegionVid, Ty, TyCtxt, TypeFoldable, TypeVisitableExt, fold_regions,
20
+ };
21
+ use rustc_middle::{bug, span_bug};
22
+ use rustc_span::{ErrorGuaranteed, kw, sym};
23
+ -use rustc_trait_selection::traits::ObligationCtxt;
24
+ use tracing::{debug, instrument};
25
+
26
+ use crate::BorrowckInferCtxt;
27
+ @@ -136,32 +133,22 @@ pub(crate) enum DefiningTy<'tcx> {
28
+ GlobalAsm(DefId),
29
+ }
30
+
31
+ -fn normalized_type_of<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> Ty<'tcx> {
32
+ - let ty = tcx.type_of(def_id).instantiate_identity();
33
+ - if !tcx.next_trait_solver_globally() {
34
+ - return ty.skip_normalization();
35
+ - }
36
+ -
37
+ - let typing_mode = if tcx.use_typing_mode_post_typeck_until_borrowck() {
38
+ - TypingMode::borrowck(tcx, def_id)
39
+ - } else {
40
+ - TypingMode::analysis_in_body(tcx, def_id)
41
+ - };
42
+ - let infcx = tcx.infer_ctxt().build(typing_mode);
43
+ - let ocx = ObligationCtxt::new(&infcx);
44
+ - let span = tcx.def_span(def_id);
45
+ - let cause = ObligationCause::misc(span, def_id);
46
+ - ocx.deeply_normalize(&cause, tcx.param_env(def_id), ty).unwrap()
47
+ -}
48
+ -
49
+ impl<'tcx> DefiningTy<'tcx> {
50
+ #[instrument(level = "debug", skip(tcx), ret)]
51
+ pub(crate) fn new(tcx: TyCtxt<'tcx>, body_def_id: LocalDefId) -> DefiningTy<'tcx> {
52
+ match tcx.hir_body_owner_kind(body_def_id) {
53
+ BodyOwnerKind::Closure | BodyOwnerKind::Fn => {
54
+ - // Normalize after instantiation so coroutine yield/resume
55
+ - // types in the args are rigid under the next solver.
56
+ - let defining_ty = normalized_type_of(tcx, body_def_id);
57
+ + let defining_ty =
58
+ + tcx.type_of(body_def_id).instantiate_identity().skip_normalization();
59
+ + let defining_ty = if tcx.next_trait_solver_globally() {
60
+ + // Closure types come from HIR typeck results, where they were already
61
+ + // normalized during writeback. Wrapping them in an `EarlyBinder`
62
+ + // conservatively makes aliases non-rigid, so restore their rigidness
63
+ + // instead of normalizing them again during borrowck.
64
+ + ty::set_aliases_to_rigid(tcx, defining_ty)
65
+ + } else {
66
+ + defining_ty
67
+ + };
68
+ match *defining_ty.kind() {
69
+ ty::Closure(def_id, args) => DefiningTy::Closure(def_id, args),
70
+ ty::Coroutine(def_id, args) => DefiningTy::Coroutine(def_id, args),
71
+ diff --git a/compiler/rustc_codegen_llvm/src/diagnostics.rs b/compiler/rustc_codegen_llvm/src/diagnostics.rs
72
+ index 54f8ffbb881da29b549ed0dfc09febaea079f606..fb43b36fe39b908ddb2bc021bd124692676cac82 100644
73
+ --- a/compiler/rustc_codegen_llvm/src/diagnostics.rs
74
+ +++ b/compiler/rustc_codegen_llvm/src/diagnostics.rs
75
+ @@ -1,4 +1,4 @@
76
+ -use std::ffi::CString;
77
+ +use std::ffi::{CString, c_uint};
78
+ use std::path::Path;
79
+
80
+ use rustc_data_structures::small_c_str::SmallCStr;
81
+ @@ -265,3 +265,15 @@ pub(crate) struct IntrinsicWrongArch<'a> {
82
+ pub(crate) struct UnknownLlvmTargetFeaturePrefix<'a> {
83
+ pub feature: &'a str,
84
+ }
85
+ +
86
+ +#[derive(Diagnostic)]
87
+ +#[diag(
88
+ + "LLVM version mismatch: this compiler was built for LLVM {$expected_version}, but LLVM {$llvm_major}.{$llvm_minor}.{$llvm_patch} was found{$dll_loc}"
89
+ +)]
90
+ +pub(crate) struct LlvmVersionMismatch<'a> {
91
+ + pub expected_version: c_uint,
92
+ + pub llvm_major: c_uint,
93
+ + pub llvm_minor: c_uint,
94
+ + pub llvm_patch: c_uint,
95
+ + pub dll_loc: &'a str,
96
+ +}
97
+ diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs
98
+ index 9819699ca5228c8e79a10d4e0aacb0ab57674cec..82ddcca3e15305e8a49fae4a444c437a4b9acb68 100644
99
+ --- a/compiler/rustc_codegen_llvm/src/llvm_util.rs
100
+ +++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs
101
+ @@ -56,20 +56,17 @@ unsafe fn configure_llvm(sess: &Session) {
102
+ llvm::LLVMGetVersion(&mut llvm_major, &mut llvm_minor, &mut llvm_patch);
103
+ let expected_version = llvm::LLVMRustVersionMajor();
104
+ if llvm_major != expected_version {
105
+ - panic!(
106
+ - concat!(
107
+ - "LLVM version mismatch: this compiler was built for LLVM {}, ",
108
+ - "but LLVM {}.{}.{} was found{}"
109
+ - ),
110
+ + sess.dcx().emit_fatal(diagnostics::LlvmVersionMismatch {
111
+ expected_version,
112
+ llvm_major,
113
+ llvm_minor,
114
+ llvm_patch,
115
+ - match rustc_session::filesearch::dll_path(llvm::LLVMGetVersion as *mut _) {
116
+ + dll_loc: &match rustc_session::filesearch::dll_path(llvm::LLVMGetVersion as *mut _)
117
+ + {
118
+ Ok(path) => format!(" at {}", path.display()),
119
+ Err(_) => String::new(),
120
+ - }
121
+ - );
122
+ + },
123
+ + })
124
+ }
125
+ }
126
+
127
+ diff --git a/compiler/rustc_llvm/llvm-wrapper/LLVMWrapper.h b/compiler/rustc_llvm/llvm-wrapper/LLVMWrapper.h
128
+ index 0cbda23f384cc07c58a2e19a6628bde28db8bac6..65dda8eb9485306dbdbdd4d3969cae553bd16729 100644
129
+ --- a/compiler/rustc_llvm/llvm-wrapper/LLVMWrapper.h
130
+ +++ b/compiler/rustc_llvm/llvm-wrapper/LLVMWrapper.h
131
+ @@ -19,8 +19,6 @@ extern "C" void LLVMRustSetLastError(const char *);
132
+ enum class LLVMRustResult { Success, Failure };
133
+
134
+ typedef struct OpaqueRustString *RustStringRef;
135
+ -typedef struct LLVMOpaqueTwine *LLVMTwineRef;
136
+ -typedef struct LLVMOpaqueSMDiagnostic *LLVMSMDiagnosticRef;
137
+
138
+ extern "C" void LLVMRustStringWriteImpl(RustStringRef buf,
139
+ const char *slice_ptr,
140
+ diff --git a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
141
+ index 6fd78c6bde4bec32ffde93be87fcf54750e686a3..e77d63d91703bbf7c66f000d101dfd4f1e037304 100644
142
+ --- a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
143
+ +++ b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
144
+ @@ -66,10 +66,8 @@ using namespace llvm;
145
+
146
+ static codegen::RegisterCodeGenFlags CGF;
147
+
148
+ -typedef struct LLVMOpaquePass *LLVMPassRef;
149
+ typedef struct LLVMOpaqueTargetMachine *LLVMTargetMachineRef;
150
+
151
+ -DEFINE_STDCXX_CONVERSION_FUNCTIONS(Pass, LLVMPassRef)
152
+ DEFINE_STDCXX_CONVERSION_FUNCTIONS(TargetMachine, LLVMTargetMachineRef)
153
+
154
+ extern "C" void LLVMRustTimeTraceProfilerInitialize() {
155
+ diff --git a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
156
+ index c928282596cdd3296db4330cc3d1feaf6abd1671..189296dc9c4c81e1422187cf597c6376b8de17f5 100644
157
+ --- a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
158
+ +++ b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
159
+ @@ -1199,11 +1199,9 @@ extern "C" void LLVMRustWriteValueToString(LLVMValueRef V, RustStringRef Str) {
160
+ }
161
+ }
162
+
163
+ -DEFINE_SIMPLE_CONVERSION_FUNCTIONS(Twine, LLVMTwineRef)
164
+ -
165
+ -extern "C" void LLVMRustWriteTwineToString(LLVMTwineRef T, RustStringRef Str) {
166
+ +extern "C" void LLVMRustWriteTwineToString(const Twine *T, RustStringRef Str) {
167
+ auto OS = RawRustStringOstream(Str);
168
+ - unwrap(T)->print(OS);
169
+ + T->print(OS);
170
+ }
171
+
172
+ extern "C" void LLVMRustUnpackOptimizationDiagnostic(
173
+ @@ -1239,13 +1237,13 @@ enum class LLVMRustDiagnosticLevel {
174
+
175
+ extern "C" void LLVMRustUnpackInlineAsmDiagnostic(
176
+ LLVMDiagnosticInfoRef DI, LLVMRustDiagnosticLevel *LevelOut,
177
+ - uint64_t *CookieOut, LLVMTwineRef *MessageOut) {
178
+ + uint64_t *CookieOut, const Twine **MessageOut) {
179
+ // Undefined to call this not on an inline assembly diagnostic!
180
+ llvm::DiagnosticInfoInlineAsm *IA =
181
+ static_cast<llvm::DiagnosticInfoInlineAsm *>(unwrap(DI));
182
+
183
+ *CookieOut = IA->getLocCookie();
184
+ - *MessageOut = wrap(&IA->getMsgStr());
185
+ + *MessageOut = &IA->getMsgStr();
186
+
187
+ switch (IA->getSeverity()) {
188
+ case DS_Error:
189
+ @@ -1334,22 +1332,20 @@ LLVMRustGetDiagInfoKind(LLVMDiagnosticInfoRef DI) {
190
+ return toRust((DiagnosticKind)unwrap(DI)->getKind());
191
+ }
192
+
193
+ -DEFINE_SIMPLE_CONVERSION_FUNCTIONS(SMDiagnostic, LLVMSMDiagnosticRef)
194
+ -
195
+ -extern "C" LLVMSMDiagnosticRef LLVMRustGetSMDiagnostic(LLVMDiagnosticInfoRef DI,
196
+ +extern "C" const SMDiagnostic *LLVMRustGetSMDiagnostic(LLVMDiagnosticInfoRef DI,
197
+ uint64_t *Cookie) {
198
+ llvm::DiagnosticInfoSrcMgr *SM =
199
+ static_cast<llvm::DiagnosticInfoSrcMgr *>(unwrap(DI));
200
+ *Cookie = SM->getLocCookie();
201
+ - return wrap(&SM->getSMDiag());
202
+ + return &SM->getSMDiag();
203
+ }
204
+
205
+ extern "C" bool
206
+ -LLVMRustUnpackSMDiagnostic(LLVMSMDiagnosticRef DRef, RustStringRef MessageOut,
207
+ +LLVMRustUnpackSMDiagnostic(const SMDiagnostic *DRef, RustStringRef MessageOut,
208
+ RustStringRef BufferOut,
209
+ LLVMRustDiagnosticLevel *LevelOut, unsigned *LocOut,
210
+ unsigned *RangesOut, size_t *NumRanges) {
211
+ - SMDiagnostic &D = *unwrap(DRef);
212
+ + const SMDiagnostic &D = *DRef;
213
+ auto MessageOS = RawRustStringOstream(MessageOut);
214
+ MessageOS << D.getMessage();
215
+
216
+ diff --git a/compiler/rustc_macros/src/diagnostics/message.rs b/compiler/rustc_macros/src/diagnostics/message.rs
217
+ index 63561e409b0ae60acd1dce4b1770859ca2399b35..8eff9a4fa9e8a5d9bb10565cc3f49aec9410ce2d 100644
218
+ --- a/compiler/rustc_macros/src/diagnostics/message.rs
219
+ +++ b/compiler/rustc_macros/src/diagnostics/message.rs
220
+ @@ -133,6 +133,7 @@ const ALLOWED_CAPITALIZED_WORDS: &[&str] = &[
221
+ "Cargo",
222
+ "Ferris",
223
+ "GCC",
224
+ + "LLVM",
225
+ "MIR",
226
+ "NaNs",
227
+ "OK",
228
+ diff --git a/compiler/rustc_mir_build/src/builder/mod.rs b/compiler/rustc_mir_build/src/builder/mod.rs
229
+ index 7701206ad03b74e4d80e458d37da9acbc92d1a38..60b8cf3f78a06142fbade7cd4f0b29778e97df56 100644
230
+ --- a/compiler/rustc_mir_build/src/builder/mod.rs
231
+ +++ b/compiler/rustc_mir_build/src/builder/mod.rs
232
+ @@ -33,7 +33,6 @@ use rustc_hir::{self as hir, BindingMode, ByRef, HirId, ItemLocalId, Node, find_
233
+ use rustc_index::bit_set::GrowableBitSet;
234
+ use rustc_index::{Idx, IndexSlice, IndexVec};
235
+ use rustc_infer::infer::{InferCtxt, TyCtxtInferExt};
236
+ -use rustc_infer::traits::ObligationCause;
237
+ use rustc_middle::hir::place::PlaceBase as HirPlaceBase;
238
+ use rustc_middle::middle::region;
239
+ use rustc_middle::mir::*;
240
+ @@ -41,7 +40,6 @@ use rustc_middle::thir::{self, ExprId, LocalVarId, Param, ParamId, PatKind, Thir
241
+ use rustc_middle::ty::{self, ScalarInt, Ty, TyCtxt, TypeVisitableExt, TypingMode};
242
+ use rustc_middle::{bug, span_bug};
243
+ use rustc_span::{Span, Symbol};
244
+ -use rustc_trait_selection::traits::ObligationCtxt;
245
+
246
+ use crate::builder::expr::as_place::PlaceBuilder;
247
+ use crate::builder::scope::LintLevel;
248
+ @@ -508,7 +506,17 @@ fn construct_fn<'tcx>(
249
+
250
+ let infcx = tcx.infer_ctxt().build(typing_mode);
251
+
252
+ - let coroutine = match normalized_type_of(&infcx, fn_def).kind() {
253
+ + let defining_ty = tcx.type_of(fn_def).instantiate_identity().skip_normalization();
254
+ + let defining_ty = if infcx.next_trait_solver() {
255
+ + // Closure types come from HIR typeck results, where they were already
256
+ + // normalized during writeback. Wrapping them in an `EarlyBinder`
257
+ + // conservatively makes aliases non-rigid, so restore their rigidness
258
+ + // instead of normalizing them again during MIR build.
259
+ + ty::set_aliases_to_rigid(tcx, defining_ty)
260
+ + } else {
261
+ + defining_ty
262
+ + };
263
+ + let coroutine = match defining_ty.kind() {
264
+ ty::Coroutine(_, args) => Some(Box::new(CoroutineInfo::initial(
265
+ tcx.coroutine_kind(fn_def).unwrap(),
266
+ args.as_coroutine().yield_ty(),
267
+ @@ -566,18 +574,6 @@ fn construct_fn<'tcx>(
268
+ body
269
+ }
270
+
271
+ -fn normalized_type_of<'tcx>(infcx: &InferCtxt<'tcx>, def_id: LocalDefId) -> Ty<'tcx> {
272
+ - let tcx = infcx.tcx;
273
+ - let ty = tcx.type_of(def_id).instantiate_identity();
274
+ - if !infcx.next_trait_solver() {
275
+ - return ty.skip_normalization();
276
+ - }
277
+ -
278
+ - let ocx = ObligationCtxt::new(infcx);
279
+ - let cause = ObligationCause::misc(tcx.def_span(def_id), def_id);
280
+ - ocx.deeply_normalize(&cause, tcx.param_env(def_id), ty).unwrap()
281
+ -}
282
+ -
283
+ fn construct_const<'a, 'tcx>(
284
+ tcx: TyCtxt<'tcx>,
285
+ def: LocalDefId,
286
+ diff --git a/compiler/rustc_session/src/filesearch.rs b/compiler/rustc_session/src/filesearch.rs
287
+ index 6ec1466500a86890d8e2480951a59a5ec7c1f027..10c62d932ba260a11e558ac8fd6db059fd239816 100644
288
+ --- a/compiler/rustc_session/src/filesearch.rs
289
+ +++ b/compiler/rustc_session/src/filesearch.rs
290
+ @@ -258,7 +258,7 @@ pub unsafe fn dll_path(function: *mut std::ffi::c_void) -> Result<PathBuf, Strin
291
+ }
292
+
293
+ #[cfg(target_os = "wasi")]
294
+ -pub unsafe fn dll_path(function: *mut std::ffi::c_void) -> Result<PathBuf, String> {
295
+ +pub unsafe fn dll_path(_function: *mut std::ffi::c_void) -> Result<PathBuf, String> {
296
+ Err("dll_path is not supported on WASI".to_string())
297
+ }
298
+
299
+ diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs
300
+ index 1c4f0ca5069dfaaeaba18c296b875fcb8666beac..11b051b530198719b55302c7c694f0ab4a888df2 100644
301
+ --- a/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs
302
+ +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs
303
+ @@ -657,6 +657,15 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
304
+ span_bug!(span, "coerce requirement gave wrong error: `{:?}`", predicate)
305
+ }
306
+
307
+ + ty::PredicateKind::Clause(ty::ClauseKind::TypeOutlives(..))
308
+ + if self.next_trait_solver() =>
309
+ + {
310
+ + // We normalize `TypeOutlives` in the next solver, which is fallible
311
+ + return self.dcx().span_delayed_bug(
312
+ + span,
313
+ + "type outlives claues errored outside borrowck without any other error",
314
+ + );
315
+ + }
316
+ ty::PredicateKind::Clause(ty::ClauseKind::RegionOutlives(..))
317
+ | ty::PredicateKind::Clause(ty::ClauseKind::TypeOutlives(..)) => {
318
+ span_bug!(
319
+ diff --git a/compiler/rustc_trait_selection/src/traits/implied_outlives_bounds.rs b/compiler/rustc_trait_selection/src/traits/implied_outlives_bounds.rs
320
+ index 79f630860235a248a8a092b60fe697f3301c5648..c0df53db4ab3420d9f097ca3bd9d4dca4c678d0c 100644
321
+ --- a/compiler/rustc_trait_selection/src/traits/implied_outlives_bounds.rs
322
+ +++ b/compiler/rustc_trait_selection/src/traits/implied_outlives_bounds.rs
323
+ @@ -39,14 +39,6 @@ impl<'tcx> QueryTypeOp<'tcx> for ImpliedOutlivesBounds<'tcx> {
324
+ ) -> Result<CanonicalQueryResponse<'tcx, Self::QueryResponse>, NoSolution> {
325
+ tcx.implied_outlives_bounds((canonicalized, false))
326
+ }
327
+ -
328
+ - fn perform_locally_with_next_solver(
329
+ - ocx: &ObligationCtxt<'_, 'tcx>,
330
+ - key: ParamEnvAnd<'tcx, Self>,
331
+ - _span: Span,
332
+ - ) -> Result<Self::QueryResponse, NoSolution> {
333
+ - query_compute_implied_outlives_bounds(ocx, key.param_env, key.value.ty, false)
334
+ - }
335
+ }
336
+
337
+ pub fn compute_implied_outlives_bounds_inner<'tcx>(
338
+ diff --git a/compiler/rustc_trait_selection/src/traits/query/type_op/ascribe_user_type.rs b/compiler/rustc_trait_selection/src/traits/query/type_op/ascribe_user_type.rs
339
+ index e8814c56c50164e526492e1dcfdcbc24d04873e5..239cbc5aa76229e2477872e2c703a7c092afb0d8 100644
340
+ --- a/compiler/rustc_trait_selection/src/traits/query/type_op/ascribe_user_type.rs
341
+ +++ b/compiler/rustc_trait_selection/src/traits/query/type_op/ascribe_user_type.rs
342
+ @@ -29,14 +29,6 @@ impl<'tcx> super::QueryTypeOp<'tcx> for AscribeUserType<'tcx> {
343
+ ) -> Result<CanonicalQueryResponse<'tcx, ()>, NoSolution> {
344
+ tcx.type_op_ascribe_user_type(canonicalized)
345
+ }
346
+ -
347
+ - fn perform_locally_with_next_solver(
348
+ - ocx: &ObligationCtxt<'_, 'tcx>,
349
+ - key: ParamEnvAnd<'tcx, Self>,
350
+ - span: Span,
351
+ - ) -> Result<Self::QueryResponse, NoSolution> {
352
+ - type_op_ascribe_user_type_with_span(ocx, key, span)
353
+ - }
354
+ }
355
+
356
+ /// The core of the `type_op_ascribe_user_type` query: for diagnostics purposes in NLL HRTB errors,
357
+ diff --git a/compiler/rustc_trait_selection/src/traits/query/type_op/mod.rs b/compiler/rustc_trait_selection/src/traits/query/type_op/mod.rs
358
+ index 62d636f2de046bad955e157ec719de05d44dcff0..250579a2b064a454a86a90cf6c7a08f34a3f67a4 100644
359
+ --- a/compiler/rustc_trait_selection/src/traits/query/type_op/mod.rs
360
+ +++ b/compiler/rustc_trait_selection/src/traits/query/type_op/mod.rs
361
+ @@ -12,7 +12,7 @@ use crate::infer::canonical::{
362
+ QueryRegionConstraints,
363
+ };
364
+ use crate::infer::{InferCtxt, InferOk};
365
+ -use crate::traits::{ObligationCause, ObligationCtxt};
366
+ +use crate::traits::ObligationCause;
367
+
368
+ pub mod ascribe_user_type;
369
+ pub mod custom;
370
+ @@ -83,18 +83,6 @@ pub trait QueryTypeOp<'tcx>: fmt::Debug + Copy + TypeFoldable<TyCtxt<'tcx>> + 't
371
+ canonicalized: CanonicalQueryInput<'tcx, ParamEnvAnd<'tcx, Self>>,
372
+ ) -> Result<CanonicalQueryResponse<'tcx, Self::QueryResponse>, NoSolution>;
373
+
374
+ - /// In the new trait solver, we already do caching in the solver itself,
375
+ - /// so there's no need to canonicalize and cache via the query system.
376
+ - /// Additionally, even if we were to canonicalize, we'd still need to
377
+ - /// make sure to feed it predefined opaque types and the defining anchor
378
+ - /// and that would require duplicating all of the tcx queries. Instead,
379
+ - /// just perform these ops locally.
380
+ - fn perform_locally_with_next_solver(
381
+ - ocx: &ObligationCtxt<'_, 'tcx>,
382
+ - key: ParamEnvAnd<'tcx, Self>,
383
+ - span: Span,
384
+ - ) -> Result<Self::QueryResponse, NoSolution>;
385
+ -
386
+ fn fully_perform_into(
387
+ query_key: ParamEnvAnd<'tcx, Self>,
388
+ infcx: &InferCtxt<'tcx>,
389
+ diff --git a/compiler/rustc_trait_selection/src/traits/query/type_op/normalize.rs b/compiler/rustc_trait_selection/src/traits/query/type_op/normalize.rs
390
+ index 7b330c942807c63f8d2ab92b862488ef31ab5e65..66a2d44699634dac4d4fd6aeea7a9220224eecc2 100644
391
+ --- a/compiler/rustc_trait_selection/src/traits/query/type_op/normalize.rs
392
+ +++ b/compiler/rustc_trait_selection/src/traits/query/type_op/normalize.rs
393
+ @@ -1,13 +1,10 @@
394
+ use std::fmt;
395
+
396
+ -use rustc_middle::traits::ObligationCause;
397
+ use rustc_middle::traits::query::NoSolution;
398
+ pub use rustc_middle::traits::query::type_op::Normalize;
399
+ use rustc_middle::ty::{self, Lift, ParamEnvAnd, Ty, TyCtxt, TypeFoldable, TypeVisitableExt};
400
+ -use rustc_span::Span;
401
+
402
+ use crate::infer::canonical::{CanonicalQueryInput, CanonicalQueryResponse};
403
+ -use crate::traits::ObligationCtxt;
404
+
405
+ impl<'tcx, T> super::QueryTypeOp<'tcx> for Normalize<'tcx, T>
406
+ where
407
+ @@ -29,19 +26,6 @@ where
408
+ ) -> Result<CanonicalQueryResponse<'tcx, Self::QueryResponse>, NoSolution> {
409
+ T::type_op_method(tcx, canonicalized)
410
+ }
411
+ -
412
+ - fn perform_locally_with_next_solver(
413
+ - ocx: &ObligationCtxt<'_, 'tcx>,
414
+ - key: ParamEnvAnd<'tcx, Self>,
415
+ - span: Span,
416
+ - ) -> Result<Self::QueryResponse, NoSolution> {
417
+ - ocx.deeply_normalize(
418
+ - &ObligationCause::dummy_with_span(span),
419
+ - key.param_env,
420
+ - key.value.value,
421
+ - )
422
+ - .map_err(|_| NoSolution)
423
+ - }
424
+ }
425
+
426
+ pub trait Normalizable<'tcx>:
427
+ diff --git a/compiler/rustc_trait_selection/src/traits/query/type_op/outlives.rs b/compiler/rustc_trait_selection/src/traits/query/type_op/outlives.rs
428
+ index 99a2779aa8212e3c8b4f44b40797aaa2203cd9f7..fd06dd4403c12da02009110ac296cdf6b557f52a 100644
429
+ --- a/compiler/rustc_trait_selection/src/traits/query/type_op/outlives.rs
430
+ +++ b/compiler/rustc_trait_selection/src/traits/query/type_op/outlives.rs
431
+ @@ -1,12 +1,8 @@
432
+ use rustc_middle::traits::query::{DropckOutlivesResult, NoSolution};
433
+ use rustc_middle::ty::{ParamEnvAnd, TyCtxt};
434
+ -use rustc_span::Span;
435
+
436
+ use crate::infer::canonical::{CanonicalQueryInput, CanonicalQueryResponse};
437
+ -use crate::traits::ObligationCtxt;
438
+ -use crate::traits::query::dropck_outlives::{
439
+ - compute_dropck_outlives_inner, trivial_dropck_outlives,
440
+ -};
441
+ +use crate::traits::query::dropck_outlives::trivial_dropck_outlives;
442
+ use crate::traits::query::type_op::DropckOutlives;
443
+
444
+ impl<'tcx> super::QueryTypeOp<'tcx> for DropckOutlives<'tcx> {
445
+ @@ -25,12 +21,4 @@ impl<'tcx> super::QueryTypeOp<'tcx> for DropckOutlives<'tcx> {
446
+ ) -> Result<CanonicalQueryResponse<'tcx, Self::QueryResponse>, NoSolution> {
447
+ tcx.dropck_outlives(canonicalized)
448
+ }
449
+ -
450
+ - fn perform_locally_with_next_solver(
451
+ - ocx: &ObligationCtxt<'_, 'tcx>,
452
+ - key: ParamEnvAnd<'tcx, Self>,
453
+ - span: Span,
454
+ - ) -> Result<Self::QueryResponse, NoSolution> {
455
+ - compute_dropck_outlives_inner(ocx, key.param_env.and(key.value), span)
456
+ - }
457
+ }
458
+ diff --git a/compiler/rustc_trait_selection/src/traits/query/type_op/prove_predicate.rs b/compiler/rustc_trait_selection/src/traits/query/type_op/prove_predicate.rs
459
+ index 8601371c7ebf2a568fe27c2bd40f7b35aceee9f1..5dedd9af40561fb7d807dedb95d9cfc490e523c0 100644
460
+ --- a/compiler/rustc_trait_selection/src/traits/query/type_op/prove_predicate.rs
461
+ +++ b/compiler/rustc_trait_selection/src/traits/query/type_op/prove_predicate.rs
462
+ @@ -3,7 +3,6 @@ use rustc_middle::traits::ObligationCause;
463
+ use rustc_middle::traits::query::NoSolution;
464
+ pub use rustc_middle::traits::query::type_op::ProvePredicate;
465
+ use rustc_middle::ty::{self, ParamEnvAnd, TyCtxt};
466
+ -use rustc_span::Span;
467
+
468
+ use crate::infer::canonical::{CanonicalQueryInput, CanonicalQueryResponse};
469
+ use crate::traits::{ObligationCtxt, sizedness_fast_path};
470
+ @@ -35,20 +34,6 @@ impl<'tcx> super::QueryTypeOp<'tcx> for ProvePredicate<'tcx> {
471
+ ) -> Result<CanonicalQueryResponse<'tcx, ()>, NoSolution> {
472
+ tcx.type_op_prove_predicate(canonicalized)
473
+ }
474
+ -
475
+ - fn perform_locally_with_next_solver(
476
+ - ocx: &ObligationCtxt<'_, 'tcx>,
477
+ - key: ParamEnvAnd<'tcx, Self>,
478
+ - span: Span,
479
+ - ) -> Result<Self::QueryResponse, NoSolution> {
480
+ - ocx.register_obligation(Obligation::new(
481
+ - ocx.infcx.tcx,
482
+ - ObligationCause::dummy_with_span(span),
483
+ - key.param_env,
484
+ - key.value.predicate,
485
+ - ));
486
+ - Ok(())
487
+ - }
488
+ }
489
+
490
+ /// The core of the `type_op_prove_predicate` query: for diagnostics purposes in NLL HRTB errors,
491
+ diff --git a/compiler/rustc_type_ir/src/ty_kind.rs b/compiler/rustc_type_ir/src/ty_kind.rs
492
+ index 94e6be03c766f7d5d38687fa09a456197d366cc2..0a9eaf360e3efa99f0cf79a269c8ec5d3e211fb7 100644
493
+ --- a/compiler/rustc_type_ir/src/ty_kind.rs
494
+ +++ b/compiler/rustc_type_ir/src/ty_kind.rs
495
+ @@ -112,6 +112,12 @@ impl<I: Interner> AliasTyKind<I> {
496
+ /// with `IsRigid::Yes`. At this point we no longer have to try and renormalize this alias
497
+ /// later on.
498
+ ///
499
+ +/// Rigidness becomes outdated when the surrounding typing mode or param env changes,
500
+ +/// because further normalization might be possible.
501
+ +/// We should also note that rigidness can be shared within some typing mode groups
502
+ +/// if the param env is the same, e.g., `Typeck/PostTypeckUntilBorrowck` and
503
+ +/// `PostAnalysis/Codegen`.
504
+ +///
505
+ /// FIXME(#155345): Alias handling is currently still in flux for the new trait
506
+ /// solver and this is currently somewhat messy. Please reach out on
507
+ /// #t-types/trait-system-refactor-initiative if you encounter this and it isn't
508
+ diff --git a/library/alloc/src/boxed/iter.rs b/library/alloc/src/boxed/iter.rs
509
+ index 904e7e3c356a723bd3f114803fb4d13bbb64a7d3..f0eccf107caded3a5e3bdeffb2c469af622c0a98 100644
510
+ --- a/library/alloc/src/boxed/iter.rs
511
+ +++ b/library/alloc/src/boxed/iter.rs
512
+ @@ -93,55 +93,55 @@ impl<S: ?Sized + AsyncIterator + Unpin> AsyncIterator for Box<S> {
513
+ }
514
+ }
515
+
516
+ -/// This implementation is required to make sure that the `Box<[I]>: IntoIterator`
517
+ +/// This implementation is required to make sure that the `Box<[T]>: IntoIterator`
518
+ /// implementation doesn't overlap with `IntoIterator for T where T: Iterator` blanket.
519
+ #[stable(feature = "boxed_slice_into_iter", since = "1.80.0")]
520
+ -impl<I, A: Allocator> !Iterator for Box<[I], A> {}
521
+ +impl<T, A: Allocator> !Iterator for Box<[T], A> {}
522
+
523
+ -/// This implementation is required to make sure that the `&Box<[I]>: IntoIterator`
524
+ +/// This implementation is required to make sure that the `&Box<[T]>: IntoIterator`
525
+ /// implementation doesn't overlap with `IntoIterator for T where T: Iterator` blanket.
526
+ #[stable(feature = "boxed_slice_into_iter", since = "1.80.0")]
527
+ -impl<'a, I, A: Allocator> !Iterator for &'a Box<[I], A> {}
528
+ +impl<'a, T, A: Allocator> !Iterator for &'a Box<[T], A> {}
529
+
530
+ -/// This implementation is required to make sure that the `&mut Box<[I]>: IntoIterator`
531
+ +/// This implementation is required to make sure that the `&mut Box<[T]>: IntoIterator`
532
+ /// implementation doesn't overlap with `IntoIterator for T where T: Iterator` blanket.
533
+ #[stable(feature = "boxed_slice_into_iter", since = "1.80.0")]
534
+ -impl<'a, I, A: Allocator> !Iterator for &'a mut Box<[I], A> {}
535
+ +impl<'a, T, A: Allocator> !Iterator for &'a mut Box<[T], A> {}
536
+
537
+ // Note: the `#[rustc_skip_during_method_dispatch(boxed_slice)]` on `trait IntoIterator`
538
+ // hides this implementation from explicit `.into_iter()` calls on editions < 2024,
539
+ // so those calls will still resolve to the slice implementation, by reference.
540
+ #[stable(feature = "boxed_slice_into_iter", since = "1.80.0")]
541
+ -impl<I, A: Allocator> IntoIterator for Box<[I], A> {
542
+ - type IntoIter = vec::IntoIter<I, A>;
543
+ - type Item = I;
544
+ - fn into_iter(self) -> vec::IntoIter<I, A> {
545
+ +impl<T, A: Allocator> IntoIterator for Box<[T], A> {
546
+ + type IntoIter = vec::IntoIter<T, A>;
547
+ + type Item = T;
548
+ + fn into_iter(self) -> vec::IntoIter<T, A> {
549
+ self.into_vec().into_iter()
550
+ }
551
+ }
552
+
553
+ #[stable(feature = "boxed_slice_into_iter", since = "1.80.0")]
554
+ -impl<'a, I, A: Allocator> IntoIterator for &'a Box<[I], A> {
555
+ - type IntoIter = slice::Iter<'a, I>;
556
+ - type Item = &'a I;
557
+ - fn into_iter(self) -> slice::Iter<'a, I> {
558
+ +impl<'a, T, A: Allocator> IntoIterator for &'a Box<[T], A> {
559
+ + type IntoIter = slice::Iter<'a, T>;
560
+ + type Item = &'a T;
561
+ + fn into_iter(self) -> slice::Iter<'a, T> {
562
+ self.iter()
563
+ }
564
+ }
565
+
566
+ #[stable(feature = "boxed_slice_into_iter", since = "1.80.0")]
567
+ -impl<'a, I, A: Allocator> IntoIterator for &'a mut Box<[I], A> {
568
+ - type IntoIter = slice::IterMut<'a, I>;
569
+ - type Item = &'a mut I;
570
+ - fn into_iter(self) -> slice::IterMut<'a, I> {
571
+ +impl<'a, T, A: Allocator> IntoIterator for &'a mut Box<[T], A> {
572
+ + type IntoIter = slice::IterMut<'a, T>;
573
+ + type Item = &'a mut T;
574
+ + fn into_iter(self) -> slice::IterMut<'a, T> {
575
+ self.iter_mut()
576
+ }
577
+ }
578
+
579
+ #[cfg(not(no_global_oom_handling))]
580
+ #[stable(feature = "boxed_slice_from_iter", since = "1.32.0")]
581
+ -impl<I> FromIterator<I> for Box<[I]> {
582
+ - fn from_iter<T: IntoIterator<Item = I>>(iter: T) -> Self {
583
+ +impl<T> FromIterator<T> for Box<[T]> {
584
+ + fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self {
585
+ iter.into_iter().collect::<Vec<_>>().into_boxed_slice()
586
+ }
587
+ }
588
+ @@ -149,7 +149,7 @@ impl<I> FromIterator<I> for Box<[I]> {
589
+ #[cfg(not(no_global_oom_handling))]
590
+ #[stable(feature = "boxed_str_from_iter", since = "1.80.0")]
591
+ impl FromIterator<char> for Box<str> {
592
+ - fn from_iter<T: IntoIterator<Item = char>>(iter: T) -> Self {
593
+ + fn from_iter<I: IntoIterator<Item = char>>(iter: I) -> Self {
594
+ String::from_iter(iter).into_boxed_str()
595
+ }
596
+ }
597
+ @@ -157,7 +157,7 @@ impl FromIterator<char> for Box<str> {
598
+ #[cfg(not(no_global_oom_handling))]
599
+ #[stable(feature = "boxed_str_from_iter", since = "1.80.0")]
600
+ impl<'a> FromIterator<&'a char> for Box<str> {
601
+ - fn from_iter<T: IntoIterator<Item = &'a char>>(iter: T) -> Self {
602
+ + fn from_iter<I: IntoIterator<Item = &'a char>>(iter: I) -> Self {
603
+ String::from_iter(iter).into_boxed_str()
604
+ }
605
+ }
606
+ @@ -165,7 +165,7 @@ impl<'a> FromIterator<&'a char> for Box<str> {
607
+ #[cfg(not(no_global_oom_handling))]
608
+ #[stable(feature = "boxed_str_from_iter", since = "1.80.0")]
609
+ impl<'a> FromIterator<&'a str> for Box<str> {
610
+ - fn from_iter<T: IntoIterator<Item = &'a str>>(iter: T) -> Self {
611
+ + fn from_iter<I: IntoIterator<Item = &'a str>>(iter: I) -> Self {
612
+ String::from_iter(iter).into_boxed_str()
613
+ }
614
+ }
615
+ @@ -173,7 +173,7 @@ impl<'a> FromIterator<&'a str> for Box<str> {
616
+ #[cfg(not(no_global_oom_handling))]
617
+ #[stable(feature = "boxed_str_from_iter", since = "1.80.0")]
618
+ impl FromIterator<String> for Box<str> {
619
+ - fn from_iter<T: IntoIterator<Item = String>>(iter: T) -> Self {
620
+ + fn from_iter<I: IntoIterator<Item = String>>(iter: I) -> Self {
621
+ String::from_iter(iter).into_boxed_str()
622
+ }
623
+ }
624
+ @@ -181,7 +181,7 @@ impl FromIterator<String> for Box<str> {
625
+ #[cfg(not(no_global_oom_handling))]
626
+ #[stable(feature = "boxed_str_from_iter", since = "1.80.0")]
627
+ impl<A: Allocator> FromIterator<Box<str, A>> for Box<str> {
628
+ - fn from_iter<T: IntoIterator<Item = Box<str, A>>>(iter: T) -> Self {
629
+ + fn from_iter<I: IntoIterator<Item = Box<str, A>>>(iter: I) -> Self {
630
+ String::from_iter(iter).into_boxed_str()
631
+ }
632
+ }
633
+ @@ -189,7 +189,7 @@ impl<A: Allocator> FromIterator<Box<str, A>> for Box<str> {
634
+ #[cfg(not(no_global_oom_handling))]
635
+ #[stable(feature = "boxed_str_from_iter", since = "1.80.0")]
636
+ impl<'a> FromIterator<Cow<'a, str>> for Box<str> {
637
+ - fn from_iter<T: IntoIterator<Item = Cow<'a, str>>>(iter: T) -> Self {
638
+ + fn from_iter<I: IntoIterator<Item = Cow<'a, str>>>(iter: I) -> Self {
639
+ String::from_iter(iter).into_boxed_str()
640
+ }
641
+ }
642
+ diff --git a/library/alloc/src/bstr.rs b/library/alloc/src/bstr.rs
643
+ index f48b2d52e80c1f39d85286c98aa3a90e31a74601..a6c6377c8b2e1126f5d06bfe67b24c3fb005124e 100644
644
+ --- a/library/alloc/src/bstr.rs
645
+ +++ b/library/alloc/src/bstr.rs
646
+ @@ -274,7 +274,7 @@ impl<'a> From<&'a ByteString> for Cow<'a, ByteStr> {
647
+ #[unstable(feature = "bstr", issue = "134915")]
648
+ impl FromIterator<char> for ByteString {
649
+ #[inline]
650
+ - fn from_iter<T: IntoIterator<Item = char>>(iter: T) -> Self {
651
+ + fn from_iter<I: IntoIterator<Item = char>>(iter: I) -> Self {
652
+ ByteString(iter.into_iter().collect::<String>().into_bytes())
653
+ }
654
+ }
655
+ @@ -282,7 +282,7 @@ impl FromIterator<char> for ByteString {
656
+ #[unstable(feature = "bstr", issue = "134915")]
657
+ impl FromIterator<u8> for ByteString {
658
+ #[inline]
659
+ - fn from_iter<T: IntoIterator<Item = u8>>(iter: T) -> Self {
660
+ + fn from_iter<I: IntoIterator<Item = u8>>(iter: I) -> Self {
661
+ ByteString(iter.into_iter().collect())
662
+ }
663
+ }
664
+ @@ -290,7 +290,7 @@ impl FromIterator<u8> for ByteString {
665
+ #[unstable(feature = "bstr", issue = "134915")]
666
+ impl<'a> FromIterator<&'a str> for ByteString {
667
+ #[inline]
668
+ - fn from_iter<T: IntoIterator<Item = &'a str>>(iter: T) -> Self {
669
+ + fn from_iter<I: IntoIterator<Item = &'a str>>(iter: I) -> Self {
670
+ ByteString(iter.into_iter().collect::<String>().into_bytes())
671
+ }
672
+ }
673
+ @@ -298,7 +298,7 @@ impl<'a> FromIterator<&'a str> for ByteString {
674
+ #[unstable(feature = "bstr", issue = "134915")]
675
+ impl<'a> FromIterator<&'a [u8]> for ByteString {
676
+ #[inline]
677
+ - fn from_iter<T: IntoIterator<Item = &'a [u8]>>(iter: T) -> Self {
678
+ + fn from_iter<I: IntoIterator<Item = &'a [u8]>>(iter: I) -> Self {
679
+ let mut buf = Vec::new();
680
+ for b in iter {
681
+ buf.extend_from_slice(b);
682
+ @@ -310,7 +310,7 @@ impl<'a> FromIterator<&'a [u8]> for ByteString {
683
+ #[unstable(feature = "bstr", issue = "134915")]
684
+ impl<'a> FromIterator<&'a ByteStr> for ByteString {
685
+ #[inline]
686
+ - fn from_iter<T: IntoIterator<Item = &'a ByteStr>>(iter: T) -> Self {
687
+ + fn from_iter<I: IntoIterator<Item = &'a ByteStr>>(iter: I) -> Self {
688
+ let mut buf = Vec::new();
689
+ for b in iter {
690
+ buf.extend_from_slice(&b.0);
691
+ @@ -322,7 +322,7 @@ impl<'a> FromIterator<&'a ByteStr> for ByteString {
692
+ #[unstable(feature = "bstr", issue = "134915")]
693
+ impl FromIterator<ByteString> for ByteString {
694
+ #[inline]
695
+ - fn from_iter<T: IntoIterator<Item = ByteString>>(iter: T) -> Self {
696
+ + fn from_iter<I: IntoIterator<Item = ByteString>>(iter: I) -> Self {
697
+ let mut buf = Vec::new();
698
+ for mut b in iter {
699
+ buf.append(&mut b.0);
700
+ diff --git a/library/alloc/src/collections/btree/map.rs b/library/alloc/src/collections/btree/map.rs
701
+ index da08f9bfa36ed375da347ff932e0c5624f5f32b0..2f60fd1f74d3500ad200701adff1ce25cc7deb70 100644
702
+ --- a/library/alloc/src/collections/btree/map.rs
703
+ +++ b/library/alloc/src/collections/btree/map.rs
704
+ @@ -2545,7 +2545,7 @@ impl<K: Ord, V> FromIterator<(K, V)> for BTreeMap<K, V> {
705
+ ///
706
+ /// If the iterator produces any pairs with equal keys,
707
+ /// all but one of the corresponding values will be dropped.
708
+ - fn from_iter<T: IntoIterator<Item = (K, V)>>(iter: T) -> BTreeMap<K, V> {
709
+ + fn from_iter<I: IntoIterator<Item = (K, V)>>(iter: I) -> BTreeMap<K, V> {
710
+ let mut inputs: Vec<_> = iter.into_iter().collect();
711
+
712
+ if inputs.is_empty() {
713
+ @@ -2561,7 +2561,7 @@ impl<K: Ord, V> FromIterator<(K, V)> for BTreeMap<K, V> {
714
+ #[stable(feature = "rust1", since = "1.0.0")]
715
+ impl<K: Ord, V, A: AllocatorClone> Extend<(K, V)> for BTreeMap<K, V, A> {
716
+ #[inline]
717
+ - fn extend<T: IntoIterator<Item = (K, V)>>(&mut self, iter: T) {
718
+ + fn extend<I: IntoIterator<Item = (K, V)>>(&mut self, iter: I) {
719
+ iter.into_iter().for_each(move |(k, v)| {
720
+ self.insert(k, v);
721
+ });
722
+ diff --git a/library/alloc/src/string.rs b/library/alloc/src/string.rs
723
+ index d2b5a5a53a34aae2850c2181809d95e082c2f1af..170b94ba0c4b83b8917f74027af7fa74e5fd8cd0 100644
724
+ --- a/library/alloc/src/string.rs
725
+ +++ b/library/alloc/src/string.rs
726
+ @@ -2503,7 +2503,7 @@ impl<'a> FromIterator<Cow<'a, str>> for String {
727
+ #[cfg(not(no_global_oom_handling))]
728
+ #[unstable(feature = "ascii_char", issue = "110998")]
729
+ impl FromIterator<core::ascii::Char> for String {
730
+ - fn from_iter<T: IntoIterator<Item = core::ascii::Char>>(iter: T) -> Self {
731
+ + fn from_iter<I: IntoIterator<Item = core::ascii::Char>>(iter: I) -> Self {
732
+ let buf = iter.into_iter().map(core::ascii::Char::to_u8).collect();
733
+ // SAFETY: `buf` is guaranteed to be valid UTF-8 because the `core::ascii::Char` type
734
+ // only contains ASCII values (0x00-0x7F), which are valid UTF-8.
735
+ @@ -2514,7 +2514,7 @@ impl FromIterator<core::ascii::Char> for String {
736
+ #[cfg(not(no_global_oom_handling))]
737
+ #[unstable(feature = "ascii_char", issue = "110998")]
738
+ impl<'a> FromIterator<&'a core::ascii::Char> for String {
739
+ - fn from_iter<T: IntoIterator<Item = &'a core::ascii::Char>>(iter: T) -> Self {
740
+ + fn from_iter<I: IntoIterator<Item = &'a core::ascii::Char>>(iter: I) -> Self {
741
+ let buf = iter.into_iter().copied().map(core::ascii::Char::to_u8).collect();
742
+ // SAFETY: `buf` is guaranteed to be valid UTF-8 because the `core::ascii::Char` type
743
+ // only contains ASCII values (0x00-0x7F), which are valid UTF-8.
744
+ @@ -3355,7 +3355,7 @@ impl<'a> FromIterator<String> for Cow<'a, str> {
745
+ #[cfg(not(no_global_oom_handling))]
746
+ #[unstable(feature = "ascii_char", issue = "110998")]
747
+ impl<'a> FromIterator<core::ascii::Char> for Cow<'a, str> {
748
+ - fn from_iter<T: IntoIterator<Item = core::ascii::Char>>(it: T) -> Self {
749
+ + fn from_iter<I: IntoIterator<Item = core::ascii::Char>>(it: I) -> Self {
750
+ Cow::Owned(FromIterator::from_iter(it))
751
+ }
752
+ }
753
+ diff --git a/library/alloc/src/wtf8/mod.rs b/library/alloc/src/wtf8/mod.rs
754
+ index 94624a57754c6035b98c89c60d282cea9e102cc1..232fbba622b35dba076e35eebd2fa90d5ed54a79 100644
755
+ --- a/library/alloc/src/wtf8/mod.rs
756
+ +++ b/library/alloc/src/wtf8/mod.rs
757
+ @@ -448,7 +448,7 @@ impl Wtf8Buf {
758
+ /// This replaces surrogate code point pairs with supplementary code points,
759
+ /// like concatenating ill-formed UTF-16 strings effectively would.
760
+ impl FromIterator<CodePoint> for Wtf8Buf {
761
+ - fn from_iter<T: IntoIterator<Item = CodePoint>>(iter: T) -> Wtf8Buf {
762
+ + fn from_iter<I: IntoIterator<Item = CodePoint>>(iter: I) -> Wtf8Buf {
763
+ let mut string = Wtf8Buf::new();
764
+ string.extend(iter);
765
+ string
766
+ @@ -460,7 +460,7 @@ impl FromIterator<CodePoint> for Wtf8Buf {
767
+ /// This replaces surrogate code point pairs with supplementary code points,
768
+ /// like concatenating ill-formed UTF-16 strings effectively would.
769
+ impl Extend<CodePoint> for Wtf8Buf {
770
+ - fn extend<T: IntoIterator<Item = CodePoint>>(&mut self, iter: T) {
771
+ + fn extend<I: IntoIterator<Item = CodePoint>>(&mut self, iter: I) {
772
+ let iterator = iter.into_iter();
773
+ let (low, _high) = iterator.size_hint();
774
+ // Lower bound of one byte per code point (ASCII only)
775
+ diff --git a/library/core/src/iter/traits/collect.rs b/library/core/src/iter/traits/collect.rs
776
+ index e7e5e30b4eff51e9cd706fc1975334e88696e653..cf79ceadf0540782af1f1d6128804d5a87776fe4 100644
777
+ --- a/library/core/src/iter/traits/collect.rs
778
+ +++ b/library/core/src/iter/traits/collect.rs
779
+ @@ -97,41 +97,41 @@ use super::TrustedLen;
780
+ #[stable(feature = "rust1", since = "1.0.0")]
781
+ #[rustc_on_unimplemented(
782
+ on(
783
+ - Self = "&[{A}]",
784
+ + Self = "&[{T}]",
785
+ message = "a slice of type `{Self}` cannot be built since we need to store the elements somewhere",
786
+ - label = "try explicitly collecting into a `Vec<{A}>`",
787
+ + label = "try explicitly collecting into a `Vec<{T}>`",
788
+ ),
789
+ on(
790
+ - all(A = "{integer}", any(Self = "&[{integral}]",)),
791
+ + all(T = "{integer}", any(Self = "&[{integral}]",)),
792
+ message = "a slice of type `{Self}` cannot be built since we need to store the elements somewhere",
793
+ - label = "try explicitly collecting into a `Vec<{A}>`",
794
+ + label = "try explicitly collecting into a `Vec<{T}>`",
795
+ ),
796
+ on(
797
+ - Self = "[{A}]",
798
+ + Self = "[{T}]",
799
+ message = "a slice of type `{Self}` cannot be built since `{Self}` has no definite size",
800
+ - label = "try explicitly collecting into a `Vec<{A}>`",
801
+ + label = "try explicitly collecting into a `Vec<{T}>`",
802
+ ),
803
+ on(
804
+ - all(A = "{integer}", any(Self = "[{integral}]",)),
805
+ + all(T = "{integer}", any(Self = "[{integral}]",)),
806
+ message = "a slice of type `{Self}` cannot be built since `{Self}` has no definite size",
807
+ - label = "try explicitly collecting into a `Vec<{A}>`",
808
+ + label = "try explicitly collecting into a `Vec<{T}>`",
809
+ ),
810
+ on(
811
+ - Self = "[{A}; _]",
812
+ + Self = "[{T}; _]",
813
+ message = "an array of type `{Self}` cannot be built directly from an iterator",
814
+ - label = "try collecting into a `Vec<{A}>`, then using `.try_into()`",
815
+ + label = "try collecting into a `Vec<{T}>`, then using `.try_into()`",
816
+ ),
817
+ on(
818
+ - all(A = "{integer}", any(Self = "[{integral}; _]",)),
819
+ + all(T = "{integer}", any(Self = "[{integral}; _]",)),
820
+ message = "an array of type `{Self}` cannot be built directly from an iterator",
821
+ - label = "try collecting into a `Vec<{A}>`, then using `.try_into()`",
822
+ + label = "try collecting into a `Vec<{T}>`, then using `.try_into()`",
823
+ ),
824
+ message = "a value of type `{Self}` cannot be built from an iterator \
825
+ - over elements of type `{A}`",
826
+ - label = "value of type `{Self}` cannot be built from `std::iter::Iterator<Item={A}>`"
827
+ + over elements of type `{T}`",
828
+ + label = "value of type `{Self}` cannot be built from `std::iter::Iterator<Item={T}>`"
829
+ )]
830
+ #[rustc_diagnostic_item = "FromIterator"]
831
+ -pub trait FromIterator<A>: Sized {
832
+ +pub trait FromIterator<T>: Sized {
833
+ /// Creates a value from an iterator.
834
+ ///
835
+ /// See the [module-level documentation] for more.
836
+ @@ -149,7 +149,7 @@ pub trait FromIterator<A>: Sized {
837
+ /// ```
838
+ #[stable(feature = "rust1", since = "1.0.0")]
839
+ #[rustc_diagnostic_item = "from_iter_fn"]
840
+ - fn from_iter<T: IntoIterator<Item = A>>(iter: T) -> Self;
841
+ + fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self;
842
+ }
843
+
844
+ /// Conversion into an [`Iterator`].
845
+ @@ -371,7 +371,7 @@ const impl<I: [const] Iterator> IntoIterator for I {
846
+ /// // This is a bit simpler with the concrete type signature: we can call
847
+ /// // extend on anything which can be turned into an Iterator which gives
848
+ /// // us i32s. Because we need i32s to put into MyCollection.
849
+ -/// fn extend<T: IntoIterator<Item=i32>>(&mut self, iter: T) {
850
+ +/// fn extend<I: IntoIterator<Item=i32>>(&mut self, iter: I) {
851
+ ///
852
+ /// // The implementation is very straightforward: loop through the
853
+ /// // iterator, and add() each element to ourselves.
854
+ @@ -394,7 +394,7 @@ const impl<I: [const] Iterator> IntoIterator for I {
855
+ /// assert_eq!("MyCollection([5, 6, 7, 1, 2, 3])", format!("{c:?}"));
856
+ /// ```
857
+ #[stable(feature = "rust1", since = "1.0.0")]
858
+ -pub trait Extend<A> {
859
+ +pub trait Extend<T> {
860
+ /// Extends a collection with the contents of an iterator.
861
+ ///
862
+ /// As this is the only required method for this trait, the [trait-level] docs
863
+ @@ -413,11 +413,11 @@ pub trait Extend<A> {
864
+ /// assert_eq!("abcdef", &message);
865
+ /// ```
866
+ #[stable(feature = "rust1", since = "1.0.0")]
867
+ - fn extend<T: IntoIterator<Item = A>>(&mut self, iter: T);
868
+ + fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I);
869
+
870
+ /// Extends a collection with exactly one element.
871
+ #[unstable(feature = "extend_one", issue = "72631")]
872
+ - fn extend_one(&mut self, item: A) {
873
+ + fn extend_one(&mut self, item: T) {
874
+ self.extend(Some(item));
875
+ }
876
+
877
+ @@ -442,7 +442,7 @@ pub trait Extend<A> {
878
+ // This method is for internal usage only. It is only on the trait because of specialization's limitations.
879
+ #[unstable(feature = "extend_one_unchecked", issue = "none")]
880
+ #[doc(hidden)]
881
+ - unsafe fn extend_one_unchecked(&mut self, item: A)
882
+ + unsafe fn extend_one_unchecked(&mut self, item: T)
883
+ where
884
+ Self: Sized,
885
+ {
886
+ @@ -452,7 +452,7 @@ pub trait Extend<A> {
887
+
888
+ #[stable(feature = "extend_for_unit", since = "1.28.0")]
889
+ impl Extend<()> for () {
890
+ - fn extend<T: IntoIterator<Item = ()>>(&mut self, iter: T) {
891
+ + fn extend<I: IntoIterator<Item = ()>>(&mut self, iter: I) {
892
+ iter.into_iter().for_each(drop)
893
+ }
894
+ fn extend_one(&mut self, _item: ()) {}
895
+ @@ -620,7 +620,7 @@ macro_rules! impl_extend_tuple {
896
+ where
897
+ $($extend_ty: Extend<$ty>,)+
898
+ {
899
+ - fn extend<T: IntoIterator<Item = ($($ty,)+)>>(&mut self, iter: T) {
900
+ + fn extend<Iter: IntoIterator<Item = ($($ty,)+)>>(&mut self, iter: Iter) {
901
+ default_extend(self, iter)
902
+ }
903
+
904
+ diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs
905
+ index 9857a3b8cfae69796390f8a64b66b743d60a4a17..ba6d786fbbd89042b3cee11901122d30a8ea3809 100644
906
+ --- a/library/core/src/lib.rs
907
+ +++ b/library/core/src/lib.rs
908
+ @@ -108,6 +108,7 @@
909
+ #![feature(adt_const_params)]
910
+ #![feature(allow_internal_unsafe)]
911
+ #![feature(allow_internal_unstable)]
912
+ +#![feature(arbitrary_self_types_pointers)]
913
+ #![feature(auto_traits)]
914
+ #![feature(cfg_sanitize)]
915
+ #![feature(cfg_target_has_atomic)]
916
+ diff --git a/library/core/src/option.rs b/library/core/src/option.rs
917
+ index 40be9131931a421e17e4c7acc1ebf779c01e6de1..8ec0414cf68741e6ce31dc8651e5703a18184938 100644
918
+ --- a/library/core/src/option.rs
919
+ +++ b/library/core/src/option.rs
920
+ @@ -465,7 +465,7 @@
921
+ //! [`Option`] of a collection of each contained value of the original
922
+ //! [`Option`] values, or [`None`] if any of the elements was [`None`].
923
+ //!
924
+ -//! [impl-FromIterator]: Option#impl-FromIterator%3COption%3CA%3E%3E-for-Option%3CV%3E
925
+ +//! [impl-FromIterator]: Option#impl-FromIterator%3COption%3CT%3E%3E-for-Option%3CV%3E
926
+ //!
927
+ //! ```
928
+ //! let v = [Some(2), Some(4), None, Some(8)];
929
+ @@ -2793,7 +2793,7 @@ unsafe impl<A: TrustedLen> TrustedLen for OptionFlatten<A> {}
930
+ /////////////////////////////////////////////////////////////////////////////
931
+
932
+ #[stable(feature = "rust1", since = "1.0.0")]
933
+ -impl<A, V: FromIterator<A>> FromIterator<Option<A>> for Option<V> {
934
+ +impl<T, V: FromIterator<T>> FromIterator<Option<T>> for Option<V> {
935
+ /// Takes each element in the [`Iterator`]: if it is [`None`][Option::None],
936
+ /// no further elements are taken, and the [`None`][Option::None] is
937
+ /// returned. Should no [`None`][Option::None] occur, a container of type
938
+ @@ -2855,7 +2855,7 @@ impl<A, V: FromIterator<A>> FromIterator<Option<A>> for Option<V> {
939
+ /// Since the third element caused an underflow, no further elements were taken,
940
+ /// so the final value of `shared` is 6 (= `3 + 2 + 1`), not 16.
941
+ #[inline]
942
+ - fn from_iter<I: IntoIterator<Item = Option<A>>>(iter: I) -> Option<V> {
943
+ + fn from_iter<I: IntoIterator<Item = Option<T>>>(iter: I) -> Option<V> {
944
+ iter::try_process(iter.into_iter(), |i| i.collect())
945
+ }
946
+ }
947
+ diff --git a/library/core/src/ptr/mod.rs b/library/core/src/ptr/mod.rs
948
+ index aedab87449ff58a0adf68d569a768f0eb5344441..f1b81de50942a2a7eb1c7d89e329341741789f90 100644
949
+ --- a/library/core/src/ptr/mod.rs
950
+ +++ b/library/core/src/ptr/mod.rs
951
+ @@ -2067,12 +2067,13 @@ pub const unsafe fn write_unaligned<T>(dst: *mut T, src: T) {
952
+ /// are two cases of usage that need to be distinguished:
953
+ ///
954
+ /// - When a volatile operation is used for memory inside an [allocation], it behaves exactly like
955
+ -/// [`read`], except for the additional guarantee that it won't be elided or reordered (see
956
+ -/// above). This implies that the operation will actually access memory and not e.g. be lowered to
957
+ -/// reusing data from a previous read. Other than that, all the usual rules for memory accesses
958
+ -/// apply (including provenance). In particular, just like in C, whether an operation is volatile
959
+ -/// has no bearing whatsoever on questions involving concurrent accesses from multiple threads.
960
+ -/// Volatile accesses behave exactly like non-atomic accesses in that regard.
961
+ +/// [`read`], except for the additional guarantee that it won't be elided or reordered across
962
+ +/// other externally observable events (see above). This implies that the operation will actually
963
+ +/// access memory and not e.g. be lowered to reusing data from a previous read. Other than that,
964
+ +/// all the usual rules for memory accesses apply (including provenance). In particular, just
965
+ +/// like in C, whether an operation is volatile has no bearing whatsoever on questions involving
966
+ +/// concurrent accesses from multiple threads. Volatile accesses behave exactly like non-atomic
967
+ +/// accesses in that regard.
968
+ ///
969
+ /// - Volatile operations, however, may also be used to access memory that is _outside_ of any Rust
970
+ /// allocation. In this use-case, the pointer does *not* have to be [valid] for reads. This is
971
+ @@ -2174,11 +2175,12 @@ pub const unsafe fn read_volatile<T>(src: *const T) -> T {
972
+ ///
973
+ /// - When a volatile operation is used for memory inside an [allocation], it behaves exactly like
974
+ /// [`write`][write()], except for the additional guarantee that it won't be elided or reordered
975
+ -/// (see above). This implies that the operation will actually access memory and not e.g. be
976
+ -/// lowered to a register access. Other than that, all the usual rules for memory accesses apply
977
+ -/// (including provenance). In particular, just like in C, whether an operation is volatile has no
978
+ -/// bearing whatsoever on questions involving concurrent access from multiple threads. Volatile
979
+ -/// accesses behave exactly like non-atomic accesses in that regard.
980
+ +/// across other externally observable events (see above). This implies that the operation will
981
+ +/// actually access memory and not e.g. be lowered to a register access. Other than that, all the
982
+ +/// usual rules for memory accesses apply (including provenance). In particular, just like in C,
983
+ +/// whether an operation is volatile has no bearing whatsoever on questions involving concurrent
984
+ +/// access from multiple threads. Volatile accesses behave exactly like non-atomic accesses in
985
+ +/// that regard.
986
+ ///
987
+ /// - Volatile operations, however, may also be used to access memory that is _outside_ of any Rust
988
+ /// allocation. In this use-case, the pointer does *not* have to be [valid] for writes. This is
989
+ @@ -2187,7 +2189,7 @@ pub const unsafe fn read_volatile<T>(src: *const T) -> T {
990
+ /// semantics associated to their manipulation, and cannot be used as general purpose memory.
991
+ /// Here, any address value is possible, including 0 and [`usize::MAX`], so long as the semantics
992
+ /// of such a write are well-defined by the target hardware. The provenance of the pointer is
993
+ -/// irrelevant, and it can be created with [`without_provenance`]. The access must not trap. It
994
+ +/// irrelevant, and it can be created with [`without_provenance_mut`]. The access must not trap. It
995
+ /// can cause side-effects, but those must not affect Rust-allocated memory in any way. This
996
+ /// access is still not considered [atomic], and as such it cannot be used for inter-thread
997
+ /// synchronization.
998
+ diff --git a/library/core/src/result.rs b/library/core/src/result.rs
999
+ index 544282d942148e055b5aa02f4014a384d9cf0792..6e76c3525b4cc15cb176d56354cb958e0667771c 100644
1000
+ --- a/library/core/src/result.rs
1001
+ +++ b/library/core/src/result.rs
1002
+ @@ -511,7 +511,7 @@
1003
+ //! [`Result`] of a collection of each contained value of the original
1004
+ //! [`Result`] values, or [`Err`] if any of the elements was [`Err`].
1005
+ //!
1006
+ -//! [impl-FromIterator]: Result#impl-FromIterator%3CResult%3CA,+E%3E%3E-for-Result%3CV,+E%3E
1007
+ +//! [impl-FromIterator]: Result#impl-FromIterator%3CResult%3CT,+E%3E%3E-for-Result%3CV,+E%3E
1008
+ //!
1009
+ //! ```
1010
+ //! let v = [Ok(2), Ok(4), Err("err!"), Ok(8)];
1011
+ @@ -2111,7 +2111,7 @@ unsafe impl<A> TrustedLen for IntoIter<A> {}
1012
+ /////////////////////////////////////////////////////////////////////////////
1013
+
1014
+ #[stable(feature = "rust1", since = "1.0.0")]
1015
+ -impl<A, E, V: FromIterator<A>> FromIterator<Result<A, E>> for Result<V, E> {
1016
+ +impl<T, E, V: FromIterator<T>> FromIterator<Result<T, E>> for Result<V, E> {
1017
+ /// Takes each element in the `Iterator`: if it is an `Err`, no further
1018
+ /// elements are taken, and the `Err` is returned. Should no `Err` occur, a
1019
+ /// container with the values of each `Result` is returned.
1020
+ @@ -2155,7 +2155,7 @@ impl<A, E, V: FromIterator<A>> FromIterator<Result<A, E>> for Result<V, E> {
1021
+ /// Since the third element caused an underflow, no further elements were taken,
1022
+ /// so the final value of `shared` is 6 (= `3 + 2 + 1`), not 16.
1023
+ #[inline]
1024
+ - fn from_iter<I: IntoIterator<Item = Result<A, E>>>(iter: I) -> Result<V, E> {
1025
+ + fn from_iter<I: IntoIterator<Item = Result<T, E>>>(iter: I) -> Result<V, E> {
1026
+ iter::try_process(iter.into_iter(), |i| i.collect())
1027
+ }
1028
+ }
1029
+ diff --git a/library/core/src/sync/atomic.rs b/library/core/src/sync/atomic.rs
1030
+ index 12208b95307eec33e0e55795379dddfca46b53e6..8b770528a1736c65838406e4f22b2d98737fa5ae 100644
1031
+ --- a/library/core/src/sync/atomic.rs
1032
+ +++ b/library/core/src/sync/atomic.rs
1033
+ @@ -606,6 +606,16 @@ impl AtomicBool {
1034
+ unsafe { &*ptr.cast() }
1035
+ }
1036
+
1037
+ + /// Creates a new pointer to `AtomicBool` from a pointer.
1038
+ + ///
1039
+ + /// This is useful if you want to do volatile atomic accesses, and thus avoid creating
1040
+ + /// a reference to the destination.
1041
+ + #[inline]
1042
+ + #[unstable(feature = "atomic_volatile", issue = "158947")]
1043
+ + pub const fn from_ptr_raw(ptr: *mut bool) -> *const AtomicBool {
1044
+ + ptr.cast_const().cast()
1045
+ + }
1046
+ +
1047
+ /// Returns a mutable reference to the underlying [`bool`].
1048
+ ///
1049
+ /// This is safe because the mutable reference guarantees that no other threads are
1050
+ @@ -765,6 +775,40 @@ impl AtomicBool {
1051
+ }
1052
+ }
1053
+
1054
+ + /// Perform a volatile atomic load from the bool.
1055
+ + ///
1056
+ + /// `load_volatile` takes an [`Ordering`] argument which describes the memory ordering
1057
+ + /// of this operation. Possible values are [`SeqCst`], [`Acquire`] and [`Relaxed`].
1058
+ + ///
1059
+ + #[doc = include_str!("./atomic_load_volatile.md")]
1060
+ + ///
1061
+ + /// # Safety
1062
+ + ///
1063
+ + /// Behavior is undefined if any of the following conditions are violated:
1064
+ + ///
1065
+ + /// * `self` must be [valid] for reads, or `self` must point to memory
1066
+ + /// outside of all Rust allocations and reading from that memory must:
1067
+ + /// - not trap, and
1068
+ + /// - not cause any memory inside a Rust allocation to be modified.
1069
+ + ///
1070
+ + /// * Reading from `self` must produce a properly initialized value of type `bool`.
1071
+ + ///
1072
+ + /// [valid]: core::ptr#safety
1073
+ + ///
1074
+ + /// # Panics
1075
+ + ///
1076
+ + /// Panics if `order` is [`Release`] or [`AcqRel`].
1077
+ + #[inline]
1078
+ + #[unstable(feature = "atomic_volatile", issue = "158947")]
1079
+ + #[rustc_const_unstable(feature = "atomic_volatile", issue = "158947")]
1080
+ + #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
1081
+ + pub const unsafe fn load_volatile(self: *const Self, order: Ordering) -> bool {
1082
+ + // SAFETY: follows from our own safety requirements.
1083
+ + unsafe {
1084
+ + atomic_load::<_, /* VOLATILE */ true>(self.cast::<u8>(), order) != 0
1085
+ + }
1086
+ + }
1087
+ +
1088
+ /// Stores a value into the bool.
1089
+ ///
1090
+ /// `store` takes an [`Ordering`] argument which describes the memory ordering
1091
+ @@ -797,6 +841,39 @@ impl AtomicBool {
1092
+ }
1093
+ }
1094
+
1095
+ + /// Performs a volatile atomic store into the bool.
1096
+ + ///
1097
+ + /// `store_volatile` takes an [`Ordering`] argument which describes the memory ordering
1098
+ + /// of this operation. Possible values are [`SeqCst`], [`Release`] and [`Relaxed`].
1099
+ + ///
1100
+ + #[doc = include_str!("./atomic_store_volatile.md")]
1101
+ + ///
1102
+ + /// # Safety
1103
+ + ///
1104
+ + /// Behavior is undefined if any of the following conditions are violated:
1105
+ + ///
1106
+ + /// * `self` must be either [valid] for writes, or `self` must point to memory
1107
+ + /// outside of all Rust allocations and writing to that memory must:
1108
+ + /// - not trap, and
1109
+ + /// - not cause any memory inside a Rust allocation to be modified.
1110
+ + ///
1111
+ + /// [valid]: core::ptr#safety
1112
+ + ///
1113
+ + /// # Panics
1114
+ + ///
1115
+ + /// Panics if `order` is [`Acquire`] or [`AcqRel`].
1116
+ + #[inline]
1117
+ + #[unstable(feature = "atomic_volatile", issue = "158947")]
1118
+ + #[rustc_const_unstable(feature = "atomic_volatile", issue = "158947")]
1119
+ + #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
1120
+ + #[rustc_should_not_be_called_on_const_items]
1121
+ + pub const unsafe fn store_volatile(self: *const Self, val: bool, order: Ordering) {
1122
+ + // SAFETY: follows from our own safety requirements.
1123
+ + unsafe {
1124
+ + atomic_store::<_, /* VOLATILE */ true>(self.cast::<u8>().cast_mut(), val as u8, order);
1125
+ + }
1126
+ + }
1127
+ +
1128
+ /// Stores a value into the bool, returning the previous value.
1129
+ ///
1130
+ /// `swap` takes an [`Ordering`] argument which describes the memory ordering
1131
+ @@ -1567,6 +1644,16 @@ impl<T> AtomicPtr<T> {
1132
+ unsafe { &*ptr.cast() }
1133
+ }
1134
+
1135
+ + /// Creates a new pointer to `AtomicPtr` from a pointer.
1136
+ + ///
1137
+ + /// This is useful if you want to do volatile atomic accesses, and thus avoid creating
1138
+ + /// a reference to the destination.
1139
+ + #[inline]
1140
+ + #[unstable(feature = "atomic_volatile", issue = "158947")]
1141
+ + pub const fn from_ptr_raw(ptr: *mut *mut T) -> *const AtomicPtr<T> {
1142
+ + ptr.cast_const().cast()
1143
+ + }
1144
+ +
1145
+ /// Creates a new `AtomicPtr` initialized with a null pointer.
1146
+ ///
1147
+ /// # Examples
1148
+ @@ -1770,6 +1857,71 @@ impl<T> AtomicPtr<T> {
1149
+ }
1150
+ }
1151
+
1152
+ + /// Perform a volatile atomic load from the pointer.
1153
+ + ///
1154
+ + /// `load_volatile` takes an [`Ordering`] argument which describes the memory ordering
1155
+ + /// of this operation. Possible values are [`SeqCst`], [`Acquire`] and [`Relaxed`].
1156
+ + ///
1157
+ + #[doc = include_str!("./atomic_load_volatile.md")]
1158
+ + ///
1159
+ + /// # Safety
1160
+ + ///
1161
+ + /// Behavior is undefined if any of the following conditions are violated:
1162
+ + ///
1163
+ + /// * `self` must be [valid] for reads, or `self` must point to memory
1164
+ + /// outside of all Rust allocations and reading from that memory must:
1165
+ + /// - not trap, and
1166
+ + /// - not cause any memory inside a Rust allocation to be modified.
1167
+ + ///
1168
+ + /// * `self` must be aligned to `align_of::<AtomicPtr<T>>()` (note that on some platforms this
1169
+ + /// can be bigger than `align_of::<*mut T>()`).
1170
+ + ///
1171
+ + /// * Reading from `self` must produce a properly initialized value of type `*mut T`.
1172
+ + ///
1173
+ + /// [valid]: core::ptr#safety
1174
+ + ///
1175
+ + /// # Panics
1176
+ + ///
1177
+ + /// Panics if `order` is [`Release`] or [`AcqRel`].
1178
+ + ///
1179
+ + /// # Examples
1180
+ + ///
1181
+ + /// Assuming an MMIO region at `MMIO_ADDR` that belongs to a device with direct memory
1182
+ + /// access, we may receive a buffer in shared memory from that device as follows:
1183
+ + ///
1184
+ + /// ```rust,no_run
1185
+ + /// #![feature(atomic_volatile)]
1186
+ + /// use std::sync::atomic::{fence, AtomicPtr, Ordering};
1187
+ + /// use std::ptr;
1188
+ + ///
1189
+ + /// const MMIO_ADDR: *mut *mut u8 = ptr::without_provenance_mut(0xCAF0);
1190
+ + /// let atomic_ptr = AtomicPtr::<u8>::from_ptr_raw(MMIO_ADDR);
1191
+ + ///
1192
+ + /// // Spin until we see a non-zero value.
1193
+ + /// let buf = 'buf: loop {
1194
+ + /// let buf = unsafe { atomic_ptr.load_volatile(Ordering::Relaxed) };
1195
+ + /// if !buf.is_null() {
1196
+ + /// break 'buf buf;
1197
+ + /// }
1198
+ + /// };
1199
+ + /// // Synchronize with the store whose value we just read.
1200
+ + /// // Note: a standard acquire fence may not be sufficient to synchronize with DMA devices.
1201
+ + /// // Depending on your target, you may have to use inline assembly to emit a special fence.
1202
+ + /// fence(Ordering::Acquire);
1203
+ + ///
1204
+ + /// // Now process the data in `buf`.
1205
+ + /// ```
1206
+ + #[inline]
1207
+ + #[unstable(feature = "atomic_volatile", issue = "158947")]
1208
+ + #[rustc_const_unstable(feature = "atomic_volatile", issue = "158947")]
1209
+ + #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
1210
+ + pub const unsafe fn load_volatile(self: *const Self, order: Ordering) -> *mut T {
1211
+ + // SAFETY: follows from our own safety requirements.
1212
+ + unsafe {
1213
+ + atomic_load::<_, /* VOLATILE */ true>(self.cast::<*mut T>(), order)
1214
+ + }
1215
+ + }
1216
+ +
1217
+ /// Stores a value into the pointer.
1218
+ ///
1219
+ /// `store` takes an [`Ordering`] argument which describes the memory ordering
1220
+ @@ -1803,6 +1955,67 @@ impl<T> AtomicPtr<T> {
1221
+ }
1222
+ }
1223
+
1224
+ + /// Performs a volatile atomic store into the pointer.
1225
+ + ///
1226
+ + /// `store_volatile` takes an [`Ordering`] argument which describes the memory ordering
1227
+ + /// of this operation. Possible values are [`SeqCst`], [`Release`] and [`Relaxed`].
1228
+ + ///
1229
+ + #[doc = include_str!("./atomic_store_volatile.md")]
1230
+ + ///
1231
+ + /// # Safety
1232
+ + ///
1233
+ + /// Behavior is undefined if any of the following conditions are violated:
1234
+ + ///
1235
+ + /// * `self` must be either [valid] for writes, or `self` must point to memory
1236
+ + /// outside of all Rust allocations and writing to that memory must:
1237
+ + /// - not trap, and
1238
+ + /// - not cause any memory inside a Rust allocation to be modified.
1239
+ + ///
1240
+ + /// * `self` must be aligned to `align_of::<AtomicPtr<T>>()` (note that on some platforms this
1241
+ + /// can be bigger than `align_of::<*mut T>()`).
1242
+ + ///
1243
+ + /// [valid]: core::ptr#safety
1244
+ + ///
1245
+ + /// # Panics
1246
+ + ///
1247
+ + /// Panics if `order` is [`Acquire`] or [`AcqRel`].
1248
+ + ///
1249
+ + /// # Examples
1250
+ + ///
1251
+ + /// Assuming an MMIO region at `MMIO_ADDR` that belongs to a device with direct memory
1252
+ + /// access, we may submit a buffer in shared memory to that device as follows:
1253
+ + ///
1254
+ + /// ```rust,no_run
1255
+ + /// #![feature(atomic_volatile)]
1256
+ + /// use std::sync::atomic::{fence, AtomicPtr, Ordering};
1257
+ + /// use std::ptr;
1258
+ + ///
1259
+ + /// const MMIO_ADDR: *mut *mut u8 = ptr::without_provenance_mut(0xCAF0);
1260
+ + /// let atomic_ptr = AtomicPtr::<u8>::from_ptr_raw(MMIO_ADDR);
1261
+ + ///
1262
+ + /// // Prepare some data for the DMA device.
1263
+ + /// # fn get_dma_buffer() -> *mut u8 { panic!() }
1264
+ + /// let buf = get_dma_buffer();
1265
+ + ///
1266
+ + /// // Ensure the other side can synchronize with the store we do below.
1267
+ + /// // Note: a standard release fence may not be sufficient to synchronize with DMA devices.
1268
+ + /// // Depending on your target, you may have to use inline assembly to emit a special fence.
1269
+ + /// fence(Ordering::Release);
1270
+ + ///
1271
+ + /// unsafe { atomic_ptr.store_volatile(buf, Ordering::Relaxed) };
1272
+ + /// ```
1273
+ + #[inline]
1274
+ + #[unstable(feature = "atomic_volatile", issue = "158947")]
1275
+ + #[rustc_const_unstable(feature = "atomic_volatile", issue = "158947")]
1276
+ + #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
1277
+ + #[rustc_should_not_be_called_on_const_items]
1278
+ + pub const unsafe fn store_volatile(self: *const Self, ptr: *mut T, order: Ordering) {
1279
+ + // SAFETY: follows from our own safety requirements.
1280
+ + unsafe {
1281
+ + atomic_store::<_, /* VOLATILE */ true>(self.cast::<*mut T>().cast_mut(), ptr, order);
1282
+ + }
1283
+ + }
1284
+ +
1285
+ /// Stores a value into the pointer, returning the previous value.
1286
+ ///
1287
+ /// `swap` takes an [`Ordering`] argument which describes the memory ordering
1288
+ @@ -2733,6 +2946,16 @@ macro_rules! atomic_int {
1289
+ unsafe { &*ptr.cast() }
1290
+ }
1291
+
1292
+ + /// Creates a new pointer to an atomic integer from a pointer.
1293
+ + ///
1294
+ + /// This is useful if you want to do volatile atomic accesses, and thus avoid creating
1295
+ + /// a reference to the destination.
1296
+ + #[inline]
1297
+ + #[unstable(feature = "atomic_volatile", issue = "158947")]
1298
+ + pub const fn from_ptr_raw(ptr: *mut $int_type) -> *const $atomic_type {
1299
+ + ptr.cast_const().cast()
1300
+ + }
1301
+ +
1302
+ /// Returns a mutable reference to the underlying integer.
1303
+ ///
1304
+ /// This is safe because the mutable reference guarantees that no other threads are
1305
+ @@ -2921,6 +3144,55 @@ macro_rules! atomic_int {
1306
+ unsafe { atomic_load::<_, /* VOLATILE */ false>(self.as_ptr(), order) }
1307
+ }
1308
+
1309
+ + /// Perform a volatile load from the atomic integer.
1310
+ + ///
1311
+ + /// `load_volatile` takes an [`Ordering`] argument which describes the memory ordering
1312
+ + /// of this operation. Possible values are [`SeqCst`], [`Acquire`] and [`Relaxed`].
1313
+ + ///
1314
+ + #[doc = include_str!("./atomic_load_volatile.md")]
1315
+ + ///
1316
+ + /// # Safety
1317
+ + ///
1318
+ + /// Behavior is undefined if any of the following conditions are violated:
1319
+ + ///
1320
+ + /// * `self` must be [valid] for reads, or `self` must point to memory
1321
+ + /// outside of all Rust allocations and reading from that memory must:
1322
+ + /// - not trap, and
1323
+ + /// - not cause any memory inside a Rust allocation to be modified.
1324
+ + ///
1325
+ + /// * `self` must be aligned to
1326
+ + #[doc = concat!(" `align_of::<", stringify!($atomic_type), ">()`")]
1327
+ + #[doc = if_8_bit!{
1328
+ + $int_type,
1329
+ + yes = [
1330
+ + " (note that this is always true, since `align_of::<",
1331
+ + stringify!($atomic_type), ">() == 1`)."
1332
+ + ],
1333
+ + no = [
1334
+ + " (note that on some platforms this can be bigger than `align_of::<",
1335
+ + stringify!($int_type), ">()`)."
1336
+ + ],
1337
+ + }]
1338
+ + ///
1339
+ + /// * Reading from `self` must produce a properly initialized value of the underlying
1340
+ + /// integer type.
1341
+ + ///
1342
+ + /// [valid]: core::ptr#safety
1343
+ + ///
1344
+ + /// # Panics
1345
+ + ///
1346
+ + /// Panics if `order` is [`Release`] or [`AcqRel`].
1347
+ + #[inline]
1348
+ + #[unstable(feature = "atomic_volatile", issue = "158947")]
1349
+ + #[rustc_const_unstable(feature = "atomic_volatile", issue = "158947")]
1350
+ + #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
1351
+ + pub const unsafe fn load_volatile(self: *const Self, order: Ordering) -> $int_type {
1352
+ + // SAFETY: follows from our own safety requirements.
1353
+ + unsafe {
1354
+ + atomic_load::<_, /* VOLATILE */ true>(self.cast::<$int_type>(), order)
1355
+ + }
1356
+ + }
1357
+ +
1358
+ /// Stores a value into the atomic integer.
1359
+ ///
1360
+ /// `store` takes an [`Ordering`] argument which describes the memory ordering of this operation.
1361
+ @@ -2951,6 +3223,53 @@ macro_rules! atomic_int {
1362
+ unsafe { atomic_store::<_, /* VOLATILE */ false>(self.as_ptr(), val, order); }
1363
+ }
1364
+
1365
+ + /// Performs a volatile store into the atomic integer.
1366
+ + ///
1367
+ + /// `store_volatile` takes an [`Ordering`] argument which describes the memory ordering
1368
+ + /// of this operation. Possible values are [`SeqCst`], [`Release`] and [`Relaxed`].
1369
+ + ///
1370
+ + #[doc = include_str!("./atomic_store_volatile.md")]
1371
+ + ///
1372
+ + /// # Safety
1373
+ + ///
1374
+ + /// Behavior is undefined if any of the following conditions are violated:
1375
+ + ///
1376
+ + /// * `self` must be either [valid] for writes, or `self` must point to memory
1377
+ + /// outside of all Rust allocations and writing to that memory must:
1378
+ + /// - not trap, and
1379
+ + /// - not cause any memory inside a Rust allocation to be modified.
1380
+ + ///
1381
+ + /// * `self` must be aligned to
1382
+ + #[doc = concat!(" `align_of::<", stringify!($atomic_type), ">()`")]
1383
+ + #[doc = if_8_bit!{
1384
+ + $int_type,
1385
+ + yes = [
1386
+ + " (note that this is always true, since `align_of::<",
1387
+ + stringify!($atomic_type), ">() == 1`)."
1388
+ + ],
1389
+ + no = [
1390
+ + " (note that on some platforms this can be bigger than `align_of::<",
1391
+ + stringify!($int_type), ">()`)."
1392
+ + ],
1393
+ + }]
1394
+ + ///
1395
+ + /// [valid]: core::ptr#safety
1396
+ + ///
1397
+ + /// # Panics
1398
+ + ///
1399
+ + /// Panics if `order` is [`Acquire`] or [`AcqRel`].
1400
+ + #[inline]
1401
+ + #[unstable(feature = "atomic_volatile", issue = "158947")]
1402
+ + #[rustc_const_unstable(feature = "atomic_volatile", issue = "158947")]
1403
+ + #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
1404
+ + #[rustc_should_not_be_called_on_const_items]
1405
+ + pub const unsafe fn store_volatile(self: *const Self, val: $int_type, order: Ordering) {
1406
+ + // SAFETY: follows from our own safety requirements.
1407
+ + unsafe {
1408
+ + atomic_store::<_, /* VOLATILE */ true>(self.cast::<$int_type>().cast_mut(), val, order);
1409
+ + }
1410
+ + }
1411
+ +
1412
+ /// Stores a value into the atomic integer, returning the previous value.
1413
+ ///
1414
+ /// `swap` takes an [`Ordering`] argument which describes the memory ordering
1415
+ diff --git a/library/core/src/sync/atomic_load_volatile.md b/library/core/src/sync/atomic_load_volatile.md
1416
+ new file mode 100644
1417
+ index 0000000000000000000000000000000000000000..be02c4bcfeccf729022d944e293093e5b15a3252
1418
+ --- /dev/null
1419
+ +++ b/library/core/src/sync/atomic_load_volatile.md
1420
+ @@ -0,0 +1,29 @@
1421
+ +Volatile operations are intended to act on I/O memory. As such, they are considered externally
1422
+ +observable events (just like syscalls, but less opaque), and are guaranteed to not be elided or
1423
+ +reordered by the compiler across other externally observable events. With this in mind, there
1424
+ +are two cases of usage that need to be distinguished:
1425
+ +
1426
+ +- When a volatile operation is used for memory inside an [allocation], it behaves exactly
1427
+ + like [`load`][Self::load], except for the additional guarantee that it won't be elided or
1428
+ + reordered across other externally observable events (see above). This implies that the
1429
+ + operation will actually access memory and not e.g. be lowered to reusing data from a
1430
+ + previous load. Other than that, all the usual rules for memory accesses apply (including
1431
+ + provenance).
1432
+ +
1433
+ +- Volatile operations, however, may also be used to access memory that is _outside_ of any Rust
1434
+ + allocation. In this use-case, the pointer does *not* have to be [valid] for reads. This is
1435
+ + typically used for CPU and peripheral registers that must be accessed via an I/O memory mapping,
1436
+ + most commonly at fixed addresses reserved by the hardware. These often have special semantics
1437
+ + associated to their manipulation, and cannot be used as general purpose memory. Here, any address
1438
+ + value is possible, including 0 and [`usize::MAX`], so long as the semantics of such a read are
1439
+ + well-defined by the target hardware. The provenance of the pointer is irrelevant, and it can be
1440
+ + created with [`without_provenance`][crate::ptr::without_provenance]. The access must not trap. It
1441
+ + can cause side-effects, but those must not affect Rust-allocated memory in any way.
1442
+ +
1443
+ +In both cases, the access is also considered atomic with the given `order`. This allows
1444
+ +synchronization with other threads or devices that share memory with this program.
1445
+ +
1446
+ +When invoked during const evaluation, this behaves like a regular atomic load. In
1447
+ +particular, such reads must always follow the first of the two cases above.
1448
+ +
1449
+ +[allocation]: crate::ptr#allocated-object
1450
+ diff --git a/library/core/src/sync/atomic_store_volatile.md b/library/core/src/sync/atomic_store_volatile.md
1451
+ new file mode 100644
1452
+ index 0000000000000000000000000000000000000000..bb78099020c1527998d268975d2095966b7a88ba
1453
+ --- /dev/null
1454
+ +++ b/library/core/src/sync/atomic_store_volatile.md
1455
+ @@ -0,0 +1,28 @@
1456
+ +Volatile operations are intended to act on I/O memory. As such, they are considered externally
1457
+ +observable events (just like syscalls), and are guaranteed to not be elided or reordered by the
1458
+ +compiler across other externally observable events. With this in mind, there are two cases of
1459
+ +usage that need to be distinguished:
1460
+ +
1461
+ +- When a volatile operation is used for memory inside an [allocation], it behaves exactly like
1462
+ + [`store`][Self::store], except for the additional guarantee that it won't be elided or reordered
1463
+ + across other externally observable events (see above). This implies that the operation will
1464
+ + actually access memory and not e.g. be lowered to a register access. Other than that, all the
1465
+ + usual rules for memory accesses apply (including provenance).
1466
+ +
1467
+ +- Volatile operations, however, may also be used to access memory that is _outside_ of any Rust
1468
+ + allocation. In this use-case, the pointer does *not* have to be [valid] for writes. This is
1469
+ + typically used for CPU and peripheral registers that must be accessed via an I/O memory mapping,
1470
+ + most commonly at fixed addresses reserved by the hardware. These often have special semantics
1471
+ + associated to their manipulation, and cannot be used as general purpose memory. Here, any address
1472
+ + value is possible, including 0 and [`usize::MAX`], so long as the semantics of such a write are
1473
+ + well-defined by the target hardware. The provenance of the pointer is irrelevant, and it can be
1474
+ + created with [`without_provenance_mut`][crate::ptr::without_provenance_mut]. The access must not
1475
+ + trap. It can cause side-effects, but those must not affect Rust-allocated memory in any way.
1476
+ +
1477
+ +In both cases, the access is also considered atomic with the given `order`. This allows
1478
+ +synchronization with other threads or devices that share memory with this program.
1479
+ +
1480
+ +When invoked during const evaluation, this behaves like a regular atomic store. In
1481
+ +particular, such reads must always follow the first of the two cases above.
1482
+ +
1483
+ +[allocation]: crate::ptr#allocated-object
1484
+ diff --git a/library/coretests/tests/atomic.rs b/library/coretests/tests/atomic.rs
1485
+ index d888bd0f55a1195c97f118aed980e9e0705cc290..31fe7980510d39a69e764fc0731c83134da8c090 100644
1486
+ --- a/library/coretests/tests/atomic.rs
1487
+ +++ b/library/coretests/tests/atomic.rs
1488
+ @@ -538,6 +538,29 @@ fn atomic_umin() {
1489
+ assert_eq!(ATOMIC.load(Relaxed), 0);
1490
+ }
1491
+
1492
+ +#[test]
1493
+ +fn atomic_volatile() {
1494
+ + use Ordering::*;
1495
+ +
1496
+ + let mut b = true;
1497
+ + let atomic = AtomicBool::from_ptr_raw(&raw mut b);
1498
+ + assert!(unsafe { atomic.load_volatile(Relaxed) });
1499
+ + unsafe { atomic.store_volatile(false, Relaxed) };
1500
+ + assert!(!b);
1501
+ +
1502
+ + let mut ptr = std::ptr::null_mut::<i32>();
1503
+ + let atomic = AtomicPtr::from_ptr_raw(&raw mut ptr);
1504
+ + assert!(unsafe { atomic.load_volatile(Relaxed) }.is_null());
1505
+ + unsafe { atomic.store_volatile(std::ptr::without_provenance_mut(16), Relaxed) };
1506
+ + assert!(ptr.addr() == 16);
1507
+ +
1508
+ + let mut int = 0i32;
1509
+ + let atomic = AtomicI32::from_ptr_raw(&raw mut int);
1510
+ + assert!(unsafe { atomic.load_volatile(Relaxed) } == 0);
1511
+ + unsafe { atomic.store_volatile(16, Relaxed) };
1512
+ + assert!(int == 16);
1513
+ +}
1514
+ +
1515
+ /* FIXME(#110395)
1516
+ #[test]
1517
+ fn atomic_const_from() {
1518
+ diff --git a/library/coretests/tests/lib.rs b/library/coretests/tests/lib.rs
1519
+ index e81cae69e18525bc560cb163eaf2923149fd1bfb..142df37c2b7fe20920a3ba22cf2f17dfb071d279 100644
1520
+ --- a/library/coretests/tests/lib.rs
1521
+ +++ b/library/coretests/tests/lib.rs
1522
+ @@ -8,6 +8,7 @@
1523
+ #![feature(ascii_char_variants)]
1524
+ #![feature(async_iter_from_iter)]
1525
+ #![feature(async_iterator)]
1526
+ +#![feature(atomic_volatile)]
1527
+ #![feature(borrowed_buf_init)]
1528
+ #![feature(bstr)]
1529
+ #![feature(casefold)]
1530
+ diff --git a/library/proc_macro/src/lib.rs b/library/proc_macro/src/lib.rs
1531
+ index 0f3e770efd965124825038ab920d97408a5753d4..b8ffcd53b25d8e518bad4b60d52dc4e5c012f373 100644
1532
+ --- a/library/proc_macro/src/lib.rs
1533
+ +++ b/library/proc_macro/src/lib.rs
1534
+ @@ -516,7 +516,7 @@ macro_rules! extend_items {
1535
+ $(
1536
+ #[stable(feature = "token_stream_extend_ts_items", since = "1.92.0")]
1537
+ impl Extend<$item> for TokenStream {
1538
+ - fn extend<T: IntoIterator<Item = $item>>(&mut self, iter: T) {
1539
+ + fn extend<I: IntoIterator<Item = $item>>(&mut self, iter: I) {
1540
+ self.extend(iter.into_iter().map(TokenTree::$item));
1541
+ }
1542
+ }
1543
+ diff --git a/library/std/src/collections/hash/map.rs b/library/std/src/collections/hash/map.rs
1544
+ index 2858680a20a49134ddb191f3698647eb85304a28..121a525bd0c4b6c7990d64df51fcf338d2eb77ec 100644
1545
+ --- a/library/std/src/collections/hash/map.rs
1546
+ +++ b/library/std/src/collections/hash/map.rs
1547
+ @@ -3010,7 +3010,7 @@ where
1548
+ ///
1549
+ /// If the iterator produces any pairs with equal keys,
1550
+ /// all but one of the corresponding values will be dropped.
1551
+ - fn from_iter<T: IntoIterator<Item = (K, V)>>(iter: T) -> HashMap<K, V, S> {
1552
+ + fn from_iter<I: IntoIterator<Item = (K, V)>>(iter: I) -> HashMap<K, V, S> {
1553
+ let mut map = HashMap::with_hasher(Default::default());
1554
+ map.extend(iter);
1555
+ map
1556
+ @@ -3027,7 +3027,7 @@ where
1557
+ A: Allocator,
1558
+ {
1559
+ #[inline]
1560
+ - fn extend<T: IntoIterator<Item = (K, V)>>(&mut self, iter: T) {
1561
+ + fn extend<I: IntoIterator<Item = (K, V)>>(&mut self, iter: I) {
1562
+ self.base.extend(iter)
1563
+ }
1564
+
1565
+ @@ -3051,7 +3051,7 @@ where
1566
+ A: Allocator,
1567
+ {
1568
+ #[inline]
1569
+ - fn extend<T: IntoIterator<Item = (&'a K, &'a V)>>(&mut self, iter: T) {
1570
+ + fn extend<I: IntoIterator<Item = (&'a K, &'a V)>>(&mut self, iter: I) {
1571
+ self.base.extend(iter)
1572
+ }
1573
+
1574
+ diff --git a/library/std/src/ffi/os_str.rs b/library/std/src/ffi/os_str.rs
1575
+ index ac4e49aa820e99790a00164c351aaeed3ac3b389..7ad313e1ed3caa6ffe8dd2f44aa94480a94f9e48 100644
1576
+ --- a/library/std/src/ffi/os_str.rs
1577
+ +++ b/library/std/src/ffi/os_str.rs
1578
+ @@ -1815,7 +1815,7 @@ impl FromStr for OsString {
1579
+ #[stable(feature = "osstring_extend", since = "1.52.0")]
1580
+ impl Extend<OsString> for OsString {
1581
+ #[inline]
1582
+ - fn extend<T: IntoIterator<Item = OsString>>(&mut self, iter: T) {
1583
+ + fn extend<I: IntoIterator<Item = OsString>>(&mut self, iter: I) {
1584
+ for s in iter {
1585
+ self.push(&s);
1586
+ }
1587
+ @@ -1825,7 +1825,7 @@ impl Extend<OsString> for OsString {
1588
+ #[stable(feature = "osstring_extend", since = "1.52.0")]
1589
+ impl<'a> Extend<&'a OsStr> for OsString {
1590
+ #[inline]
1591
+ - fn extend<T: IntoIterator<Item = &'a OsStr>>(&mut self, iter: T) {
1592
+ + fn extend<I: IntoIterator<Item = &'a OsStr>>(&mut self, iter: I) {
1593
+ for s in iter {
1594
+ self.push(s);
1595
+ }
1596
+ @@ -1835,7 +1835,7 @@ impl<'a> Extend<&'a OsStr> for OsString {
1597
+ #[stable(feature = "osstring_extend", since = "1.52.0")]
1598
+ impl<'a> Extend<Cow<'a, OsStr>> for OsString {
1599
+ #[inline]
1600
+ - fn extend<T: IntoIterator<Item = Cow<'a, OsStr>>>(&mut self, iter: T) {
1601
+ + fn extend<I: IntoIterator<Item = Cow<'a, OsStr>>>(&mut self, iter: I) {
1602
+ for s in iter {
1603
+ self.push(&s);
1604
+ }
1605
+ diff --git a/tests/ui/suggestions/missing-assoc-fn.stderr b/tests/ui/suggestions/missing-assoc-fn.stderr
1606
+ index d819f7e8bd2c4637121835768ed6dfe6c187f139..ac04f6653866e3df2aaf5e744537c4a36e7af03e 100644
1607
+ --- a/tests/ui/suggestions/missing-assoc-fn.stderr
1608
+ +++ b/tests/ui/suggestions/missing-assoc-fn.stderr
1609
+ @@ -19,7 +19,7 @@ error[E0046]: not all trait items implemented, missing: `from_iter`
1610
+ LL | impl FromIterator<()> for X {
1611
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `from_iter` in implementation
1612
+ |
1613
+ - = help: implement the missing item: `fn from_iter<T: IntoIterator<Item = ()>>(_: T) -> Self { todo!() }`
1614
+ + = help: implement the missing item: `fn from_iter<I: IntoIterator<Item = ()>>(_: I) -> Self { todo!() }`
1615
+
1616
+ error: aborting due to 2 previous errors
1617
+
1618
+ diff --git a/tests/ui/suggestions/semi-suggestion-when-stmt-and-expr-span-equal.stderr b/tests/ui/suggestions/semi-suggestion-when-stmt-and-expr-span-equal.stderr
1619
+ index 6dd4b1e5d51104d58015674925d45deb386e0f14..1f225767472ad2bd3a23fe771a0eb54927161d07 100644
1620
+ --- a/tests/ui/suggestions/semi-suggestion-when-stmt-and-expr-span-equal.stderr
1621
+ +++ b/tests/ui/suggestions/semi-suggestion-when-stmt-and-expr-span-equal.stderr
1622
+ @@ -20,7 +20,7 @@ LL | .collect::<String>();
1623
+ | required by a bound introduced by this call
1624
+ |
1625
+ = help: the trait `FromIterator<()>` is not implemented for `String`
1626
+ - = help: `String` implements trait `FromIterator<A>`:
1627
+ + = help: `String` implements trait `FromIterator<T>`:
1628
+ FromIterator<&char>
1629
+ FromIterator<&std::ascii::Char>
1630
+ FromIterator<&str>
1631
+ diff --git a/tests/ui/traits/next-solver/outlives-goal-error-due-to-normalization-failure-no-ice.rs b/tests/ui/traits/next-solver/outlives-goal-error-due-to-normalization-failure-no-ice.rs
1632
+ new file mode 100644
1633
+ index 0000000000000000000000000000000000000000..61a9a1df8e8eedfc5f54437bdeb438ac86807bda
1634
+ --- /dev/null
1635
+ +++ b/tests/ui/traits/next-solver/outlives-goal-error-due-to-normalization-failure-no-ice.rs
1636
+ @@ -0,0 +1,13 @@
1637
+ +//@ compile-flags: -Znext-solver
1638
+ +
1639
+ +// Regression test for <https://github.com/rust-lang/rust/issues/161527>
1640
+ +
1641
+ +trait Z<'a, T: ?Sized>
1642
+ +where
1643
+ + T: Z<'a, ()>, //~ ERROR: the trait bound `(): Z<'a, ()>` is not satisfied
1644
+ + for<'b> <T as Z<'b, ()>>::W: 'a,
1645
+ +{
1646
+ + type W;
1647
+ +}
1648
+ +
1649
+ +fn main() {}
1650
+ diff --git a/tests/ui/traits/next-solver/outlives-goal-error-due-to-normalization-failure-no-ice.stderr b/tests/ui/traits/next-solver/outlives-goal-error-due-to-normalization-failure-no-ice.stderr
1651
+ new file mode 100644
1652
+ index 0000000000000000000000000000000000000000..80f1a9328d5e05a12416b1587b971ee75361d040
1653
+ --- /dev/null
1654
+ +++ b/tests/ui/traits/next-solver/outlives-goal-error-due-to-normalization-failure-no-ice.stderr
1655
+ @@ -0,0 +1,23 @@
1656
+ +error[E0277]: the trait bound `(): Z<'a, ()>` is not satisfied
1657
+ + --> $DIR/outlives-goal-error-due-to-normalization-failure-no-ice.rs:7:8
1658
+ + |
1659
+ +LL | T: Z<'a, ()>,
1660
+ + | ^^^^^^^^^ the trait `Z<'a, ()>` is not implemented for `()`
1661
+ + |
1662
+ +help: this trait has no implementations, consider adding one
1663
+ + --> $DIR/outlives-goal-error-due-to-normalization-failure-no-ice.rs:5:1
1664
+ + |
1665
+ +LL | trait Z<'a, T: ?Sized>
1666
+ + | ^^^^^^^^^^^^^^^^^^^^^^
1667
+ +note: required by a bound in `Z`
1668
+ + --> $DIR/outlives-goal-error-due-to-normalization-failure-no-ice.rs:7:8
1669
+ + |
1670
+ +LL | trait Z<'a, T: ?Sized>
1671
+ + | - required by a bound in this trait
1672
+ +LL | where
1673
+ +LL | T: Z<'a, ()>,
1674
+ + | ^^^^^^^^^ required by this bound in `Z`
1675
+ +
1676
+ +error: aborting due to 1 previous error
1677
+ +
1678
+ +For more information about this error, try `rustc --explain E0277`.
patches/20261028T105419Z/rust-lang--rust-part009/4a1c2491ff2853a51d7b6aef065fcf7426086d83.patch ADDED
@@ -0,0 +1,347 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ diff --git a/compiler/rustc_builtin_macros/src/env.rs b/compiler/rustc_builtin_macros/src/env.rs
2
+ index 74653139fec021f6623661c501beb8660472f687..cced54e3cb5343a45d9eefaf6164c779399a641f 100644
3
+ --- a/compiler/rustc_builtin_macros/src/env.rs
4
+ +++ b/compiler/rustc_builtin_macros/src/env.rs
5
+ @@ -17,13 +17,9 @@ use thin_vec::thin_vec;
6
+ use crate::diagnostics;
7
+ use crate::util::{expr_to_string, get_exprs_from_tts, get_single_expr_from_tts};
8
+
9
+ -fn lookup_env<'cx>(cx: &'cx ExtCtxt<'_>, var: Symbol) -> Result<Symbol, VarError> {
10
+ +fn lookup_env(var: Symbol) -> Result<Symbol, VarError> {
11
+ let var = var.as_str();
12
+ - if let Some(value) = cx.sess.opts.logical_env.get(var) {
13
+ - return Ok(Symbol::intern(value));
14
+ - }
15
+ - // If the environment variable was not defined with the `--env-set` option, we try to retrieve it
16
+ - // from rustc's environment.
17
+ + // Try to retrieve the environment variable from rustc's environment.
18
+ Ok(Symbol::intern(&env::var(var)?))
19
+ }
20
+
21
+ @@ -50,7 +46,7 @@ pub(crate) fn expand_option_env<'cx>(
22
+ };
23
+
24
+ let sp = cx.with_def_site_ctxt(sp);
25
+ - let value = lookup_env(cx, var);
26
+ + let value = lookup_env(var);
27
+ cx.sess.env_depinfo.borrow_mut().insert((var, value.as_ref().ok().copied()));
28
+ let e = match value {
29
+ Err(VarError::NotPresent) => {
30
+ @@ -124,7 +120,7 @@ pub(crate) fn expand_env<'cx>(
31
+ };
32
+
33
+ let span = cx.with_def_site_ctxt(sp);
34
+ - let value = lookup_env(cx, var);
35
+ + let value = lookup_env(var);
36
+ cx.sess.env_depinfo.borrow_mut().insert((var, value.as_ref().ok().copied()));
37
+ let e = match value {
38
+ Err(VarError::NotPresent) => {
39
+ diff --git a/compiler/rustc_expand/src/proc_macro_server.rs b/compiler/rustc_expand/src/proc_macro_server.rs
40
+ index 7b52a5600ae2aa77bba58d997e43c9aa5995188d..c522626b3956245ab42685298da8847a83dbbdb5 100644
41
+ --- a/compiler/rustc_expand/src/proc_macro_server.rs
42
+ +++ b/compiler/rustc_expand/src/proc_macro_server.rs
43
+ @@ -473,10 +473,6 @@ impl server::Server for Rustc<'_, '_> {
44
+ f(symbol.as_str())
45
+ }
46
+
47
+ - fn injected_env_var(&mut self, var: &str) -> Option<String> {
48
+ - self.ecx.sess.opts.logical_env.get(var).cloned()
49
+ - }
50
+ -
51
+ fn track_env_var(&mut self, var: &str, value: Option<&str>) {
52
+ self.ecx
53
+ .sess
54
+ diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs
55
+ index 95f6348cfbdbbae98fc2f47c73935fa1eacba3b3..68bbc1520a06d923e9de29ca084dd156f0ebabdd 100644
56
+ --- a/compiler/rustc_session/src/config.rs
57
+ +++ b/compiler/rustc_session/src/config.rs
58
+ @@ -14,7 +14,7 @@ use std::sync::LazyLock;
59
+ use std::{cmp, fs, iter, thread};
60
+
61
+ use externs::{ExternOpt, split_extern_opt};
62
+ -use rustc_data_structures::fx::{FxHashSet, FxIndexMap};
63
+ +use rustc_data_structures::fx::FxHashSet;
64
+ use rustc_data_structures::stable_hash::{StableHasher, StableOrd};
65
+ use rustc_errors::emitter::HumanReadableErrorType;
66
+ use rustc_errors::{ColorConfig, DiagCtxtFlags};
67
+ @@ -1499,7 +1499,6 @@ impl Default for Options {
68
+ pretty: None,
69
+ working_dir,
70
+ color: ColorConfig::Auto,
71
+ - logical_env: FxIndexMap::default(),
72
+ verbose: false,
73
+ target_modifiers: BTreeMap::default(),
74
+ mitigation_coverage_map: Default::default(),
75
+ @@ -2121,7 +2120,6 @@ pub fn rustc_optgroups() -> Vec<RustcOptGroup> {
76
+ "Defines which scopes of paths should be remapped by `--remap-path-prefix`",
77
+ "<macro,diagnostics,debuginfo,coverage,object,all>",
78
+ ),
79
+ - opt(Unstable, Multi, "", "env-set", "Inject an environment variable", "<VAR>=<VALUE>"),
80
+ opt(Unstable, Opt, "j", "jobs", "Limit on the number of used parallel jobs", "<N>"),
81
+ opt(
82
+ Unstable,
83
+ @@ -2664,23 +2662,6 @@ fn parse_remap_path_prefix(
84
+ .collect()
85
+ }
86
+
87
+ -fn parse_logical_env(
88
+ - early_dcx: &EarlyDiagCtxt,
89
+ - matches: &getopts::Matches,
90
+ -) -> FxIndexMap<String, String> {
91
+ - let mut vars = FxIndexMap::default();
92
+ -
93
+ - for arg in matches.opt_strs("env-set") {
94
+ - if let Some((name, val)) = arg.split_once('=') {
95
+ - vars.insert(name.to_string(), val.to_string());
96
+ - } else {
97
+ - early_dcx.early_fatal(format!("`--env-set`: specify value for variable `{arg}`"));
98
+ - }
99
+ - }
100
+ -
101
+ - vars
102
+ -}
103
+ -
104
+ // JUSTIFICATION: before wrapper fn is available
105
+ #[allow(rustc::bad_opt_access)]
106
+ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::Matches) -> Options {
107
+ @@ -2956,8 +2937,6 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M
108
+ early_dcx.early_fatal("can't dump dependency graph without `-Z query-dep-graph`");
109
+ }
110
+
111
+ - let logical_env = parse_logical_env(early_dcx, matches);
112
+ -
113
+ let sysroot = Sysroot::new(matches.opt_str("sysroot").map(PathBuf::from));
114
+
115
+ let real_source_base_dir = |suffix: &str, confirm: &str| {
116
+ @@ -3072,7 +3051,6 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M
117
+ pretty,
118
+ working_dir,
119
+ color,
120
+ - logical_env,
121
+ verbose,
122
+ target_modifiers: collected_options.target_modifiers,
123
+ mitigation_coverage_map: collected_options.mitigations,
124
+ diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs
125
+ index bab087249593aa3ef57e8eda6cf7fd9049c0bf24..a075a088d206ce5ad914a8f08a2c07f4afe6af44 100644
126
+ --- a/compiler/rustc_session/src/options.rs
127
+ +++ b/compiler/rustc_session/src/options.rs
128
+ @@ -5,7 +5,6 @@ use std::str;
129
+
130
+ use rustc_abi::Align;
131
+ use rustc_ast::attr::version::RustcVersion;
132
+ -use rustc_data_structures::fx::FxIndexMap;
133
+ use rustc_data_structures::profiling::TimePassesFormat;
134
+ use rustc_data_structures::stable_hash::StableHasher;
135
+ use rustc_errors::{ColorConfig, TerminalUrl};
136
+ @@ -354,9 +353,6 @@ top_level_options!(
137
+
138
+ target_triple: TargetTuple [TRACKED],
139
+
140
+ - /// Effective logical environment used by `env!`/`option_env!` macros
141
+ - logical_env: FxIndexMap<String, String> [TRACKED],
142
+ -
143
+ test: bool [TRACKED],
144
+ error_format: ErrorOutputType [UNTRACKED],
145
+ diagnostic_width: Option<usize> [UNTRACKED],
146
+ diff --git a/library/proc_macro/src/bridge/mod.rs b/library/proc_macro/src/bridge/mod.rs
147
+ index 8b60043f5dc2af7c76e3b88f773f208db9a33946..0761549b2e30dc25c0667e98c0da3355bd4dc307 100644
148
+ --- a/library/proc_macro/src/bridge/mod.rs
149
+ +++ b/library/proc_macro/src/bridge/mod.rs
150
+ @@ -33,7 +33,6 @@ use crate::{Delimiter, Level};
151
+ macro_rules! with_api {
152
+ ($m:ident, $TokenStream: path, $Span: path, $Symbol: path) => {
153
+ $m! {
154
+ - fn injected_env_var(var: &str) -> Option<String>;
155
+ fn track_env_var(var: &str, value: Option<&str>);
156
+ fn track_path(path: &str);
157
+ fn literal_from_str(s: &str) -> Result<Literal<$Span, $Symbol>, String>;
158
+ diff --git a/library/proc_macro/src/lib.rs b/library/proc_macro/src/lib.rs
159
+ index 2f026fb81ee1ba3bb4cdceda33aa43feefdca75e..0f3e770efd965124825038ab920d97408a5753d4 100644
160
+ --- a/library/proc_macro/src/lib.rs
161
+ +++ b/library/proc_macro/src/lib.rs
162
+ @@ -1910,7 +1910,7 @@ pub mod tracked {
163
+ #[unstable(feature = "proc_macro_tracked_env", issue = "99515")]
164
+ pub fn env_var<K: AsRef<OsStr> + AsRef<str>>(key: K) -> Result<String, VarError> {
165
+ let key: &str = key.as_ref();
166
+ - let value = BridgeMethods::injected_env_var(key).map_or_else(|| env::var(key), Ok);
167
+ + let value = env::var(key);
168
+ BridgeMethods::track_env_var(key, value.as_deref().ok());
169
+ value
170
+ }
171
+ diff --git a/src/doc/unstable-book/src/compiler-flags/env-set.md b/src/doc/unstable-book/src/compiler-flags/env-set.md
172
+ deleted file mode 100644
173
+ index e5d7206c3a340ab8990fd13ec11a1d808b1111f6..0000000000000000000000000000000000000000
174
+ --- a/src/doc/unstable-book/src/compiler-flags/env-set.md
175
+ +++ /dev/null
176
+ @@ -1,45 +0,0 @@
177
+ -# `env-set`
178
+ -
179
+ -The tracking issue for this feature is: [#118372](https://github.com/rust-lang/rust/issues/118372).
180
+ -
181
+ -------------------------
182
+ -
183
+ -This option flag allows to specify environment variables value at compile time to be
184
+ -used by `env!` and `option_env!` macros. It also impacts `tracked_env::var` function
185
+ -from the `proc_macro` crate.
186
+ -
187
+ -This information will be stored in the dep-info files. For more information about
188
+ -dep-info files, take a look [here](https://doc.rust-lang.org/cargo/guide/build-cache.html#dep-info-files).
189
+ -
190
+ -When retrieving an environment variable value, the one specified by `--env-set` will take
191
+ -precedence. For example, if you want have `PATH=a` in your environment and pass:
192
+ -
193
+ -```bash
194
+ -rustc --env-set PATH=env
195
+ -```
196
+ -
197
+ -Then you will have:
198
+ -
199
+ -```rust,no_run
200
+ -assert_eq!(env!("PATH"), "env");
201
+ -```
202
+ -
203
+ -It will trigger a new compilation if any of the `--env-set` argument value is different.
204
+ -So if you first passed:
205
+ -
206
+ -```bash
207
+ ---env-set A=B --env X=12
208
+ -```
209
+ -
210
+ -and then on next compilation:
211
+ -
212
+ -```bash
213
+ ---env-set A=B
214
+ -```
215
+ -
216
+ -`X` value is different (not set) so the code will be re-compiled.
217
+ -
218
+ -Please note that on Windows, environment variables are case insensitive but case
219
+ -preserving whereas `rustc`'s environment variables are case sensitive. For example,
220
+ -having `Path` in your environment (case insensitive) is different than using
221
+ -`rustc --env-set Path=...` (case sensitive).
222
+ diff --git a/src/tools/rust-analyzer/crates/proc-macro-srv/src/server_impl/rust_analyzer_span.rs b/src/tools/rust-analyzer/crates/proc-macro-srv/src/server_impl/rust_analyzer_span.rs
223
+ index bdac9c920c4336ae34f40363a42629514440b935..188d24abcc67b8e1576c10298eb8116aad7de7b1 100644
224
+ --- a/src/tools/rust-analyzer/crates/proc-macro-srv/src/server_impl/rust_analyzer_span.rs
225
+ +++ b/src/tools/rust-analyzer/crates/proc-macro-srv/src/server_impl/rust_analyzer_span.rs
226
+ @@ -46,10 +46,6 @@ impl server::Server for RaSpanServer<'_> {
227
+ f(symbol.as_str())
228
+ }
229
+
230
+ - fn injected_env_var(&mut self, _: &str) -> Option<std::string::String> {
231
+ - None
232
+ - }
233
+ -
234
+ fn track_env_var(&mut self, var: &str, value: Option<&str>) {
235
+ self.tracked_env.env_vars.insert(var.into(), value.map(Into::into));
236
+ }
237
+ diff --git a/src/tools/rust-analyzer/crates/proc-macro-srv/src/server_impl/token_id.rs b/src/tools/rust-analyzer/crates/proc-macro-srv/src/server_impl/token_id.rs
238
+ index 6c393b8befb15a7066904bed03d5dd1980b06553..a42476f8567213d5ad1df61eebc732d2a82eda9d 100644
239
+ --- a/src/tools/rust-analyzer/crates/proc-macro-srv/src/server_impl/token_id.rs
240
+ +++ b/src/tools/rust-analyzer/crates/proc-macro-srv/src/server_impl/token_id.rs
241
+ @@ -50,9 +50,6 @@ impl server::Server for SpanIdServer<'_> {
242
+ f(symbol.as_str())
243
+ }
244
+
245
+ - fn injected_env_var(&mut self, _: &str) -> Option<std::string::String> {
246
+ - None
247
+ - }
248
+ fn track_env_var(&mut self, _: &str, _: Option<&str>) {}
249
+
250
+ fn track_path(&mut self, _: &str) {}
251
+ diff --git a/tests/ui/env-macro/env-env-overload.rs b/tests/ui/env-macro/env-env-overload.rs
252
+ deleted file mode 100644
253
+ index b3497ffbc882ffc9d5cfddd6db1e3fc6fd634289..0000000000000000000000000000000000000000
254
+ --- a/tests/ui/env-macro/env-env-overload.rs
255
+ +++ /dev/null
256
+ @@ -1,9 +0,0 @@
257
+ -//@ run-pass
258
+ -//@ rustc-env:MY_VAR=tadam
259
+ -//@ compile-flags: --env-set MY_VAR=123abc -Zunstable-options
260
+ -
261
+ -// This test ensures that variables provided with `--env` take precedence over
262
+ -// variables from environment.
263
+ -fn main() {
264
+ - assert_eq!(env!("MY_VAR"), "123abc");
265
+ -}
266
+ diff --git a/tests/ui/env-macro/env-not-env.rs b/tests/ui/env-macro/env-not-env.rs
267
+ index e903eab4e96b5fd8016f7c1de6e94895878e1cb8..b42036700788f4b8cbbeb306f3b9dc60551a06be 100644
268
+ --- a/tests/ui/env-macro/env-not-env.rs
269
+ +++ b/tests/ui/env-macro/env-not-env.rs
270
+ @@ -1,6 +1,5 @@
271
+ //@ run-pass
272
+ //@ rustc-env:MY_ENV=/
273
+ -// Ensures that variables not defined through `--env-set` are still available.
274
+
275
+ fn main() {
276
+ assert!(!env!("MY_ENV").is_empty());
277
+ diff --git a/tests/ui/env-macro/env-env.rs b/tests/ui/env-macro/simple.rs
278
+ similarity index 52%
279
+ rename from tests/ui/env-macro/env-env.rs
280
+ rename to tests/ui/env-macro/simple.rs
281
+ index 18226256b648773dd9335948d0018edc12a3e4c4..80fc005fa0f6823f3abf72f65e2e5e339ec29d9f 100644
282
+ --- a/tests/ui/env-macro/env-env.rs
283
+ +++ b/tests/ui/env-macro/simple.rs
284
+ @@ -1,4 +1,4 @@
285
+ -//@ compile-flags: --env-set FOO=123abc -Zunstable-options
286
+ +//@ rustc-env: FOO=123abc
287
+ //@ run-pass
288
+ fn main() {
289
+ assert_eq!(env!("FOO"), "123abc");
290
+ diff --git a/tests/ui/feature-gates/env-flag.rs b/tests/ui/feature-gates/env-flag.rs
291
+ deleted file mode 100644
292
+ index 0abc93994065a128ba794e0f2f5583d6a7833a64..0000000000000000000000000000000000000000
293
+ --- a/tests/ui/feature-gates/env-flag.rs
294
+ +++ /dev/null
295
+ @@ -1,3 +0,0 @@
296
+ -//@ compile-flags: --env-set A=B
297
+ -
298
+ -fn main() {}
299
+ diff --git a/tests/ui/feature-gates/env-flag.stderr b/tests/ui/feature-gates/env-flag.stderr
300
+ deleted file mode 100644
301
+ index a9fa1b65ea18c86b5fe8230cc4bb474810c80bfd..0000000000000000000000000000000000000000
302
+ --- a/tests/ui/feature-gates/env-flag.stderr
303
+ +++ /dev/null
304
+ @@ -1,2 +0,0 @@
305
+ -error: the `-Z unstable-options` flag must also be passed to enable the flag `env-set`
306
+ -
307
+ diff --git a/tests/ui/proc-macro/auxiliary/env.rs b/tests/ui/proc-macro/auxiliary/env.rs
308
+ index f0f0328e131e68d06f1b6a8343da051158b1d58b..089ace7792d4b17f6063bbbf3fdfaf033ddbd15f 100644
309
+ --- a/tests/ui/proc-macro/auxiliary/env.rs
310
+ +++ b/tests/ui/proc-macro/auxiliary/env.rs
311
+ @@ -8,12 +8,10 @@ use proc_macro::tracked::env_var;
312
+ #[proc_macro]
313
+ pub fn generate_const(input: TokenStream) -> TokenStream {
314
+ let the_const = match env_var("THE_CONST") {
315
+ - Ok(x) if x == "12" => {
316
+ - "const THE_CONST: u32 = 12;"
317
+ - }
318
+ - _ => {
319
+ - "const THE_CONST: u32 = 0;"
320
+ + Ok(x) => {
321
+ + format!("const THE_CONST: u32 = {x};")
322
+ }
323
+ + _ => "const THE_CONST: u32 = 0;".to_string(),
324
+ };
325
+ let another = if env_var("ANOTHER").is_ok() {
326
+ "const ANOTHER: u32 = 1;"
327
+ diff --git a/tests/ui/proc-macro/env.rs b/tests/ui/proc-macro/env.rs
328
+ index fc248f8835964c3388fbdc3e42e575b8eac181bf..ef3d8b5a898cbdac161fe66a232be5bbf514d713 100644
329
+ --- a/tests/ui/proc-macro/env.rs
330
+ +++ b/tests/ui/proc-macro/env.rs
331
+ @@ -1,7 +1,6 @@
332
+ //@ proc-macro: env.rs
333
+ //@ run-pass
334
+ //@ rustc-env: THE_CONST=1
335
+ -//@ compile-flags: -Zunstable-options --env-set THE_CONST=12 --env-set ANOTHER=4
336
+ //@ ignore-backends: gcc
337
+
338
+ #![crate_name = "foo"]
339
+ @@ -13,6 +12,6 @@ use env::generate_const;
340
+ generate_const!();
341
+
342
+ fn main() {
343
+ - assert_eq!(THE_CONST, 12);
344
+ - assert_eq!(ANOTHER, 1);
345
+ + assert_eq!(THE_CONST, 1);
346
+ + assert_eq!(ANOTHER, 2); // not found, see env::generate_const
347
+ }
patches/20261028T105419Z/rust-lang--rust-part009/4a6a067d7950c7eaebb111196e99f935cc0475bd.patch ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ diff --git a/clippy_lints/src/methods/mod.rs b/clippy_lints/src/methods/mod.rs
2
+ index 84decf478295e0b83ab53058f2de3d504d65ddd4..3153c7a73049223b27f0fc3364e27790e8725455 100644
3
+ --- a/clippy_lints/src/methods/mod.rs
4
+ +++ b/clippy_lints/src/methods/mod.rs
5
+ @@ -1775,7 +1775,7 @@ declare_clippy_lint! {
6
+ /// ### Example
7
+ /// ```no_run
8
+ /// # use std::ffi::CStr;
9
+ - /// # mod libc { pub unsafe fn puts(_: *const i8) {} }
10
+ + /// # mod libc { pub unsafe fn puts(_: *const std::ffi::c_char) {} }
11
+ /// fn needs_cstr(_: &CStr) {}
12
+ ///
13
+ /// needs_cstr(CStr::from_bytes_with_nul(b"Hello\0").unwrap());
14
+ @@ -1784,7 +1784,7 @@ declare_clippy_lint! {
15
+ /// Use instead:
16
+ /// ```no_run
17
+ /// # use std::ffi::CStr;
18
+ - /// # mod libc { pub unsafe fn puts(_: *const i8) {} }
19
+ + /// # mod libc { pub unsafe fn puts(_: *const std::ffi::c_char) {} }
20
+ /// fn needs_cstr(_: &CStr) {}
21
+ ///
22
+ /// needs_cstr(c"Hello");
patches/20261028T105419Z/rust-lang--rust-part009/51f306c0e5fcb3a08a97592b1dcab49cf4b64c81.patch ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ diff --git a/compiler/rustc_codegen_llvm/src/diagnostics.rs b/compiler/rustc_codegen_llvm/src/diagnostics.rs
2
+ index 54f8ffbb881da29b549ed0dfc09febaea079f606..fb43b36fe39b908ddb2bc021bd124692676cac82 100644
3
+ --- a/compiler/rustc_codegen_llvm/src/diagnostics.rs
4
+ +++ b/compiler/rustc_codegen_llvm/src/diagnostics.rs
5
+ @@ -1,4 +1,4 @@
6
+ -use std::ffi::CString;
7
+ +use std::ffi::{CString, c_uint};
8
+ use std::path::Path;
9
+
10
+ use rustc_data_structures::small_c_str::SmallCStr;
11
+ @@ -265,3 +265,15 @@ pub(crate) struct IntrinsicWrongArch<'a> {
12
+ pub(crate) struct UnknownLlvmTargetFeaturePrefix<'a> {
13
+ pub feature: &'a str,
14
+ }
15
+ +
16
+ +#[derive(Diagnostic)]
17
+ +#[diag(
18
+ + "LLVM version mismatch: this compiler was built for LLVM {$expected_version}, but LLVM {$llvm_major}.{$llvm_minor}.{$llvm_patch} was found{$dll_loc}"
19
+ +)]
20
+ +pub(crate) struct LlvmVersionMismatch<'a> {
21
+ + pub expected_version: c_uint,
22
+ + pub llvm_major: c_uint,
23
+ + pub llvm_minor: c_uint,
24
+ + pub llvm_patch: c_uint,
25
+ + pub dll_loc: &'a str,
26
+ +}
27
+ diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs
28
+ index 9819699ca5228c8e79a10d4e0aacb0ab57674cec..82ddcca3e15305e8a49fae4a444c437a4b9acb68 100644
29
+ --- a/compiler/rustc_codegen_llvm/src/llvm_util.rs
30
+ +++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs
31
+ @@ -56,20 +56,17 @@ unsafe fn configure_llvm(sess: &Session) {
32
+ llvm::LLVMGetVersion(&mut llvm_major, &mut llvm_minor, &mut llvm_patch);
33
+ let expected_version = llvm::LLVMRustVersionMajor();
34
+ if llvm_major != expected_version {
35
+ - panic!(
36
+ - concat!(
37
+ - "LLVM version mismatch: this compiler was built for LLVM {}, ",
38
+ - "but LLVM {}.{}.{} was found{}"
39
+ - ),
40
+ + sess.dcx().emit_fatal(diagnostics::LlvmVersionMismatch {
41
+ expected_version,
42
+ llvm_major,
43
+ llvm_minor,
44
+ llvm_patch,
45
+ - match rustc_session::filesearch::dll_path(llvm::LLVMGetVersion as *mut _) {
46
+ + dll_loc: &match rustc_session::filesearch::dll_path(llvm::LLVMGetVersion as *mut _)
47
+ + {
48
+ Ok(path) => format!(" at {}", path.display()),
49
+ Err(_) => String::new(),
50
+ - }
51
+ - );
52
+ + },
53
+ + })
54
+ }
55
+ }
56
+
57
+ diff --git a/compiler/rustc_macros/src/diagnostics/message.rs b/compiler/rustc_macros/src/diagnostics/message.rs
58
+ index 63561e409b0ae60acd1dce4b1770859ca2399b35..8eff9a4fa9e8a5d9bb10565cc3f49aec9410ce2d 100644
59
+ --- a/compiler/rustc_macros/src/diagnostics/message.rs
60
+ +++ b/compiler/rustc_macros/src/diagnostics/message.rs
61
+ @@ -133,6 +133,7 @@ const ALLOWED_CAPITALIZED_WORDS: &[&str] = &[
62
+ "Cargo",
63
+ "Ferris",
64
+ "GCC",
65
+ + "LLVM",
66
+ "MIR",
67
+ "NaNs",
68
+ "OK",
patches/20261028T105419Z/rust-lang--rust-part009/52b03b32d115af35abb8945bf6103f26e7ffc169.patch ADDED
@@ -0,0 +1,165 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ diff --git a/src/bootstrap/src/core/build_steps/llvm.rs b/src/bootstrap/src/core/build_steps/llvm.rs
2
+ index ff68abdbaaf891791ce3c99fb4dd1b5f422e0c03..9d6e27ffc698ed829c04a4770ab33766d8fb973b 100644
3
+ --- a/src/bootstrap/src/core/build_steps/llvm.rs
4
+ +++ b/src/bootstrap/src/core/build_steps/llvm.rs
5
+ @@ -286,13 +286,6 @@ fn try_download_ci_llvm(builder: &Builder<'_>, target: TargetSelection) -> Optio
6
+ }
7
+ }
8
+
9
+ - // FIXME: this should eventually be relaxed
10
+ - if target != builder.host_target {
11
+ - builder
12
+ - .info(&format!("Warning: LLVM will not be downloaded for a non-host target {target}"));
13
+ - return None;
14
+ - }
15
+ -
16
+ if !is_ci_llvm_available_for_target(&target, builder.config.llvm_assertions) {
17
+ builder.info(&format!(
18
+ "Warning: LLVM not available on CI for target={target} and assertions={}",
19
+ @@ -301,7 +294,7 @@ fn try_download_ci_llvm(builder: &Builder<'_>, target: TargetSelection) -> Optio
20
+ return None;
21
+ }
22
+
23
+ - let ci_llvm = builder.config.maybe_download_host_ci_llvm()?;
24
+ + let ci_llvm = builder.config.maybe_download_ci_llvm(target)?;
25
+ let link_shared = if !builder.config.dry_run() {
26
+ let link_type = t!(
27
+ std::fs::read_to_string(ci_llvm.join(LLVM_CI_LINK_TYPE_PATH)),
28
+ @@ -314,7 +307,7 @@ fn try_download_ci_llvm(builder: &Builder<'_>, target: TargetSelection) -> Optio
29
+
30
+ Some(DownloadedLlvm {
31
+ output: LlvmOutput {
32
+ - llvm_config: ci_llvm.join("bin").join(exe("llvm-config", builder.host_target)),
33
+ + llvm_config: ci_llvm.join("bin").join(exe("llvm-config", target)),
34
+ link_shared,
35
+ llvm_root_dir: ci_llvm,
36
+ kind: LlvmKind::DownloadedFromCi,
37
+ @@ -431,8 +424,12 @@ impl Step for LlvmFromCi {
38
+
39
+ fn run(self, builder: &Builder<'_>) -> Self::Output {
40
+ let llvm_ci = try_download_ci_llvm(builder, self.target)?;
41
+ +
42
+ // Sanity check
43
+ - check_llvm_version(builder, llvm_ci.output.llvm_config());
44
+ + if builder.host_target == self.target {
45
+ + check_llvm_version(builder, llvm_ci.output.llvm_config());
46
+ + }
47
+ +
48
+ Some(llvm_ci)
49
+ }
50
+ }
51
+ diff --git a/src/bootstrap/src/core/config/tests.rs b/src/bootstrap/src/core/config/tests.rs
52
+ index 4344ec413c979deac9252eb908b4785da78fac61..6318042602dbefba43d3c7716a9ab174c8c8f4f4 100644
53
+ --- a/src/bootstrap/src/core/config/tests.rs
54
+ +++ b/src/bootstrap/src/core/config/tests.rs
55
+ @@ -12,7 +12,6 @@ use super::flags::Flags;
56
+ use super::toml::change_id::ChangeIdWrapper;
57
+ use super::toml::rust::parse_codegen_backends;
58
+ use super::{Config, DebuggerPath, LlvmCiMode, RUSTC_IF_UNCHANGED_ALLOWED_PATHS};
59
+ -use crate::Build;
60
+ use crate::core::build_steps::clippy::{LintConfig, get_clippy_rules_in_order};
61
+ use crate::core::build_steps::llvm::{LLVM_INVALIDATION_PATHS, LlvmKind, get_llvm_build_status};
62
+ use crate::core::builder::Builder;
63
+ @@ -20,6 +19,7 @@ use crate::core::config::flags::Subcommand;
64
+ use crate::core::config::{
65
+ BootstrapOverrideLld, ChangeId, CompilerBuiltins, Target, TargetSelection,
66
+ };
67
+ +use crate::core::session::Session;
68
+ use crate::utils::tests::TestCtx;
69
+ use crate::utils::tests::git::git_test;
70
+
71
+ @@ -45,7 +45,7 @@ fn download_ci_llvm() {
72
+ .with_default_toml_config("llvm.download-ci-llvm = \"if-unchanged\"")
73
+ .create_config();
74
+ if if_unchanged_config.is_running_on_ci() {
75
+ - let build = Build::new(config.clone());
76
+ + let build = Session::new(config.clone());
77
+ let builder = Builder::new(&build);
78
+
79
+ let llvm = get_llvm_build_status(&builder, builder.config.host_target);
80
+ diff --git a/src/bootstrap/src/core/download.rs b/src/bootstrap/src/core/download.rs
81
+ index 9a3cfe4a791d496e641243faea9faa1f0768dc35..86cb4614e775184d8f008c4f4b2d071877d4fad5 100644
82
+ --- a/src/bootstrap/src/core/download.rs
83
+ +++ b/src/bootstrap/src/core/download.rs
84
+ @@ -268,15 +268,15 @@ impl Config {
85
+ download_component(dwn_ctx, &self.out, mode, filename, prefix, key, destination);
86
+ }
87
+
88
+ - /// Attempts to download LLVM from CI for the **host target**.
89
+ + /// Attempts to download LLVM from CI for the given **target**.
90
+ /// Returns a path to the downloaded and extracted directory.
91
+ - pub(crate) fn maybe_download_host_ci_llvm(&self) -> Option<PathBuf> {
92
+ + pub(crate) fn maybe_download_ci_llvm(&self, target: TargetSelection) -> Option<PathBuf> {
93
+ // Never try to download CI LLVM during unit tests.
94
+ if cfg!(test) {
95
+ return None;
96
+ }
97
+
98
+ - let llvm_root = self.out.join(self.host_target).join("ci-llvm");
99
+ + let llvm_root = self.out.join(target).join("ci-llvm");
100
+ let llvm_freshness =
101
+ detect_llvm_freshness(self, self.rust_info.is_managed_git_subrepository());
102
+ self.do_if_verbose(|| {
103
+ @@ -296,7 +296,7 @@ impl Config {
104
+ let stamp_key = format!("{}{}", llvm_sha, self.llvm_assertions);
105
+ let llvm_stamp = BuildStamp::new(&llvm_root).with_prefix("llvm").add_stamp(stamp_key);
106
+ if !llvm_stamp.is_up_to_date() && !self.dry_run() {
107
+ - self.download_ci_llvm(&llvm_root, &llvm_sha);
108
+ + self.download_ci_llvm(&llvm_root, target, &llvm_sha);
109
+
110
+ if self.should_fix_bins_and_dylibs() {
111
+ for entry in t!(fs::read_dir(llvm_root.join("bin"))) {
112
+ @@ -315,7 +315,7 @@ impl Config {
113
+ let now = std::time::SystemTime::now();
114
+ let file_times = fs::FileTimes::new().set_accessed(now).set_modified(now);
115
+
116
+ - let llvm_config = llvm_root.join("bin").join(exe("llvm-config", self.host_target));
117
+ + let llvm_config = llvm_root.join("bin").join(exe("llvm-config", target));
118
+ t!(crate::utils::helpers::set_file_times(llvm_config, file_times));
119
+
120
+ if self.should_fix_bins_and_dylibs() {
121
+ @@ -353,13 +353,13 @@ impl Config {
122
+ Some(llvm_root)
123
+ }
124
+
125
+ - fn download_ci_llvm(&self, llvm_root: &Path, llvm_sha: &str) {
126
+ + fn download_ci_llvm(&self, llvm_root: &Path, target: TargetSelection, llvm_sha: &str) {
127
+ // For unit tests, downloading should have been blocked by `maybe_download_ci_llvm`.
128
+ assert!(cfg!(not(test)), "unit tests shouldn't be downloading CI LLVM");
129
+
130
+ let llvm_assertions = self.llvm_assertions;
131
+
132
+ - let cache_prefix = format!("llvm-{llvm_sha}-{llvm_assertions}");
133
+ + let cache_prefix = format!("llvm-{}-{llvm_sha}-{llvm_assertions}", target.triple);
134
+ let cache_dst =
135
+ self.bootstrap_cache_path.as_ref().cloned().unwrap_or_else(|| self.out.join("cache"));
136
+
137
+ @@ -373,20 +373,23 @@ impl Config {
138
+ &self.stage0_metadata.config.artifacts_server
139
+ };
140
+ let version = self.artifact_version_part(llvm_sha);
141
+ - let filename = format!("rust-dev-{}-{}.tar.xz", version, self.host_target.triple);
142
+ + let filename = format!("rust-dev-{}-{}.tar.xz", version, target.triple);
143
+ let tarball = rustc_cache.join(&filename);
144
+ if !tarball.exists() {
145
+ - let help_on_error = "ERROR: failed to download llvm from ci
146
+ + let help_on_error = format!(
147
+ + "ERROR: failed to download llvm from CI for `{target}`
148
+
149
+ HELP: There could be two reasons behind this:
150
+ - 1) The host triple is not supported for `download-ci-llvm`.
151
+ + 1) `{target}` is not supported for `download-ci-llvm`.
152
+ 2) Old builds get deleted after a certain time.
153
+ HELP: In either case, disable `download-ci-llvm` in your bootstrap.toml:
154
+
155
+ [llvm]
156
+ download-ci-llvm = false
157
+ - ";
158
+ - self.download_file(&format!("{base}/{llvm_sha}/{filename}"), &tarball, help_on_error);
159
+ + ",
160
+ + target = target.triple
161
+ + );
162
+ + self.download_file(&format!("{base}/{llvm_sha}/{filename}"), &tarball, &help_on_error);
163
+ }
164
+ self.unpack(&tarball, llvm_root, "rust-dev");
165
+ }
patches/20261028T105419Z/rust-lang--rust-part009/5321a4f40c957cf3587c055e77461febc2ebc865.patch ADDED
@@ -0,0 +1,461 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ diff --git a/compiler/rustc_builtin_macros/src/env.rs b/compiler/rustc_builtin_macros/src/env.rs
2
+ index 74653139fec021f6623661c501beb8660472f687..cced54e3cb5343a45d9eefaf6164c779399a641f 100644
3
+ --- a/compiler/rustc_builtin_macros/src/env.rs
4
+ +++ b/compiler/rustc_builtin_macros/src/env.rs
5
+ @@ -17,13 +17,9 @@ use thin_vec::thin_vec;
6
+ use crate::diagnostics;
7
+ use crate::util::{expr_to_string, get_exprs_from_tts, get_single_expr_from_tts};
8
+
9
+ -fn lookup_env<'cx>(cx: &'cx ExtCtxt<'_>, var: Symbol) -> Result<Symbol, VarError> {
10
+ +fn lookup_env(var: Symbol) -> Result<Symbol, VarError> {
11
+ let var = var.as_str();
12
+ - if let Some(value) = cx.sess.opts.logical_env.get(var) {
13
+ - return Ok(Symbol::intern(value));
14
+ - }
15
+ - // If the environment variable was not defined with the `--env-set` option, we try to retrieve it
16
+ - // from rustc's environment.
17
+ + // Try to retrieve the environment variable from rustc's environment.
18
+ Ok(Symbol::intern(&env::var(var)?))
19
+ }
20
+
21
+ @@ -50,7 +46,7 @@ pub(crate) fn expand_option_env<'cx>(
22
+ };
23
+
24
+ let sp = cx.with_def_site_ctxt(sp);
25
+ - let value = lookup_env(cx, var);
26
+ + let value = lookup_env(var);
27
+ cx.sess.env_depinfo.borrow_mut().insert((var, value.as_ref().ok().copied()));
28
+ let e = match value {
29
+ Err(VarError::NotPresent) => {
30
+ @@ -124,7 +120,7 @@ pub(crate) fn expand_env<'cx>(
31
+ };
32
+
33
+ let span = cx.with_def_site_ctxt(sp);
34
+ - let value = lookup_env(cx, var);
35
+ + let value = lookup_env(var);
36
+ cx.sess.env_depinfo.borrow_mut().insert((var, value.as_ref().ok().copied()));
37
+ let e = match value {
38
+ Err(VarError::NotPresent) => {
39
+ diff --git a/compiler/rustc_expand/src/proc_macro_server.rs b/compiler/rustc_expand/src/proc_macro_server.rs
40
+ index 7b52a5600ae2aa77bba58d997e43c9aa5995188d..c522626b3956245ab42685298da8847a83dbbdb5 100644
41
+ --- a/compiler/rustc_expand/src/proc_macro_server.rs
42
+ +++ b/compiler/rustc_expand/src/proc_macro_server.rs
43
+ @@ -473,10 +473,6 @@ impl server::Server for Rustc<'_, '_> {
44
+ f(symbol.as_str())
45
+ }
46
+
47
+ - fn injected_env_var(&mut self, var: &str) -> Option<String> {
48
+ - self.ecx.sess.opts.logical_env.get(var).cloned()
49
+ - }
50
+ -
51
+ fn track_env_var(&mut self, var: &str, value: Option<&str>) {
52
+ self.ecx
53
+ .sess
54
+ diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs
55
+ index 95f6348cfbdbbae98fc2f47c73935fa1eacba3b3..68bbc1520a06d923e9de29ca084dd156f0ebabdd 100644
56
+ --- a/compiler/rustc_session/src/config.rs
57
+ +++ b/compiler/rustc_session/src/config.rs
58
+ @@ -14,7 +14,7 @@ use std::sync::LazyLock;
59
+ use std::{cmp, fs, iter, thread};
60
+
61
+ use externs::{ExternOpt, split_extern_opt};
62
+ -use rustc_data_structures::fx::{FxHashSet, FxIndexMap};
63
+ +use rustc_data_structures::fx::FxHashSet;
64
+ use rustc_data_structures::stable_hash::{StableHasher, StableOrd};
65
+ use rustc_errors::emitter::HumanReadableErrorType;
66
+ use rustc_errors::{ColorConfig, DiagCtxtFlags};
67
+ @@ -1499,7 +1499,6 @@ impl Default for Options {
68
+ pretty: None,
69
+ working_dir,
70
+ color: ColorConfig::Auto,
71
+ - logical_env: FxIndexMap::default(),
72
+ verbose: false,
73
+ target_modifiers: BTreeMap::default(),
74
+ mitigation_coverage_map: Default::default(),
75
+ @@ -2121,7 +2120,6 @@ pub fn rustc_optgroups() -> Vec<RustcOptGroup> {
76
+ "Defines which scopes of paths should be remapped by `--remap-path-prefix`",
77
+ "<macro,diagnostics,debuginfo,coverage,object,all>",
78
+ ),
79
+ - opt(Unstable, Multi, "", "env-set", "Inject an environment variable", "<VAR>=<VALUE>"),
80
+ opt(Unstable, Opt, "j", "jobs", "Limit on the number of used parallel jobs", "<N>"),
81
+ opt(
82
+ Unstable,
83
+ @@ -2664,23 +2662,6 @@ fn parse_remap_path_prefix(
84
+ .collect()
85
+ }
86
+
87
+ -fn parse_logical_env(
88
+ - early_dcx: &EarlyDiagCtxt,
89
+ - matches: &getopts::Matches,
90
+ -) -> FxIndexMap<String, String> {
91
+ - let mut vars = FxIndexMap::default();
92
+ -
93
+ - for arg in matches.opt_strs("env-set") {
94
+ - if let Some((name, val)) = arg.split_once('=') {
95
+ - vars.insert(name.to_string(), val.to_string());
96
+ - } else {
97
+ - early_dcx.early_fatal(format!("`--env-set`: specify value for variable `{arg}`"));
98
+ - }
99
+ - }
100
+ -
101
+ - vars
102
+ -}
103
+ -
104
+ // JUSTIFICATION: before wrapper fn is available
105
+ #[allow(rustc::bad_opt_access)]
106
+ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::Matches) -> Options {
107
+ @@ -2956,8 +2937,6 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M
108
+ early_dcx.early_fatal("can't dump dependency graph without `-Z query-dep-graph`");
109
+ }
110
+
111
+ - let logical_env = parse_logical_env(early_dcx, matches);
112
+ -
113
+ let sysroot = Sysroot::new(matches.opt_str("sysroot").map(PathBuf::from));
114
+
115
+ let real_source_base_dir = |suffix: &str, confirm: &str| {
116
+ @@ -3072,7 +3051,6 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M
117
+ pretty,
118
+ working_dir,
119
+ color,
120
+ - logical_env,
121
+ verbose,
122
+ target_modifiers: collected_options.target_modifiers,
123
+ mitigation_coverage_map: collected_options.mitigations,
124
+ diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs
125
+ index bab087249593aa3ef57e8eda6cf7fd9049c0bf24..a075a088d206ce5ad914a8f08a2c07f4afe6af44 100644
126
+ --- a/compiler/rustc_session/src/options.rs
127
+ +++ b/compiler/rustc_session/src/options.rs
128
+ @@ -5,7 +5,6 @@ use std::str;
129
+
130
+ use rustc_abi::Align;
131
+ use rustc_ast::attr::version::RustcVersion;
132
+ -use rustc_data_structures::fx::FxIndexMap;
133
+ use rustc_data_structures::profiling::TimePassesFormat;
134
+ use rustc_data_structures::stable_hash::StableHasher;
135
+ use rustc_errors::{ColorConfig, TerminalUrl};
136
+ @@ -354,9 +353,6 @@ top_level_options!(
137
+
138
+ target_triple: TargetTuple [TRACKED],
139
+
140
+ - /// Effective logical environment used by `env!`/`option_env!` macros
141
+ - logical_env: FxIndexMap<String, String> [TRACKED],
142
+ -
143
+ test: bool [TRACKED],
144
+ error_format: ErrorOutputType [UNTRACKED],
145
+ diagnostic_width: Option<usize> [UNTRACKED],
146
+ diff --git a/library/proc_macro/src/bridge/mod.rs b/library/proc_macro/src/bridge/mod.rs
147
+ index 8b60043f5dc2af7c76e3b88f773f208db9a33946..0761549b2e30dc25c0667e98c0da3355bd4dc307 100644
148
+ --- a/library/proc_macro/src/bridge/mod.rs
149
+ +++ b/library/proc_macro/src/bridge/mod.rs
150
+ @@ -33,7 +33,6 @@ use crate::{Delimiter, Level};
151
+ macro_rules! with_api {
152
+ ($m:ident, $TokenStream: path, $Span: path, $Symbol: path) => {
153
+ $m! {
154
+ - fn injected_env_var(var: &str) -> Option<String>;
155
+ fn track_env_var(var: &str, value: Option<&str>);
156
+ fn track_path(path: &str);
157
+ fn literal_from_str(s: &str) -> Result<Literal<$Span, $Symbol>, String>;
158
+ diff --git a/library/proc_macro/src/lib.rs b/library/proc_macro/src/lib.rs
159
+ index 2f026fb81ee1ba3bb4cdceda33aa43feefdca75e..0f3e770efd965124825038ab920d97408a5753d4 100644
160
+ --- a/library/proc_macro/src/lib.rs
161
+ +++ b/library/proc_macro/src/lib.rs
162
+ @@ -1910,7 +1910,7 @@ pub mod tracked {
163
+ #[unstable(feature = "proc_macro_tracked_env", issue = "99515")]
164
+ pub fn env_var<K: AsRef<OsStr> + AsRef<str>>(key: K) -> Result<String, VarError> {
165
+ let key: &str = key.as_ref();
166
+ - let value = BridgeMethods::injected_env_var(key).map_or_else(|| env::var(key), Ok);
167
+ + let value = env::var(key);
168
+ BridgeMethods::track_env_var(key, value.as_deref().ok());
169
+ value
170
+ }
171
+ diff --git a/src/bootstrap/download-ci-llvm-stamp b/src/bootstrap/download-ci-llvm-stamp
172
+ index 2ebc3066f1facf9c92ddebd24ecc3fe8efb1fd1c..f182cbd3b65fb55f0b3776f43102a70079ef4fa6 100644
173
+ --- a/src/bootstrap/download-ci-llvm-stamp
174
+ +++ b/src/bootstrap/download-ci-llvm-stamp
175
+ @@ -1,4 +1,4 @@
176
+ Change this file to make users of the `download-ci-llvm` configuration download
177
+ a new version of LLVM from CI, even if the LLVM submodule hasn’t changed.
178
+
179
+ -Last change is for: https://github.com/rust-lang/rust/pull/160100
180
+ +Last change is for: https://github.com/rust-lang/rust/pull/161603
181
+ diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs
182
+ index cc9e4f9834d54c767497eb7de11774a56c066877..6e2db69d13370c3f4da4688d328bc4373989e4bb 100644
183
+ --- a/src/bootstrap/src/core/build_steps/compile.rs
184
+ +++ b/src/bootstrap/src/core/build_steps/compile.rs
185
+ @@ -2199,10 +2199,17 @@ impl CommandLineStep for Assemble {
186
+ let tool_exe = exe(tool, target_compiler.host);
187
+ let src_path = llvm_bin_dir.join(&tool_exe);
188
+
189
+ - // When using `download-ci-llvm`, some of the tools may not exist, so skip trying to copy them.
190
+ - if !src_path.exists() && builder.config.llvm_ci_mode.download_from_ci() {
191
+ - eprintln!("{} does not exist; skipping copy", src_path.display());
192
+ - continue;
193
+ + if !src_path.exists() {
194
+ + // When using `download-ci-llvm`, some of the tools may not exist, so skip trying to copy them.
195
+ + if builder.config.llvm_ci_mode.download_from_ci() {
196
+ + eprintln!("{} does not exist; skipping copy", src_path.display());
197
+ + continue;
198
+ + }
199
+ + // On older LLVM versions, llubi isn't in the default tools. Remove this
200
+ + // code when LLVM 23 is the minimum version.
201
+ + if *tool == "llubi" {
202
+ + continue;
203
+ + }
204
+ }
205
+
206
+ // There is a chance that these tools are being installed from an external LLVM.
207
+ diff --git a/src/bootstrap/src/core/build_steps/dist.rs b/src/bootstrap/src/core/build_steps/dist.rs
208
+ index a266fba781e1a0dfcb275eee89ce5a93a74e098e..871c2ac3b43e98446700b5f4f8c1cdf594cfb510 100644
209
+ --- a/src/bootstrap/src/core/build_steps/dist.rs
210
+ +++ b/src/bootstrap/src/core/build_steps/dist.rs
211
+ @@ -60,9 +60,10 @@ pub(crate) const LLVM_TOOLS: &[&str] = &[
212
+ "llvm-ar", // used for creating and modifying archive files
213
+ "llvm-as", // used to convert LLVM assembly to LLVM bitcode
214
+ "llvm-dis", // used to disassemble LLVM bitcode
215
+ - "llvm-link", // Used to link LLVM bitcode
216
+ - "llc", // used to compile LLVM bytecode
217
+ - "opt", // used to optimize LLVM bytecode
218
+ + "llvm-link", // used to link LLVM bitcode
219
+ + "llc", // used to compile LLVM IR
220
+ + "opt", // used to optimize LLVM IR
221
+ + "llubi", // used to execute LLVM while checking for Undefined Behavior
222
+ ];
223
+
224
+ /// LLD file names for all flavors.
225
+ diff --git a/src/doc/unstable-book/src/compiler-flags/env-set.md b/src/doc/unstable-book/src/compiler-flags/env-set.md
226
+ deleted file mode 100644
227
+ index e5d7206c3a340ab8990fd13ec11a1d808b1111f6..0000000000000000000000000000000000000000
228
+ --- a/src/doc/unstable-book/src/compiler-flags/env-set.md
229
+ +++ /dev/null
230
+ @@ -1,45 +0,0 @@
231
+ -# `env-set`
232
+ -
233
+ -The tracking issue for this feature is: [#118372](https://github.com/rust-lang/rust/issues/118372).
234
+ -
235
+ -------------------------
236
+ -
237
+ -This option flag allows to specify environment variables value at compile time to be
238
+ -used by `env!` and `option_env!` macros. It also impacts `tracked_env::var` function
239
+ -from the `proc_macro` crate.
240
+ -
241
+ -This information will be stored in the dep-info files. For more information about
242
+ -dep-info files, take a look [here](https://doc.rust-lang.org/cargo/guide/build-cache.html#dep-info-files).
243
+ -
244
+ -When retrieving an environment variable value, the one specified by `--env-set` will take
245
+ -precedence. For example, if you want have `PATH=a` in your environment and pass:
246
+ -
247
+ -```bash
248
+ -rustc --env-set PATH=env
249
+ -```
250
+ -
251
+ -Then you will have:
252
+ -
253
+ -```rust,no_run
254
+ -assert_eq!(env!("PATH"), "env");
255
+ -```
256
+ -
257
+ -It will trigger a new compilation if any of the `--env-set` argument value is different.
258
+ -So if you first passed:
259
+ -
260
+ -```bash
261
+ ---env-set A=B --env X=12
262
+ -```
263
+ -
264
+ -and then on next compilation:
265
+ -
266
+ -```bash
267
+ ---env-set A=B
268
+ -```
269
+ -
270
+ -`X` value is different (not set) so the code will be re-compiled.
271
+ -
272
+ -Please note that on Windows, environment variables are case insensitive but case
273
+ -preserving whereas `rustc`'s environment variables are case sensitive. For example,
274
+ -having `Path` in your environment (case insensitive) is different than using
275
+ -`rustc --env-set Path=...` (case sensitive).
276
+ diff --git a/src/etc/lldb_lookup.py b/src/etc/lldb_lookup.py
277
+ index 8f1a4c452df1224ab40cacc98a0dfc6e4d882e90..f45506e0c53a795ab8af0d4b014a46538b8b7fc9 100644
278
+ --- a/src/etc/lldb_lookup.py
279
+ +++ b/src/etc/lldb_lookup.py
280
+ @@ -39,6 +39,7 @@ from lldb_providers import (
281
+ MSVCTupleSyntheticProvider,
282
+ ClangEncodedEnumSummaryProvider,
283
+ StructSummaryProvider,
284
+ + f16SummaryProvider,
285
+ # re-exports
286
+ get_template_args as get_template_args,
287
+ resolve_msvc_template_arg as resolve_msvc_template_arg,
288
+ @@ -138,6 +139,16 @@ def register_providers_compatibility():
289
+ | lldb.eTypeOptionHideChildren,
290
+ )
291
+
292
+ + # Force f16 summary on windows-msvc since PDB does not have a node for f16
293
+ + register_summary(
294
+ + f16SummaryProvider,
295
+ + lldb.SBTypeNameSpecifier(
296
+ + MOD_PREFIX + is_msvc_f16.__name__,
297
+ + lldb.eFormatterMatchCallback,
298
+ + ),
299
+ + DEFAULT_TYPE_OPTIONS | lldb.eTypeOptionHideChildren,
300
+ + )
301
+ +
302
+ # Tuple-structs
303
+ register_synth(
304
+ TupleSyntheticProvider,
305
+ @@ -452,6 +463,11 @@ def is_tuple_type(type: lldb.SBType, _dict: LLDBOpaque) -> bool:
306
+ return len(fields) != 0 and is_tuple_fields(fields)
307
+
308
+
309
+ +def is_msvc_f16(type: lldb.SBType, _dict: LLDBOpaque) -> bool:
310
+ + # DWARF has a proper tag for f16, PDB does not.
311
+ + return type.GetName() == "f16" and type.IsAggregateType()
312
+ +
313
+ +
314
+ def classify_rust_type(type: lldb.SBType, is_msvc: bool) -> RustType:
315
+ if type.IsPointerType():
316
+ return RustType.Indirection
317
+ diff --git a/src/etc/lldb_providers.py b/src/etc/lldb_providers.py
318
+ index f251fdb29ace275e8868e30bf0d930d56232bf16..4fdc9e28363b682684e58cfeb96e15fb20ba5e9b 100644
319
+ --- a/src/etc/lldb_providers.py
320
+ +++ b/src/etc/lldb_providers.py
321
+ @@ -505,6 +505,14 @@ def StdPathSummaryProvider(valobj: SBValue, _dict: LLDBOpaque) -> str:
322
+ return read_string(process, start, length)
323
+
324
+
325
+ +def f16SummaryProvider(valobj: SBValue, _dict: LLDBOpaque) -> str:
326
+ + return (
327
+ + valobj.GetChildAtIndex(0)
328
+ + .Cast(valobj.GetTarget().GetBasicType(eBasicTypeHalf))
329
+ + .GetValue()
330
+ + )
331
+ +
332
+ +
333
+ def sequence_formatter(output: str, valobj: SBValue, _dict: LLDBOpaque):
334
+ length: int = valobj.GetNumChildren()
335
+
336
+ diff --git a/src/tools/rust-analyzer/crates/proc-macro-srv/src/server_impl/rust_analyzer_span.rs b/src/tools/rust-analyzer/crates/proc-macro-srv/src/server_impl/rust_analyzer_span.rs
337
+ index bdac9c920c4336ae34f40363a42629514440b935..188d24abcc67b8e1576c10298eb8116aad7de7b1 100644
338
+ --- a/src/tools/rust-analyzer/crates/proc-macro-srv/src/server_impl/rust_analyzer_span.rs
339
+ +++ b/src/tools/rust-analyzer/crates/proc-macro-srv/src/server_impl/rust_analyzer_span.rs
340
+ @@ -46,10 +46,6 @@ impl server::Server for RaSpanServer<'_> {
341
+ f(symbol.as_str())
342
+ }
343
+
344
+ - fn injected_env_var(&mut self, _: &str) -> Option<std::string::String> {
345
+ - None
346
+ - }
347
+ -
348
+ fn track_env_var(&mut self, var: &str, value: Option<&str>) {
349
+ self.tracked_env.env_vars.insert(var.into(), value.map(Into::into));
350
+ }
351
+ diff --git a/src/tools/rust-analyzer/crates/proc-macro-srv/src/server_impl/token_id.rs b/src/tools/rust-analyzer/crates/proc-macro-srv/src/server_impl/token_id.rs
352
+ index 6c393b8befb15a7066904bed03d5dd1980b06553..a42476f8567213d5ad1df61eebc732d2a82eda9d 100644
353
+ --- a/src/tools/rust-analyzer/crates/proc-macro-srv/src/server_impl/token_id.rs
354
+ +++ b/src/tools/rust-analyzer/crates/proc-macro-srv/src/server_impl/token_id.rs
355
+ @@ -50,9 +50,6 @@ impl server::Server for SpanIdServer<'_> {
356
+ f(symbol.as_str())
357
+ }
358
+
359
+ - fn injected_env_var(&mut self, _: &str) -> Option<std::string::String> {
360
+ - None
361
+ - }
362
+ fn track_env_var(&mut self, _: &str, _: Option<&str>) {}
363
+
364
+ fn track_path(&mut self, _: &str) {}
365
+ diff --git a/tests/ui/env-macro/env-env-overload.rs b/tests/ui/env-macro/env-env-overload.rs
366
+ deleted file mode 100644
367
+ index b3497ffbc882ffc9d5cfddd6db1e3fc6fd634289..0000000000000000000000000000000000000000
368
+ --- a/tests/ui/env-macro/env-env-overload.rs
369
+ +++ /dev/null
370
+ @@ -1,9 +0,0 @@
371
+ -//@ run-pass
372
+ -//@ rustc-env:MY_VAR=tadam
373
+ -//@ compile-flags: --env-set MY_VAR=123abc -Zunstable-options
374
+ -
375
+ -// This test ensures that variables provided with `--env` take precedence over
376
+ -// variables from environment.
377
+ -fn main() {
378
+ - assert_eq!(env!("MY_VAR"), "123abc");
379
+ -}
380
+ diff --git a/tests/ui/env-macro/env-not-env.rs b/tests/ui/env-macro/env-not-env.rs
381
+ index e903eab4e96b5fd8016f7c1de6e94895878e1cb8..b42036700788f4b8cbbeb306f3b9dc60551a06be 100644
382
+ --- a/tests/ui/env-macro/env-not-env.rs
383
+ +++ b/tests/ui/env-macro/env-not-env.rs
384
+ @@ -1,6 +1,5 @@
385
+ //@ run-pass
386
+ //@ rustc-env:MY_ENV=/
387
+ -// Ensures that variables not defined through `--env-set` are still available.
388
+
389
+ fn main() {
390
+ assert!(!env!("MY_ENV").is_empty());
391
+ diff --git a/tests/ui/env-macro/env-env.rs b/tests/ui/env-macro/simple.rs
392
+ similarity index 52%
393
+ rename from tests/ui/env-macro/env-env.rs
394
+ rename to tests/ui/env-macro/simple.rs
395
+ index 18226256b648773dd9335948d0018edc12a3e4c4..80fc005fa0f6823f3abf72f65e2e5e339ec29d9f 100644
396
+ --- a/tests/ui/env-macro/env-env.rs
397
+ +++ b/tests/ui/env-macro/simple.rs
398
+ @@ -1,4 +1,4 @@
399
+ -//@ compile-flags: --env-set FOO=123abc -Zunstable-options
400
+ +//@ rustc-env: FOO=123abc
401
+ //@ run-pass
402
+ fn main() {
403
+ assert_eq!(env!("FOO"), "123abc");
404
+ diff --git a/tests/ui/feature-gates/env-flag.rs b/tests/ui/feature-gates/env-flag.rs
405
+ deleted file mode 100644
406
+ index 0abc93994065a128ba794e0f2f5583d6a7833a64..0000000000000000000000000000000000000000
407
+ --- a/tests/ui/feature-gates/env-flag.rs
408
+ +++ /dev/null
409
+ @@ -1,3 +0,0 @@
410
+ -//@ compile-flags: --env-set A=B
411
+ -
412
+ -fn main() {}
413
+ diff --git a/tests/ui/feature-gates/env-flag.stderr b/tests/ui/feature-gates/env-flag.stderr
414
+ deleted file mode 100644
415
+ index a9fa1b65ea18c86b5fe8230cc4bb474810c80bfd..0000000000000000000000000000000000000000
416
+ --- a/tests/ui/feature-gates/env-flag.stderr
417
+ +++ /dev/null
418
+ @@ -1,2 +0,0 @@
419
+ -error: the `-Z unstable-options` flag must also be passed to enable the flag `env-set`
420
+ -
421
+ diff --git a/tests/ui/proc-macro/auxiliary/env.rs b/tests/ui/proc-macro/auxiliary/env.rs
422
+ index f0f0328e131e68d06f1b6a8343da051158b1d58b..089ace7792d4b17f6063bbbf3fdfaf033ddbd15f 100644
423
+ --- a/tests/ui/proc-macro/auxiliary/env.rs
424
+ +++ b/tests/ui/proc-macro/auxiliary/env.rs
425
+ @@ -8,12 +8,10 @@ use proc_macro::tracked::env_var;
426
+ #[proc_macro]
427
+ pub fn generate_const(input: TokenStream) -> TokenStream {
428
+ let the_const = match env_var("THE_CONST") {
429
+ - Ok(x) if x == "12" => {
430
+ - "const THE_CONST: u32 = 12;"
431
+ - }
432
+ - _ => {
433
+ - "const THE_CONST: u32 = 0;"
434
+ + Ok(x) => {
435
+ + format!("const THE_CONST: u32 = {x};")
436
+ }
437
+ + _ => "const THE_CONST: u32 = 0;".to_string(),
438
+ };
439
+ let another = if env_var("ANOTHER").is_ok() {
440
+ "const ANOTHER: u32 = 1;"
441
+ diff --git a/tests/ui/proc-macro/env.rs b/tests/ui/proc-macro/env.rs
442
+ index fc248f8835964c3388fbdc3e42e575b8eac181bf..ef3d8b5a898cbdac161fe66a232be5bbf514d713 100644
443
+ --- a/tests/ui/proc-macro/env.rs
444
+ +++ b/tests/ui/proc-macro/env.rs
445
+ @@ -1,7 +1,6 @@
446
+ //@ proc-macro: env.rs
447
+ //@ run-pass
448
+ //@ rustc-env: THE_CONST=1
449
+ -//@ compile-flags: -Zunstable-options --env-set THE_CONST=12 --env-set ANOTHER=4
450
+ //@ ignore-backends: gcc
451
+
452
+ #![crate_name = "foo"]
453
+ @@ -13,6 +12,6 @@ use env::generate_const;
454
+ generate_const!();
455
+
456
+ fn main() {
457
+ - assert_eq!(THE_CONST, 12);
458
+ - assert_eq!(ANOTHER, 1);
459
+ + assert_eq!(THE_CONST, 1);
460
+ + assert_eq!(ANOTHER, 2); // not found, see env::generate_const
461
+ }
patches/20261028T105419Z/rust-lang--rust-part009/5a41279a06746a114695e96e9d6e1d561e37516d.patch ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ diff --git a/compiler/rustc_session/src/filesearch.rs b/compiler/rustc_session/src/filesearch.rs
2
+ index 6ec1466500a86890d8e2480951a59a5ec7c1f027..10c62d932ba260a11e558ac8fd6db059fd239816 100644
3
+ --- a/compiler/rustc_session/src/filesearch.rs
4
+ +++ b/compiler/rustc_session/src/filesearch.rs
5
+ @@ -258,7 +258,7 @@ pub unsafe fn dll_path(function: *mut std::ffi::c_void) -> Result<PathBuf, Strin
6
+ }
7
+
8
+ #[cfg(target_os = "wasi")]
9
+ -pub unsafe fn dll_path(function: *mut std::ffi::c_void) -> Result<PathBuf, String> {
10
+ +pub unsafe fn dll_path(_function: *mut std::ffi::c_void) -> Result<PathBuf, String> {
11
+ Err("dll_path is not supported on WASI".to_string())
12
+ }
13
+
patches/20261028T105419Z/rust-lang--rust-part009/5c8d4746317b634a361daba38e24514f0bfc569d.patch ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md
2
+ new file mode 100644
3
+ index 0000000000000000000000000000000000000000..ed9dbb7395d9abb9fd5557b695809aa40fae2acf
4
+ --- /dev/null
5
+ +++ b/.github/pull_request_template.md
6
+ @@ -0,0 +1,11 @@
7
+ +- [ ] I did not use an LLM to create a change in this PR.
8
+ +- [ ] I used an LLM to create a change in this PR, and I have explained below how it was used.
9
+ +
10
+ +<!--
11
+ +Please read our [LLM policy] before opening a PR,
12
+ +and check one of the boxes above to indicate whether you've used an LLM.
13
+ +If you do not check a box, a reviewer may ask you whether an LLM was involved.
14
+ +LLM contributions are not banned, but are held to a higher standard of review and correctness.
15
+ +
16
+ +[LLM policy]: https://forge.rust-lang.org/policies/llm-usage.html
17
+ +-->
18
+ diff --git a/Contributing.md b/Contributing.md
19
+ index 7b298052ab2a0d9346a73b893eede4aad39058d4..99558079984b4a93787ddc76c59448b4d0f4fe53 100644
20
+ --- a/Contributing.md
21
+ +++ b/Contributing.md
22
+ @@ -9,6 +9,15 @@ or file new issues specifically to get help.
23
+ All contributors are expected to follow our [Code of
24
+ Conduct](CODE_OF_CONDUCT.md).
25
+
26
+ +
27
+ +## LLM policy
28
+ +
29
+ +rustfmt follows the same [LLM usage policy] as `rust-lang/rust`. Please read it before using LLM
30
+ +assistance when participating in `rust-lang/rustfmt`.
31
+ +
32
+ +[LLM usage policy]: https://forge.rust-lang.org/policies/llm-usage.html
33
+ +
34
+ +
35
+ ## Test and file issues
36
+
37
+ It would be really useful to have people use rustfmt on their projects and file
patches/20261028T105419Z/rust-lang--rust-part009/5e8508c0f02f55084f7d616a90b5d2fee42933bf.patch ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ diff --git a/src/bootstrap/download-ci-llvm-stamp b/src/bootstrap/download-ci-llvm-stamp
2
+ index 2ebc3066f1facf9c92ddebd24ecc3fe8efb1fd1c..f182cbd3b65fb55f0b3776f43102a70079ef4fa6 100644
3
+ --- a/src/bootstrap/download-ci-llvm-stamp
4
+ +++ b/src/bootstrap/download-ci-llvm-stamp
5
+ @@ -1,4 +1,4 @@
6
+ Change this file to make users of the `download-ci-llvm` configuration download
7
+ a new version of LLVM from CI, even if the LLVM submodule hasn’t changed.
8
+
9
+ -Last change is for: https://github.com/rust-lang/rust/pull/160100
10
+ +Last change is for: https://github.com/rust-lang/rust/pull/161603
11
+ diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs
12
+ index cc9e4f9834d54c767497eb7de11774a56c066877..6e2db69d13370c3f4da4688d328bc4373989e4bb 100644
13
+ --- a/src/bootstrap/src/core/build_steps/compile.rs
14
+ +++ b/src/bootstrap/src/core/build_steps/compile.rs
15
+ @@ -2199,10 +2199,17 @@ impl CommandLineStep for Assemble {
16
+ let tool_exe = exe(tool, target_compiler.host);
17
+ let src_path = llvm_bin_dir.join(&tool_exe);
18
+
19
+ - // When using `download-ci-llvm`, some of the tools may not exist, so skip trying to copy them.
20
+ - if !src_path.exists() && builder.config.llvm_ci_mode.download_from_ci() {
21
+ - eprintln!("{} does not exist; skipping copy", src_path.display());
22
+ - continue;
23
+ + if !src_path.exists() {
24
+ + // When using `download-ci-llvm`, some of the tools may not exist, so skip trying to copy them.
25
+ + if builder.config.llvm_ci_mode.download_from_ci() {
26
+ + eprintln!("{} does not exist; skipping copy", src_path.display());
27
+ + continue;
28
+ + }
29
+ + // On older LLVM versions, llubi isn't in the default tools. Remove this
30
+ + // code when LLVM 23 is the minimum version.
31
+ + if *tool == "llubi" {
32
+ + continue;
33
+ + }
34
+ }
35
+
36
+ // There is a chance that these tools are being installed from an external LLVM.
37
+ diff --git a/src/bootstrap/src/core/build_steps/dist.rs b/src/bootstrap/src/core/build_steps/dist.rs
38
+ index a266fba781e1a0dfcb275eee89ce5a93a74e098e..871c2ac3b43e98446700b5f4f8c1cdf594cfb510 100644
39
+ --- a/src/bootstrap/src/core/build_steps/dist.rs
40
+ +++ b/src/bootstrap/src/core/build_steps/dist.rs
41
+ @@ -60,9 +60,10 @@ pub(crate) const LLVM_TOOLS: &[&str] = &[
42
+ "llvm-ar", // used for creating and modifying archive files
43
+ "llvm-as", // used to convert LLVM assembly to LLVM bitcode
44
+ "llvm-dis", // used to disassemble LLVM bitcode
45
+ - "llvm-link", // Used to link LLVM bitcode
46
+ - "llc", // used to compile LLVM bytecode
47
+ - "opt", // used to optimize LLVM bytecode
48
+ + "llvm-link", // used to link LLVM bitcode
49
+ + "llc", // used to compile LLVM IR
50
+ + "opt", // used to optimize LLVM IR
51
+ + "llubi", // used to execute LLVM while checking for Undefined Behavior
52
+ ];
53
+
54
+ /// LLD file names for all flavors.
patches/20261028T105419Z/rust-lang--rust-part009/5f96a1cac7a6c204f76559bbba7ffedc1a696b80.patch ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ diff --git a/compiler/rustc_ast/src/tokenstream.rs b/compiler/rustc_ast/src/tokenstream.rs
2
+ index e860ef61a53324adfa3b2be60c8545ab1190bbe2..df71aad0111cd5c9651ab7ae45016fd1aa4208b1 100644
3
+ --- a/compiler/rustc_ast/src/tokenstream.rs
4
+ +++ b/compiler/rustc_ast/src/tokenstream.rs
5
+ @@ -7,7 +7,7 @@
6
+ use std::borrow::Cow;
7
+ use std::hash::Hash;
8
+ use std::ops::Range;
9
+ -use std::sync::Arc;
10
+ +use std::sync::{Arc, LazyLock};
11
+ use std::{cmp, fmt, iter, mem};
12
+
13
+ use rustc_data_structures::stable_hash::{StableHash, StableHashCtxt, StableHasher};
14
+ @@ -419,6 +419,11 @@ fn make_attr_token_stream(
15
+ AttrTokenStream::new(stack_top.inner)
16
+ }
17
+
18
+ +/// A shared empty attr token stream, used to avoid an unnecessary `Arc` allocation for every empty
19
+ +/// token stream.
20
+ +static EMPTY_ATTR_TOKEN_STREAM: LazyLock<AttrTokenStream> =
21
+ + LazyLock::new(|| AttrTokenStream(Arc::new(Vec::new())));
22
+ +
23
+ /// Like `TokenTree`, but for `AttrTokenStream`.
24
+ #[derive(Clone, Debug, Encodable, Decodable)]
25
+ pub enum AttrTokenTree {
26
+ @@ -431,8 +436,12 @@ pub enum AttrTokenTree {
27
+ }
28
+
29
+ impl AttrTokenStream {
30
+ - pub fn new(tokens: Vec<AttrTokenTree>) -> AttrTokenStream {
31
+ - AttrTokenStream(Arc::new(tokens))
32
+ + pub fn new(tts: Vec<AttrTokenTree>) -> AttrTokenStream {
33
+ + if tts.is_empty() {
34
+ + EMPTY_ATTR_TOKEN_STREAM.clone()
35
+ + } else {
36
+ + AttrTokenStream(Arc::new(tts))
37
+ + }
38
+ }
39
+
40
+ /// Converts this `AttrTokenStream` to a plain `Vec<TokenTree>`. During
41
+ @@ -620,13 +629,18 @@ pub enum Spacing {
42
+ JointHidden,
43
+ }
44
+
45
+ +/// A shared empty token stream, used to avoid an unnecessary `Arc` allocation for every empty
46
+ +/// token stream.
47
+ +static EMPTY_TOKEN_STREAM: LazyLock<TokenStream> =
48
+ + LazyLock::new(|| TokenStream(Arc::new(Vec::new())));
49
+ +
50
+ /// A `TokenStream` is an abstract sequence of tokens, organized into [`TokenTree`]s.
51
+ -#[derive(Clone, Debug, Default, PartialEq, Eq, Hash, Encodable, Decodable)]
52
+ +#[derive(Clone, Debug, PartialEq, Eq, Hash, Encodable, Decodable)]
53
+ pub struct TokenStream(Arc<Vec<TokenTree>>);
54
+
55
+ impl TokenStream {
56
+ pub fn new(tts: Vec<TokenTree>) -> TokenStream {
57
+ - TokenStream(Arc::new(tts))
58
+ + if tts.is_empty() { TokenStream::default() } else { TokenStream(Arc::new(tts)) }
59
+ }
60
+
61
+ pub fn is_empty(&self) -> bool {
62
+ @@ -840,6 +854,12 @@ impl TokenStream {
63
+ }
64
+ }
65
+
66
+ +impl Default for TokenStream {
67
+ + fn default() -> TokenStream {
68
+ + EMPTY_TOKEN_STREAM.clone()
69
+ + }
70
+ +}
71
+ +
72
+ impl FromIterator<TokenTree> for TokenStream {
73
+ fn from_iter<I: IntoIterator<Item = TokenTree>>(iter: I) -> Self {
74
+ TokenStream::new(iter.into_iter().collect::<Vec<TokenTree>>())
patches/20261028T105419Z/rust-lang--rust-part009/60be5628af1f9202097d63613e9c68f1f5990378.patch ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ diff --git a/compiler/rustc_attr_parsing/src/attributes/cfg.rs b/compiler/rustc_attr_parsing/src/attributes/cfg.rs
2
+ index d7f2243faaab9894eb115c649e05f0fb24534189..e9ace7088d8f012039c91169f3b306f9a1f68395 100644
3
+ --- a/compiler/rustc_attr_parsing/src/attributes/cfg.rs
4
+ +++ b/compiler/rustc_attr_parsing/src/attributes/cfg.rs
5
+ @@ -436,7 +436,7 @@ fn parse_cfg_attr_internal<'a>(
6
+ }
7
+
8
+ fn try_gate_cfg(name: Symbol, span: Span, sess: &Session, features: Option<&Features>) {
9
+ - let gate = find_gated_cfg(|sym| sym == name);
10
+ + let gate = find_gated_cfg(name);
11
+ if let (Some(feats), Some(gated_cfg)) = (features, gate) {
12
+ gate_cfg(gated_cfg, span, sess, feats);
13
+ }
14
+ diff --git a/compiler/rustc_driver_impl/src/lib.rs b/compiler/rustc_driver_impl/src/lib.rs
15
+ index 54a1babbaae72c591ebd57bf6a189bef0ad692f1..b2a2d3dbd60dddb4d434385f107e041508eda0d1 100644
16
+ --- a/compiler/rustc_driver_impl/src/lib.rs
17
+ +++ b/compiler/rustc_driver_impl/src/lib.rs
18
+ @@ -741,9 +741,7 @@ fn print_crate_info(
19
+ .iter()
20
+ .filter_map(|&(name, value)| {
21
+ // On stable, exclude unstable flags.
22
+ - if !sess.is_nightly_build()
23
+ - && find_gated_cfg(|cfg_sym| cfg_sym == name).is_some()
24
+ - {
25
+ + if !sess.is_nightly_build() && find_gated_cfg(name).is_some() {
26
+ return None;
27
+ }
28
+
29
+ diff --git a/compiler/rustc_feature/src/builtin_attrs.rs b/compiler/rustc_feature/src/builtin_attrs.rs
30
+ index 89d87937cea5d6b1d12c8f856d7ed96a6d2fdd40..7e491a7569d11debfae36640d4b796fc47d51906 100644
31
+ --- a/compiler/rustc_feature/src/builtin_attrs.rs
32
+ +++ b/compiler/rustc_feature/src/builtin_attrs.rs
33
+ @@ -54,9 +54,9 @@ const GATED_CFGS: &[GatedCfg] = &[
34
+ (sym::target_object_format, sym::cfg_target_object_format, Features::cfg_target_object_format),
35
+ ];
36
+
37
+ -/// Find a gated cfg determined by the `pred`icate which is given the cfg's name.
38
+ -pub fn find_gated_cfg(pred: impl Fn(Symbol) -> bool) -> Option<&'static GatedCfg> {
39
+ - GATED_CFGS.iter().find(|(cfg_sym, ..)| pred(*cfg_sym))
40
+ +/// Find a gated cfg matching `name`.
41
+ +pub fn find_gated_cfg(name: Symbol) -> Option<&'static GatedCfg> {
42
+ + GATED_CFGS.iter().find(|(cfg_sym, ..)| name == *cfg_sym)
43
+ }
44
+
45
+ #[derive(Clone, Debug, Copy)]
patches/20261028T105419Z/rust-lang--rust-part009/6146d3aacc810466c9f367d7da467067a465a1ed.patch ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ diff --git a/compiler/rustc_feature/src/removed.rs b/compiler/rustc_feature/src/removed.rs
2
+ index 0253f16666628ab9d305a33e29fc344f2dce1af5..bcdffe75259a9af357654f9448326ef1d060c56e 100644
3
+ --- a/compiler/rustc_feature/src/removed.rs
4
+ +++ b/compiler/rustc_feature/src/removed.rs
5
+ @@ -1,6 +1,6 @@
6
+ //! List of the removed feature gates.
7
+
8
+ -use std::num::{NonZero, NonZeroU32};
9
+ +use std::num::NonZero;
10
+
11
+ use rustc_span::sym;
12
+
13
+ @@ -17,7 +17,7 @@ macro_rules! opt_nonzero_u32 {
14
+ None
15
+ };
16
+ ($val:expr) => {
17
+ - Some(NonZeroU32::new($val).unwrap())
18
+ + Some(<NonZero<u32>>::new($val).unwrap())
19
+ };
20
+ }
21
+
22
+ @@ -34,7 +34,7 @@ macro_rules! declare_features {
23
+ issue: to_nonzero($issue),
24
+ },
25
+ reason: $reason,
26
+ - pull: opt_nonzero_u32!($($pull)?),
27
+ + pull: opt_nonzero_u32!($($pull)?),
28
+ }),+
29
+ ];
30
+ };
patches/20261028T105419Z/rust-lang--rust-part009/614d9ea42ce84b46371e653f882496877ce277b4.patch ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ diff --git a/tests/rustdoc-ui/lints/renamed-lint-still-applies.stderr b/tests/rustdoc-ui/lints/renamed-lint-still-applies.stderr
2
+ index 88807dfb495d01071b5c6c7057d971d114122dfc..f4428ff6e5983819ef5196f85b44d7a3a80fa7ce 100644
3
+ --- a/tests/rustdoc-ui/lints/renamed-lint-still-applies.stderr
4
+ +++ b/tests/rustdoc-ui/lints/renamed-lint-still-applies.stderr
5
+ @@ -1,5 +1,5 @@
6
+ warning: lint `broken_intra_doc_links` has been renamed to `rustdoc::broken_intra_doc_links`
7
+ - --> $DIR/renamed-lint-still-applies.rs:2:9
8
+ + --> $DIR/renamed-lint-still-applies.rs:3:9
9
+ |
10
+ LL | #![deny(broken_intra_doc_links)]
11
+ | ^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `rustdoc::broken_intra_doc_links`
12
+ @@ -7,33 +7,33 @@ LL | #![deny(broken_intra_doc_links)]
13
+ = note: `#[warn(renamed_and_removed_lints)]` on by default
14
+
15
+ warning: lint `rustdoc::non_autolinks` has been renamed to `rustdoc::bare_urls`
16
+ - --> $DIR/renamed-lint-still-applies.rs:7:9
17
+ + --> $DIR/renamed-lint-still-applies.rs:8:9
18
+ |
19
+ LL | #![deny(rustdoc::non_autolinks)]
20
+ | ^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `rustdoc::bare_urls`
21
+
22
+ error: unresolved link to `x`
23
+ - --> $DIR/renamed-lint-still-applies.rs:4:6
24
+ + --> $DIR/renamed-lint-still-applies.rs:5:6
25
+ |
26
+ LL | //! [x]
27
+ | ^ no item named `x` in scope
28
+ |
29
+ = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
30
+ note: the lint level is defined here
31
+ - --> $DIR/renamed-lint-still-applies.rs:2:9
32
+ + --> $DIR/renamed-lint-still-applies.rs:3:9
33
+ |
34
+ LL | #![deny(broken_intra_doc_links)]
35
+ | ^^^^^^^^^^^^^^^^^^^^^^
36
+
37
+ error: this URL is not a hyperlink
38
+ - --> $DIR/renamed-lint-still-applies.rs:9:5
39
+ + --> $DIR/renamed-lint-still-applies.rs:10:5
40
+ |
41
+ LL | //! http://example.com
42
+ | ^^^^^^^^^^^^^^^^^^
43
+ |
44
+ = note: bare URLs are not automatically turned into clickable links
45
+ note: the lint level is defined here
46
+ - --> $DIR/renamed-lint-still-applies.rs:7:9
47
+ + --> $DIR/renamed-lint-still-applies.rs:8:9
48
+ |
49
+ LL | #![deny(rustdoc::non_autolinks)]
50
+ | ^^^^^^^^^^^^^^^^^^^^^^
51
+ diff --git a/tests/ui/lint/forbid-error-capped.rs b/tests/ui/lint/forbid-error-capped.rs
52
+ index e458ddf90746ee0e6e31773d75a4708beea3d3fd..bfa72beac5828a1a2bbbbaf007e0c8935a05ff9a 100644
53
+ --- a/tests/ui/lint/forbid-error-capped.rs
54
+ +++ b/tests/ui/lint/forbid-error-capped.rs
55
+ @@ -1,5 +1,4 @@
56
+ //@ check-pass
57
+ -// compile-args: --cap-lints=warn -Fwarnings
58
+
59
+ // This checks that the forbid attribute checking is ignored when the forbidden
60
+ // lint is capped.
61
+ diff --git a/tests/ui/lint/forbid-error-capped.stderr b/tests/ui/lint/forbid-error-capped.stderr
62
+ index 479e7b9412d5757b3bae01a9917df51befe14dc6..3de8c2fe0ce6161091e171ff8cb1d5cbfe98f3b8 100644
63
+ --- a/tests/ui/lint/forbid-error-capped.stderr
64
+ +++ b/tests/ui/lint/forbid-error-capped.stderr
65
+ @@ -1,5 +1,5 @@
66
+ warning: allow(unused) incompatible with previous forbid
67
+ - --> $DIR/forbid-error-capped.rs:8:10
68
+ + --> $DIR/forbid-error-capped.rs:7:10
69
+ |
70
+ LL | #![forbid(warnings)]
71
+ | -------- `forbid` level set here
72
+ @@ -14,7 +14,7 @@ warning: 1 warning emitted
73
+
74
+ Future incompatibility report: Future breakage diagnostic:
75
+ warning: allow(unused) incompatible with previous forbid
76
+ - --> $DIR/forbid-error-capped.rs:8:10
77
+ + --> $DIR/forbid-error-capped.rs:7:10
78
+ |
79
+ LL | #![forbid(warnings)]
80
+ | -------- `forbid` level set here
81
+ diff --git a/tests/ui/mir/issue-71793-inline-args-storage.rs b/tests/ui/mir/issue-71793-inline-args-storage.rs
82
+ index 0ed4d4723731ef51075456afc2e436669c9dc957..38ce28a035346555bf917d82ad2e839d4cfd5c24 100644
83
+ --- a/tests/ui/mir/issue-71793-inline-args-storage.rs
84
+ +++ b/tests/ui/mir/issue-71793-inline-args-storage.rs
85
+ @@ -1,10 +1,10 @@
86
+ // Verifies that inliner emits StorageLive & StorageDead when introducing
87
+ // temporaries for arguments, so that they don't become part of the coroutine.
88
+ // Regression test for #71793.
89
+ -//
90
+ +
91
+ //@ check-pass
92
+ //@ edition:2018
93
+ -// compile-args: -Zmir-opt-level=3
94
+ +//@ compile-flags: -Zmir-opt-level=3
95
+
96
+ #![crate_type = "lib"]
97
+
patches/20261028T105419Z/rust-lang--rust-part009/61dec2208f5d0a6ea9aa22f19c2f1c14584c8daf.patch ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ diff --git a/library/compiler-builtins/compiler-builtins/src/lib.rs b/library/compiler-builtins/compiler-builtins/src/lib.rs
2
+ index 0d25495abf8aae3c67c138e11b9bd9dafbfe3e3a..5dfc6733befecc109117ca20fdf04afa7fdd81a1 100644
3
+ --- a/library/compiler-builtins/compiler-builtins/src/lib.rs
4
+ +++ b/library/compiler-builtins/compiler-builtins/src/lib.rs
5
+ @@ -3,7 +3,6 @@
6
+ #![no_std]
7
+ //
8
+ #![feature(abi_custom)]
9
+ -#![feature(abi_unadjusted)]
10
+ #![feature(asm_experimental_arch)]
11
+ #![feature(cfg_target_has_atomic)]
12
+ #![feature(compiler_builtins)]
patches/20261028T105419Z/rust-lang--rust-part009/61f12cc266bc3581360d66cd55d7f27bf3479fec.patch ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ diff --git a/src/tools/rust-analyzer/crates/proc-macro-srv/src/dylib.rs b/src/tools/rust-analyzer/crates/proc-macro-srv/src/dylib.rs
2
+ index 8e9335df19b7736d038ab4c7042da1a47f514cc1..718eb47228eb8ee36820502234c05632685f26b6 100644
3
+ --- a/src/tools/rust-analyzer/crates/proc-macro-srv/src/dylib.rs
4
+ +++ b/src/tools/rust-analyzer/crates/proc-macro-srv/src/dylib.rs
5
+ @@ -102,11 +102,8 @@ fn ensure_file_with_lock_free_access(path: Utf8PathBuf) -> NamedTempFile {
6
+ &format!("proc-macro-srv-{file_name}.dll"),
7
+ path.as_std_path(),
8
+ )
9
+ - })
10
+ - .unwrap_or_else(|err| {
11
+ - tracing::warn!("failed to create temporary file: {err}");
12
+ - NamedTempFile::from_path(path.into_std_path_buf())
13
+ - })
14
+ + })()
15
+ + .unwrap_or_else(|_err| NamedTempFile::from_path(path.into_std_path_buf()))
16
+ }
17
+
18
+ #[cfg(unix)]
patches/20261028T105419Z/rust-lang--rust-part009/6508e60c9139ac2ccf98f812709f324ec5c4f521.patch ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ diff --git a/library/std/src/sys/thread/unix.rs b/library/std/src/sys/thread/unix.rs
2
+ index 1d87e2095f134bbc7fc141658ddcb195099d7344..b7908dea2b5deda94bca109deb29d0c2d1f1ff2a 100644
3
+ --- a/library/std/src/sys/thread/unix.rs
4
+ +++ b/library/std/src/sys/thread/unix.rs
5
+ @@ -67,7 +67,7 @@ impl Thread {
6
+ assert_eq!(
7
+ libc::pthread_attr_setstacksize(
8
+ attr.get(),
9
+ - cmp::max(stack, min_stack_size(attr.as_ptr()))
10
+ + cmp::max(stack, min_stack_size(attr.get()))
11
+ ),
12
+ 0
13
+ );
patches/20261028T105419Z/rust-lang--rust-part009/6b1b19c41d3d184814233bcda6bf863440408331.patch ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ diff --git a/src/tools/rust-analyzer/.github/workflows/ci.yaml b/src/tools/rust-analyzer/.github/workflows/ci.yaml
2
+ index 14582f8405f55236d750ad73a6b57ee0bd80815e..7ea734e7ef1c0e618c03c54ac317a7e3524fa1b5 100644
3
+ --- a/src/tools/rust-analyzer/.github/workflows/ci.yaml
4
+ +++ b/src/tools/rust-analyzer/.github/workflows/ci.yaml
5
+ @@ -41,7 +41,11 @@ jobs:
6
+ proc-macro-srv:
7
+ if: github.repository == 'rust-lang/rust-analyzer'
8
+ name: proc-macro-srv
9
+ - runs-on: ubuntu-latest
10
+ + runs-on: ${{ matrix.os }}
11
+ +
12
+ + strategy:
13
+ + matrix:
14
+ + os: [ubuntu-latest, windows-latest]
15
+
16
+ steps:
17
+ - name: Checkout repository
18
+ diff --git a/src/tools/rust-analyzer/crates/proc-macro-srv/src/dylib.rs b/src/tools/rust-analyzer/crates/proc-macro-srv/src/dylib.rs
19
+ index 8e9335df19b7736d038ab4c7042da1a47f514cc1..718eb47228eb8ee36820502234c05632685f26b6 100644
20
+ --- a/src/tools/rust-analyzer/crates/proc-macro-srv/src/dylib.rs
21
+ +++ b/src/tools/rust-analyzer/crates/proc-macro-srv/src/dylib.rs
22
+ @@ -102,11 +102,8 @@ fn ensure_file_with_lock_free_access(path: Utf8PathBuf) -> NamedTempFile {
23
+ &format!("proc-macro-srv-{file_name}.dll"),
24
+ path.as_std_path(),
25
+ )
26
+ - })
27
+ - .unwrap_or_else(|err| {
28
+ - tracing::warn!("failed to create temporary file: {err}");
29
+ - NamedTempFile::from_path(path.into_std_path_buf())
30
+ - })
31
+ + })()
32
+ + .unwrap_or_else(|_err| NamedTempFile::from_path(path.into_std_path_buf()))
33
+ }
34
+
35
+ #[cfg(unix)]
patches/20261028T105419Z/rust-lang--rust-part009/6c317cc6df2f2d90baaaa8fdf6f6b542b0f7d620.patch ADDED
@@ -0,0 +1,291 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs
2
+ index 6e2db69d13370c3f4da4688d328bc4373989e4bb..8489c56d98cca5f11b05735e834c5dedc43d2133 100644
3
+ --- a/src/bootstrap/src/core/build_steps/compile.rs
4
+ +++ b/src/bootstrap/src/core/build_steps/compile.rs
5
+ @@ -21,7 +21,7 @@ use tracing::span;
6
+
7
+ use crate::core::backend::CodegenBackendKind;
8
+ use crate::core::build_steps::gcc::{Gcc, GccOutput, GccTargetPair};
9
+ -use crate::core::build_steps::llvm::{LlvmFromCi, prebuilt_llvm_output};
10
+ +use crate::core::build_steps::llvm::{LlvmFromCi, LlvmKind, prebuilt_llvm_output};
11
+ use crate::core::build_steps::tool::{RustcPrivateCompilers, SourceType, copy_lld_artifacts};
12
+ use crate::core::build_steps::{dist, llvm};
13
+ use crate::core::builder::{
14
+ @@ -2201,7 +2201,7 @@ impl CommandLineStep for Assemble {
15
+
16
+ if !src_path.exists() {
17
+ // When using `download-ci-llvm`, some of the tools may not exist, so skip trying to copy them.
18
+ - if builder.config.llvm_ci_mode.download_from_ci() {
19
+ + if llvm_output.kind() == LlvmKind::DownloadedFromCi {
20
+ eprintln!("{} does not exist; skipping copy", src_path.display());
21
+ continue;
22
+ }
23
+ diff --git a/src/bootstrap/src/core/build_steps/dist.rs b/src/bootstrap/src/core/build_steps/dist.rs
24
+ index 871c2ac3b43e98446700b5f4f8c1cdf594cfb510..a335172631307705e44e55beb67a5157c09f7f32 100644
25
+ --- a/src/bootstrap/src/core/build_steps/dist.rs
26
+ +++ b/src/bootstrap/src/core/build_steps/dist.rs
27
+ @@ -26,7 +26,7 @@ use crate::core::build_steps::compile::{
28
+ use crate::core::build_steps::doc::DocumentationFormat;
29
+ use crate::core::build_steps::gcc::GccTargetPair;
30
+ use crate::core::build_steps::llvm::{
31
+ - LLVM_CI_LINK_TYPE_PATH, LlvmBuildStatus, get_llvm_build_status,
32
+ + LLVM_CI_LINK_TYPE_PATH, LlvmBuildStatus, LlvmKind, get_llvm_build_status,
33
+ };
34
+ use crate::core::build_steps::tool::{
35
+ self, RustcPrivateCompilers, ToolTargetBuildMode, get_tool_target_compiler,
36
+ @@ -2526,12 +2526,7 @@ fn maybe_install_llvm(
37
+ // If the LLVM is coming from ourselves (just from CI) though, we
38
+ // still want to install it, as it otherwise won't be available.
39
+
40
+ - // FIXME: this should be simplified once we stop pre-setting LLVM CI llvm-config during
41
+ - // config parsing.
42
+ - let is_system_llvm =
43
+ - builder.config.target_config.get(&target).and_then(|t| t.llvm_config.as_ref()).is_some()
44
+ - && !(builder.config.llvm_ci_mode.download_from_ci()
45
+ - && builder.config.is_host_target(target));
46
+ + let is_system_llvm = llvm.llvm_output().kind() == LlvmKind::External;
47
+ if is_system_llvm {
48
+ trace!("system LLVM requested, no install");
49
+ return false;
50
+ @@ -2713,11 +2708,10 @@ impl CommandLineStep for LlvmTools {
51
+
52
+ let target = self.target;
53
+
54
+ + let llvm_output = builder.ensure(crate::core::build_steps::llvm::Llvm { target });
55
+ +
56
+ // Run only if a custom llvm-config is not used
57
+ - if let Some(config) = builder.config.target_config.get(&target)
58
+ - && !builder.config.llvm_ci_mode.download_from_ci()
59
+ - && config.llvm_config.is_some()
60
+ - {
61
+ + if llvm_output.kind() == LlvmKind::External {
62
+ builder.info(&format!("Skipping LlvmTools ({target}): external LLVM"));
63
+ return None;
64
+ }
65
+ @@ -2726,8 +2720,6 @@ impl CommandLineStep for LlvmTools {
66
+ builder.require_submodule("src/llvm-project", None);
67
+ }
68
+
69
+ - let llvm_output = builder.ensure(crate::core::build_steps::llvm::Llvm { target });
70
+ -
71
+ let mut tarball = Tarball::new(builder, "llvm-tools", &target.triple);
72
+ tarball.set_overlay(OverlayKind::Llvm);
73
+ tarball.is_preview(true);
74
+ @@ -2739,7 +2731,7 @@ impl CommandLineStep for LlvmTools {
75
+ for tool in tools_to_install(&builder.paths) {
76
+ let exe = src_bindir.join(exe(tool, target));
77
+ // When using `download-ci-llvm`, some of the tools may not exist, so skip trying to copy them.
78
+ - if !exe.exists() && builder.config.llvm_ci_mode.download_from_ci() {
79
+ + if !exe.exists() && llvm_output.kind() == LlvmKind::DownloadedFromCi {
80
+ eprintln!("{} does not exist; skipping copy", exe.display());
81
+ continue;
82
+ }
83
+ diff --git a/src/bootstrap/src/core/build_steps/llvm.rs b/src/bootstrap/src/core/build_steps/llvm.rs
84
+ index 81e0726f414cc6112ad6692c33e56c78132d35fe..1077ed41067afb7d98a9b1089374862cdada0083 100644
85
+ --- a/src/bootstrap/src/core/build_steps/llvm.rs
86
+ +++ b/src/bootstrap/src/core/build_steps/llvm.rs
87
+ @@ -32,7 +32,7 @@ use crate::utils::helpers::{
88
+ /// Path where a file containing the link type (dynamic or static) is stored in the LLVM CI tarball.
89
+ pub const LLVM_CI_LINK_TYPE_PATH: &str = "link-type.txt";
90
+
91
+ -#[derive(Copy, Clone)]
92
+ +#[derive(Copy, Clone, PartialEq, Eq)]
93
+ pub enum LlvmKind {
94
+ /// The LLVM was built from in-tree sources
95
+ BuiltLocally,
96
+ diff --git a/src/bootstrap/src/core/builder/mod.rs b/src/bootstrap/src/core/builder/mod.rs
97
+ index 966279c2938086c5866829319fb1a6419c7d4212..0bd07811336842b9604cf3a8d817a6fc3f0401cf 100644
98
+ --- a/src/bootstrap/src/core/builder/mod.rs
99
+ +++ b/src/bootstrap/src/core/builder/mod.rs
100
+ @@ -15,6 +15,7 @@ use tracing::instrument;
101
+
102
+ pub(crate) use self::cargo::{Cargo, apply_pgo, cargo_profile_var};
103
+ use crate::core::build_steps::compile::{Std, StdLink, looks_like_codegen_backend};
104
+ +use crate::core::build_steps::llvm::{LlvmKind, get_llvm_build_status};
105
+ use crate::core::build_steps::tool::RustcPrivateCompilers;
106
+ use crate::core::build_steps::{
107
+ check, clean, clippy, compile, dist, doc, gcc, install, llvm, run, setup, test, tool, vendor,
108
+ @@ -1399,7 +1400,10 @@ Alternatively, you can set `build.local-rebuild=true` and use a stage0 compiler
109
+ let mut dylib_dirs = vec![self.rustc_libdir(compiler)];
110
+
111
+ // Ensure that the downloaded LLVM libraries can be found.
112
+ - if self.config.llvm_ci_mode.download_from_ci() {
113
+ + // FIXME: the libraries should be added elsewhere, not in this function...
114
+ + if get_llvm_build_status(self, compiler.host).llvm_output().kind()
115
+ + == LlvmKind::DownloadedFromCi
116
+ + {
117
+ let ci_llvm_lib = self.out.join(compiler.host).join("ci-llvm").join("lib");
118
+ dylib_dirs.push(ci_llvm_lib);
119
+ }
120
+ diff --git a/src/bootstrap/src/core/builder/tests.rs b/src/bootstrap/src/core/builder/tests.rs
121
+ index 1f08ee9c118649a5111bd2cb929b9eb53ec73054..f5ab543e87d2b43866f62a151c3483cdbb4699f0 100644
122
+ --- a/src/bootstrap/src/core/builder/tests.rs
123
+ +++ b/src/bootstrap/src/core/builder/tests.rs
124
+ @@ -5,6 +5,7 @@ use build_helper::stage0_parser::parse_stage0_file;
125
+ use llvm::get_llvm_build_status;
126
+
127
+ use super::*;
128
+ +use crate::core::build_steps::llvm::LlvmKind;
129
+ use crate::core::config::Config;
130
+ use crate::utils::cache::ExecutedStep;
131
+ use crate::utils::helpers::get_host_target;
132
+ @@ -293,15 +294,14 @@ fn test_prebuilt_llvm_config_path_resolution() {
133
+ "#,
134
+ );
135
+
136
+ - // CI-LLVM isn't always available; check if it's enabled before testing.
137
+ - if config.llvm_ci_mode.download_from_ci() {
138
+ - let sess = Session::new(config.clone());
139
+ - let builder = Builder::new(&sess);
140
+ + let sess = Session::new(config.clone());
141
+ + let builder = Builder::new(&sess);
142
+
143
+ - let actual = get_llvm_build_status(&builder, builder.config.host_target)
144
+ - .llvm_output()
145
+ - .llvm_config()
146
+ - .to_path_buf();
147
+ + let llvm = get_llvm_build_status(&builder, builder.config.host_target);
148
+ + let llvm = llvm.llvm_output();
149
+ + // CI-LLVM isn't always available; check if it's enabled before testing.
150
+ + if llvm.kind() == LlvmKind::DownloadedFromCi {
151
+ + let actual = llvm.llvm_config().to_path_buf();
152
+ let expected = builder
153
+ .out
154
+ .join(builder.config.host_target)
155
+ diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs
156
+ index 6fbf632472b2bc916a5f5670ef6157a577a56c7c..789e249e151f50ab265a5747e6922d022b4a8c86 100644
157
+ --- a/src/bootstrap/src/core/config/config.rs
158
+ +++ b/src/bootstrap/src/core/config/config.rs
159
+ @@ -1736,18 +1736,18 @@ NOTE: Please add `--stage 2` to your command line, or if you're sure you want to
160
+ Some(commit) => {
161
+ self.download_ci_rustc(commit);
162
+
163
+ - // CI-rustc can't be used without CI-LLVM. If `self.llvm_from_ci` is false, it means the "if-unchanged"
164
+ - // logic has detected some changes in the LLVM submodule (download-ci-llvm=false can't happen here as
165
+ - // we don't allow it while parsing the configuration).
166
+ - if !self.llvm_ci_mode.download_from_ci() {
167
+ - // This happens when LLVM submodule is updated in CI, we should disable ci-rustc without an error
168
+ - // to not break CI. For non-CI environments, we should return an error.
169
+ - if self.is_running_on_ci() {
170
+ - println!("WARNING: LLVM submodule has changes, `download-rustc` will be disabled.");
171
+ - return None;
172
+ - } else {
173
+ - panic!("ERROR: LLVM submodule has changes, `download-rustc` can't be used.");
174
+ - }
175
+ + let llvm_ci_requested = match self.llvm_ci_mode {
176
+ + LlvmCiMode::BuildLocally => false,
177
+ + LlvmCiMode::DownloadFromCi => true
178
+ + };
179
+ + // CI-rustc can't be used without CI-LLVM. If LLVM Ci is requested, but the
180
+ + // LLVM submodule has changes, it is an error.
181
+ + // FIXME: this whole logic should be refactored to not use
182
+ + // `has_changes_from_upstream` explicitly
183
+ + if llvm_ci_requested && self.has_changes_from_upstream(LLVM_INVALIDATION_PATHS) {
184
+ + // download-ci-rustc should not be used on CI at the moment
185
+ + assert!(self.is_running_on_ci());
186
+ + panic!("ERROR: LLVM submodule has changes, `download-rustc` can't be used.");
187
+ }
188
+
189
+ if let Some(config_path) = &self.config {
190
+ diff --git a/src/bootstrap/src/core/config/mod.rs b/src/bootstrap/src/core/config/mod.rs
191
+ index d8ce0161da23ebdd005e31dcd060e261f478296d..a13eace17cbaf9d70d0f7848bffdc4056c65d5db 100644
192
+ --- a/src/bootstrap/src/core/config/mod.rs
193
+ +++ b/src/bootstrap/src/core/config/mod.rs
194
+ @@ -380,7 +380,9 @@ pub enum LlvmCiMode {
195
+ }
196
+
197
+ impl LlvmCiMode {
198
+ - pub fn download_from_ci(&self) -> bool {
199
+ + /// Return true if the user has requested LLVM to be downloaded from CI.
200
+ + /// **Note:** this does not mean that it will be actually downloaded.
201
+ + pub fn requests_download_from_ci(&self) -> bool {
202
+ match self {
203
+ LlvmCiMode::BuildLocally => false,
204
+ LlvmCiMode::DownloadFromCi => true,
205
+ diff --git a/src/bootstrap/src/core/config/tests.rs b/src/bootstrap/src/core/config/tests.rs
206
+ index 7afaa6997514be41129a2e6af19cca881ead0811..4344ec413c979deac9252eb908b4785da78fac61 100644
207
+ --- a/src/bootstrap/src/core/config/tests.rs
208
+ +++ b/src/bootstrap/src/core/config/tests.rs
209
+ @@ -11,9 +11,11 @@ use clap::CommandFactory;
210
+ use super::flags::Flags;
211
+ use super::toml::change_id::ChangeIdWrapper;
212
+ use super::toml::rust::parse_codegen_backends;
213
+ -use super::{Config, DebuggerPath, RUSTC_IF_UNCHANGED_ALLOWED_PATHS};
214
+ +use super::{Config, DebuggerPath, LlvmCiMode, RUSTC_IF_UNCHANGED_ALLOWED_PATHS};
215
+ +use crate::Build;
216
+ use crate::core::build_steps::clippy::{LintConfig, get_clippy_rules_in_order};
217
+ -use crate::core::build_steps::llvm::LLVM_INVALIDATION_PATHS;
218
+ +use crate::core::build_steps::llvm::{LLVM_INVALIDATION_PATHS, LlvmKind, get_llvm_build_status};
219
+ +use crate::core::builder::Builder;
220
+ use crate::core::config::flags::Subcommand;
221
+ use crate::core::config::{
222
+ BootstrapOverrideLld, ChangeId, CompilerBuiltins, Target, TargetSelection,
223
+ @@ -35,21 +37,28 @@ fn modified(upstream: impl Into<String>, changes: &[&str]) -> PathFreshness {
224
+ #[test]
225
+ fn download_ci_llvm() {
226
+ let config = TestCtx::new().config("check").create_config();
227
+ - assert!(!config.llvm_ci_mode.download_from_ci());
228
+ + assert_eq!(config.llvm_ci_mode, LlvmCiMode::BuildLocally);
229
+
230
+ // this doesn't make sense, as we are overriding it later.
231
+ let if_unchanged_config = TestCtx::new()
232
+ .config("check")
233
+ .with_default_toml_config("llvm.download-ci-llvm = \"if-unchanged\"")
234
+ .create_config();
235
+ - if if_unchanged_config.llvm_ci_mode.download_from_ci() && if_unchanged_config.is_running_on_ci()
236
+ - {
237
+ - let has_changes = if_unchanged_config.has_changes_from_upstream(LLVM_INVALIDATION_PATHS);
238
+ -
239
+ - assert!(
240
+ - !has_changes,
241
+ - "CI LLVM can't be enabled with 'if-unchanged' while there are changes in LLVM submodule."
242
+ - );
243
+ + if if_unchanged_config.is_running_on_ci() {
244
+ + let build = Build::new(config.clone());
245
+ + let builder = Builder::new(&build);
246
+ +
247
+ + let llvm = get_llvm_build_status(&builder, builder.config.host_target);
248
+ + let llvm = llvm.llvm_output();
249
+ + if llvm.kind() == LlvmKind::DownloadedFromCi {
250
+ + let has_changes =
251
+ + if_unchanged_config.has_changes_from_upstream(LLVM_INVALIDATION_PATHS);
252
+ +
253
+ + assert!(
254
+ + !has_changes,
255
+ + "CI LLVM can't be enabled with 'if-unchanged' while there are changes in LLVM submodule."
256
+ + );
257
+ + }
258
+ }
259
+ }
260
+
261
+ @@ -163,7 +172,7 @@ fn override_toml() {
262
+ .collect(),
263
+ "setting dictionary value"
264
+ );
265
+ - assert!(!config.llvm_ci_mode.download_from_ci());
266
+ + assert!(matches!(config.llvm_ci_mode, LlvmCiMode::BuildLocally));
267
+ assert!(!config.download_rustc());
268
+ }
269
+
270
+ diff --git a/src/bootstrap/src/core/sanity.rs b/src/bootstrap/src/core/sanity.rs
271
+ index 5ce92f273695b9841bf67d1745bbd117e363b646..6983030fedd0a2435f61aa3720dea05017a4814c 100644
272
+ --- a/src/bootstrap/src/core/sanity.rs
273
+ +++ b/src/bootstrap/src/core/sanity.rs
274
+ @@ -110,7 +110,7 @@ pub(crate) fn check(sess: &mut Session) {
275
+ if cfg!(not(test))
276
+ && !sess.config.dry_run()
277
+ && !sess.host_target.is_msvc()
278
+ - && sess.config.llvm_ci_mode.download_from_ci()
279
+ + && sess.config.llvm_ci_mode.requests_download_from_ci()
280
+ {
281
+ let builder = Builder::new(sess);
282
+ let libcxx_version = builder.ensure(tool::LibcxxVersionTool { target: sess.host_target });
283
+ @@ -138,7 +138,7 @@ pub(crate) fn check(sess: &mut Session) {
284
+ }
285
+
286
+ // We need cmake, but only if we're actually building LLVM or sanitizers.
287
+ - let building_llvm = !sess.config.llvm_ci_mode.download_from_ci()
288
+ + let building_llvm = !sess.config.llvm_ci_mode.requests_download_from_ci()
289
+ && !sess.config.local_rebuild
290
+ && sess.hosts.iter().any(|host| {
291
+ sess.config.llvm_enabled(*host)
patches/20261028T105419Z/rust-lang--rust-part009/6d74441f2887f645b83dcd97f01471f2bfd49a72.patch ADDED
@@ -0,0 +1,172 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ diff --git a/compiler/rustc_trait_selection/src/traits/implied_outlives_bounds.rs b/compiler/rustc_trait_selection/src/traits/implied_outlives_bounds.rs
2
+ index 79f630860235a248a8a092b60fe697f3301c5648..c0df53db4ab3420d9f097ca3bd9d4dca4c678d0c 100644
3
+ --- a/compiler/rustc_trait_selection/src/traits/implied_outlives_bounds.rs
4
+ +++ b/compiler/rustc_trait_selection/src/traits/implied_outlives_bounds.rs
5
+ @@ -39,14 +39,6 @@ impl<'tcx> QueryTypeOp<'tcx> for ImpliedOutlivesBounds<'tcx> {
6
+ ) -> Result<CanonicalQueryResponse<'tcx, Self::QueryResponse>, NoSolution> {
7
+ tcx.implied_outlives_bounds((canonicalized, false))
8
+ }
9
+ -
10
+ - fn perform_locally_with_next_solver(
11
+ - ocx: &ObligationCtxt<'_, 'tcx>,
12
+ - key: ParamEnvAnd<'tcx, Self>,
13
+ - _span: Span,
14
+ - ) -> Result<Self::QueryResponse, NoSolution> {
15
+ - query_compute_implied_outlives_bounds(ocx, key.param_env, key.value.ty, false)
16
+ - }
17
+ }
18
+
19
+ pub fn compute_implied_outlives_bounds_inner<'tcx>(
20
+ diff --git a/compiler/rustc_trait_selection/src/traits/query/type_op/ascribe_user_type.rs b/compiler/rustc_trait_selection/src/traits/query/type_op/ascribe_user_type.rs
21
+ index e8814c56c50164e526492e1dcfdcbc24d04873e5..239cbc5aa76229e2477872e2c703a7c092afb0d8 100644
22
+ --- a/compiler/rustc_trait_selection/src/traits/query/type_op/ascribe_user_type.rs
23
+ +++ b/compiler/rustc_trait_selection/src/traits/query/type_op/ascribe_user_type.rs
24
+ @@ -29,14 +29,6 @@ impl<'tcx> super::QueryTypeOp<'tcx> for AscribeUserType<'tcx> {
25
+ ) -> Result<CanonicalQueryResponse<'tcx, ()>, NoSolution> {
26
+ tcx.type_op_ascribe_user_type(canonicalized)
27
+ }
28
+ -
29
+ - fn perform_locally_with_next_solver(
30
+ - ocx: &ObligationCtxt<'_, 'tcx>,
31
+ - key: ParamEnvAnd<'tcx, Self>,
32
+ - span: Span,
33
+ - ) -> Result<Self::QueryResponse, NoSolution> {
34
+ - type_op_ascribe_user_type_with_span(ocx, key, span)
35
+ - }
36
+ }
37
+
38
+ /// The core of the `type_op_ascribe_user_type` query: for diagnostics purposes in NLL HRTB errors,
39
+ diff --git a/compiler/rustc_trait_selection/src/traits/query/type_op/mod.rs b/compiler/rustc_trait_selection/src/traits/query/type_op/mod.rs
40
+ index 62d636f2de046bad955e157ec719de05d44dcff0..250579a2b064a454a86a90cf6c7a08f34a3f67a4 100644
41
+ --- a/compiler/rustc_trait_selection/src/traits/query/type_op/mod.rs
42
+ +++ b/compiler/rustc_trait_selection/src/traits/query/type_op/mod.rs
43
+ @@ -12,7 +12,7 @@ use crate::infer::canonical::{
44
+ QueryRegionConstraints,
45
+ };
46
+ use crate::infer::{InferCtxt, InferOk};
47
+ -use crate::traits::{ObligationCause, ObligationCtxt};
48
+ +use crate::traits::ObligationCause;
49
+
50
+ pub mod ascribe_user_type;
51
+ pub mod custom;
52
+ @@ -83,18 +83,6 @@ pub trait QueryTypeOp<'tcx>: fmt::Debug + Copy + TypeFoldable<TyCtxt<'tcx>> + 't
53
+ canonicalized: CanonicalQueryInput<'tcx, ParamEnvAnd<'tcx, Self>>,
54
+ ) -> Result<CanonicalQueryResponse<'tcx, Self::QueryResponse>, NoSolution>;
55
+
56
+ - /// In the new trait solver, we already do caching in the solver itself,
57
+ - /// so there's no need to canonicalize and cache via the query system.
58
+ - /// Additionally, even if we were to canonicalize, we'd still need to
59
+ - /// make sure to feed it predefined opaque types and the defining anchor
60
+ - /// and that would require duplicating all of the tcx queries. Instead,
61
+ - /// just perform these ops locally.
62
+ - fn perform_locally_with_next_solver(
63
+ - ocx: &ObligationCtxt<'_, 'tcx>,
64
+ - key: ParamEnvAnd<'tcx, Self>,
65
+ - span: Span,
66
+ - ) -> Result<Self::QueryResponse, NoSolution>;
67
+ -
68
+ fn fully_perform_into(
69
+ query_key: ParamEnvAnd<'tcx, Self>,
70
+ infcx: &InferCtxt<'tcx>,
71
+ diff --git a/compiler/rustc_trait_selection/src/traits/query/type_op/normalize.rs b/compiler/rustc_trait_selection/src/traits/query/type_op/normalize.rs
72
+ index 7b330c942807c63f8d2ab92b862488ef31ab5e65..66a2d44699634dac4d4fd6aeea7a9220224eecc2 100644
73
+ --- a/compiler/rustc_trait_selection/src/traits/query/type_op/normalize.rs
74
+ +++ b/compiler/rustc_trait_selection/src/traits/query/type_op/normalize.rs
75
+ @@ -1,13 +1,10 @@
76
+ use std::fmt;
77
+
78
+ -use rustc_middle::traits::ObligationCause;
79
+ use rustc_middle::traits::query::NoSolution;
80
+ pub use rustc_middle::traits::query::type_op::Normalize;
81
+ use rustc_middle::ty::{self, Lift, ParamEnvAnd, Ty, TyCtxt, TypeFoldable, TypeVisitableExt};
82
+ -use rustc_span::Span;
83
+
84
+ use crate::infer::canonical::{CanonicalQueryInput, CanonicalQueryResponse};
85
+ -use crate::traits::ObligationCtxt;
86
+
87
+ impl<'tcx, T> super::QueryTypeOp<'tcx> for Normalize<'tcx, T>
88
+ where
89
+ @@ -29,19 +26,6 @@ where
90
+ ) -> Result<CanonicalQueryResponse<'tcx, Self::QueryResponse>, NoSolution> {
91
+ T::type_op_method(tcx, canonicalized)
92
+ }
93
+ -
94
+ - fn perform_locally_with_next_solver(
95
+ - ocx: &ObligationCtxt<'_, 'tcx>,
96
+ - key: ParamEnvAnd<'tcx, Self>,
97
+ - span: Span,
98
+ - ) -> Result<Self::QueryResponse, NoSolution> {
99
+ - ocx.deeply_normalize(
100
+ - &ObligationCause::dummy_with_span(span),
101
+ - key.param_env,
102
+ - key.value.value,
103
+ - )
104
+ - .map_err(|_| NoSolution)
105
+ - }
106
+ }
107
+
108
+ pub trait Normalizable<'tcx>:
109
+ diff --git a/compiler/rustc_trait_selection/src/traits/query/type_op/outlives.rs b/compiler/rustc_trait_selection/src/traits/query/type_op/outlives.rs
110
+ index 99a2779aa8212e3c8b4f44b40797aaa2203cd9f7..fd06dd4403c12da02009110ac296cdf6b557f52a 100644
111
+ --- a/compiler/rustc_trait_selection/src/traits/query/type_op/outlives.rs
112
+ +++ b/compiler/rustc_trait_selection/src/traits/query/type_op/outlives.rs
113
+ @@ -1,12 +1,8 @@
114
+ use rustc_middle::traits::query::{DropckOutlivesResult, NoSolution};
115
+ use rustc_middle::ty::{ParamEnvAnd, TyCtxt};
116
+ -use rustc_span::Span;
117
+
118
+ use crate::infer::canonical::{CanonicalQueryInput, CanonicalQueryResponse};
119
+ -use crate::traits::ObligationCtxt;
120
+ -use crate::traits::query::dropck_outlives::{
121
+ - compute_dropck_outlives_inner, trivial_dropck_outlives,
122
+ -};
123
+ +use crate::traits::query::dropck_outlives::trivial_dropck_outlives;
124
+ use crate::traits::query::type_op::DropckOutlives;
125
+
126
+ impl<'tcx> super::QueryTypeOp<'tcx> for DropckOutlives<'tcx> {
127
+ @@ -25,12 +21,4 @@ impl<'tcx> super::QueryTypeOp<'tcx> for DropckOutlives<'tcx> {
128
+ ) -> Result<CanonicalQueryResponse<'tcx, Self::QueryResponse>, NoSolution> {
129
+ tcx.dropck_outlives(canonicalized)
130
+ }
131
+ -
132
+ - fn perform_locally_with_next_solver(
133
+ - ocx: &ObligationCtxt<'_, 'tcx>,
134
+ - key: ParamEnvAnd<'tcx, Self>,
135
+ - span: Span,
136
+ - ) -> Result<Self::QueryResponse, NoSolution> {
137
+ - compute_dropck_outlives_inner(ocx, key.param_env.and(key.value), span)
138
+ - }
139
+ }
140
+ diff --git a/compiler/rustc_trait_selection/src/traits/query/type_op/prove_predicate.rs b/compiler/rustc_trait_selection/src/traits/query/type_op/prove_predicate.rs
141
+ index 8601371c7ebf2a568fe27c2bd40f7b35aceee9f1..5dedd9af40561fb7d807dedb95d9cfc490e523c0 100644
142
+ --- a/compiler/rustc_trait_selection/src/traits/query/type_op/prove_predicate.rs
143
+ +++ b/compiler/rustc_trait_selection/src/traits/query/type_op/prove_predicate.rs
144
+ @@ -3,7 +3,6 @@ use rustc_middle::traits::ObligationCause;
145
+ use rustc_middle::traits::query::NoSolution;
146
+ pub use rustc_middle::traits::query::type_op::ProvePredicate;
147
+ use rustc_middle::ty::{self, ParamEnvAnd, TyCtxt};
148
+ -use rustc_span::Span;
149
+
150
+ use crate::infer::canonical::{CanonicalQueryInput, CanonicalQueryResponse};
151
+ use crate::traits::{ObligationCtxt, sizedness_fast_path};
152
+ @@ -35,20 +34,6 @@ impl<'tcx> super::QueryTypeOp<'tcx> for ProvePredicate<'tcx> {
153
+ ) -> Result<CanonicalQueryResponse<'tcx, ()>, NoSolution> {
154
+ tcx.type_op_prove_predicate(canonicalized)
155
+ }
156
+ -
157
+ - fn perform_locally_with_next_solver(
158
+ - ocx: &ObligationCtxt<'_, 'tcx>,
159
+ - key: ParamEnvAnd<'tcx, Self>,
160
+ - span: Span,
161
+ - ) -> Result<Self::QueryResponse, NoSolution> {
162
+ - ocx.register_obligation(Obligation::new(
163
+ - ocx.infcx.tcx,
164
+ - ObligationCause::dummy_with_span(span),
165
+ - key.param_env,
166
+ - key.value.predicate,
167
+ - ));
168
+ - Ok(())
169
+ - }
170
+ }
171
+
172
+ /// The core of the `type_op_prove_predicate` query: for diagnostics purposes in NLL HRTB errors,
patches/20261028T105419Z/rust-lang--rust-part009/7876a7b6f1b50204bbde12770df4d7fc02dd14ed.patch ADDED
@@ -0,0 +1,283 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ diff --git a/src/bootstrap/src/core/build_steps/llvm.rs b/src/bootstrap/src/core/build_steps/llvm.rs
2
+ index 1077ed41067afb7d98a9b1089374862cdada0083..ff68abdbaaf891791ce3c99fb4dd1b5f422e0c03 100644
3
+ --- a/src/bootstrap/src/core/build_steps/llvm.rs
4
+ +++ b/src/bootstrap/src/core/build_steps/llvm.rs
5
+ @@ -256,22 +256,48 @@ fn llvm_output_dir(builder: &Builder<'_>, target: TargetSelection) -> PathBuf {
6
+ }
7
+
8
+ fn try_download_ci_llvm(builder: &Builder<'_>, target: TargetSelection) -> Option<DownloadedLlvm> {
9
+ + if builder.config.llvm_ci_mode.requests_download_from_ci()
10
+ + && let Some(config) = builder.config.target_config.get(&target)
11
+ + {
12
+ + if config.llvm_config.is_some() {
13
+ + panic!(
14
+ + "Cannot configure `llvm-config` for {target} when using `llvm.download-ci-llvm`",
15
+ + );
16
+ + }
17
+ + if config.llvm_filecheck.is_some() {
18
+ + panic!(
19
+ + "Cannot configure `llvm-filecheck` for {target} when using `llvm.download-ci-llvm`"
20
+ + );
21
+ + }
22
+ + }
23
+ +
24
+ match builder.config.llvm_ci_mode {
25
+ LlvmCiMode::BuildLocally => return None,
26
+ - LlvmCiMode::DownloadFromCi => {}
27
+ + LlvmCiMode::Download => {}
28
+ + LlvmCiMode::DownloadIfUnchanged => {
29
+ + builder.config.update_submodule("src/llvm-project");
30
+ +
31
+ + // Check for untracked changes in `src/llvm-project` and other important places.
32
+ + let has_changes = builder.config.has_changes_from_upstream(LLVM_INVALIDATION_PATHS);
33
+ + if has_changes {
34
+ + builder.info("Warning: LLVM will not be downloaded because of local changes");
35
+ + return None;
36
+ + }
37
+ + }
38
+ }
39
+
40
+ // FIXME: this should eventually be relaxed
41
+ if target != builder.host_target {
42
+ - crate::debug!("LLVM not available on CI for non-host target {target}");
43
+ + builder
44
+ + .info(&format!("Warning: LLVM will not be downloaded for a non-host target {target}"));
45
+ return None;
46
+ }
47
+
48
+ if !is_ci_llvm_available_for_target(&target, builder.config.llvm_assertions) {
49
+ - crate::debug!(
50
+ - "LLVM not available on CI for target={target} and assertions={}",
51
+ + builder.info(&format!(
52
+ + "Warning: LLVM not available on CI for target={target} and assertions={}",
53
+ builder.config.llvm_assertions
54
+ - );
55
+ + ));
56
+ return None;
57
+ }
58
+
59
+ diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs
60
+ index 789e249e151f50ab265a5747e6922d022b4a8c86..9b1a543d64ebfa282b507236addb364b897c88f6 100644
61
+ --- a/src/bootstrap/src/core/config/config.rs
62
+ +++ b/src/bootstrap/src/core/config/config.rs
63
+ @@ -27,11 +27,9 @@ use serde::Deserialize;
64
+ use tracing::{instrument, span};
65
+
66
+ use crate::core::backend::CodegenBackendKind;
67
+ -use crate::core::build_steps::llvm;
68
+ use crate::core::build_steps::llvm::{LLVM_INVALIDATION_PATHS, LlvmKind, LlvmOutput};
69
+ use crate::core::build_steps::test::failed_tests::collect_previously_failed_tests;
70
+ use crate::core::config::flags::{Color, Flags, Subcommand, Warnings};
71
+ -use crate::core::config::macros::check_ci_llvm;
72
+ use crate::core::config::target_selection::TargetSelectionList;
73
+ use crate::core::config::toml::TomlConfig;
74
+ use crate::core::config::toml::build::{Build, Tool};
75
+ @@ -1059,23 +1057,37 @@ impl Config {
76
+ }
77
+ }
78
+
79
+ - let llvm_from_ci = parse_download_ci_llvm(
80
+ - &dwn_ctx,
81
+ - &rust_info,
82
+ - &download_rustc_commit,
83
+ - llvm_download_ci_llvm,
84
+ - llvm_assertions,
85
+ - );
86
+ -
87
+ - // FIXME: llvm_ci_mode should eventually represent what was used in the config, not the
88
+ - // dynamic value used for determining whether it is actually available.
89
+ - let llvm_ci_mode =
90
+ - if llvm_from_ci { LlvmCiMode::DownloadFromCi } else { LlvmCiMode::BuildLocally };
91
+ + let llvm_ci_mode = parse_download_ci_llvm(llvm_download_ci_llvm);
92
+
93
+ - let is_host_system_llvm =
94
+ - target_config.get(&host_target).and_then(|c| c.llvm_config.as_ref()).is_some();
95
+ + // Sanity checks
96
+ + match llvm_ci_mode {
97
+ + LlvmCiMode::DownloadIfUnchanged => {
98
+ + if rust_info.is_from_tarball() {
99
+ + // Git is needed for running "if-unchanged" logic.
100
+ + panic!("ERROR: 'if-unchanged' is only compatible with Git managed sources.");
101
+ + }
102
+ + }
103
+ + LlvmCiMode::Download => {
104
+ + if cfg!(not(test))
105
+ + && ci_env.is_running_in_ci()
106
+ + && CiEnv::is_rust_lang_managed_ci_job()
107
+ + {
108
+ + // On rust-lang CI, we must always rebuild LLVM if there were any modifications to it
109
+ + panic!(
110
+ + "`llvm.download-ci-llvm` cannot be set to `true` on CI. Use `if-unchanged` instead."
111
+ + );
112
+ + }
113
+ + }
114
+ + LlvmCiMode::BuildLocally => {
115
+ + if download_rustc_commit.is_some() {
116
+ + panic!(
117
+ + "`llvm.download-ci-llvm` cannot be set to `false` if `rust.download-rustc` is set to `true` or `if-unchanged`."
118
+ + );
119
+ + }
120
+ + }
121
+ + }
122
+
123
+ - if llvm_from_ci {
124
+ + if llvm_ci_mode.requests_download_from_ci() {
125
+ let warn = |option: &str| {
126
+ println!(
127
+ "WARNING: `{option}` will only be used on `compiler/rustc_llvm` build, not for the LLVM build."
128
+ @@ -1108,13 +1120,11 @@ impl Config {
129
+ "HELP: To use `llvm.libzstd` for LLVM/LLD builds, set `download-ci-llvm` option to false."
130
+ );
131
+ }
132
+ -
133
+ - if let Some(target) = target_config.get(&host_target) {
134
+ - check_ci_llvm!(target.llvm_config);
135
+ - check_ci_llvm!(target.llvm_filecheck);
136
+ - }
137
+ }
138
+
139
+ + let is_host_system_llvm =
140
+ + target_config.get(&host_target).and_then(|c| c.llvm_config.as_ref()).is_some();
141
+ +
142
+ for (target, linker_override) in default_linux_linker_overrides() {
143
+ // If the user overrode the default Linux linker, do not apply bootstrap defaults
144
+ if targets_with_user_linker_override.contains(&target) {
145
+ @@ -1386,8 +1396,7 @@ NOTE: Please add `--stage 2` to your command line, or if you're sure you want to
146
+ // If we're building with ThinLTO on, by default we want to link
147
+ // to LLVM shared, to avoid re-doing ThinLTO (which happens in
148
+ // the link step) with each stage.
149
+ - let llvm_link_shared =
150
+ - llvm_link_shared.or((!llvm_from_ci && llvm_thin_lto.unwrap_or(false)).then_some(true));
151
+ + let llvm_link_shared = llvm_link_shared.or(llvm_thin_lto.unwrap_or(false).then_some(true));
152
+
153
+ Config {
154
+ // tidy-alphabetical-start
155
+ @@ -1736,10 +1745,7 @@ NOTE: Please add `--stage 2` to your command line, or if you're sure you want to
156
+ Some(commit) => {
157
+ self.download_ci_rustc(commit);
158
+
159
+ - let llvm_ci_requested = match self.llvm_ci_mode {
160
+ - LlvmCiMode::BuildLocally => false,
161
+ - LlvmCiMode::DownloadFromCi => true
162
+ - };
163
+ + let llvm_ci_requested = self.llvm_ci_mode.requests_download_from_ci();
164
+ // CI-rustc can't be used without CI-LLVM. If LLVM Ci is requested, but the
165
+ // LLVM submodule has changes, it is an error.
166
+ // FIXME: this whole logic should be refactored to not use
167
+ @@ -2427,62 +2433,17 @@ pub fn git_config(stage0_metadata: &build_helper::stage0_parser::Stage0) -> GitC
168
+ }
169
+ }
170
+
171
+ -pub fn parse_download_ci_llvm<'a>(
172
+ - dwn_ctx: impl AsRef<DownloadContext<'a>>,
173
+ - rust_info: &channel::GitInfo,
174
+ - download_rustc_commit: &Option<String>,
175
+ - download_ci_llvm: Option<StringOrBool>,
176
+ - asserts: bool,
177
+ -) -> bool {
178
+ - let dwn_ctx = dwn_ctx.as_ref();
179
+ +pub fn parse_download_ci_llvm(download_ci_llvm: Option<StringOrBool>) -> LlvmCiMode {
180
+ let download_ci_llvm = download_ci_llvm.unwrap_or(StringOrBool::Bool(true));
181
+ -
182
+ - let if_unchanged = || {
183
+ - if rust_info.is_from_tarball() {
184
+ - // Git is needed for running "if-unchanged" logic.
185
+ - println!("ERROR: 'if-unchanged' is only compatible with Git managed sources.");
186
+ - helpers::exit_process(1);
187
+ - }
188
+ -
189
+ - // Fetching the LLVM submodule is unnecessary for self-tests.
190
+ - if cfg!(not(test)) {
191
+ - update_submodule(dwn_ctx, rust_info, "src/llvm-project");
192
+ - }
193
+ -
194
+ - // Check for untracked changes in `src/llvm-project` and other important places.
195
+ - let has_changes = has_changes_from_upstream(dwn_ctx, LLVM_INVALIDATION_PATHS);
196
+ -
197
+ - // Return false if there are untracked changes, otherwise check if CI LLVM is available.
198
+ - if has_changes {
199
+ - false
200
+ - } else {
201
+ - llvm::is_ci_llvm_available_for_target(&dwn_ctx.host_target, asserts)
202
+ - }
203
+ - };
204
+ -
205
+ match download_ci_llvm {
206
+ StringOrBool::Bool(b) => {
207
+ - if !b && download_rustc_commit.is_some() {
208
+ - panic!(
209
+ - "`llvm.download-ci-llvm` cannot be set to `false` if `rust.download-rustc` is set to `true` or `if-unchanged`."
210
+ - );
211
+ - }
212
+ -
213
+ - if cfg!(not(test))
214
+ - && b
215
+ - && dwn_ctx.is_running_on_ci()
216
+ - && CiEnv::is_rust_lang_managed_ci_job()
217
+ - {
218
+ - // On rust-lang CI, we must always rebuild LLVM if there were any modifications to it
219
+ - panic!(
220
+ - "`llvm.download-ci-llvm` cannot be set to `true` on CI. Use `if-unchanged` instead."
221
+ - );
222
+ + if b {
223
+ + LlvmCiMode::Download
224
+ + } else {
225
+ + LlvmCiMode::BuildLocally
226
+ }
227
+ -
228
+ - // If download-ci-llvm=true we also want to check that CI llvm is available
229
+ - b && llvm::is_ci_llvm_available_for_target(&dwn_ctx.host_target, asserts)
230
+ }
231
+ - StringOrBool::String(s) if s == "if-unchanged" => if_unchanged(),
232
+ + StringOrBool::String(s) if s == "if-unchanged" => LlvmCiMode::DownloadIfUnchanged,
233
+ StringOrBool::String(other) => {
234
+ panic!("unrecognized option for download-ci-llvm: {other:?}")
235
+ }
236
+ diff --git a/src/bootstrap/src/core/config/macros.rs b/src/bootstrap/src/core/config/macros.rs
237
+ index 3c3805968d0c1c3b8304f155ec976b7fd05c9983..37c04d251cb4e37a4fe6b54534194e9daedb5fd1 100644
238
+ --- a/src/bootstrap/src/core/config/macros.rs
239
+ +++ b/src/bootstrap/src/core/config/macros.rs
240
+ @@ -136,15 +136,4 @@ macro_rules! define_config {
241
+ }
242
+ }
243
+
244
+ -macro_rules! check_ci_llvm {
245
+ - ($name:expr) => {
246
+ - assert!(
247
+ - $name.is_none(),
248
+ - "setting {} is incompatible with download-ci-llvm.",
249
+ - stringify!($name).replace("_", "-")
250
+ - );
251
+ - };
252
+ -}
253
+ -
254
+ -pub(crate) use check_ci_llvm;
255
+ pub(crate) use define_config;
256
+ diff --git a/src/bootstrap/src/core/config/mod.rs b/src/bootstrap/src/core/config/mod.rs
257
+ index a13eace17cbaf9d70d0f7848bffdc4056c65d5db..1093f0c1d035aa0f2cc71aaf15ca208cb40040c3 100644
258
+ --- a/src/bootstrap/src/core/config/mod.rs
259
+ +++ b/src/bootstrap/src/core/config/mod.rs
260
+ @@ -373,10 +373,13 @@ pub enum GccCiMode {
261
+ pub enum LlvmCiMode {
262
+ /// Build LLVM from the local `src/llvm-project` submodule.
263
+ BuildLocally,
264
+ + /// Try to download LLVM from CI if the `src/llvm-project` submodule
265
+ + /// (and some other files that affect LLVM's build) are not modified in git.
266
+ + DownloadIfUnchanged,
267
+ /// Try to download LLVM from CI.
268
+ /// If it is not available on CI, it will be built locally instead.
269
+ #[default]
270
+ - DownloadFromCi,
271
+ + Download,
272
+ }
273
+
274
+ impl LlvmCiMode {
275
+ @@ -385,7 +388,7 @@ impl LlvmCiMode {
276
+ pub fn requests_download_from_ci(&self) -> bool {
277
+ match self {
278
+ LlvmCiMode::BuildLocally => false,
279
+ - LlvmCiMode::DownloadFromCi => true,
280
+ + LlvmCiMode::Download | LlvmCiMode::DownloadIfUnchanged => true,
281
+ }
282
+ }
283
+ }
patches/20261028T105419Z/rust-lang--rust-part009/799c6d0902f86e9f3356ad5fe78883e05c066701.patch ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ diff --git a/compiler/rustc_feature/src/accepted.rs b/compiler/rustc_feature/src/accepted.rs
2
+ index a6e6f4f78323c6b74610e71eee9629ee70acb5d8..37a3594e374ea0de21caa1fc5d2fbf513214b116 100644
3
+ --- a/compiler/rustc_feature/src/accepted.rs
4
+ +++ b/compiler/rustc_feature/src/accepted.rs
5
+ @@ -278,7 +278,7 @@ declare_features! (
6
+ /// Allows some increased flexibility in the name resolution rules,
7
+ /// especially around globs and shadowing (RFC 1560).
8
+ (accepted, item_like_imports, "1.15.0", Some(35120)),
9
+ - // Allows using the `kl` and `widekl` target features and the associated intrinsics
10
+ + /// Allows using the `kl` and `widekl` target features and the associated intrinsics
11
+ (accepted, keylocker_x86, "1.89.0", Some(134813)),
12
+ /// Allows `'a: { break 'a; }`.
13
+ (accepted, label_break_value, "1.65.0", Some(48594)),
14
+ diff --git a/compiler/rustc_feature/src/removed.rs b/compiler/rustc_feature/src/removed.rs
15
+ index 96dbd346e4fc610bff8046dd2e2232548a5030d6..0253f16666628ab9d305a33e29fc344f2dce1af5 100644
16
+ --- a/compiler/rustc_feature/src/removed.rs
17
+ +++ b/compiler/rustc_feature/src/removed.rs
18
+ @@ -211,7 +211,7 @@ declare_features! (
19
+ (removed, no_coverage, "1.74.0", Some(84605), Some("renamed to `coverage_attribute`"), 114656),
20
+ /// Allows `#[no_debug]`.
21
+ (removed, no_debug, "1.43.0", Some(29721), Some("removed due to lack of demand"), 69667),
22
+ - // Allows the use of `no_sanitize` attribute.
23
+ + /// Allows the use of `no_sanitize` attribute.
24
+ /// The feature was renamed to `sanitize` and the attribute to `#[sanitize(xyz = "on|off")]`
25
+ (removed, no_sanitize, "1.91.0", Some(39699), Some(r#"renamed to sanitize(xyz = "on|off")"#), 142681),
26
+ /// Note: this feature was previously recorded in a separate
27
+ diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs
28
+ index d08054d89ee81b85ea9925e3e33f67384bae3331..ca703898151410e43053f773a34397e74c747025 100644
29
+ --- a/compiler/rustc_feature/src/unstable.rs
30
+ +++ b/compiler/rustc_feature/src/unstable.rs
31
+ @@ -100,7 +100,7 @@ impl Features {
32
+ &self.enabled_features
33
+ }
34
+
35
+ - /// Returns a iterator of enabled features in stable order.
36
+ + /// Returns an iterator of enabled features in stable order.
37
+ pub fn enabled_features_iter_stable_order(
38
+ &self,
39
+ ) -> impl Iterator<Item = (Symbol, Span)> + Clone {
40
+ @@ -490,7 +490,7 @@ declare_features! (
41
+ (unstable, diagnostic_on_unknown, "1.96.0", Some(152900)),
42
+ /// Allows macros to customize macro argument matcher diagnostics.
43
+ (unstable, diagnostic_on_unmatched_args, "1.97.0", Some(155642)),
44
+ - // Used by macros to not show their bodies in error messages. No-op with `-Z macro-backtrace`.
45
+ + /// Used by macros to not show their bodies in error messages. No-op with `-Z macro-backtrace`.
46
+ (unstable, diagnostic_opaque, "1.99.0", Some(158813)),
47
+ /// Allows `#[doc(cfg(...))]`.
48
+ (unstable, doc_cfg, "1.21.0", Some(43781)),
49
+ @@ -553,7 +553,8 @@ declare_features! (
50
+ (incomplete, generic_const_parameter_types, "1.87.0", Some(137626)),
51
+ /// Allows any generic constants being used as pattern type range ends
52
+ (incomplete, generic_pattern_types, "1.86.0", Some(136574)),
53
+ - /// Allows registering static items globally, possibly across crates, to iterate over at runtime.
54
+ + /// Allows registering static items globally, possibly across crates, to iterate over at
55
+ + /// runtime.
56
+ (unstable, global_registration, "1.80.0", Some(125119)),
57
+ /// Allows using guards in patterns.
58
+ (incomplete, guard_patterns, "1.85.0", Some(129967)),
59
+ @@ -654,7 +655,7 @@ declare_features! (
60
+ (unstable, non_exhaustive_omitted_patterns_lint, "1.57.0", Some(89554)),
61
+ /// Allows `for<T>` binders in where-clauses
62
+ (incomplete, non_lifetime_binders, "1.69.0", Some(108185)),
63
+ - /// Target feaures on nvptx.
64
+ + /// Target features on nvptx.
65
+ (unstable, nvptx_target_feature, "1.91.0", Some(150254)),
66
+ /// Allows using enums in offset_of!
67
+ (unstable, offset_of_enum, "1.75.0", Some(120141)),
68
+ @@ -676,10 +677,12 @@ declare_features! (
69
+ (unstable, proc_macro_hygiene, "1.30.0", Some(54727)),
70
+ /// Allows the use of raw-dylibs on ELF platforms
71
+ (incomplete, raw_dylib_elf, "1.87.0", Some(135694)),
72
+ + /// Allows the `Reborrow` and `CoerceShared` traits.
73
+ (unstable, reborrow, "1.91.0", Some(145612)),
74
+ /// Makes `&` and `&mut` patterns eat only one layer of references in Rust 2024.
75
+ (incomplete, ref_pat_eat_one_layer_2024, "1.79.0", Some(123076)),
76
+ - /// Makes `&` and `&mut` patterns eat only one layer of references in Rust 2024—structural variant
77
+ + /// Makes `&` and `&mut` patterns eat only one layer of references in Rust 2024—structural
78
+ + /// variant.
79
+ (incomplete, ref_pat_eat_one_layer_2024_structural, "1.81.0", Some(123076)),
80
+ /// Allows using the `#[register_tool]` attribute.
81
+ (unstable, register_tool, "1.41.0", Some(66079)),
82
+ @@ -766,6 +769,7 @@ declare_features! (
83
+ (unstable, xtensa_target_feature, "1.98.0", Some(157063)),
84
+ /// Allows `do yeet` expressions
85
+ (unstable, yeet_expr, "1.62.0", Some(96373)),
86
+ + /// Allows the `yield` keyword for coroutines/generators.
87
+ (unstable, yield_expr, "1.87.0", Some(43122)),
88
+ // !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!! !!!!
89
+ // Features are listed in alphabetical order. Tidy will fail if you don't keep it this way.
patches/20261028T105419Z/rust-lang--rust-part009/7b98255ea37f2557b1e79c1729b86fcdd5122ee3.patch ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ diff --git a/library/compiler-builtins/.github/workflows/main.yaml b/library/compiler-builtins/.github/workflows/main.yaml
2
+ index a069590d61c1d8a69e6a4b3efc44ebde738ada5f..51d0734a4c4df9d93aa4207b0d7c6fe4b65305e9 100644
3
+ --- a/library/compiler-builtins/.github/workflows/main.yaml
4
+ +++ b/library/compiler-builtins/.github/workflows/main.yaml
5
+ @@ -114,9 +114,10 @@ jobs:
6
+ os: windows-2025-vs2026
7
+ - target: x86_64-pc-windows-msvc
8
+ os: windows-2025-vs2026
9
+ - - target: i686-pc-windows-gnu
10
+ - os: windows-2025-vs2026
11
+ - channel: nightly-i686-gnu
12
+ + # FIXME(rust-lang/compiler-builtins#1306): disabled due to broken environment
13
+ + # - target: i686-pc-windows-gnu
14
+ + # os: windows-2025-vs2026
15
+ + # channel: nightly-i686-gnu
16
+ - target: x86_64-pc-windows-gnu
17
+ os: windows-2025-vs2026
18
+ channel: nightly-x86_64-gnu
patches/20261028T105419Z/rust-lang--rust-part009/7f0581d42e299ea0824c13338832daa20d442e62.patch ADDED
@@ -0,0 +1,348 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ diff --git a/compiler/rustc_codegen_llvm/src/back/mod.rs b/compiler/rustc_codegen_llvm/src/back/mod.rs
2
+ index 6cb89f80ab89a796af30162cc1873bf99578e5ec..de6007c17bfff0612934b9f54521ac34dbec5e2a 100644
3
+ --- a/compiler/rustc_codegen_llvm/src/back/mod.rs
4
+ +++ b/compiler/rustc_codegen_llvm/src/back/mod.rs
5
+ @@ -1,5 +1,6 @@
6
+ pub(crate) mod archive;
7
+ pub(crate) mod lto;
8
+ +pub(crate) mod owned_mc_subtarget_info;
9
+ pub(crate) mod owned_target_machine;
10
+ mod profiling;
11
+ pub(crate) mod write;
12
+ diff --git a/compiler/rustc_codegen_llvm/src/back/owned_mc_subtarget_info.rs b/compiler/rustc_codegen_llvm/src/back/owned_mc_subtarget_info.rs
13
+ new file mode 100644
14
+ index 0000000000000000000000000000000000000000..f57368e755add6454470f2e88e8cc17bfb14f908
15
+ --- /dev/null
16
+ +++ b/compiler/rustc_codegen_llvm/src/back/owned_mc_subtarget_info.rs
17
+ @@ -0,0 +1,49 @@
18
+ +use std::ffi::CStr;
19
+ +use std::ptr::NonNull;
20
+ +
21
+ +use rustc_data_structures::small_c_str::SmallCStr;
22
+ +
23
+ +use crate::diagnostics::LlvmError;
24
+ +use crate::llvm;
25
+ +
26
+ +/// Responsible for safely creating and disposing llvm::MCSubtargetInfo via ffi functions.
27
+ +/// Not cloneable as there is no clone function for llvm::MCSubtargetInfo.
28
+ +pub(crate) struct OwnedMCSubtargetInfo {
29
+ + info_unique: NonNull<llvm::MCSubtargetInfo>,
30
+ +}
31
+ +
32
+ +impl OwnedMCSubtargetInfo {
33
+ + pub(crate) fn new(
34
+ + triple: &CStr,
35
+ + cpu: &CStr,
36
+ + features: &CStr,
37
+ + ) -> Result<Self, LlvmError<'static>> {
38
+ + // SAFETY: llvm::LLVMRustCreateMCSubtargetInfo copies pointed-to data.
39
+ + let info_ptr = unsafe {
40
+ + llvm::LLVMRustCreateMCSubtargetInfo(triple.as_ptr(), cpu.as_ptr(), features.as_ptr())
41
+ + };
42
+ +
43
+ + NonNull::new(info_ptr)
44
+ + .map(|info_unique| Self { info_unique })
45
+ + .ok_or_else(|| LlvmError::CreateMCSubtargetInfo { triple: SmallCStr::from(triple) })
46
+ + }
47
+ +
48
+ + pub(crate) fn has_feature(&self, feature: &CStr) -> bool {
49
+ + // SAFETY: `new` ensures we have a valid pointer created by
50
+ + // `llvm::LLVMRustCreateMCSubtargetInfo`.
51
+ + unsafe {
52
+ + llvm::LLVMRustMCSubtargetInfoHasFeature(self.info_unique.as_ref(), feature.as_ptr())
53
+ + }
54
+ + }
55
+ +}
56
+ +
57
+ +impl Drop for OwnedMCSubtargetInfo {
58
+ + fn drop(&mut self) {
59
+ + // SAFETY: `new` ensures we have a valid pointer created by
60
+ + // `llvm::LLVMRustCreateMCSubtargetInfo` and `OwnedMCSubtargetInfo` is not copyable so
61
+ + // there is no double free or use after free.
62
+ + unsafe {
63
+ + llvm::LLVMRustDisposeMCSubtargetInfo(self.info_unique);
64
+ + }
65
+ + }
66
+ +}
67
+ diff --git a/compiler/rustc_codegen_llvm/src/back/owned_target_machine.rs b/compiler/rustc_codegen_llvm/src/back/owned_target_machine.rs
68
+ index 5b1046817c90414e67e951452a3cf2981d4e72d1..5a1dc8080c2c1201519f7d7ba2291d5b28070b0e 100644
69
+ --- a/compiler/rustc_codegen_llvm/src/back/owned_target_machine.rs
70
+ +++ b/compiler/rustc_codegen_llvm/src/back/owned_target_machine.rs
71
+ @@ -38,7 +38,7 @@ impl OwnedTargetMachine {
72
+ use_wasm_eh: bool,
73
+ large_data_threshold: u64,
74
+ ) -> Result<Self, LlvmError<'static>> {
75
+ - // SAFETY: llvm::LLVMRustCreateTargetMachine copies pointed to data
76
+ + // SAFETY: llvm::LLVMRustCreateTargetMachine copies pointed-to data.
77
+ let tm_ptr = unsafe {
78
+ llvm::LLVMRustCreateTargetMachine(
79
+ triple.as_ptr(),
80
+ diff --git a/compiler/rustc_codegen_llvm/src/back/write.rs b/compiler/rustc_codegen_llvm/src/back/write.rs
81
+ index b8952ffc6bf81d193b4b474a4a12aacab03a75ae..3884f5af7f46adf6606aa40ddf97674c06ce007f 100644
82
+ --- a/compiler/rustc_codegen_llvm/src/back/write.rs
83
+ +++ b/compiler/rustc_codegen_llvm/src/back/write.rs
84
+ @@ -100,17 +100,12 @@ fn write_output_file<'ll>(
85
+ result.into_result().unwrap_or_else(|()| llvm_err(dcx, LlvmError::WriteOutput { path: output }))
86
+ }
87
+
88
+ -/// If `for_cfg` is `true` then we are creating this machine for the purpose of populating
89
+ -/// [`rustc_codegen_ssa::TargetConfig`] based on what LLVM actually enables in this configuration.
90
+ -/// `-Ctarget-feature` should be ignored in that case since it is already processed separately.
91
+ -pub(crate) fn create_informational_target_machine(
92
+ - sess: &Session,
93
+ - for_cfg: bool,
94
+ -) -> OwnedTargetMachine {
95
+ +pub(crate) fn create_informational_target_machine(sess: &Session) -> OwnedTargetMachine {
96
+ let config = TargetMachineFactoryConfig { split_dwarf_file: None, output_obj_file: None };
97
+ // Can't use query system here quite yet because this function is invoked before the query
98
+ // system/tcx is set up.
99
+ - let features = llvm_util::global_llvm_features(sess, for_cfg);
100
+ + let features = llvm_util::global_llvm_features(sess, /* for_cfg */ false);
101
+ +
102
+ target_machine_factory(sess, config::OptLevel::No, &features)(sess.dcx(), config)
103
+ }
104
+
105
+ @@ -212,7 +207,6 @@ pub(crate) fn target_machine_factory(
106
+
107
+ let code_model = to_llvm_code_model(sess.code_model());
108
+
109
+ - // This is used to set cfg_has_threads, so all logic must be in this method.
110
+ let singlethread = sess.target.singlethread(&sess.internal_target_features);
111
+
112
+ let triple = SmallCStr::new(&versioned_llvm_target(sess));
113
+ diff --git a/compiler/rustc_codegen_llvm/src/context.rs b/compiler/rustc_codegen_llvm/src/context.rs
114
+ index 853c4bfc9ca3f8c995cc4180b5c32492328ca449..f913bda10052e893413ce0138deded200eb9edec 100644
115
+ --- a/compiler/rustc_codegen_llvm/src/context.rs
116
+ +++ b/compiler/rustc_codegen_llvm/src/context.rs
117
+ @@ -228,7 +228,7 @@ pub(crate) unsafe fn create_module<'ll>(
118
+
119
+ // Ensure the data-layout values hardcoded remain the defaults.
120
+ {
121
+ - let tm = crate::back::write::create_informational_target_machine(sess, false);
122
+ + let tm = crate::back::write::create_informational_target_machine(sess);
123
+ unsafe {
124
+ llvm::LLVMRustSetDataLayoutFromTargetMachine(llmod, tm.raw());
125
+ }
126
+ diff --git a/compiler/rustc_codegen_llvm/src/diagnostics.rs b/compiler/rustc_codegen_llvm/src/diagnostics.rs
127
+ index 54f8ffbb881da29b549ed0dfc09febaea079f606..c981b5eaeb7308d7c4dd63b4b372d43080ddf2e2 100644
128
+ --- a/compiler/rustc_codegen_llvm/src/diagnostics.rs
129
+ +++ b/compiler/rustc_codegen_llvm/src/diagnostics.rs
130
+ @@ -119,6 +119,8 @@ pub(crate) enum LlvmError<'a> {
131
+ WriteOutput { path: &'a Path },
132
+ #[diag("could not create LLVM TargetMachine for triple: {$triple}")]
133
+ CreateTargetMachine { triple: SmallCStr },
134
+ + #[diag("could not create LLVM MCSubtargetInfo for triple: {$triple}")]
135
+ + CreateMCSubtargetInfo { triple: SmallCStr },
136
+ #[diag("failed to run LLVM passes")]
137
+ RunLlvmPasses,
138
+ #[diag("failed to write LLVM IR to {$path}")]
139
+ @@ -145,6 +147,9 @@ impl<G: EmissionGuarantee> Diagnostic<'_, G> for WithLlvmError<'_> {
140
+ CreateTargetMachine { .. } => {
141
+ msg!("could not create LLVM TargetMachine for triple: {$triple}: {$llvm_err}")
142
+ }
143
+ + CreateMCSubtargetInfo { .. } => {
144
+ + msg!("could not create LLVM MCSubtargetInfo for triple: {$triple}: {$llvm_err}")
145
+ + }
146
+ RunLlvmPasses => msg!("failed to run LLVM passes: {$llvm_err}"),
147
+ WriteIr { .. } => msg!("failed to write LLVM IR to {$path}: {$llvm_err}"),
148
+ PrepareThinLtoContext => {
149
+ diff --git a/compiler/rustc_codegen_llvm/src/lib.rs b/compiler/rustc_codegen_llvm/src/lib.rs
150
+ index 552a91ffee0713987719c6702aea31a06cfb815d..29fcb69ff28fceb462ca6c5b9197ffaf02850c97 100644
151
+ --- a/compiler/rustc_codegen_llvm/src/lib.rs
152
+ +++ b/compiler/rustc_codegen_llvm/src/lib.rs
153
+ @@ -247,7 +247,7 @@ impl CodegenBackend for LlvmCodegenBackend {
154
+
155
+ fn provide(&self, providers: &mut Providers) {
156
+ providers.queries.global_backend_features =
157
+ - |tcx, ()| llvm_util::global_llvm_features(tcx.sess, false)
158
+ + |tcx, ()| llvm_util::global_llvm_features(tcx.sess, /* for_cfg */ false)
159
+ }
160
+
161
+ fn print(&self, req: &PrintRequest, out: &mut String, sess: &Session) {
162
+ @@ -493,7 +493,7 @@ impl ModuleLlvm {
163
+ ModuleLlvm {
164
+ llmod_raw,
165
+ llcx,
166
+ - tm: ManuallyDrop::new(create_informational_target_machine(tcx.sess, false)),
167
+ + tm: ManuallyDrop::new(create_informational_target_machine(tcx.sess)),
168
+ }
169
+ }
170
+ }
171
+ diff --git a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs
172
+ index 05d3bd0b08b95a2bf8da188b92ff3b70b3c44e35..8551f9b6fb3fe05f36bf87db08b179ab6caf135b 100644
173
+ --- a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs
174
+ +++ b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs
175
+ @@ -720,6 +720,7 @@ unsafe extern "C" {
176
+ pub type TargetMachine;
177
+ }
178
+ unsafe extern "C" {
179
+ + pub(crate) type MCSubtargetInfo;
180
+ pub(crate) type Twine;
181
+ pub(crate) type DiagnosticInfo;
182
+ pub(crate) type SMDiagnostic;
183
+ @@ -2362,7 +2363,6 @@ unsafe extern "C" {
184
+ pub(crate) fn LLVMRustWriteTypeToString(Type: &Type, s: &RustString);
185
+ pub(crate) fn LLVMRustWriteValueToString(value_ref: &Value, s: &RustString);
186
+
187
+ - pub(crate) fn LLVMRustHasFeature(T: &TargetMachine, s: *const c_char) -> bool;
188
+ pub(crate) fn LLVMRustTargetHasMnemonic(T: &TargetMachine, s: *const c_char) -> bool;
189
+
190
+ pub(crate) fn LLVMRustPrintTargetCPUs(TM: &TargetMachine, OutStr: &RustString);
191
+ @@ -2404,6 +2404,19 @@ unsafe extern "C" {
192
+ LargeDataThreshold: u64,
193
+ ) -> *mut TargetMachine;
194
+
195
+ + pub(crate) fn LLVMRustCreateMCSubtargetInfo(
196
+ + TripleStr: *const c_char,
197
+ + CPU: *const c_char,
198
+ + Features: *const c_char,
199
+ + ) -> *mut MCSubtargetInfo;
200
+ +
201
+ + pub(crate) fn LLVMRustMCSubtargetInfoHasFeature(
202
+ + MCInfo: &MCSubtargetInfo,
203
+ + Feature: *const c_char,
204
+ + ) -> bool;
205
+ +
206
+ + pub(crate) fn LLVMRustDisposeMCSubtargetInfo(MCInfo: ptr::NonNull<MCSubtargetInfo>);
207
+ +
208
+ pub(crate) fn LLVMRustAddLibraryInfo<'a>(
209
+ T: &TargetMachine,
210
+ PM: &PassManager<'a>,
211
+ diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs
212
+ index cebc3ffc2bbdd2082b80d907a9b4b4be6dc6bb22..7090e21e863dff7f8ac130ac3b282453d5d8b2d7 100644
213
+ --- a/compiler/rustc_codegen_llvm/src/llvm_util.rs
214
+ +++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs
215
+ @@ -6,6 +6,7 @@ use std::sync::Once;
216
+ use std::{ptr, slice, str};
217
+
218
+ use libc::c_int;
219
+ +use rustc_codegen_ssa::back::versioned_llvm_target;
220
+ use rustc_codegen_ssa::base::wants_wasm_eh;
221
+ use rustc_codegen_ssa::target_features::internal_target_features;
222
+ use rustc_codegen_ssa::{TargetConfig, target_features};
223
+ @@ -20,7 +21,8 @@ use rustc_target::spec::{
224
+ };
225
+ use smallvec::{SmallVec, smallvec};
226
+
227
+ -use crate::back::write::create_informational_target_machine;
228
+ +use crate::back::owned_mc_subtarget_info::OwnedMCSubtargetInfo;
229
+ +use crate::back::write::{create_informational_target_machine, llvm_err};
230
+ use crate::{diagnostics, llvm};
231
+
232
+ static INIT: Once = Once::new();
233
+ @@ -318,7 +320,14 @@ pub(crate) fn to_llvm_features<'a>(sess: &Session, s: &'a str) -> Option<LLVMFea
234
+ ///
235
+ /// We do not have to worry about RUSTC_SPECIFIC_FEATURES here, those are handled outside codegen.
236
+ pub(crate) fn target_config(sess: &Session) -> TargetConfig {
237
+ - let target_machine = create_informational_target_machine(sess, true);
238
+ + require_inited();
239
+ + let target_features = global_llvm_features(sess, /* for_cfg */ true);
240
+ +
241
+ + let triple = SmallCStr::new(&versioned_llvm_target(sess));
242
+ + let cpu = SmallCStr::new(target_cpu(sess));
243
+ + let features = CString::new(target_features.join(",")).unwrap();
244
+ + let mc_subtarget_info = OwnedMCSubtargetInfo::new(&triple, &cpu, &features)
245
+ + .unwrap_or_else(|err| llvm_err(sess.dcx(), err));
246
+
247
+ let internal_target_features = internal_target_features(
248
+ sess,
249
+ @@ -329,16 +338,17 @@ pub(crate) fn target_config(sess: &Session) -> TargetConfig {
250
+ },
251
+ |feature| {
252
+ // This closure determines whether the target CPU has the feature according to LLVM. We
253
+ - // do *not* consider the `-Ctarget-feature`s here, as that will be handled later in
254
+ + // do *not* consider the `-Ctarget-feature`s here (that's why we passed `for_cfg: true`
255
+ + // to `global_llvm_features` above) because that will be handled later in
256
+ // `internal_target_features`.
257
+ if let Some(feat) = to_llvm_features(sess, feature) {
258
+ // All the LLVM features this expands to must be enabled.
259
+ for llvm_feature in feat {
260
+ let cstr = SmallCStr::new(llvm_feature);
261
+ - // `LLVMRustHasFeature` is moderately expensive. On targets with many
262
+ + // `has_feature` is moderately expensive. On targets with many
263
+ // features (e.g. x86) these calls take a non-trivial fraction of runtime
264
+ // when compiling very small programs.
265
+ - if !unsafe { llvm::LLVMRustHasFeature(target_machine.raw(), cstr.as_ptr()) } {
266
+ + if !mc_subtarget_info.has_feature(&cstr) {
267
+ return false;
268
+ }
269
+ }
270
+ @@ -479,7 +489,7 @@ fn llvm_target_features(tm: &llvm::TargetMachine) -> Vec<(&str, &str)> {
271
+
272
+ pub(crate) fn print(req: &PrintRequest, out: &mut String, sess: &Session) {
273
+ require_inited();
274
+ - let tm = create_informational_target_machine(sess, false);
275
+ + let tm = create_informational_target_machine(sess);
276
+ match req.kind {
277
+ PrintKind::TargetCPUs => print_target_cpus(sess, tm.raw(), out),
278
+ PrintKind::TargetFeatures => print_target_features(sess, tm.raw(), out),
279
+ @@ -777,7 +787,7 @@ pub(crate) fn tune_cpu(sess: &Session) -> Option<&str> {
280
+
281
+ pub(crate) fn target_has_mnemonic(sess: &Session, mnemonic: &str) -> bool {
282
+ require_inited();
283
+ - let tm = create_informational_target_machine(sess, false);
284
+ + let tm = create_informational_target_machine(sess);
285
+ let cstr = SmallCStr::new(mnemonic);
286
+ unsafe { llvm::LLVMRustTargetHasMnemonic(tm.raw(), cstr.as_ptr()) }
287
+ }
288
+ diff --git a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
289
+ index 6fd78c6bde4bec32ffde93be87fcf54750e686a3..0e75c95763bd91ed13b4f045a469f39fad6aade5 100644
290
+ --- a/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
291
+ +++ b/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
292
+ @@ -91,15 +91,31 @@ extern "C" void LLVMRustTimeTraceProfilerFinish(const char *FileName) {
293
+ timeTraceProfilerCleanup();
294
+ }
295
+
296
+ -extern "C" bool LLVMRustHasFeature(LLVMTargetMachineRef TM,
297
+ - const char *Feature) {
298
+ - TargetMachine *Target = unwrap(TM);
299
+ -#if LLVM_VERSION_GE(23, 0)
300
+ - const MCSubtargetInfo &MCInfo = Target->getMCSubtargetInfo();
301
+ +extern "C" MCSubtargetInfo *
302
+ +LLVMRustCreateMCSubtargetInfo(const char *TripleStr, const char *CPU,
303
+ + const char *Features) {
304
+ + std::string Error;
305
+ + auto Trip = Triple(Triple::normalize(TripleStr));
306
+ + const llvm::Target *TheTarget = TargetRegistry::lookupTarget(Trip, Error);
307
+ + if (TheTarget == nullptr) {
308
+ + LLVMRustSetLastError(Error.c_str());
309
+ + return nullptr;
310
+ + }
311
+ +
312
+ +#if LLVM_VERSION_GE(22, 0)
313
+ + return TheTarget->createMCSubtargetInfo(Trip, CPU, Features);
314
+ #else
315
+ - const MCSubtargetInfo &MCInfo = *Target->getMCSubtargetInfo();
316
+ + return TheTarget->createMCSubtargetInfo(Trip.str(), CPU, Features);
317
+ #endif
318
+ - return MCInfo.checkFeatures(std::string("+") + Feature);
319
+ +}
320
+ +
321
+ +extern "C" bool LLVMRustMCSubtargetInfoHasFeature(MCSubtargetInfo *MCInfo,
322
+ + const char *Feature) {
323
+ + return MCInfo->checkFeatures(std::string("+") + Feature);
324
+ +}
325
+ +
326
+ +extern "C" void LLVMRustDisposeMCSubtargetInfo(MCSubtargetInfo *MCInfo) {
327
+ + delete MCInfo;
328
+ }
329
+
330
+ /// Check whether the target has a specific assembly mnemonic like `ret` or
331
+ diff --git a/tests/ui/codegen/custom-target-invalid-llvm-target.rs b/tests/ui/codegen/custom-target-invalid-llvm-target.rs
332
+ index 72c80cd7af4f1186475c72c870dcbfead3242cd0..d90b56c5d13c002c5c352d7213d66ad78dee77b4 100644
333
+ --- a/tests/ui/codegen/custom-target-invalid-llvm-target.rs
334
+ +++ b/tests/ui/codegen/custom-target-invalid-llvm-target.rs
335
+ @@ -7,4 +7,4 @@
336
+
337
+ fn main() {}
338
+
339
+ -//~? ERROR failed to parse target machine config to target machine
340
+ +//~? ERROR could not create LLVM MCSubtargetInfo for triple: not-a-real-target
341
+ diff --git a/tests/ui/codegen/custom-target-invalid-llvm-target.stderr b/tests/ui/codegen/custom-target-invalid-llvm-target.stderr
342
+ index d5ac437a2b646863a3f23a814e3d224901023e02..e2e844fa1bce78b1b81c83c98088f49f8aaea84e 100644
343
+ --- a/tests/ui/codegen/custom-target-invalid-llvm-target.stderr
344
+ +++ b/tests/ui/codegen/custom-target-invalid-llvm-target.stderr
345
+ @@ -1,2 +1,2 @@
346
+ -error: failed to parse target machine config to target machine: could not create LLVM TargetMachine for triple: not-a-real-target
347
+ +error: could not create LLVM MCSubtargetInfo for triple: not-a-real-target: No available targets are compatible with triple "not-a-real-target"
348
+
patches/20261028T105419Z/rust-lang--rust-part009/7f0cd463543d4cc9213517619dd8f784e87896f7.patch ADDED
@@ -0,0 +1,564 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs
2
+ index 9857a3b8cfae69796390f8a64b66b743d60a4a17..ba6d786fbbd89042b3cee11901122d30a8ea3809 100644
3
+ --- a/library/core/src/lib.rs
4
+ +++ b/library/core/src/lib.rs
5
+ @@ -108,6 +108,7 @@
6
+ #![feature(adt_const_params)]
7
+ #![feature(allow_internal_unsafe)]
8
+ #![feature(allow_internal_unstable)]
9
+ +#![feature(arbitrary_self_types_pointers)]
10
+ #![feature(auto_traits)]
11
+ #![feature(cfg_sanitize)]
12
+ #![feature(cfg_target_has_atomic)]
13
+ diff --git a/library/core/src/ptr/mod.rs b/library/core/src/ptr/mod.rs
14
+ index aedab87449ff58a0adf68d569a768f0eb5344441..f1b81de50942a2a7eb1c7d89e329341741789f90 100644
15
+ --- a/library/core/src/ptr/mod.rs
16
+ +++ b/library/core/src/ptr/mod.rs
17
+ @@ -2067,12 +2067,13 @@ pub const unsafe fn write_unaligned<T>(dst: *mut T, src: T) {
18
+ /// are two cases of usage that need to be distinguished:
19
+ ///
20
+ /// - When a volatile operation is used for memory inside an [allocation], it behaves exactly like
21
+ -/// [`read`], except for the additional guarantee that it won't be elided or reordered (see
22
+ -/// above). This implies that the operation will actually access memory and not e.g. be lowered to
23
+ -/// reusing data from a previous read. Other than that, all the usual rules for memory accesses
24
+ -/// apply (including provenance). In particular, just like in C, whether an operation is volatile
25
+ -/// has no bearing whatsoever on questions involving concurrent accesses from multiple threads.
26
+ -/// Volatile accesses behave exactly like non-atomic accesses in that regard.
27
+ +/// [`read`], except for the additional guarantee that it won't be elided or reordered across
28
+ +/// other externally observable events (see above). This implies that the operation will actually
29
+ +/// access memory and not e.g. be lowered to reusing data from a previous read. Other than that,
30
+ +/// all the usual rules for memory accesses apply (including provenance). In particular, just
31
+ +/// like in C, whether an operation is volatile has no bearing whatsoever on questions involving
32
+ +/// concurrent accesses from multiple threads. Volatile accesses behave exactly like non-atomic
33
+ +/// accesses in that regard.
34
+ ///
35
+ /// - Volatile operations, however, may also be used to access memory that is _outside_ of any Rust
36
+ /// allocation. In this use-case, the pointer does *not* have to be [valid] for reads. This is
37
+ @@ -2174,11 +2175,12 @@ pub const unsafe fn read_volatile<T>(src: *const T) -> T {
38
+ ///
39
+ /// - When a volatile operation is used for memory inside an [allocation], it behaves exactly like
40
+ /// [`write`][write()], except for the additional guarantee that it won't be elided or reordered
41
+ -/// (see above). This implies that the operation will actually access memory and not e.g. be
42
+ -/// lowered to a register access. Other than that, all the usual rules for memory accesses apply
43
+ -/// (including provenance). In particular, just like in C, whether an operation is volatile has no
44
+ -/// bearing whatsoever on questions involving concurrent access from multiple threads. Volatile
45
+ -/// accesses behave exactly like non-atomic accesses in that regard.
46
+ +/// across other externally observable events (see above). This implies that the operation will
47
+ +/// actually access memory and not e.g. be lowered to a register access. Other than that, all the
48
+ +/// usual rules for memory accesses apply (including provenance). In particular, just like in C,
49
+ +/// whether an operation is volatile has no bearing whatsoever on questions involving concurrent
50
+ +/// access from multiple threads. Volatile accesses behave exactly like non-atomic accesses in
51
+ +/// that regard.
52
+ ///
53
+ /// - Volatile operations, however, may also be used to access memory that is _outside_ of any Rust
54
+ /// allocation. In this use-case, the pointer does *not* have to be [valid] for writes. This is
55
+ @@ -2187,7 +2189,7 @@ pub const unsafe fn read_volatile<T>(src: *const T) -> T {
56
+ /// semantics associated to their manipulation, and cannot be used as general purpose memory.
57
+ /// Here, any address value is possible, including 0 and [`usize::MAX`], so long as the semantics
58
+ /// of such a write are well-defined by the target hardware. The provenance of the pointer is
59
+ -/// irrelevant, and it can be created with [`without_provenance`]. The access must not trap. It
60
+ +/// irrelevant, and it can be created with [`without_provenance_mut`]. The access must not trap. It
61
+ /// can cause side-effects, but those must not affect Rust-allocated memory in any way. This
62
+ /// access is still not considered [atomic], and as such it cannot be used for inter-thread
63
+ /// synchronization.
64
+ diff --git a/library/core/src/sync/atomic.rs b/library/core/src/sync/atomic.rs
65
+ index 12208b95307eec33e0e55795379dddfca46b53e6..8b770528a1736c65838406e4f22b2d98737fa5ae 100644
66
+ --- a/library/core/src/sync/atomic.rs
67
+ +++ b/library/core/src/sync/atomic.rs
68
+ @@ -606,6 +606,16 @@ impl AtomicBool {
69
+ unsafe { &*ptr.cast() }
70
+ }
71
+
72
+ + /// Creates a new pointer to `AtomicBool` from a pointer.
73
+ + ///
74
+ + /// This is useful if you want to do volatile atomic accesses, and thus avoid creating
75
+ + /// a reference to the destination.
76
+ + #[inline]
77
+ + #[unstable(feature = "atomic_volatile", issue = "158947")]
78
+ + pub const fn from_ptr_raw(ptr: *mut bool) -> *const AtomicBool {
79
+ + ptr.cast_const().cast()
80
+ + }
81
+ +
82
+ /// Returns a mutable reference to the underlying [`bool`].
83
+ ///
84
+ /// This is safe because the mutable reference guarantees that no other threads are
85
+ @@ -765,6 +775,40 @@ impl AtomicBool {
86
+ }
87
+ }
88
+
89
+ + /// Perform a volatile atomic load from the bool.
90
+ + ///
91
+ + /// `load_volatile` takes an [`Ordering`] argument which describes the memory ordering
92
+ + /// of this operation. Possible values are [`SeqCst`], [`Acquire`] and [`Relaxed`].
93
+ + ///
94
+ + #[doc = include_str!("./atomic_load_volatile.md")]
95
+ + ///
96
+ + /// # Safety
97
+ + ///
98
+ + /// Behavior is undefined if any of the following conditions are violated:
99
+ + ///
100
+ + /// * `self` must be [valid] for reads, or `self` must point to memory
101
+ + /// outside of all Rust allocations and reading from that memory must:
102
+ + /// - not trap, and
103
+ + /// - not cause any memory inside a Rust allocation to be modified.
104
+ + ///
105
+ + /// * Reading from `self` must produce a properly initialized value of type `bool`.
106
+ + ///
107
+ + /// [valid]: core::ptr#safety
108
+ + ///
109
+ + /// # Panics
110
+ + ///
111
+ + /// Panics if `order` is [`Release`] or [`AcqRel`].
112
+ + #[inline]
113
+ + #[unstable(feature = "atomic_volatile", issue = "158947")]
114
+ + #[rustc_const_unstable(feature = "atomic_volatile", issue = "158947")]
115
+ + #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
116
+ + pub const unsafe fn load_volatile(self: *const Self, order: Ordering) -> bool {
117
+ + // SAFETY: follows from our own safety requirements.
118
+ + unsafe {
119
+ + atomic_load::<_, /* VOLATILE */ true>(self.cast::<u8>(), order) != 0
120
+ + }
121
+ + }
122
+ +
123
+ /// Stores a value into the bool.
124
+ ///
125
+ /// `store` takes an [`Ordering`] argument which describes the memory ordering
126
+ @@ -797,6 +841,39 @@ impl AtomicBool {
127
+ }
128
+ }
129
+
130
+ + /// Performs a volatile atomic store into the bool.
131
+ + ///
132
+ + /// `store_volatile` takes an [`Ordering`] argument which describes the memory ordering
133
+ + /// of this operation. Possible values are [`SeqCst`], [`Release`] and [`Relaxed`].
134
+ + ///
135
+ + #[doc = include_str!("./atomic_store_volatile.md")]
136
+ + ///
137
+ + /// # Safety
138
+ + ///
139
+ + /// Behavior is undefined if any of the following conditions are violated:
140
+ + ///
141
+ + /// * `self` must be either [valid] for writes, or `self` must point to memory
142
+ + /// outside of all Rust allocations and writing to that memory must:
143
+ + /// - not trap, and
144
+ + /// - not cause any memory inside a Rust allocation to be modified.
145
+ + ///
146
+ + /// [valid]: core::ptr#safety
147
+ + ///
148
+ + /// # Panics
149
+ + ///
150
+ + /// Panics if `order` is [`Acquire`] or [`AcqRel`].
151
+ + #[inline]
152
+ + #[unstable(feature = "atomic_volatile", issue = "158947")]
153
+ + #[rustc_const_unstable(feature = "atomic_volatile", issue = "158947")]
154
+ + #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
155
+ + #[rustc_should_not_be_called_on_const_items]
156
+ + pub const unsafe fn store_volatile(self: *const Self, val: bool, order: Ordering) {
157
+ + // SAFETY: follows from our own safety requirements.
158
+ + unsafe {
159
+ + atomic_store::<_, /* VOLATILE */ true>(self.cast::<u8>().cast_mut(), val as u8, order);
160
+ + }
161
+ + }
162
+ +
163
+ /// Stores a value into the bool, returning the previous value.
164
+ ///
165
+ /// `swap` takes an [`Ordering`] argument which describes the memory ordering
166
+ @@ -1567,6 +1644,16 @@ impl<T> AtomicPtr<T> {
167
+ unsafe { &*ptr.cast() }
168
+ }
169
+
170
+ + /// Creates a new pointer to `AtomicPtr` from a pointer.
171
+ + ///
172
+ + /// This is useful if you want to do volatile atomic accesses, and thus avoid creating
173
+ + /// a reference to the destination.
174
+ + #[inline]
175
+ + #[unstable(feature = "atomic_volatile", issue = "158947")]
176
+ + pub const fn from_ptr_raw(ptr: *mut *mut T) -> *const AtomicPtr<T> {
177
+ + ptr.cast_const().cast()
178
+ + }
179
+ +
180
+ /// Creates a new `AtomicPtr` initialized with a null pointer.
181
+ ///
182
+ /// # Examples
183
+ @@ -1770,6 +1857,71 @@ impl<T> AtomicPtr<T> {
184
+ }
185
+ }
186
+
187
+ + /// Perform a volatile atomic load from the pointer.
188
+ + ///
189
+ + /// `load_volatile` takes an [`Ordering`] argument which describes the memory ordering
190
+ + /// of this operation. Possible values are [`SeqCst`], [`Acquire`] and [`Relaxed`].
191
+ + ///
192
+ + #[doc = include_str!("./atomic_load_volatile.md")]
193
+ + ///
194
+ + /// # Safety
195
+ + ///
196
+ + /// Behavior is undefined if any of the following conditions are violated:
197
+ + ///
198
+ + /// * `self` must be [valid] for reads, or `self` must point to memory
199
+ + /// outside of all Rust allocations and reading from that memory must:
200
+ + /// - not trap, and
201
+ + /// - not cause any memory inside a Rust allocation to be modified.
202
+ + ///
203
+ + /// * `self` must be aligned to `align_of::<AtomicPtr<T>>()` (note that on some platforms this
204
+ + /// can be bigger than `align_of::<*mut T>()`).
205
+ + ///
206
+ + /// * Reading from `self` must produce a properly initialized value of type `*mut T`.
207
+ + ///
208
+ + /// [valid]: core::ptr#safety
209
+ + ///
210
+ + /// # Panics
211
+ + ///
212
+ + /// Panics if `order` is [`Release`] or [`AcqRel`].
213
+ + ///
214
+ + /// # Examples
215
+ + ///
216
+ + /// Assuming an MMIO region at `MMIO_ADDR` that belongs to a device with direct memory
217
+ + /// access, we may receive a buffer in shared memory from that device as follows:
218
+ + ///
219
+ + /// ```rust,no_run
220
+ + /// #![feature(atomic_volatile)]
221
+ + /// use std::sync::atomic::{fence, AtomicPtr, Ordering};
222
+ + /// use std::ptr;
223
+ + ///
224
+ + /// const MMIO_ADDR: *mut *mut u8 = ptr::without_provenance_mut(0xCAF0);
225
+ + /// let atomic_ptr = AtomicPtr::<u8>::from_ptr_raw(MMIO_ADDR);
226
+ + ///
227
+ + /// // Spin until we see a non-zero value.
228
+ + /// let buf = 'buf: loop {
229
+ + /// let buf = unsafe { atomic_ptr.load_volatile(Ordering::Relaxed) };
230
+ + /// if !buf.is_null() {
231
+ + /// break 'buf buf;
232
+ + /// }
233
+ + /// };
234
+ + /// // Synchronize with the store whose value we just read.
235
+ + /// // Note: a standard acquire fence may not be sufficient to synchronize with DMA devices.
236
+ + /// // Depending on your target, you may have to use inline assembly to emit a special fence.
237
+ + /// fence(Ordering::Acquire);
238
+ + ///
239
+ + /// // Now process the data in `buf`.
240
+ + /// ```
241
+ + #[inline]
242
+ + #[unstable(feature = "atomic_volatile", issue = "158947")]
243
+ + #[rustc_const_unstable(feature = "atomic_volatile", issue = "158947")]
244
+ + #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
245
+ + pub const unsafe fn load_volatile(self: *const Self, order: Ordering) -> *mut T {
246
+ + // SAFETY: follows from our own safety requirements.
247
+ + unsafe {
248
+ + atomic_load::<_, /* VOLATILE */ true>(self.cast::<*mut T>(), order)
249
+ + }
250
+ + }
251
+ +
252
+ /// Stores a value into the pointer.
253
+ ///
254
+ /// `store` takes an [`Ordering`] argument which describes the memory ordering
255
+ @@ -1803,6 +1955,67 @@ impl<T> AtomicPtr<T> {
256
+ }
257
+ }
258
+
259
+ + /// Performs a volatile atomic store into the pointer.
260
+ + ///
261
+ + /// `store_volatile` takes an [`Ordering`] argument which describes the memory ordering
262
+ + /// of this operation. Possible values are [`SeqCst`], [`Release`] and [`Relaxed`].
263
+ + ///
264
+ + #[doc = include_str!("./atomic_store_volatile.md")]
265
+ + ///
266
+ + /// # Safety
267
+ + ///
268
+ + /// Behavior is undefined if any of the following conditions are violated:
269
+ + ///
270
+ + /// * `self` must be either [valid] for writes, or `self` must point to memory
271
+ + /// outside of all Rust allocations and writing to that memory must:
272
+ + /// - not trap, and
273
+ + /// - not cause any memory inside a Rust allocation to be modified.
274
+ + ///
275
+ + /// * `self` must be aligned to `align_of::<AtomicPtr<T>>()` (note that on some platforms this
276
+ + /// can be bigger than `align_of::<*mut T>()`).
277
+ + ///
278
+ + /// [valid]: core::ptr#safety
279
+ + ///
280
+ + /// # Panics
281
+ + ///
282
+ + /// Panics if `order` is [`Acquire`] or [`AcqRel`].
283
+ + ///
284
+ + /// # Examples
285
+ + ///
286
+ + /// Assuming an MMIO region at `MMIO_ADDR` that belongs to a device with direct memory
287
+ + /// access, we may submit a buffer in shared memory to that device as follows:
288
+ + ///
289
+ + /// ```rust,no_run
290
+ + /// #![feature(atomic_volatile)]
291
+ + /// use std::sync::atomic::{fence, AtomicPtr, Ordering};
292
+ + /// use std::ptr;
293
+ + ///
294
+ + /// const MMIO_ADDR: *mut *mut u8 = ptr::without_provenance_mut(0xCAF0);
295
+ + /// let atomic_ptr = AtomicPtr::<u8>::from_ptr_raw(MMIO_ADDR);
296
+ + ///
297
+ + /// // Prepare some data for the DMA device.
298
+ + /// # fn get_dma_buffer() -> *mut u8 { panic!() }
299
+ + /// let buf = get_dma_buffer();
300
+ + ///
301
+ + /// // Ensure the other side can synchronize with the store we do below.
302
+ + /// // Note: a standard release fence may not be sufficient to synchronize with DMA devices.
303
+ + /// // Depending on your target, you may have to use inline assembly to emit a special fence.
304
+ + /// fence(Ordering::Release);
305
+ + ///
306
+ + /// unsafe { atomic_ptr.store_volatile(buf, Ordering::Relaxed) };
307
+ + /// ```
308
+ + #[inline]
309
+ + #[unstable(feature = "atomic_volatile", issue = "158947")]
310
+ + #[rustc_const_unstable(feature = "atomic_volatile", issue = "158947")]
311
+ + #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
312
+ + #[rustc_should_not_be_called_on_const_items]
313
+ + pub const unsafe fn store_volatile(self: *const Self, ptr: *mut T, order: Ordering) {
314
+ + // SAFETY: follows from our own safety requirements.
315
+ + unsafe {
316
+ + atomic_store::<_, /* VOLATILE */ true>(self.cast::<*mut T>().cast_mut(), ptr, order);
317
+ + }
318
+ + }
319
+ +
320
+ /// Stores a value into the pointer, returning the previous value.
321
+ ///
322
+ /// `swap` takes an [`Ordering`] argument which describes the memory ordering
323
+ @@ -2733,6 +2946,16 @@ macro_rules! atomic_int {
324
+ unsafe { &*ptr.cast() }
325
+ }
326
+
327
+ + /// Creates a new pointer to an atomic integer from a pointer.
328
+ + ///
329
+ + /// This is useful if you want to do volatile atomic accesses, and thus avoid creating
330
+ + /// a reference to the destination.
331
+ + #[inline]
332
+ + #[unstable(feature = "atomic_volatile", issue = "158947")]
333
+ + pub const fn from_ptr_raw(ptr: *mut $int_type) -> *const $atomic_type {
334
+ + ptr.cast_const().cast()
335
+ + }
336
+ +
337
+ /// Returns a mutable reference to the underlying integer.
338
+ ///
339
+ /// This is safe because the mutable reference guarantees that no other threads are
340
+ @@ -2921,6 +3144,55 @@ macro_rules! atomic_int {
341
+ unsafe { atomic_load::<_, /* VOLATILE */ false>(self.as_ptr(), order) }
342
+ }
343
+
344
+ + /// Perform a volatile load from the atomic integer.
345
+ + ///
346
+ + /// `load_volatile` takes an [`Ordering`] argument which describes the memory ordering
347
+ + /// of this operation. Possible values are [`SeqCst`], [`Acquire`] and [`Relaxed`].
348
+ + ///
349
+ + #[doc = include_str!("./atomic_load_volatile.md")]
350
+ + ///
351
+ + /// # Safety
352
+ + ///
353
+ + /// Behavior is undefined if any of the following conditions are violated:
354
+ + ///
355
+ + /// * `self` must be [valid] for reads, or `self` must point to memory
356
+ + /// outside of all Rust allocations and reading from that memory must:
357
+ + /// - not trap, and
358
+ + /// - not cause any memory inside a Rust allocation to be modified.
359
+ + ///
360
+ + /// * `self` must be aligned to
361
+ + #[doc = concat!(" `align_of::<", stringify!($atomic_type), ">()`")]
362
+ + #[doc = if_8_bit!{
363
+ + $int_type,
364
+ + yes = [
365
+ + " (note that this is always true, since `align_of::<",
366
+ + stringify!($atomic_type), ">() == 1`)."
367
+ + ],
368
+ + no = [
369
+ + " (note that on some platforms this can be bigger than `align_of::<",
370
+ + stringify!($int_type), ">()`)."
371
+ + ],
372
+ + }]
373
+ + ///
374
+ + /// * Reading from `self` must produce a properly initialized value of the underlying
375
+ + /// integer type.
376
+ + ///
377
+ + /// [valid]: core::ptr#safety
378
+ + ///
379
+ + /// # Panics
380
+ + ///
381
+ + /// Panics if `order` is [`Release`] or [`AcqRel`].
382
+ + #[inline]
383
+ + #[unstable(feature = "atomic_volatile", issue = "158947")]
384
+ + #[rustc_const_unstable(feature = "atomic_volatile", issue = "158947")]
385
+ + #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
386
+ + pub const unsafe fn load_volatile(self: *const Self, order: Ordering) -> $int_type {
387
+ + // SAFETY: follows from our own safety requirements.
388
+ + unsafe {
389
+ + atomic_load::<_, /* VOLATILE */ true>(self.cast::<$int_type>(), order)
390
+ + }
391
+ + }
392
+ +
393
+ /// Stores a value into the atomic integer.
394
+ ///
395
+ /// `store` takes an [`Ordering`] argument which describes the memory ordering of this operation.
396
+ @@ -2951,6 +3223,53 @@ macro_rules! atomic_int {
397
+ unsafe { atomic_store::<_, /* VOLATILE */ false>(self.as_ptr(), val, order); }
398
+ }
399
+
400
+ + /// Performs a volatile store into the atomic integer.
401
+ + ///
402
+ + /// `store_volatile` takes an [`Ordering`] argument which describes the memory ordering
403
+ + /// of this operation. Possible values are [`SeqCst`], [`Release`] and [`Relaxed`].
404
+ + ///
405
+ + #[doc = include_str!("./atomic_store_volatile.md")]
406
+ + ///
407
+ + /// # Safety
408
+ + ///
409
+ + /// Behavior is undefined if any of the following conditions are violated:
410
+ + ///
411
+ + /// * `self` must be either [valid] for writes, or `self` must point to memory
412
+ + /// outside of all Rust allocations and writing to that memory must:
413
+ + /// - not trap, and
414
+ + /// - not cause any memory inside a Rust allocation to be modified.
415
+ + ///
416
+ + /// * `self` must be aligned to
417
+ + #[doc = concat!(" `align_of::<", stringify!($atomic_type), ">()`")]
418
+ + #[doc = if_8_bit!{
419
+ + $int_type,
420
+ + yes = [
421
+ + " (note that this is always true, since `align_of::<",
422
+ + stringify!($atomic_type), ">() == 1`)."
423
+ + ],
424
+ + no = [
425
+ + " (note that on some platforms this can be bigger than `align_of::<",
426
+ + stringify!($int_type), ">()`)."
427
+ + ],
428
+ + }]
429
+ + ///
430
+ + /// [valid]: core::ptr#safety
431
+ + ///
432
+ + /// # Panics
433
+ + ///
434
+ + /// Panics if `order` is [`Acquire`] or [`AcqRel`].
435
+ + #[inline]
436
+ + #[unstable(feature = "atomic_volatile", issue = "158947")]
437
+ + #[rustc_const_unstable(feature = "atomic_volatile", issue = "158947")]
438
+ + #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
439
+ + #[rustc_should_not_be_called_on_const_items]
440
+ + pub const unsafe fn store_volatile(self: *const Self, val: $int_type, order: Ordering) {
441
+ + // SAFETY: follows from our own safety requirements.
442
+ + unsafe {
443
+ + atomic_store::<_, /* VOLATILE */ true>(self.cast::<$int_type>().cast_mut(), val, order);
444
+ + }
445
+ + }
446
+ +
447
+ /// Stores a value into the atomic integer, returning the previous value.
448
+ ///
449
+ /// `swap` takes an [`Ordering`] argument which describes the memory ordering
450
+ diff --git a/library/core/src/sync/atomic_load_volatile.md b/library/core/src/sync/atomic_load_volatile.md
451
+ new file mode 100644
452
+ index 0000000000000000000000000000000000000000..be02c4bcfeccf729022d944e293093e5b15a3252
453
+ --- /dev/null
454
+ +++ b/library/core/src/sync/atomic_load_volatile.md
455
+ @@ -0,0 +1,29 @@
456
+ +Volatile operations are intended to act on I/O memory. As such, they are considered externally
457
+ +observable events (just like syscalls, but less opaque), and are guaranteed to not be elided or
458
+ +reordered by the compiler across other externally observable events. With this in mind, there
459
+ +are two cases of usage that need to be distinguished:
460
+ +
461
+ +- When a volatile operation is used for memory inside an [allocation], it behaves exactly
462
+ + like [`load`][Self::load], except for the additional guarantee that it won't be elided or
463
+ + reordered across other externally observable events (see above). This implies that the
464
+ + operation will actually access memory and not e.g. be lowered to reusing data from a
465
+ + previous load. Other than that, all the usual rules for memory accesses apply (including
466
+ + provenance).
467
+ +
468
+ +- Volatile operations, however, may also be used to access memory that is _outside_ of any Rust
469
+ + allocation. In this use-case, the pointer does *not* have to be [valid] for reads. This is
470
+ + typically used for CPU and peripheral registers that must be accessed via an I/O memory mapping,
471
+ + most commonly at fixed addresses reserved by the hardware. These often have special semantics
472
+ + associated to their manipulation, and cannot be used as general purpose memory. Here, any address
473
+ + value is possible, including 0 and [`usize::MAX`], so long as the semantics of such a read are
474
+ + well-defined by the target hardware. The provenance of the pointer is irrelevant, and it can be
475
+ + created with [`without_provenance`][crate::ptr::without_provenance]. The access must not trap. It
476
+ + can cause side-effects, but those must not affect Rust-allocated memory in any way.
477
+ +
478
+ +In both cases, the access is also considered atomic with the given `order`. This allows
479
+ +synchronization with other threads or devices that share memory with this program.
480
+ +
481
+ +When invoked during const evaluation, this behaves like a regular atomic load. In
482
+ +particular, such reads must always follow the first of the two cases above.
483
+ +
484
+ +[allocation]: crate::ptr#allocated-object
485
+ diff --git a/library/core/src/sync/atomic_store_volatile.md b/library/core/src/sync/atomic_store_volatile.md
486
+ new file mode 100644
487
+ index 0000000000000000000000000000000000000000..bb78099020c1527998d268975d2095966b7a88ba
488
+ --- /dev/null
489
+ +++ b/library/core/src/sync/atomic_store_volatile.md
490
+ @@ -0,0 +1,28 @@
491
+ +Volatile operations are intended to act on I/O memory. As such, they are considered externally
492
+ +observable events (just like syscalls), and are guaranteed to not be elided or reordered by the
493
+ +compiler across other externally observable events. With this in mind, there are two cases of
494
+ +usage that need to be distinguished:
495
+ +
496
+ +- When a volatile operation is used for memory inside an [allocation], it behaves exactly like
497
+ + [`store`][Self::store], except for the additional guarantee that it won't be elided or reordered
498
+ + across other externally observable events (see above). This implies that the operation will
499
+ + actually access memory and not e.g. be lowered to a register access. Other than that, all the
500
+ + usual rules for memory accesses apply (including provenance).
501
+ +
502
+ +- Volatile operations, however, may also be used to access memory that is _outside_ of any Rust
503
+ + allocation. In this use-case, the pointer does *not* have to be [valid] for writes. This is
504
+ + typically used for CPU and peripheral registers that must be accessed via an I/O memory mapping,
505
+ + most commonly at fixed addresses reserved by the hardware. These often have special semantics
506
+ + associated to their manipulation, and cannot be used as general purpose memory. Here, any address
507
+ + value is possible, including 0 and [`usize::MAX`], so long as the semantics of such a write are
508
+ + well-defined by the target hardware. The provenance of the pointer is irrelevant, and it can be
509
+ + created with [`without_provenance_mut`][crate::ptr::without_provenance_mut]. The access must not
510
+ + trap. It can cause side-effects, but those must not affect Rust-allocated memory in any way.
511
+ +
512
+ +In both cases, the access is also considered atomic with the given `order`. This allows
513
+ +synchronization with other threads or devices that share memory with this program.
514
+ +
515
+ +When invoked during const evaluation, this behaves like a regular atomic store. In
516
+ +particular, such reads must always follow the first of the two cases above.
517
+ +
518
+ +[allocation]: crate::ptr#allocated-object
519
+ diff --git a/library/coretests/tests/atomic.rs b/library/coretests/tests/atomic.rs
520
+ index d888bd0f55a1195c97f118aed980e9e0705cc290..31fe7980510d39a69e764fc0731c83134da8c090 100644
521
+ --- a/library/coretests/tests/atomic.rs
522
+ +++ b/library/coretests/tests/atomic.rs
523
+ @@ -538,6 +538,29 @@ fn atomic_umin() {
524
+ assert_eq!(ATOMIC.load(Relaxed), 0);
525
+ }
526
+
527
+ +#[test]
528
+ +fn atomic_volatile() {
529
+ + use Ordering::*;
530
+ +
531
+ + let mut b = true;
532
+ + let atomic = AtomicBool::from_ptr_raw(&raw mut b);
533
+ + assert!(unsafe { atomic.load_volatile(Relaxed) });
534
+ + unsafe { atomic.store_volatile(false, Relaxed) };
535
+ + assert!(!b);
536
+ +
537
+ + let mut ptr = std::ptr::null_mut::<i32>();
538
+ + let atomic = AtomicPtr::from_ptr_raw(&raw mut ptr);
539
+ + assert!(unsafe { atomic.load_volatile(Relaxed) }.is_null());
540
+ + unsafe { atomic.store_volatile(std::ptr::without_provenance_mut(16), Relaxed) };
541
+ + assert!(ptr.addr() == 16);
542
+ +
543
+ + let mut int = 0i32;
544
+ + let atomic = AtomicI32::from_ptr_raw(&raw mut int);
545
+ + assert!(unsafe { atomic.load_volatile(Relaxed) } == 0);
546
+ + unsafe { atomic.store_volatile(16, Relaxed) };
547
+ + assert!(int == 16);
548
+ +}
549
+ +
550
+ /* FIXME(#110395)
551
+ #[test]
552
+ fn atomic_const_from() {
553
+ diff --git a/library/coretests/tests/lib.rs b/library/coretests/tests/lib.rs
554
+ index e81cae69e18525bc560cb163eaf2923149fd1bfb..142df37c2b7fe20920a3ba22cf2f17dfb071d279 100644
555
+ --- a/library/coretests/tests/lib.rs
556
+ +++ b/library/coretests/tests/lib.rs
557
+ @@ -8,6 +8,7 @@
558
+ #![feature(ascii_char_variants)]
559
+ #![feature(async_iter_from_iter)]
560
+ #![feature(async_iterator)]
561
+ +#![feature(atomic_volatile)]
562
+ #![feature(borrowed_buf_init)]
563
+ #![feature(bstr)]
564
+ #![feature(casefold)]
patches/20261028T105419Z/rust-lang--rust-part009/84eb2cf29b4891230b4d6faffa4225600f81b584.patch ADDED
@@ -0,0 +1,564 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs
2
+ index 9857a3b8cfae69796390f8a64b66b743d60a4a17..ba6d786fbbd89042b3cee11901122d30a8ea3809 100644
3
+ --- a/library/core/src/lib.rs
4
+ +++ b/library/core/src/lib.rs
5
+ @@ -108,6 +108,7 @@
6
+ #![feature(adt_const_params)]
7
+ #![feature(allow_internal_unsafe)]
8
+ #![feature(allow_internal_unstable)]
9
+ +#![feature(arbitrary_self_types_pointers)]
10
+ #![feature(auto_traits)]
11
+ #![feature(cfg_sanitize)]
12
+ #![feature(cfg_target_has_atomic)]
13
+ diff --git a/library/core/src/ptr/mod.rs b/library/core/src/ptr/mod.rs
14
+ index aedab87449ff58a0adf68d569a768f0eb5344441..f1b81de50942a2a7eb1c7d89e329341741789f90 100644
15
+ --- a/library/core/src/ptr/mod.rs
16
+ +++ b/library/core/src/ptr/mod.rs
17
+ @@ -2067,12 +2067,13 @@ pub const unsafe fn write_unaligned<T>(dst: *mut T, src: T) {
18
+ /// are two cases of usage that need to be distinguished:
19
+ ///
20
+ /// - When a volatile operation is used for memory inside an [allocation], it behaves exactly like
21
+ -/// [`read`], except for the additional guarantee that it won't be elided or reordered (see
22
+ -/// above). This implies that the operation will actually access memory and not e.g. be lowered to
23
+ -/// reusing data from a previous read. Other than that, all the usual rules for memory accesses
24
+ -/// apply (including provenance). In particular, just like in C, whether an operation is volatile
25
+ -/// has no bearing whatsoever on questions involving concurrent accesses from multiple threads.
26
+ -/// Volatile accesses behave exactly like non-atomic accesses in that regard.
27
+ +/// [`read`], except for the additional guarantee that it won't be elided or reordered across
28
+ +/// other externally observable events (see above). This implies that the operation will actually
29
+ +/// access memory and not e.g. be lowered to reusing data from a previous read. Other than that,
30
+ +/// all the usual rules for memory accesses apply (including provenance). In particular, just
31
+ +/// like in C, whether an operation is volatile has no bearing whatsoever on questions involving
32
+ +/// concurrent accesses from multiple threads. Volatile accesses behave exactly like non-atomic
33
+ +/// accesses in that regard.
34
+ ///
35
+ /// - Volatile operations, however, may also be used to access memory that is _outside_ of any Rust
36
+ /// allocation. In this use-case, the pointer does *not* have to be [valid] for reads. This is
37
+ @@ -2174,11 +2175,12 @@ pub const unsafe fn read_volatile<T>(src: *const T) -> T {
38
+ ///
39
+ /// - When a volatile operation is used for memory inside an [allocation], it behaves exactly like
40
+ /// [`write`][write()], except for the additional guarantee that it won't be elided or reordered
41
+ -/// (see above). This implies that the operation will actually access memory and not e.g. be
42
+ -/// lowered to a register access. Other than that, all the usual rules for memory accesses apply
43
+ -/// (including provenance). In particular, just like in C, whether an operation is volatile has no
44
+ -/// bearing whatsoever on questions involving concurrent access from multiple threads. Volatile
45
+ -/// accesses behave exactly like non-atomic accesses in that regard.
46
+ +/// across other externally observable events (see above). This implies that the operation will
47
+ +/// actually access memory and not e.g. be lowered to a register access. Other than that, all the
48
+ +/// usual rules for memory accesses apply (including provenance). In particular, just like in C,
49
+ +/// whether an operation is volatile has no bearing whatsoever on questions involving concurrent
50
+ +/// access from multiple threads. Volatile accesses behave exactly like non-atomic accesses in
51
+ +/// that regard.
52
+ ///
53
+ /// - Volatile operations, however, may also be used to access memory that is _outside_ of any Rust
54
+ /// allocation. In this use-case, the pointer does *not* have to be [valid] for writes. This is
55
+ @@ -2187,7 +2189,7 @@ pub const unsafe fn read_volatile<T>(src: *const T) -> T {
56
+ /// semantics associated to their manipulation, and cannot be used as general purpose memory.
57
+ /// Here, any address value is possible, including 0 and [`usize::MAX`], so long as the semantics
58
+ /// of such a write are well-defined by the target hardware. The provenance of the pointer is
59
+ -/// irrelevant, and it can be created with [`without_provenance`]. The access must not trap. It
60
+ +/// irrelevant, and it can be created with [`without_provenance_mut`]. The access must not trap. It
61
+ /// can cause side-effects, but those must not affect Rust-allocated memory in any way. This
62
+ /// access is still not considered [atomic], and as such it cannot be used for inter-thread
63
+ /// synchronization.
64
+ diff --git a/library/core/src/sync/atomic.rs b/library/core/src/sync/atomic.rs
65
+ index 12208b95307eec33e0e55795379dddfca46b53e6..8b770528a1736c65838406e4f22b2d98737fa5ae 100644
66
+ --- a/library/core/src/sync/atomic.rs
67
+ +++ b/library/core/src/sync/atomic.rs
68
+ @@ -606,6 +606,16 @@ impl AtomicBool {
69
+ unsafe { &*ptr.cast() }
70
+ }
71
+
72
+ + /// Creates a new pointer to `AtomicBool` from a pointer.
73
+ + ///
74
+ + /// This is useful if you want to do volatile atomic accesses, and thus avoid creating
75
+ + /// a reference to the destination.
76
+ + #[inline]
77
+ + #[unstable(feature = "atomic_volatile", issue = "158947")]
78
+ + pub const fn from_ptr_raw(ptr: *mut bool) -> *const AtomicBool {
79
+ + ptr.cast_const().cast()
80
+ + }
81
+ +
82
+ /// Returns a mutable reference to the underlying [`bool`].
83
+ ///
84
+ /// This is safe because the mutable reference guarantees that no other threads are
85
+ @@ -765,6 +775,40 @@ impl AtomicBool {
86
+ }
87
+ }
88
+
89
+ + /// Perform a volatile atomic load from the bool.
90
+ + ///
91
+ + /// `load_volatile` takes an [`Ordering`] argument which describes the memory ordering
92
+ + /// of this operation. Possible values are [`SeqCst`], [`Acquire`] and [`Relaxed`].
93
+ + ///
94
+ + #[doc = include_str!("./atomic_load_volatile.md")]
95
+ + ///
96
+ + /// # Safety
97
+ + ///
98
+ + /// Behavior is undefined if any of the following conditions are violated:
99
+ + ///
100
+ + /// * `self` must be [valid] for reads, or `self` must point to memory
101
+ + /// outside of all Rust allocations and reading from that memory must:
102
+ + /// - not trap, and
103
+ + /// - not cause any memory inside a Rust allocation to be modified.
104
+ + ///
105
+ + /// * Reading from `self` must produce a properly initialized value of type `bool`.
106
+ + ///
107
+ + /// [valid]: core::ptr#safety
108
+ + ///
109
+ + /// # Panics
110
+ + ///
111
+ + /// Panics if `order` is [`Release`] or [`AcqRel`].
112
+ + #[inline]
113
+ + #[unstable(feature = "atomic_volatile", issue = "158947")]
114
+ + #[rustc_const_unstable(feature = "atomic_volatile", issue = "158947")]
115
+ + #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
116
+ + pub const unsafe fn load_volatile(self: *const Self, order: Ordering) -> bool {
117
+ + // SAFETY: follows from our own safety requirements.
118
+ + unsafe {
119
+ + atomic_load::<_, /* VOLATILE */ true>(self.cast::<u8>(), order) != 0
120
+ + }
121
+ + }
122
+ +
123
+ /// Stores a value into the bool.
124
+ ///
125
+ /// `store` takes an [`Ordering`] argument which describes the memory ordering
126
+ @@ -797,6 +841,39 @@ impl AtomicBool {
127
+ }
128
+ }
129
+
130
+ + /// Performs a volatile atomic store into the bool.
131
+ + ///
132
+ + /// `store_volatile` takes an [`Ordering`] argument which describes the memory ordering
133
+ + /// of this operation. Possible values are [`SeqCst`], [`Release`] and [`Relaxed`].
134
+ + ///
135
+ + #[doc = include_str!("./atomic_store_volatile.md")]
136
+ + ///
137
+ + /// # Safety
138
+ + ///
139
+ + /// Behavior is undefined if any of the following conditions are violated:
140
+ + ///
141
+ + /// * `self` must be either [valid] for writes, or `self` must point to memory
142
+ + /// outside of all Rust allocations and writing to that memory must:
143
+ + /// - not trap, and
144
+ + /// - not cause any memory inside a Rust allocation to be modified.
145
+ + ///
146
+ + /// [valid]: core::ptr#safety
147
+ + ///
148
+ + /// # Panics
149
+ + ///
150
+ + /// Panics if `order` is [`Acquire`] or [`AcqRel`].
151
+ + #[inline]
152
+ + #[unstable(feature = "atomic_volatile", issue = "158947")]
153
+ + #[rustc_const_unstable(feature = "atomic_volatile", issue = "158947")]
154
+ + #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
155
+ + #[rustc_should_not_be_called_on_const_items]
156
+ + pub const unsafe fn store_volatile(self: *const Self, val: bool, order: Ordering) {
157
+ + // SAFETY: follows from our own safety requirements.
158
+ + unsafe {
159
+ + atomic_store::<_, /* VOLATILE */ true>(self.cast::<u8>().cast_mut(), val as u8, order);
160
+ + }
161
+ + }
162
+ +
163
+ /// Stores a value into the bool, returning the previous value.
164
+ ///
165
+ /// `swap` takes an [`Ordering`] argument which describes the memory ordering
166
+ @@ -1567,6 +1644,16 @@ impl<T> AtomicPtr<T> {
167
+ unsafe { &*ptr.cast() }
168
+ }
169
+
170
+ + /// Creates a new pointer to `AtomicPtr` from a pointer.
171
+ + ///
172
+ + /// This is useful if you want to do volatile atomic accesses, and thus avoid creating
173
+ + /// a reference to the destination.
174
+ + #[inline]
175
+ + #[unstable(feature = "atomic_volatile", issue = "158947")]
176
+ + pub const fn from_ptr_raw(ptr: *mut *mut T) -> *const AtomicPtr<T> {
177
+ + ptr.cast_const().cast()
178
+ + }
179
+ +
180
+ /// Creates a new `AtomicPtr` initialized with a null pointer.
181
+ ///
182
+ /// # Examples
183
+ @@ -1770,6 +1857,71 @@ impl<T> AtomicPtr<T> {
184
+ }
185
+ }
186
+
187
+ + /// Perform a volatile atomic load from the pointer.
188
+ + ///
189
+ + /// `load_volatile` takes an [`Ordering`] argument which describes the memory ordering
190
+ + /// of this operation. Possible values are [`SeqCst`], [`Acquire`] and [`Relaxed`].
191
+ + ///
192
+ + #[doc = include_str!("./atomic_load_volatile.md")]
193
+ + ///
194
+ + /// # Safety
195
+ + ///
196
+ + /// Behavior is undefined if any of the following conditions are violated:
197
+ + ///
198
+ + /// * `self` must be [valid] for reads, or `self` must point to memory
199
+ + /// outside of all Rust allocations and reading from that memory must:
200
+ + /// - not trap, and
201
+ + /// - not cause any memory inside a Rust allocation to be modified.
202
+ + ///
203
+ + /// * `self` must be aligned to `align_of::<AtomicPtr<T>>()` (note that on some platforms this
204
+ + /// can be bigger than `align_of::<*mut T>()`).
205
+ + ///
206
+ + /// * Reading from `self` must produce a properly initialized value of type `*mut T`.
207
+ + ///
208
+ + /// [valid]: core::ptr#safety
209
+ + ///
210
+ + /// # Panics
211
+ + ///
212
+ + /// Panics if `order` is [`Release`] or [`AcqRel`].
213
+ + ///
214
+ + /// # Examples
215
+ + ///
216
+ + /// Assuming an MMIO region at `MMIO_ADDR` that belongs to a device with direct memory
217
+ + /// access, we may receive a buffer in shared memory from that device as follows:
218
+ + ///
219
+ + /// ```rust,no_run
220
+ + /// #![feature(atomic_volatile)]
221
+ + /// use std::sync::atomic::{fence, AtomicPtr, Ordering};
222
+ + /// use std::ptr;
223
+ + ///
224
+ + /// const MMIO_ADDR: *mut *mut u8 = ptr::without_provenance_mut(0xCAF0);
225
+ + /// let atomic_ptr = AtomicPtr::<u8>::from_ptr_raw(MMIO_ADDR);
226
+ + ///
227
+ + /// // Spin until we see a non-zero value.
228
+ + /// let buf = 'buf: loop {
229
+ + /// let buf = unsafe { atomic_ptr.load_volatile(Ordering::Relaxed) };
230
+ + /// if !buf.is_null() {
231
+ + /// break 'buf buf;
232
+ + /// }
233
+ + /// };
234
+ + /// // Synchronize with the store whose value we just read.
235
+ + /// // Note: a standard acquire fence may not be sufficient to synchronize with DMA devices.
236
+ + /// // Depending on your target, you may have to use inline assembly to emit a special fence.
237
+ + /// fence(Ordering::Acquire);
238
+ + ///
239
+ + /// // Now process the data in `buf`.
240
+ + /// ```
241
+ + #[inline]
242
+ + #[unstable(feature = "atomic_volatile", issue = "158947")]
243
+ + #[rustc_const_unstable(feature = "atomic_volatile", issue = "158947")]
244
+ + #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
245
+ + pub const unsafe fn load_volatile(self: *const Self, order: Ordering) -> *mut T {
246
+ + // SAFETY: follows from our own safety requirements.
247
+ + unsafe {
248
+ + atomic_load::<_, /* VOLATILE */ true>(self.cast::<*mut T>(), order)
249
+ + }
250
+ + }
251
+ +
252
+ /// Stores a value into the pointer.
253
+ ///
254
+ /// `store` takes an [`Ordering`] argument which describes the memory ordering
255
+ @@ -1803,6 +1955,67 @@ impl<T> AtomicPtr<T> {
256
+ }
257
+ }
258
+
259
+ + /// Performs a volatile atomic store into the pointer.
260
+ + ///
261
+ + /// `store_volatile` takes an [`Ordering`] argument which describes the memory ordering
262
+ + /// of this operation. Possible values are [`SeqCst`], [`Release`] and [`Relaxed`].
263
+ + ///
264
+ + #[doc = include_str!("./atomic_store_volatile.md")]
265
+ + ///
266
+ + /// # Safety
267
+ + ///
268
+ + /// Behavior is undefined if any of the following conditions are violated:
269
+ + ///
270
+ + /// * `self` must be either [valid] for writes, or `self` must point to memory
271
+ + /// outside of all Rust allocations and writing to that memory must:
272
+ + /// - not trap, and
273
+ + /// - not cause any memory inside a Rust allocation to be modified.
274
+ + ///
275
+ + /// * `self` must be aligned to `align_of::<AtomicPtr<T>>()` (note that on some platforms this
276
+ + /// can be bigger than `align_of::<*mut T>()`).
277
+ + ///
278
+ + /// [valid]: core::ptr#safety
279
+ + ///
280
+ + /// # Panics
281
+ + ///
282
+ + /// Panics if `order` is [`Acquire`] or [`AcqRel`].
283
+ + ///
284
+ + /// # Examples
285
+ + ///
286
+ + /// Assuming an MMIO region at `MMIO_ADDR` that belongs to a device with direct memory
287
+ + /// access, we may submit a buffer in shared memory to that device as follows:
288
+ + ///
289
+ + /// ```rust,no_run
290
+ + /// #![feature(atomic_volatile)]
291
+ + /// use std::sync::atomic::{fence, AtomicPtr, Ordering};
292
+ + /// use std::ptr;
293
+ + ///
294
+ + /// const MMIO_ADDR: *mut *mut u8 = ptr::without_provenance_mut(0xCAF0);
295
+ + /// let atomic_ptr = AtomicPtr::<u8>::from_ptr_raw(MMIO_ADDR);
296
+ + ///
297
+ + /// // Prepare some data for the DMA device.
298
+ + /// # fn get_dma_buffer() -> *mut u8 { panic!() }
299
+ + /// let buf = get_dma_buffer();
300
+ + ///
301
+ + /// // Ensure the other side can synchronize with the store we do below.
302
+ + /// // Note: a standard release fence may not be sufficient to synchronize with DMA devices.
303
+ + /// // Depending on your target, you may have to use inline assembly to emit a special fence.
304
+ + /// fence(Ordering::Release);
305
+ + ///
306
+ + /// unsafe { atomic_ptr.store_volatile(buf, Ordering::Relaxed) };
307
+ + /// ```
308
+ + #[inline]
309
+ + #[unstable(feature = "atomic_volatile", issue = "158947")]
310
+ + #[rustc_const_unstable(feature = "atomic_volatile", issue = "158947")]
311
+ + #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
312
+ + #[rustc_should_not_be_called_on_const_items]
313
+ + pub const unsafe fn store_volatile(self: *const Self, ptr: *mut T, order: Ordering) {
314
+ + // SAFETY: follows from our own safety requirements.
315
+ + unsafe {
316
+ + atomic_store::<_, /* VOLATILE */ true>(self.cast::<*mut T>().cast_mut(), ptr, order);
317
+ + }
318
+ + }
319
+ +
320
+ /// Stores a value into the pointer, returning the previous value.
321
+ ///
322
+ /// `swap` takes an [`Ordering`] argument which describes the memory ordering
323
+ @@ -2733,6 +2946,16 @@ macro_rules! atomic_int {
324
+ unsafe { &*ptr.cast() }
325
+ }
326
+
327
+ + /// Creates a new pointer to an atomic integer from a pointer.
328
+ + ///
329
+ + /// This is useful if you want to do volatile atomic accesses, and thus avoid creating
330
+ + /// a reference to the destination.
331
+ + #[inline]
332
+ + #[unstable(feature = "atomic_volatile", issue = "158947")]
333
+ + pub const fn from_ptr_raw(ptr: *mut $int_type) -> *const $atomic_type {
334
+ + ptr.cast_const().cast()
335
+ + }
336
+ +
337
+ /// Returns a mutable reference to the underlying integer.
338
+ ///
339
+ /// This is safe because the mutable reference guarantees that no other threads are
340
+ @@ -2921,6 +3144,55 @@ macro_rules! atomic_int {
341
+ unsafe { atomic_load::<_, /* VOLATILE */ false>(self.as_ptr(), order) }
342
+ }
343
+
344
+ + /// Perform a volatile load from the atomic integer.
345
+ + ///
346
+ + /// `load_volatile` takes an [`Ordering`] argument which describes the memory ordering
347
+ + /// of this operation. Possible values are [`SeqCst`], [`Acquire`] and [`Relaxed`].
348
+ + ///
349
+ + #[doc = include_str!("./atomic_load_volatile.md")]
350
+ + ///
351
+ + /// # Safety
352
+ + ///
353
+ + /// Behavior is undefined if any of the following conditions are violated:
354
+ + ///
355
+ + /// * `self` must be [valid] for reads, or `self` must point to memory
356
+ + /// outside of all Rust allocations and reading from that memory must:
357
+ + /// - not trap, and
358
+ + /// - not cause any memory inside a Rust allocation to be modified.
359
+ + ///
360
+ + /// * `self` must be aligned to
361
+ + #[doc = concat!(" `align_of::<", stringify!($atomic_type), ">()`")]
362
+ + #[doc = if_8_bit!{
363
+ + $int_type,
364
+ + yes = [
365
+ + " (note that this is always true, since `align_of::<",
366
+ + stringify!($atomic_type), ">() == 1`)."
367
+ + ],
368
+ + no = [
369
+ + " (note that on some platforms this can be bigger than `align_of::<",
370
+ + stringify!($int_type), ">()`)."
371
+ + ],
372
+ + }]
373
+ + ///
374
+ + /// * Reading from `self` must produce a properly initialized value of the underlying
375
+ + /// integer type.
376
+ + ///
377
+ + /// [valid]: core::ptr#safety
378
+ + ///
379
+ + /// # Panics
380
+ + ///
381
+ + /// Panics if `order` is [`Release`] or [`AcqRel`].
382
+ + #[inline]
383
+ + #[unstable(feature = "atomic_volatile", issue = "158947")]
384
+ + #[rustc_const_unstable(feature = "atomic_volatile", issue = "158947")]
385
+ + #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
386
+ + pub const unsafe fn load_volatile(self: *const Self, order: Ordering) -> $int_type {
387
+ + // SAFETY: follows from our own safety requirements.
388
+ + unsafe {
389
+ + atomic_load::<_, /* VOLATILE */ true>(self.cast::<$int_type>(), order)
390
+ + }
391
+ + }
392
+ +
393
+ /// Stores a value into the atomic integer.
394
+ ///
395
+ /// `store` takes an [`Ordering`] argument which describes the memory ordering of this operation.
396
+ @@ -2951,6 +3223,53 @@ macro_rules! atomic_int {
397
+ unsafe { atomic_store::<_, /* VOLATILE */ false>(self.as_ptr(), val, order); }
398
+ }
399
+
400
+ + /// Performs a volatile store into the atomic integer.
401
+ + ///
402
+ + /// `store_volatile` takes an [`Ordering`] argument which describes the memory ordering
403
+ + /// of this operation. Possible values are [`SeqCst`], [`Release`] and [`Relaxed`].
404
+ + ///
405
+ + #[doc = include_str!("./atomic_store_volatile.md")]
406
+ + ///
407
+ + /// # Safety
408
+ + ///
409
+ + /// Behavior is undefined if any of the following conditions are violated:
410
+ + ///
411
+ + /// * `self` must be either [valid] for writes, or `self` must point to memory
412
+ + /// outside of all Rust allocations and writing to that memory must:
413
+ + /// - not trap, and
414
+ + /// - not cause any memory inside a Rust allocation to be modified.
415
+ + ///
416
+ + /// * `self` must be aligned to
417
+ + #[doc = concat!(" `align_of::<", stringify!($atomic_type), ">()`")]
418
+ + #[doc = if_8_bit!{
419
+ + $int_type,
420
+ + yes = [
421
+ + " (note that this is always true, since `align_of::<",
422
+ + stringify!($atomic_type), ">() == 1`)."
423
+ + ],
424
+ + no = [
425
+ + " (note that on some platforms this can be bigger than `align_of::<",
426
+ + stringify!($int_type), ">()`)."
427
+ + ],
428
+ + }]
429
+ + ///
430
+ + /// [valid]: core::ptr#safety
431
+ + ///
432
+ + /// # Panics
433
+ + ///
434
+ + /// Panics if `order` is [`Acquire`] or [`AcqRel`].
435
+ + #[inline]
436
+ + #[unstable(feature = "atomic_volatile", issue = "158947")]
437
+ + #[rustc_const_unstable(feature = "atomic_volatile", issue = "158947")]
438
+ + #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
439
+ + #[rustc_should_not_be_called_on_const_items]
440
+ + pub const unsafe fn store_volatile(self: *const Self, val: $int_type, order: Ordering) {
441
+ + // SAFETY: follows from our own safety requirements.
442
+ + unsafe {
443
+ + atomic_store::<_, /* VOLATILE */ true>(self.cast::<$int_type>().cast_mut(), val, order);
444
+ + }
445
+ + }
446
+ +
447
+ /// Stores a value into the atomic integer, returning the previous value.
448
+ ///
449
+ /// `swap` takes an [`Ordering`] argument which describes the memory ordering
450
+ diff --git a/library/core/src/sync/atomic_load_volatile.md b/library/core/src/sync/atomic_load_volatile.md
451
+ new file mode 100644
452
+ index 0000000000000000000000000000000000000000..be02c4bcfeccf729022d944e293093e5b15a3252
453
+ --- /dev/null
454
+ +++ b/library/core/src/sync/atomic_load_volatile.md
455
+ @@ -0,0 +1,29 @@
456
+ +Volatile operations are intended to act on I/O memory. As such, they are considered externally
457
+ +observable events (just like syscalls, but less opaque), and are guaranteed to not be elided or
458
+ +reordered by the compiler across other externally observable events. With this in mind, there
459
+ +are two cases of usage that need to be distinguished:
460
+ +
461
+ +- When a volatile operation is used for memory inside an [allocation], it behaves exactly
462
+ + like [`load`][Self::load], except for the additional guarantee that it won't be elided or
463
+ + reordered across other externally observable events (see above). This implies that the
464
+ + operation will actually access memory and not e.g. be lowered to reusing data from a
465
+ + previous load. Other than that, all the usual rules for memory accesses apply (including
466
+ + provenance).
467
+ +
468
+ +- Volatile operations, however, may also be used to access memory that is _outside_ of any Rust
469
+ + allocation. In this use-case, the pointer does *not* have to be [valid] for reads. This is
470
+ + typically used for CPU and peripheral registers that must be accessed via an I/O memory mapping,
471
+ + most commonly at fixed addresses reserved by the hardware. These often have special semantics
472
+ + associated to their manipulation, and cannot be used as general purpose memory. Here, any address
473
+ + value is possible, including 0 and [`usize::MAX`], so long as the semantics of such a read are
474
+ + well-defined by the target hardware. The provenance of the pointer is irrelevant, and it can be
475
+ + created with [`without_provenance`][crate::ptr::without_provenance]. The access must not trap. It
476
+ + can cause side-effects, but those must not affect Rust-allocated memory in any way.
477
+ +
478
+ +In both cases, the access is also considered atomic with the given `order`. This allows
479
+ +synchronization with other threads or devices that share memory with this program.
480
+ +
481
+ +When invoked during const evaluation, this behaves like a regular atomic load. In
482
+ +particular, such reads must always follow the first of the two cases above.
483
+ +
484
+ +[allocation]: crate::ptr#allocated-object
485
+ diff --git a/library/core/src/sync/atomic_store_volatile.md b/library/core/src/sync/atomic_store_volatile.md
486
+ new file mode 100644
487
+ index 0000000000000000000000000000000000000000..bb78099020c1527998d268975d2095966b7a88ba
488
+ --- /dev/null
489
+ +++ b/library/core/src/sync/atomic_store_volatile.md
490
+ @@ -0,0 +1,28 @@
491
+ +Volatile operations are intended to act on I/O memory. As such, they are considered externally
492
+ +observable events (just like syscalls), and are guaranteed to not be elided or reordered by the
493
+ +compiler across other externally observable events. With this in mind, there are two cases of
494
+ +usage that need to be distinguished:
495
+ +
496
+ +- When a volatile operation is used for memory inside an [allocation], it behaves exactly like
497
+ + [`store`][Self::store], except for the additional guarantee that it won't be elided or reordered
498
+ + across other externally observable events (see above). This implies that the operation will
499
+ + actually access memory and not e.g. be lowered to a register access. Other than that, all the
500
+ + usual rules for memory accesses apply (including provenance).
501
+ +
502
+ +- Volatile operations, however, may also be used to access memory that is _outside_ of any Rust
503
+ + allocation. In this use-case, the pointer does *not* have to be [valid] for writes. This is
504
+ + typically used for CPU and peripheral registers that must be accessed via an I/O memory mapping,
505
+ + most commonly at fixed addresses reserved by the hardware. These often have special semantics
506
+ + associated to their manipulation, and cannot be used as general purpose memory. Here, any address
507
+ + value is possible, including 0 and [`usize::MAX`], so long as the semantics of such a write are
508
+ + well-defined by the target hardware. The provenance of the pointer is irrelevant, and it can be
509
+ + created with [`without_provenance_mut`][crate::ptr::without_provenance_mut]. The access must not
510
+ + trap. It can cause side-effects, but those must not affect Rust-allocated memory in any way.
511
+ +
512
+ +In both cases, the access is also considered atomic with the given `order`. This allows
513
+ +synchronization with other threads or devices that share memory with this program.
514
+ +
515
+ +When invoked during const evaluation, this behaves like a regular atomic store. In
516
+ +particular, such reads must always follow the first of the two cases above.
517
+ +
518
+ +[allocation]: crate::ptr#allocated-object
519
+ diff --git a/library/coretests/tests/atomic.rs b/library/coretests/tests/atomic.rs
520
+ index d888bd0f55a1195c97f118aed980e9e0705cc290..31fe7980510d39a69e764fc0731c83134da8c090 100644
521
+ --- a/library/coretests/tests/atomic.rs
522
+ +++ b/library/coretests/tests/atomic.rs
523
+ @@ -538,6 +538,29 @@ fn atomic_umin() {
524
+ assert_eq!(ATOMIC.load(Relaxed), 0);
525
+ }
526
+
527
+ +#[test]
528
+ +fn atomic_volatile() {
529
+ + use Ordering::*;
530
+ +
531
+ + let mut b = true;
532
+ + let atomic = AtomicBool::from_ptr_raw(&raw mut b);
533
+ + assert!(unsafe { atomic.load_volatile(Relaxed) });
534
+ + unsafe { atomic.store_volatile(false, Relaxed) };
535
+ + assert!(!b);
536
+ +
537
+ + let mut ptr = std::ptr::null_mut::<i32>();
538
+ + let atomic = AtomicPtr::from_ptr_raw(&raw mut ptr);
539
+ + assert!(unsafe { atomic.load_volatile(Relaxed) }.is_null());
540
+ + unsafe { atomic.store_volatile(std::ptr::without_provenance_mut(16), Relaxed) };
541
+ + assert!(ptr.addr() == 16);
542
+ +
543
+ + let mut int = 0i32;
544
+ + let atomic = AtomicI32::from_ptr_raw(&raw mut int);
545
+ + assert!(unsafe { atomic.load_volatile(Relaxed) } == 0);
546
+ + unsafe { atomic.store_volatile(16, Relaxed) };
547
+ + assert!(int == 16);
548
+ +}
549
+ +
550
+ /* FIXME(#110395)
551
+ #[test]
552
+ fn atomic_const_from() {
553
+ diff --git a/library/coretests/tests/lib.rs b/library/coretests/tests/lib.rs
554
+ index e81cae69e18525bc560cb163eaf2923149fd1bfb..142df37c2b7fe20920a3ba22cf2f17dfb071d279 100644
555
+ --- a/library/coretests/tests/lib.rs
556
+ +++ b/library/coretests/tests/lib.rs
557
+ @@ -8,6 +8,7 @@
558
+ #![feature(ascii_char_variants)]
559
+ #![feature(async_iter_from_iter)]
560
+ #![feature(async_iterator)]
561
+ +#![feature(atomic_volatile)]
562
+ #![feature(borrowed_buf_init)]
563
+ #![feature(bstr)]
564
+ #![feature(casefold)]
patches/20261028T105419Z/rust-lang--rust-part009/8517e0f05f445518a924e4c93a390c4ac532e1f5.patch ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ diff --git a/src/tools/rust-analyzer/.github/workflows/ci.yaml b/src/tools/rust-analyzer/.github/workflows/ci.yaml
2
+ index 14582f8405f55236d750ad73a6b57ee0bd80815e..7ea734e7ef1c0e618c03c54ac317a7e3524fa1b5 100644
3
+ --- a/src/tools/rust-analyzer/.github/workflows/ci.yaml
4
+ +++ b/src/tools/rust-analyzer/.github/workflows/ci.yaml
5
+ @@ -41,7 +41,11 @@ jobs:
6
+ proc-macro-srv:
7
+ if: github.repository == 'rust-lang/rust-analyzer'
8
+ name: proc-macro-srv
9
+ - runs-on: ubuntu-latest
10
+ + runs-on: ${{ matrix.os }}
11
+ +
12
+ + strategy:
13
+ + matrix:
14
+ + os: [ubuntu-latest, windows-latest]
15
+
16
+ steps:
17
+ - name: Checkout repository
patches/20261028T105419Z/rust-lang--rust-part009/85eaa63195a932c731059139342153c1a55a3ddd.patch ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs
2
+ index 1c4f0ca5069dfaaeaba18c296b875fcb8666beac..11b051b530198719b55302c7c694f0ab4a888df2 100644
3
+ --- a/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs
4
+ +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs
5
+ @@ -657,6 +657,15 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
6
+ span_bug!(span, "coerce requirement gave wrong error: `{:?}`", predicate)
7
+ }
8
+
9
+ + ty::PredicateKind::Clause(ty::ClauseKind::TypeOutlives(..))
10
+ + if self.next_trait_solver() =>
11
+ + {
12
+ + // We normalize `TypeOutlives` in the next solver, which is fallible
13
+ + return self.dcx().span_delayed_bug(
14
+ + span,
15
+ + "type outlives claues errored outside borrowck without any other error",
16
+ + );
17
+ + }
18
+ ty::PredicateKind::Clause(ty::ClauseKind::RegionOutlives(..))
19
+ | ty::PredicateKind::Clause(ty::ClauseKind::TypeOutlives(..)) => {
20
+ span_bug!(
21
+ diff --git a/tests/ui/traits/next-solver/outlives-goal-error-due-to-normalization-failure-no-ice.rs b/tests/ui/traits/next-solver/outlives-goal-error-due-to-normalization-failure-no-ice.rs
22
+ new file mode 100644
23
+ index 0000000000000000000000000000000000000000..61a9a1df8e8eedfc5f54437bdeb438ac86807bda
24
+ --- /dev/null
25
+ +++ b/tests/ui/traits/next-solver/outlives-goal-error-due-to-normalization-failure-no-ice.rs
26
+ @@ -0,0 +1,13 @@
27
+ +//@ compile-flags: -Znext-solver
28
+ +
29
+ +// Regression test for <https://github.com/rust-lang/rust/issues/161527>
30
+ +
31
+ +trait Z<'a, T: ?Sized>
32
+ +where
33
+ + T: Z<'a, ()>, //~ ERROR: the trait bound `(): Z<'a, ()>` is not satisfied
34
+ + for<'b> <T as Z<'b, ()>>::W: 'a,
35
+ +{
36
+ + type W;
37
+ +}
38
+ +
39
+ +fn main() {}
40
+ diff --git a/tests/ui/traits/next-solver/outlives-goal-error-due-to-normalization-failure-no-ice.stderr b/tests/ui/traits/next-solver/outlives-goal-error-due-to-normalization-failure-no-ice.stderr
41
+ new file mode 100644
42
+ index 0000000000000000000000000000000000000000..80f1a9328d5e05a12416b1587b971ee75361d040
43
+ --- /dev/null
44
+ +++ b/tests/ui/traits/next-solver/outlives-goal-error-due-to-normalization-failure-no-ice.stderr
45
+ @@ -0,0 +1,23 @@
46
+ +error[E0277]: the trait bound `(): Z<'a, ()>` is not satisfied
47
+ + --> $DIR/outlives-goal-error-due-to-normalization-failure-no-ice.rs:7:8
48
+ + |
49
+ +LL | T: Z<'a, ()>,
50
+ + | ^^^^^^^^^ the trait `Z<'a, ()>` is not implemented for `()`
51
+ + |
52
+ +help: this trait has no implementations, consider adding one
53
+ + --> $DIR/outlives-goal-error-due-to-normalization-failure-no-ice.rs:5:1
54
+ + |
55
+ +LL | trait Z<'a, T: ?Sized>
56
+ + | ^^^^^^^^^^^^^^^^^^^^^^
57
+ +note: required by a bound in `Z`
58
+ + --> $DIR/outlives-goal-error-due-to-normalization-failure-no-ice.rs:7:8
59
+ + |
60
+ +LL | trait Z<'a, T: ?Sized>
61
+ + | - required by a bound in this trait
62
+ +LL | where
63
+ +LL | T: Z<'a, ()>,
64
+ + | ^^^^^^^^^ required by this bound in `Z`
65
+ +
66
+ +error: aborting due to 1 previous error
67
+ +
68
+ +For more information about this error, try `rustc --explain E0277`.
patches/20261028T105419Z/rust-lang--rust-part009/862ae981f33f053b6e4b3df9582e519bb7a1e541.patch ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ diff --git a/compiler/rustc_infer/src/infer/mod.rs b/compiler/rustc_infer/src/infer/mod.rs
2
+ index a49a4355b66b16a2c118dd1cdf4ff143ccd2f624..6f5d3bb75ebe46604fe1774c151d9ea166faa352 100644
3
+ --- a/compiler/rustc_infer/src/infer/mod.rs
4
+ +++ b/compiler/rustc_infer/src/infer/mod.rs
5
+ @@ -89,10 +89,11 @@ pub(crate) type UnificationTable<'a, 'tcx, T> = ut::UnificationTable<
6
+ ut::InPlace<T, &'a mut ut::UnificationStorage<T>, &'a mut InferCtxtUndoLogs<'tcx>>,
7
+ >;
8
+
9
+ -/// This type contains all the things within `InferCtxt` that sit within a
10
+ -/// `RefCell` and are involved with taking/rolling back snapshots. Snapshot
11
+ -/// operations are hot enough that we want only one call to `borrow_mut` per
12
+ -/// call to `start_snapshot` and `rollback_to`.
13
+ +/// This type contains all the things within [`InferCtxt`] that sit within a
14
+ +/// [`RefCell`] and are involved with taking/rolling back snapshots. Snapshot
15
+ +/// operations are hot enough that we want only one call to
16
+ +/// [`RefCell::borrow_mut`] per call to [`InferCtxt::start_snapshot`] and
17
+ +/// [`InferCtxt::rollback_to`].
18
+ #[derive(Clone)]
19
+ pub struct InferCtxtInner<'tcx> {
20
+ undo_log: InferCtxtUndoLogs<'tcx>,
21
+ @@ -102,7 +103,10 @@ pub struct InferCtxtInner<'tcx> {
22
+ /// This cache is snapshotted along with the infcx.
23
+ projection_cache: traits::ProjectionCacheStorage<'tcx>,
24
+
25
+ - /// We instantiate `UnificationTable` with `bounds<Ty>` because the types
26
+ + /// Primary map of inference variables to the types that they currently
27
+ + /// represent.
28
+ + ///
29
+ + /// We instantiate [`UnificationTable`] with `bounds<Ty>` because the types
30
+ /// that might instantiate a general type variable have an order,
31
+ /// represented by its upper and lower bounds.
32
+ type_variable_storage: type_variable::TypeVariableStorage<'tcx>,
patches/20261028T105419Z/rust-lang--rust-part009/892c6bb8e88536aafabe1d4734073b82c15da566.patch ADDED
@@ -0,0 +1,1882 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ diff --git a/compiler/rustc_borrowck/src/type_check/mod.rs b/compiler/rustc_borrowck/src/type_check/mod.rs
2
+ index 6f89a64f95360243ef6d385b0b356ba7140bbc80..d9534527dc48fd87e086c76473661f7c8a4b23af 100644
3
+ --- a/compiler/rustc_borrowck/src/type_check/mod.rs
4
+ +++ b/compiler/rustc_borrowck/src/type_check/mod.rs
5
+ @@ -1769,7 +1769,8 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
6
+ Const::Ty(_, ct) => match ct.kind() {
7
+ ty::ConstKind::Alias(_, alias_const) => match alias_const.kind {
8
+ ty::AliasConstKind::Projection { def_id }
9
+ - | ty::AliasConstKind::Inherent { def_id }
10
+ + | ty::AliasConstKind::InherentSelf { def_id }
11
+ + | ty::AliasConstKind::InherentImpl { def_id }
12
+ | ty::AliasConstKind::Free { def_id }
13
+ | ty::AliasConstKind::Anon { def_id } => Some(UnevaluatedConst {
14
+ def: def_id,
15
+ diff --git a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs b/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs
16
+ index 7ad57107eebbd8058171d9cc91c9f69facdffc2a..e5d26cf72f9a5700296ace9a4823336db014acfa 100644
17
+ --- a/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs
18
+ +++ b/compiler/rustc_hir_analysis/src/check/compare_impl_item.rs
19
+ @@ -2727,9 +2727,9 @@ fn param_env_with_gat_bounds<'tcx>(
20
+ _ => clauses.push(
21
+ ty::Binder::bind_with_vars(
22
+ ty::ProjectionClause {
23
+ - projection_term: ty::AliasTerm::new_from_def_id(
24
+ + projection_term: ty::AliasTerm::new(
25
+ tcx,
26
+ - trait_ty.def_id,
27
+ + ty::AliasTermKind::ProjectionTy { def_id: trait_ty.def_id },
28
+ rebased_args,
29
+ ),
30
+ term: normalize_impl_ty.into(),
31
+ diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs
32
+ index c12bafd9d5d57f631838744fc69b1d4f56ffb9c2..9fde34f473205ab09d3c9afa08f896b0a6b95a69 100644
33
+ --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs
34
+ +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs
35
+ @@ -477,7 +477,12 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
36
+ );
37
+ debug!(?alias_args);
38
+
39
+ - ty::AliasTerm::new_from_def_id(tcx, assoc_item.def_id, alias_args)
40
+ + ty::AliasTerm::new_from_def_id(
41
+ + tcx,
42
+ + assoc_item.def_id,
43
+ + alias_args,
44
+ + ty::AliasConstInherentArgsKind::WithSelf,
45
+ + )
46
+ })
47
+ };
48
+
49
+ diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs
50
+ index dc108c41cf7878aeb6aeacd9a046440c47134fd5..8c22506a8b9183ad57c533d706b64462e3d6c33b 100644
51
+ --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs
52
+ +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs
53
+ @@ -485,6 +485,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
54
+ tcx,
55
+ assoc_item.def_id,
56
+ alias_args,
57
+ + ty::AliasConstInherentArgsKind::WithSelf,
58
+ )
59
+ });
60
+
61
+ diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs
62
+ index 16a622da61c2b355b030395d0e047ca5b55ea7ef..cfff8d1768f0e807c3d6a014077f3729d7931722 100644
63
+ --- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs
64
+ +++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs
65
+ @@ -1609,7 +1609,12 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
66
+ );
67
+ }
68
+
69
+ - Ok(TypeRelativePath::AssocItem(ty::AliasTerm::new_from_def_id(tcx, item_def_id, args)))
70
+ + Ok(TypeRelativePath::AssocItem(ty::AliasTerm::new_from_def_id(
71
+ + tcx,
72
+ + item_def_id,
73
+ + args,
74
+ + ty::AliasConstInherentArgsKind::WithSelf,
75
+ + )))
76
+ }
77
+
78
+ /// Resolve a [type-relative](hir::QPath::TypeRelative) (and type-level) path.
79
+ @@ -1773,12 +1778,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
80
+
81
+ let kind = match assoc_tag {
82
+ ty::AssocTag::Type => ty::AliasTermKind::InherentTy { def_id: assoc_item },
83
+ - ty::AssocTag::Const => {
84
+ - // FIXME(mgca): drop once `InherentConst` accepts IAC-shaped args (issue #156181)
85
+ - // without this, `new_from_args` errors (#155341).
86
+ - self.require_type_const_attribute(assoc_item, span)?;
87
+ - ty::AliasTermKind::InherentConst { def_id: assoc_item }
88
+ - }
89
+ + ty::AssocTag::Const => ty::AliasTermKind::InherentConstSelf { def_id: assoc_item },
90
+ ty::AssocTag::Fn => unreachable!(),
91
+ };
92
+
93
+ @@ -1948,7 +1948,11 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
94
+ self.require_type_const_attribute(item_def_id, span)?;
95
+ let alias_const = ty::AliasConst::new(
96
+ tcx,
97
+ - ty::AliasConstKind::new_from_def_id(tcx, item_def_id),
98
+ + ty::AliasConstKind::new_from_def_id(
99
+ + tcx,
100
+ + item_def_id,
101
+ + ty::AliasConstInherentArgsKind::WithSelf,
102
+ + ),
103
+ item_args,
104
+ );
105
+ Ok(Const::new_alias(tcx, ty::IsRigid::No, alias_const))
106
+ @@ -2903,7 +2907,15 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
107
+ ty::Const::new_alias(
108
+ tcx,
109
+ ty::IsRigid::No,
110
+ - ty::AliasConst::new(tcx, ty::AliasConstKind::new_from_def_id(tcx, did), args),
111
+ + ty::AliasConst::new(
112
+ + tcx,
113
+ + ty::AliasConstKind::new_from_def_id(
114
+ + tcx,
115
+ + did,
116
+ + ty::AliasConstInherentArgsKind::WithSelf,
117
+ + ),
118
+ + args,
119
+ + ),
120
+ )
121
+ }
122
+ Res::Def(kind @ DefKind::Ctor(ctor_of, CtorKind::Const), did) => {
123
+ @@ -3141,14 +3153,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
124
+ span: Span,
125
+ ) -> Result<(), ErrorGuaranteed> {
126
+ let tcx = self.tcx();
127
+ - // FIXME(gca): Intentionally disallowing paths to inherent associated non-type constants
128
+ - // until a refactoring for how generic args for IACs are represented has been landed.
129
+ - let is_inherent_assoc_const = tcx.def_kind(def_id)
130
+ - == DefKind::AssocConst { is_type_const: false }
131
+ - && tcx.def_kind(tcx.parent(def_id)) == DefKind::Impl { of_trait: false };
132
+ - if tcx.is_type_const(def_id)
133
+ - || tcx.features().generic_const_args() && !is_inherent_assoc_const
134
+ - {
135
+ + if tcx.is_type_const(def_id) || tcx.features().generic_const_args() {
136
+ Ok(())
137
+ } else {
138
+ let mut err = self.dcx().struct_span_err(
139
+ diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs
140
+ index 651b4ca33be991de39a20256398e9204f62f39b1..b59dc21981ce63aac5438a7c439a6717c2d88cb7 100644
141
+ --- a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs
142
+ +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs
143
+ @@ -48,38 +48,6 @@ use crate::method::{self, MethodCallee};
144
+ use crate::{BreakableCtxt, Diverges, Expectation, FnCtxt, LoweredTy};
145
+
146
+ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
147
+ - /// Transform generic args for inherent associated type constants (IACs).
148
+ - ///
149
+ - /// IACs have a different generic parameter structure than regular associated constants:
150
+ - /// - Regular assoc const: parent (impl) generic params + own generic params
151
+ - /// - IAC (type_const): Self type + own generic params
152
+ - pub(crate) fn transform_args_for_inherent_type_const(
153
+ - &self,
154
+ - def_id: DefId,
155
+ - args: GenericArgsRef<'tcx>,
156
+ - ) -> GenericArgsRef<'tcx> {
157
+ - let tcx = self.tcx;
158
+ - if !tcx.is_type_const(def_id) {
159
+ - return args;
160
+ - }
161
+ - let Some(assoc_item) = tcx.opt_associated_item(def_id) else {
162
+ - return args;
163
+ - };
164
+ - if !matches!(assoc_item.container, ty::AssocContainer::InherentImpl) {
165
+ - return args;
166
+ - }
167
+ -
168
+ - let impl_def_id = assoc_item.container_id(tcx);
169
+ - let generics = tcx.generics_of(def_id);
170
+ - let impl_args = &args[..generics.parent_count];
171
+ - let self_ty = tcx.type_of(impl_def_id).instantiate(tcx, impl_args).skip_norm_wip();
172
+ - // Build new args: [Self, own_args...]
173
+ - let own_args = &args[generics.parent_count..];
174
+ - tcx.mk_args_from_iter(
175
+ - std::iter::once(ty::GenericArg::from(self_ty)).chain(own_args.iter().copied()),
176
+ - )
177
+ - }
178
+ -
179
+ /// Produces warning on the given node, if the current point in the
180
+ /// function is unreachable, and there hasn't been another warning.
181
+ pub(crate) fn warn_if_unreachable(&self, id: HirId, span: Span, kind: &str) {
182
+ @@ -1399,7 +1367,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
183
+ }
184
+ }
185
+
186
+ - let args_raw = implicit_args.unwrap_or_else(|| {
187
+ + let args_for_user_type = implicit_args.unwrap_or_else(|| {
188
+ lower_generic_args(
189
+ self,
190
+ def_id,
191
+ @@ -1417,17 +1385,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
192
+ )
193
+ });
194
+
195
+ - let args_for_user_type = if let Res::Def(DefKind::AssocConst { .. }, def_id) = res {
196
+ - self.transform_args_for_inherent_type_const(def_id, args_raw)
197
+ - } else {
198
+ - args_raw
199
+ - };
200
+ -
201
+ // First, store the "user args" for later.
202
+ self.write_user_type_annotation_from_args(hir_id, def_id, args_for_user_type, user_self_ty);
203
+
204
+ // Normalize only after registering type annotations.
205
+ - let args = self.normalize(span, Unnormalized::new_wip(args_raw));
206
+ + let args = self.normalize(span, Unnormalized::new_wip(args_for_user_type));
207
+
208
+ self.add_required_obligations_for_hir(span, def_id, args, hir_id);
209
+
210
+ @@ -1465,12 +1427,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
211
+
212
+ debug!("instantiate_value_path: type of {:?} is {:?}", hir_id, ty_instantiated);
213
+
214
+ - let args = if let Res::Def(DefKind::AssocConst { .. }, def_id) = res {
215
+ - self.transform_args_for_inherent_type_const(def_id, args)
216
+ - } else {
217
+ - args
218
+ - };
219
+ -
220
+ self.write_args(hir_id, args);
221
+
222
+ (ty_instantiated, res)
223
+ diff --git a/compiler/rustc_hir_typeck/src/lib.rs b/compiler/rustc_hir_typeck/src/lib.rs
224
+ index 57fd6a8658ae32a5d486685b77d5a603978bf164..0f977710fbe0984354a54fd897d3e6a049e796de 100644
225
+ --- a/compiler/rustc_hir_typeck/src/lib.rs
226
+ +++ b/compiler/rustc_hir_typeck/src/lib.rs
227
+ @@ -392,7 +392,8 @@ fn infer_type_if_missing<'tcx>(fcx: &FnCtxt<'_, 'tcx>, node: Node<'tcx>) -> Opti
228
+ impl_def_id,
229
+ impl_trait_ref.args,
230
+ );
231
+ - tcx.check_args_compatible(trait_item_def_id, args)
232
+ + let alias_kind = ty::AliasTermKind::ProjectionConst { def_id: trait_item_def_id };
233
+ + tcx.check_alias_term_args_compatible(alias_kind, args)
234
+ .then(|| tcx.type_of(trait_item_def_id).instantiate(tcx, args).skip_norm_wip())
235
+ } else {
236
+ Some(fcx.next_ty_var(span))
237
+ diff --git a/compiler/rustc_infer/src/infer/mod.rs b/compiler/rustc_infer/src/infer/mod.rs
238
+ index a49a4355b66b16a2c118dd1cdf4ff143ccd2f624..773cd9b75aaea7e1e3d7bf09bcc456c946fae879 100644
239
+ --- a/compiler/rustc_infer/src/infer/mod.rs
240
+ +++ b/compiler/rustc_infer/src/infer/mod.rs
241
+ @@ -994,7 +994,8 @@ impl<'tcx> InferCtxt<'tcx> {
242
+ | ty::AliasTermKind::OpaqueTy { .. }
243
+ | ty::AliasTermKind::FreeTy { .. } => self.next_ty_var(span).into(),
244
+ ty::AliasTermKind::FreeConst { .. }
245
+ - | ty::AliasTermKind::InherentConst { .. }
246
+ + | ty::AliasTermKind::InherentConstSelf { .. }
247
+ + | ty::AliasTermKind::InherentConstImpl { .. }
248
+ | ty::AliasTermKind::AnonConst { .. }
249
+ | ty::AliasTermKind::ProjectionConst { .. } => self.next_const_var(span).into(),
250
+ }
251
+ diff --git a/compiler/rustc_infer/src/infer/relate/generalize.rs b/compiler/rustc_infer/src/infer/relate/generalize.rs
252
+ index afdabb38c3b2015c488728d24e9250c28a59634b..35d04597451c0268fec03410276881c3f8446f7c 100644
253
+ --- a/compiler/rustc_infer/src/infer/relate/generalize.rs
254
+ +++ b/compiler/rustc_infer/src/infer/relate/generalize.rs
255
+ @@ -182,7 +182,8 @@ impl<'tcx> InferCtxt<'tcx> {
256
+ | ty::AliasTermKind::OpaqueTy { .. } => {
257
+ return Err(TypeError::CyclicTy(source_term.expect_type()));
258
+ }
259
+ - ty::AliasTermKind::InherentConst { .. }
260
+ + ty::AliasTermKind::InherentConstSelf { .. }
261
+ + | ty::AliasTermKind::InherentConstImpl { .. }
262
+ | ty::AliasTermKind::FreeConst { .. }
263
+ | ty::AliasTermKind::AnonConst { .. } => {
264
+ return Err(TypeError::CyclicConst(source_term.expect_const()));
265
+ diff --git a/compiler/rustc_middle/src/mir/consts.rs b/compiler/rustc_middle/src/mir/consts.rs
266
+ index 54e64b37245c374b9cf0164c6cad36f409ac96ea..3b85651ee5f7606a998b7b50a92988192ed6c176 100644
267
+ --- a/compiler/rustc_middle/src/mir/consts.rs
268
+ +++ b/compiler/rustc_middle/src/mir/consts.rs
269
+ @@ -474,7 +474,15 @@ impl<'tcx> UnevaluatedConst<'tcx> {
270
+ #[inline]
271
+ pub fn shrink(self, tcx: TyCtxt<'tcx>) -> ty::AliasConst<'tcx> {
272
+ assert_eq!(self.promoted, None);
273
+ - ty::AliasConst::new(tcx, ty::AliasConstKind::new_from_def_id(tcx, self.def), self.args)
274
+ + ty::AliasConst::new(
275
+ + tcx,
276
+ + ty::AliasConstKind::new_from_def_id(
277
+ + tcx,
278
+ + self.def,
279
+ + ty::AliasConstInherentArgsKind::Impl,
280
+ + ),
281
+ + self.args,
282
+ + )
283
+ }
284
+ }
285
+
286
+ diff --git a/compiler/rustc_middle/src/mir/interpret/queries.rs b/compiler/rustc_middle/src/mir/interpret/queries.rs
287
+ index 9b98f4787371b9687537fa7d09f969846a62c417..406a96ff7ca57383f7423f35bdec7765a8b4bda7 100644
288
+ --- a/compiler/rustc_middle/src/mir/interpret/queries.rs
289
+ +++ b/compiler/rustc_middle/src/mir/interpret/queries.rs
290
+ @@ -104,8 +104,11 @@ impl<'tcx> TyCtxt<'tcx> {
291
+ }
292
+
293
+ let def_id = match ct.kind {
294
+ + ty::AliasConstKind::InherentSelf { .. } => {
295
+ + bug!("got AliasConstKind::InherentSelf in const_eval_resolve_for_typeck")
296
+ + }
297
+ ty::AliasConstKind::Projection { def_id }
298
+ - | ty::AliasConstKind::Inherent { def_id }
299
+ + | ty::AliasConstKind::InherentImpl { def_id }
300
+ | ty::AliasConstKind::Free { def_id }
301
+ | ty::AliasConstKind::Anon { def_id } => def_id,
302
+ };
303
+ diff --git a/compiler/rustc_middle/src/mir/pretty.rs b/compiler/rustc_middle/src/mir/pretty.rs
304
+ index 021c1c176d7884492d86f9f2534ee797b9ef0c46..c8d0820a78903440b27ac8ea4db4400b69ee234d 100644
305
+ --- a/compiler/rustc_middle/src/mir/pretty.rs
306
+ +++ b/compiler/rustc_middle/src/mir/pretty.rs
307
+ @@ -1494,7 +1494,8 @@ impl<'tcx> Visitor<'tcx> for ExtraComments<'tcx> {
308
+ ty::ConstKind::Alias(_, alias_const) => {
309
+ let kind = match alias_const.kind {
310
+ ty::AliasConstKind::Projection { def_id }
311
+ - | ty::AliasConstKind::Inherent { def_id }
312
+ + | ty::AliasConstKind::InherentSelf { def_id }
313
+ + | ty::AliasConstKind::InherentImpl { def_id }
314
+ | ty::AliasConstKind::Free { def_id }
315
+ | ty::AliasConstKind::Anon { def_id } => self.tcx.def_path_str(def_id),
316
+ };
317
+ diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs
318
+ index 7a3b4c7fbbeb82fd8b8ac5b2d9fe2d5d5879b103..924dc7552e59bc60c7dd99c1c3513b532e9a7437 100644
319
+ --- a/compiler/rustc_middle/src/ty/context.rs
320
+ +++ b/compiler/rustc_middle/src/ty/context.rs
321
+ @@ -13,7 +13,7 @@ use std::hash::{Hash, Hasher};
322
+ use std::marker::PointeeSized;
323
+ use std::ops::Deref;
324
+ use std::sync::{Arc, OnceLock};
325
+ -use std::{fmt, iter, mem};
326
+ +use std::{debug_assert_matches, fmt, iter, mem};
327
+
328
+ use rustc_abi::{ExternAbi, FieldIdx, Layout, LayoutData, TargetDataLayout, VariantIdx};
329
+ use rustc_ast as ast;
330
+ @@ -2117,27 +2117,44 @@ impl<'tcx> TyCtxt<'tcx> {
331
+ if pred.kind() != binder { self.mk_predicate(binder) } else { pred }
332
+ }
333
+
334
+ + /// If you have a [`ty::Alias`], you should almost certainly be calling
335
+ + /// [`Self::check_alias_term_args_compatible`] instead. This method assumes that inherent alias
336
+ + /// consts always have `impl`-form args, and will return an invalid result if the `def_id` comes
337
+ + /// from a [`ty::AliasConstKind::InherentSelf`] (see the doc on that for what "impl form args"
338
+ + /// means).
339
+ pub fn check_args_compatible(self, def_id: DefId, args: &'tcx [ty::GenericArg<'tcx>]) -> bool {
340
+ - self.check_args_compatible_inner(def_id, args, false)
341
+ + let is_inherent_assoc_ty = matches!(self.def_kind(def_id), DefKind::AssocTy)
342
+ + && matches!(self.def_kind(self.parent(def_id)), DefKind::Impl { of_trait: false });
343
+ + self.check_args_compatible_inner(def_id, args, is_inherent_assoc_ty)
344
+ + }
345
+ +
346
+ + pub fn check_alias_term_args_compatible(
347
+ + self,
348
+ + kind: ty::AliasTermKind<'tcx>,
349
+ + args: &'tcx [ty::GenericArg<'tcx>],
350
+ + ) -> bool {
351
+ + let (def_id, is_self_args) = match kind {
352
+ + ty::AliasTermKind::ProjectionTy { def_id }
353
+ + | ty::AliasTermKind::OpaqueTy { def_id }
354
+ + | ty::AliasTermKind::FreeTy { def_id }
355
+ + | ty::AliasTermKind::AnonConst { def_id }
356
+ + | ty::AliasTermKind::ProjectionConst { def_id }
357
+ + | ty::AliasTermKind::FreeConst { def_id }
358
+ + | ty::AliasTermKind::InherentConstImpl { def_id } => (def_id, false),
359
+ + ty::AliasTermKind::InherentTy { def_id }
360
+ + | ty::AliasTermKind::InherentConstSelf { def_id } => (def_id, true),
361
+ + };
362
+ + self.check_args_compatible_inner(def_id, args, is_self_args)
363
+ }
364
+
365
+ fn check_args_compatible_inner(
366
+ self,
367
+ def_id: DefId,
368
+ args: &'tcx [ty::GenericArg<'tcx>],
369
+ - nested: bool,
370
+ + is_self_args: bool,
371
+ ) -> bool {
372
+ let generics = self.generics_of(def_id);
373
+ -
374
+ - // IATs and IACs (inherent associated types/consts with `type const`) themselves have a
375
+ - // weird arg setup (self + own args), but nested items *in* IATs (namely: opaques, i.e.
376
+ - // ATPITs) do not.
377
+ - let is_inherent_assoc_ty = matches!(self.def_kind(def_id), DefKind::AssocTy)
378
+ - && matches!(self.def_kind(self.parent(def_id)), DefKind::Impl { of_trait: false });
379
+ - let is_inherent_assoc_type_const =
380
+ - matches!(self.def_kind(def_id), DefKind::AssocConst { is_type_const: true })
381
+ - && matches!(self.def_kind(self.parent(def_id)), DefKind::Impl { of_trait: false });
382
+ - let own_args = if !nested && (is_inherent_assoc_ty || is_inherent_assoc_type_const) {
383
+ + let own_args = if is_self_args {
384
+ if generics.own_params.len() + 1 != args.len() {
385
+ return false;
386
+ }
387
+ @@ -2154,8 +2171,11 @@ impl<'tcx> TyCtxt<'tcx> {
388
+
389
+ let (parent_args, own_args) = args.split_at(generics.parent_count);
390
+
391
+ + // In the type system, IATs and IACs (inherent associated types/consts) themselves have a
392
+ + // weird arg setup (self + own args), but nested items *in* IATs (namely: opaques, i.e.
393
+ + // ATPITs) do not. So, set `is_self_args` to false for the parent generic check.
394
+ if let Some(parent) = generics.parent
395
+ - && !self.check_args_compatible_inner(parent, parent_args, true)
396
+ + && !self.check_args_compatible_inner(parent, parent_args, false)
397
+ {
398
+ return false;
399
+ }
400
+ @@ -2177,39 +2197,116 @@ impl<'tcx> TyCtxt<'tcx> {
401
+
402
+ /// With `cfg(debug_assertions)`, assert that args are compatible with their generics,
403
+ /// and print out the args if not.
404
+ + ///
405
+ + /// If you have a [`ty::Alias`], you should use
406
+ + /// [`Self::debug_assert_alias_term_args_compatible`] instead. See note on
407
+ + /// [`Self::check_args_compatible`].
408
+ pub fn debug_assert_args_compatible(self, def_id: DefId, args: &'tcx [ty::GenericArg<'tcx>]) {
409
+ if cfg!(debug_assertions) && !self.check_args_compatible(def_id, args) {
410
+ let is_inherent_assoc_ty = matches!(self.def_kind(def_id), DefKind::AssocTy)
411
+ && matches!(self.def_kind(self.parent(def_id)), DefKind::Impl { of_trait: false });
412
+ - let is_inherent_assoc_type_const =
413
+ - matches!(self.def_kind(def_id), DefKind::AssocConst { is_type_const: true })
414
+ - && matches!(
415
+ - self.def_kind(self.parent(def_id)),
416
+ - DefKind::Impl { of_trait: false }
417
+ - );
418
+ - if is_inherent_assoc_ty || is_inherent_assoc_type_const {
419
+ - bug!(
420
+ - "args not compatible with generics for {}: args={:#?}, generics={:#?}",
421
+ - self.def_path_str(def_id),
422
+ - args,
423
+ - // Make `[Self, GAT_ARGS...]` (this could be simplified)
424
+ - self.mk_args_from_iter(
425
+ - [self.types.self_param.into()].into_iter().chain(
426
+ - self.generics_of(def_id)
427
+ - .own_args(ty::GenericArgs::identity_for_item(self, def_id))
428
+ - .iter()
429
+ - .copied()
430
+ - )
431
+ - )
432
+ + self.emit_bug_args_compatible(def_id, args, is_inherent_assoc_ty);
433
+ + }
434
+ + }
435
+ +
436
+ + pub fn debug_assert_alias_term_args_compatible(
437
+ + self,
438
+ + kind: ty::AliasTermKind<'tcx>,
439
+ + args: ty::GenericArgsRef<'tcx>,
440
+ + ) {
441
+ + if cfg!(debug_assertions) {
442
+ + self.debug_assert_alias_term_kind_matches_def_kind(kind);
443
+ + if !self.check_alias_term_args_compatible(kind, args) {
444
+ + let (def_id, is_self_args) = match kind {
445
+ + ty::AliasTermKind::ProjectionTy { def_id }
446
+ + | ty::AliasTermKind::OpaqueTy { def_id }
447
+ + | ty::AliasTermKind::FreeTy { def_id }
448
+ + | ty::AliasTermKind::AnonConst { def_id }
449
+ + | ty::AliasTermKind::ProjectionConst { def_id }
450
+ + | ty::AliasTermKind::FreeConst { def_id }
451
+ + | ty::AliasTermKind::InherentConstImpl { def_id } => (def_id, false),
452
+ + ty::AliasTermKind::InherentTy { def_id }
453
+ + | ty::AliasTermKind::InherentConstSelf { def_id } => (def_id, true),
454
+ + };
455
+ + self.emit_bug_args_compatible(def_id, args, is_self_args);
456
+ + }
457
+ + }
458
+ + }
459
+ +
460
+ + fn debug_assert_alias_term_kind_matches_def_kind(self, kind: ty::AliasTermKind<'tcx>) {
461
+ + match kind {
462
+ + ty::AliasTermKind::ProjectionTy { def_id } => {
463
+ + debug_assert_matches!(self.def_kind(def_id), DefKind::AssocTy);
464
+ + debug_assert_matches!(
465
+ + self.def_kind(self.parent(def_id)),
466
+ + DefKind::Trait | DefKind::Impl { of_trait: true }
467
+ + );
468
+ + }
469
+ + ty::AliasTermKind::InherentTy { def_id } => {
470
+ + debug_assert_matches!(self.def_kind(def_id), DefKind::AssocTy);
471
+ + debug_assert_matches!(
472
+ + self.def_kind(self.parent(def_id)),
473
+ + DefKind::Impl { of_trait: false }
474
+ + );
475
+ + }
476
+ + ty::AliasTermKind::OpaqueTy { def_id } => {
477
+ + debug_assert_matches!(self.def_kind(def_id), DefKind::OpaqueTy);
478
+ + }
479
+ + ty::AliasTermKind::FreeTy { def_id } => {
480
+ + debug_assert_matches!(self.def_kind(def_id), DefKind::TyAlias);
481
+ + }
482
+ + ty::AliasTermKind::AnonConst { def_id } => {
483
+ + debug_assert_matches!(self.def_kind(def_id), DefKind::AnonConst);
484
+ + }
485
+ + ty::AliasTermKind::ProjectionConst { def_id } => {
486
+ + debug_assert_matches!(self.def_kind(def_id), DefKind::AssocConst { .. });
487
+ + debug_assert_matches!(
488
+ + self.def_kind(self.parent(def_id)),
489
+ + DefKind::Trait | DefKind::Impl { of_trait: true }
490
+ );
491
+ - } else {
492
+ - bug!(
493
+ - "args not compatible with generics for {}: args={:#?}, generics={:#?}",
494
+ - self.def_path_str(def_id),
495
+ - args,
496
+ - ty::GenericArgs::identity_for_item(self, def_id)
497
+ + }
498
+ + ty::AliasTermKind::InherentConstSelf { def_id }
499
+ + | ty::AliasTermKind::InherentConstImpl { def_id } => {
500
+ + debug_assert_matches!(self.def_kind(def_id), DefKind::AssocConst { .. });
501
+ + debug_assert_matches!(
502
+ + self.def_kind(self.parent(def_id)),
503
+ + DefKind::Impl { of_trait: false }
504
+ );
505
+ }
506
+ + ty::AliasTermKind::FreeConst { def_id } => {
507
+ + debug_assert_matches!(self.def_kind(def_id), DefKind::Const { .. });
508
+ + }
509
+ + }
510
+ + }
511
+ +
512
+ + fn emit_bug_args_compatible(
513
+ + self,
514
+ + def_id: DefId,
515
+ + args: &'tcx [ty::GenericArg<'tcx>],
516
+ + is_self_args: bool,
517
+ + ) -> ! {
518
+ + if is_self_args {
519
+ + bug!(
520
+ + "args not compatible with generics for {}: args={:#?}, generics={:#?}",
521
+ + self.def_path_str(def_id),
522
+ + args,
523
+ + // Make `[Self, GAT_ARGS...]` (this could be simplified)
524
+ + self.mk_args_from_iter(
525
+ + [self.types.self_param.into()].into_iter().chain(
526
+ + self.generics_of(def_id)
527
+ + .own_args(ty::GenericArgs::identity_for_item(self, def_id))
528
+ + .iter()
529
+ + .copied()
530
+ + )
531
+ + )
532
+ + );
533
+ + } else {
534
+ + bug!(
535
+ + "args not compatible with generics for {}: args={:#?}, generics={:#?}",
536
+ + self.def_path_str(def_id),
537
+ + args,
538
+ + ty::GenericArgs::identity_for_item(self, def_id)
539
+ + );
540
+ }
541
+ }
542
+
543
+ diff --git a/compiler/rustc_middle/src/ty/context/impl_interner.rs b/compiler/rustc_middle/src/ty/context/impl_interner.rs
544
+ index 048e509ec88e0a6660041fdf0c4e83cff568ad0c..576fdd8cb605334bdfc32feaaba9f46052a911ad 100644
545
+ --- a/compiler/rustc_middle/src/ty/context/impl_interner.rs
546
+ +++ b/compiler/rustc_middle/src/ty/context/impl_interner.rs
547
+ @@ -204,11 +204,22 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
548
+ self.adt_def(adt_def_id)
549
+ }
550
+
551
+ - fn alias_const_kind_from_def_id(self, def_id: Self::DefId) -> ty::AliasConstKind<'tcx> {
552
+ + fn alias_const_kind_from_def_id(
553
+ + self,
554
+ + def_id: Self::DefId,
555
+ + inherent_args: ty::AliasConstInherentArgsKind,
556
+ + ) -> ty::AliasConstKind<'tcx> {
557
+ match self.def_kind(def_id) {
558
+ DefKind::AssocConst { .. } => {
559
+ if let DefKind::Impl { of_trait: false } = self.def_kind(self.parent(def_id)) {
560
+ - ty::AliasConstKind::Inherent { def_id }
561
+ + match inherent_args {
562
+ + ty::AliasConstInherentArgsKind::WithSelf => {
563
+ + ty::AliasConstKind::InherentSelf { def_id }
564
+ + }
565
+ + ty::AliasConstInherentArgsKind::Impl => {
566
+ + ty::AliasConstKind::InherentImpl { def_id }
567
+ + }
568
+ + }
569
+ } else {
570
+ ty::AliasConstKind::Projection { def_id }
571
+ }
572
+ @@ -221,7 +232,11 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
573
+ }
574
+ }
575
+
576
+ - fn alias_term_kind_from_def_id(self, def_id: DefId) -> ty::AliasTermKind<'tcx> {
577
+ + fn alias_term_kind_from_def_id(
578
+ + self,
579
+ + def_id: DefId,
580
+ + inherent_args: ty::AliasConstInherentArgsKind,
581
+ + ) -> ty::AliasTermKind<'tcx> {
582
+ match self.def_kind(def_id) {
583
+ DefKind::AssocTy => {
584
+ if let DefKind::Impl { of_trait: false } = self.def_kind(self.parent(def_id)) {
585
+ @@ -232,7 +247,14 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
586
+ }
587
+ DefKind::AssocConst { .. } => {
588
+ if let DefKind::Impl { of_trait: false } = self.def_kind(self.parent(def_id)) {
589
+ - ty::AliasTermKind::InherentConst { def_id }
590
+ + match inherent_args {
591
+ + ty::AliasConstInherentArgsKind::WithSelf => {
592
+ + ty::AliasTermKind::InherentConstSelf { def_id }
593
+ + }
594
+ + ty::AliasConstInherentArgsKind::Impl => {
595
+ + ty::AliasTermKind::InherentConstImpl { def_id }
596
+ + }
597
+ + }
598
+ } else {
599
+ ty::AliasTermKind::ProjectionConst { def_id }
600
+ }
601
+ @@ -271,14 +293,26 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
602
+ self.mk_args_from_iter(args)
603
+ }
604
+
605
+ - fn check_args_compatible(self, def_id: DefId, args: ty::GenericArgsRef<'tcx>) -> bool {
606
+ - self.check_args_compatible(def_id, args)
607
+ + fn check_alias_term_args_compatible(
608
+ + self,
609
+ + kind: ty::AliasTermKind<'tcx>,
610
+ + args: ty::GenericArgsRef<'tcx>,
611
+ + ) -> bool {
612
+ + self.check_alias_term_args_compatible(kind, args)
613
+ }
614
+
615
+ fn debug_assert_args_compatible(self, def_id: DefId, args: ty::GenericArgsRef<'tcx>) {
616
+ self.debug_assert_args_compatible(def_id, args);
617
+ }
618
+
619
+ + fn debug_assert_alias_term_args_compatible(
620
+ + self,
621
+ + kind: ty::AliasTermKind<'tcx>,
622
+ + args: ty::GenericArgsRef<'tcx>,
623
+ + ) {
624
+ + self.debug_assert_alias_term_args_compatible(kind, args);
625
+ + }
626
+ +
627
+ /// Assert that the args from an `ExistentialTraitRef` or `ExistentialProjection`
628
+ /// are compatible with the `DefId`. Since we're missing a `Self` type, stick on
629
+ /// a dummy self type and forward to `debug_assert_args_compatible`.
630
+ diff --git a/compiler/rustc_middle/src/ty/error.rs b/compiler/rustc_middle/src/ty/error.rs
631
+ index 33541dee52fe684ef7cc28be4f11d7aceb5507a6..fb4e30b161d443e3754ad583a1fd63f41b816ec0 100644
632
+ --- a/compiler/rustc_middle/src/ty/error.rs
633
+ +++ b/compiler/rustc_middle/src/ty/error.rs
634
+ @@ -334,7 +334,8 @@ impl<'tcx> TyCtxt<'tcx> {
635
+ | ty::AliasTermKind::AnonConst { def_id }
636
+ | ty::AliasTermKind::ProjectionConst { def_id }
637
+ | ty::AliasTermKind::FreeConst { def_id }
638
+ - | ty::AliasTermKind::InherentConst { def_id } => self.def_path_str(def_id),
639
+ + | ty::AliasTermKind::InherentConstSelf { def_id }
640
+ + | ty::AliasTermKind::InherentConstImpl { def_id } => self.def_path_str(def_id),
641
+ }
642
+ }
643
+ }
644
+ diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs
645
+ index f055051580e811228ece4e6db0a80d06791ecc5d..f5960e65c44937f0ec8eba1eb48c9df1e44f45cf 100644
646
+ --- a/compiler/rustc_middle/src/ty/print/pretty.rs
647
+ +++ b/compiler/rustc_middle/src/ty/print/pretty.rs
648
+ @@ -1539,7 +1539,8 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
649
+ ty::ConstKind::Alias(_, ty::AliasConst { kind, args, .. }) => {
650
+ match kind {
651
+ ty::AliasConstKind::Projection { def_id }
652
+ - | ty::AliasConstKind::Inherent { def_id }
653
+ + | ty::AliasConstKind::InherentSelf { def_id }
654
+ + | ty::AliasConstKind::InherentImpl { def_id }
655
+ | ty::AliasConstKind::Free { def_id } => {
656
+ self.pretty_print_value_path(def_id, args)?;
657
+ }
658
+ @@ -3172,7 +3173,7 @@ define_print! {
659
+
660
+ ty::AliasTerm<'tcx> {
661
+ match self.kind {
662
+ - ty::AliasTermKind::InherentTy { .. } | ty::AliasTermKind::InherentConst { .. } => {
663
+ + ty::AliasTermKind::InherentTy { .. } | ty::AliasTermKind::InherentConstSelf { .. } => {
664
+ p.pretty_print_inherent_projection(*self)?;
665
+ }
666
+ ty::AliasTermKind::ProjectionTy { def_id } => {
667
+ @@ -3188,7 +3189,8 @@ define_print! {
668
+ | ty::AliasTermKind::FreeConst { def_id }
669
+ | ty::AliasTermKind::OpaqueTy { def_id }
670
+ | ty::AliasTermKind::AnonConst { def_id }
671
+ - | ty::AliasTermKind::ProjectionConst { def_id } => {
672
+ + | ty::AliasTermKind::ProjectionConst { def_id }
673
+ + | ty::AliasTermKind::InherentConstImpl { def_id } => {
674
+ p.print_def_path(def_id, self.args)?;
675
+ }
676
+ }
677
+ diff --git a/compiler/rustc_middle/src/ty/sty.rs b/compiler/rustc_middle/src/ty/sty.rs
678
+ index bef267b7eaf2709114b9608690a50aad00587e7b..013064b5cec4b7953c53081b74854b0aa066d224 100644
679
+ --- a/compiler/rustc_middle/src/ty/sty.rs
680
+ +++ b/compiler/rustc_middle/src/ty/sty.rs
681
+ @@ -478,22 +478,6 @@ impl<'tcx> Ty<'tcx> {
682
+ is_rigid: ty::IsRigid,
683
+ alias_ty: ty::AliasTy<'tcx>,
684
+ ) -> Ty<'tcx> {
685
+ - if cfg!(debug_assertions) {
686
+ - match alias_ty.kind {
687
+ - ty::AliasTyKind::Projection { def_id } => {
688
+ - debug_assert_matches!(tcx.def_kind(def_id), DefKind::AssocTy)
689
+ - }
690
+ - ty::AliasTyKind::Inherent { def_id } => {
691
+ - debug_assert_matches!(tcx.def_kind(def_id), DefKind::AssocTy)
692
+ - }
693
+ - ty::AliasTyKind::Opaque { def_id } => {
694
+ - debug_assert_matches!(tcx.def_kind(def_id), DefKind::OpaqueTy)
695
+ - }
696
+ - ty::AliasTyKind::Free { def_id } => {
697
+ - debug_assert_matches!(tcx.def_kind(def_id), DefKind::TyAlias)
698
+ - }
699
+ - }
700
+ - }
701
+ Ty::new(tcx, Alias(is_rigid, alias_ty))
702
+ }
703
+
704
+ diff --git a/compiler/rustc_middle/src/ty/util.rs b/compiler/rustc_middle/src/ty/util.rs
705
+ index 09963dba563ecdd01bc192d8e27657910ab87ee2..622086b56c638a0185161a3d4aa4ab25c1e7e076 100644
706
+ --- a/compiler/rustc_middle/src/ty/util.rs
707
+ +++ b/compiler/rustc_middle/src/ty/util.rs
708
+ @@ -962,7 +962,8 @@ impl<'tcx> TyCtxt<'tcx> {
709
+ }
710
+ ty::AliasTermKind::OpaqueTy { def_id } => Some(self.variances_of(def_id)),
711
+ ty::AliasTermKind::InherentTy { .. }
712
+ - | ty::AliasTermKind::InherentConst { .. }
713
+ + | ty::AliasTermKind::InherentConstSelf { .. }
714
+ + | ty::AliasTermKind::InherentConstImpl { .. }
715
+ | ty::AliasTermKind::FreeTy { .. }
716
+ | ty::AliasTermKind::FreeConst { .. }
717
+ | ty::AliasTermKind::AnonConst { .. }
718
+ diff --git a/compiler/rustc_mir_build/src/builder/expr/as_constant.rs b/compiler/rustc_mir_build/src/builder/expr/as_constant.rs
719
+ index 6e09c365dbf7c8dedef4cd8899fdfbc72e144d45..5996073241e2c85faa7c2c1f612af2ef07a8d1ef 100644
720
+ --- a/compiler/rustc_mir_build/src/builder/expr/as_constant.rs
721
+ +++ b/compiler/rustc_mir_build/src/builder/expr/as_constant.rs
722
+ @@ -74,7 +74,11 @@ pub(crate) fn as_constant_inner<'tcx>(
723
+ if tcx.is_type_const(def_id) {
724
+ let uneval = ty::AliasConst::new(
725
+ tcx,
726
+ - ty::AliasConstKind::new_from_def_id(tcx, def_id),
727
+ + ty::AliasConstKind::new_from_def_id(
728
+ + tcx,
729
+ + def_id,
730
+ + ty::AliasConstInherentArgsKind::Impl,
731
+ + ),
732
+ args,
733
+ );
734
+ let ct = ty::Const::new_alias(tcx, ty::IsRigid::No, uneval);
735
+ diff --git a/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs b/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs
736
+ index 0230840ef2fb8b19a09cc88bb5b721e33a102620..86387f5caf32536b39285509ffd81bea9b2b4860 100644
737
+ --- a/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs
738
+ +++ b/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs
739
+ @@ -80,14 +80,16 @@ impl<'tcx> ConstToPat<'tcx> {
740
+ fn mk_err(&self, mut err: Diag<'_>, ty: Ty<'tcx>) -> Box<Pat<'tcx>> {
741
+ if let ty::ConstKind::Alias(_, alias_const) = self.c.kind() {
742
+ if let ty::AliasConstKind::Projection { def_id }
743
+ - | ty::AliasConstKind::Inherent { def_id } = alias_const.kind
744
+ + | ty::AliasConstKind::InherentSelf { def_id }
745
+ + | ty::AliasConstKind::InherentImpl { def_id } = alias_const.kind
746
+ && let Some(def_id) = def_id.as_local()
747
+ {
748
+ // Include the container item in the output.
749
+ err.span_label(self.tcx.def_span(self.tcx.local_parent(def_id)), "");
750
+ }
751
+ if let ty::AliasConstKind::Projection { def_id }
752
+ - | ty::AliasConstKind::Inherent { def_id }
753
+ + | ty::AliasConstKind::InherentSelf { def_id }
754
+ + | ty::AliasConstKind::InherentImpl { def_id }
755
+ | ty::AliasConstKind::Free { def_id } = alias_const.kind
756
+ {
757
+ err.span_label(self.tcx.def_span(def_id), msg!("constant defined here"));
758
+ @@ -166,7 +168,8 @@ impl<'tcx> ConstToPat<'tcx> {
759
+ // on its use as well.
760
+ if let ty::ConstKind::Alias(_, alias_const) = self.c.kind()
761
+ && let ty::AliasConstKind::Projection { .. }
762
+ - | ty::AliasConstKind::Inherent { .. }
763
+ + | ty::AliasConstKind::InherentSelf { .. }
764
+ + | ty::AliasConstKind::InherentImpl { .. }
765
+ | ty::AliasConstKind::Free { .. } = alias_const.kind
766
+ {
767
+ err.downgrade_to_delayed_bug();
768
+ diff --git a/compiler/rustc_mir_build/src/thir/pattern/mod.rs b/compiler/rustc_mir_build/src/thir/pattern/mod.rs
769
+ index b69519f3c714f64950cecbea6c0aa30b8fed8905..d64f98542b3a37262ed2f9f17af8d260fb42ca96 100644
770
+ --- a/compiler/rustc_mir_build/src/thir/pattern/mod.rs
771
+ +++ b/compiler/rustc_mir_build/src/thir/pattern/mod.rs
772
+ @@ -658,7 +658,11 @@ impl<'tcx, 'ptcx> PatCtxt<'tcx, 'ptcx> {
773
+ ty::IsRigid::No,
774
+ ty::AliasConst::new(
775
+ self.tcx,
776
+ - ty::AliasConstKind::new_from_def_id(self.tcx, def_id),
777
+ + ty::AliasConstKind::new_from_def_id(
778
+ + self.tcx,
779
+ + def_id,
780
+ + ty::AliasConstInherentArgsKind::Impl,
781
+ + ),
782
+ args,
783
+ ),
784
+ );
785
+ diff --git a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs b/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs
786
+ index a0abc918107df118e2b71f7165f7b9ee0cd1fded..034ad3463ba1327f32a84be8cee5d41f7371745c 100644
787
+ --- a/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs
788
+ +++ b/compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs
789
+ @@ -1074,7 +1074,8 @@ where
790
+ | ty::AliasTermKind::OpaqueTy { .. }
791
+ | ty::AliasTermKind::FreeTy { .. } => self.next_ty_infer().into(),
792
+ ty::AliasTermKind::FreeConst { .. }
793
+ - | ty::AliasTermKind::InherentConst { .. }
794
+ + | ty::AliasTermKind::InherentConstSelf { .. }
795
+ + | ty::AliasTermKind::InherentConstImpl { .. }
796
+ | ty::AliasTermKind::AnonConst { .. }
797
+ | ty::AliasTermKind::ProjectionConst { .. } => self.next_const_infer().into(),
798
+ }
799
+ @@ -1440,12 +1441,15 @@ where
800
+ if self.resolve_vars_if_possible(alias_const).has_non_region_infer() {
801
+ self.evaluate_added_goals_and_make_canonical_response(Certainty::AMBIGUOUS)
802
+ } else {
803
+ + // Evaluation failed because the const was too generic or was an invalid type
804
+ + // for const generics. The result of normalization is the alias itself,
805
+ + // unchanged, but marked as rigid.
806
+ + //
807
+ // We do not instantiate to the `alias_const` passed in, but rather
808
+ - // `goal.predicate.alias`. The `alias_const` passed in might correspond to the `impl`
809
+ - // form of a constant (with generic arguments corresponding to the impl block),
810
+ - // however, we want to structurally instantiate to the original, non-rebased,
811
+ - // trait `Self` form of the constant (with generic arguments being the trait
812
+ - // `Self` type).
813
+ + // `projection_term`, which is the unprocessed, original alias contained within
814
+ + // the goal. The `alias_const` passed in might be a Projection whose DefId is an
815
+ + // impl of the trait, however, we want to structurally instantiate to the
816
+ + // original DefId on the trait itself.
817
+ self.eq(
818
+ param_env,
819
+ projection_term.to_term(self.cx(), ty::IsRigid::Yes),
820
+ diff --git a/compiler/rustc_next_trait_solver/src/solve/normalizes_to.rs b/compiler/rustc_next_trait_solver/src/solve/normalizes_to.rs
821
+ index f5b1df1be3eff72061543781046557d1177aaf1d..75f15623a9ba7bc84ae31dd7fc4eaed22e07c31b 100644
822
+ --- a/compiler/rustc_next_trait_solver/src/solve/normalizes_to.rs
823
+ +++ b/compiler/rustc_next_trait_solver/src/solve/normalizes_to.rs
824
+ @@ -417,7 +417,17 @@ where
825
+ target_container_def_id,
826
+ )?;
827
+
828
+ - if !cx.check_args_compatible(target_item_def_id.into(), target_args) {
829
+ + let target_item_def_id: I::DefId = target_item_def_id.into();
830
+ +
831
+ + let target_item_kind = if goal.predicate.alias.kind.is_type() {
832
+ + ty::AliasTermKind::ProjectionTy { def_id: target_item_def_id.try_into().unwrap() }
833
+ + } else {
834
+ + ty::AliasTermKind::ProjectionConst {
835
+ + def_id: target_item_def_id.try_into().unwrap(),
836
+ + }
837
+ + };
838
+ +
839
+ + if !cx.check_alias_term_args_compatible(target_item_kind, target_args) {
840
+ return error_response(
841
+ ecx,
842
+ cx.delay_bug("associated item has mismatched arguments"),
843
+ @@ -427,15 +437,14 @@ where
844
+ // Finally we construct the actual value of the associated type.
845
+ let term = match goal.predicate.alias.kind {
846
+ ty::AliasTermKind::ProjectionTy { .. } => {
847
+ - let t = cx.type_of(target_item_def_id.into()).instantiate(cx, target_args);
848
+ + let t = cx.type_of(target_item_def_id).instantiate(cx, target_args);
849
+ let t = ecx.normalize(GoalSource::Misc, goal.param_env, t)?;
850
+ t.into()
851
+ }
852
+ ty::AliasTermKind::ProjectionConst { .. }
853
+ - if cx.is_type_const(target_item_def_id.into()) =>
854
+ + if cx.is_type_const(target_item_def_id) =>
855
+ {
856
+ - let c =
857
+ - cx.const_of_item(target_item_def_id.into()).instantiate(cx, target_args);
858
+ + let c = cx.const_of_item(target_item_def_id).instantiate(cx, target_args);
859
+ let c = ecx.normalize(GoalSource::Misc, goal.param_env, c)?;
860
+ c.into()
861
+ }
862
+ @@ -443,7 +452,7 @@ where
863
+ let alias_const = ty::AliasConst::new(
864
+ cx,
865
+ ty::AliasConstKind::Projection {
866
+ - def_id: target_item_def_id.into().try_into().unwrap(),
867
+ + def_id: target_item_def_id.try_into().unwrap(),
868
+ },
869
+ target_args,
870
+ );
871
+ @@ -827,13 +836,7 @@ where
872
+ CandidateSource::BuiltinImpl(BuiltinImplSource::Misc),
873
+ goal,
874
+ ty::ProjectionClause {
875
+ - projection_term: ty::AliasTerm::new(
876
+ - ecx.cx(),
877
+ - cx.alias_term_kind_from_def_id(
878
+ - goal.predicate.alias.expect_projection_def_id().into(),
879
+ - ),
880
+ - [self_ty],
881
+ - ),
882
+ + projection_term: ty::AliasTerm::new(ecx.cx(), goal.predicate.alias.kind, [self_ty]),
883
+ term,
884
+ }
885
+ .upcast(cx),
886
+ @@ -865,13 +868,7 @@ where
887
+ CandidateSource::BuiltinImpl(BuiltinImplSource::Misc),
888
+ goal,
889
+ ty::ProjectionClause {
890
+ - projection_term: ty::AliasTerm::new(
891
+ - ecx.cx(),
892
+ - cx.alias_term_kind_from_def_id(
893
+ - goal.predicate.alias.expect_projection_def_id().into(),
894
+ - ),
895
+ - [self_ty],
896
+ - ),
897
+ + projection_term: ty::AliasTerm::new(ecx.cx(), goal.predicate.alias.kind, [self_ty]),
898
+ term,
899
+ }
900
+ .upcast(cx),
901
+ diff --git a/compiler/rustc_next_trait_solver/src/solve/project_goals/inherent.rs b/compiler/rustc_next_trait_solver/src/solve/project_goals/inherent.rs
902
+ index a7480cded05141d9fffe3ffea188c18af5198837..51c2475a334611af1a495f91ecf8c009da2b63e4 100644
903
+ --- a/compiler/rustc_next_trait_solver/src/solve/project_goals/inherent.rs
904
+ +++ b/compiler/rustc_next_trait_solver/src/solve/project_goals/inherent.rs
905
+ @@ -5,7 +5,7 @@
906
+ //! 2. equate the self type, and
907
+ //! 3. instantiate and register where clauses.
908
+
909
+ -use rustc_type_ir::solve::QueryResultOrRerunNonErased;
910
+ +use rustc_type_ir::solve::{NoSolutionOrRerunNonErased, QueryResultOrRerunNonErased};
911
+ use rustc_type_ir::{self as ty, Interner, Unnormalized};
912
+
913
+ use crate::delegate::SolverDelegate;
914
+ @@ -21,20 +21,9 @@ where
915
+ goal: Goal<I, ty::ProjectionClause<I>>,
916
+ ) -> QueryResultOrRerunNonErased<I> {
917
+ let cx = self.cx();
918
+ - let inherent = goal.predicate.projection_term;
919
+ - let def_id = inherent.expect_inherent_def_id();
920
+ - let impl_def_id = cx.inherent_alias_term_parent(def_id);
921
+ - let impl_args = self.fresh_args_for_item(impl_def_id.into());
922
+ -
923
+ - // Equate impl header and add impl where clauses
924
+ - self.eq(
925
+ - goal.param_env,
926
+ - inherent.self_ty(),
927
+ - cx.type_of(impl_def_id.into()).instantiate(cx, impl_args).skip_norm_wip(),
928
+ - )?;
929
+ -
930
+ - // Equate IAT with the RHS of the project goal
931
+ - let inherent_args = inherent.rebase_inherent_args_onto_impl(impl_args, cx);
932
+ + let def_id = goal.predicate.projection_term.expect_inherent_def_id();
933
+ + let (inherent_kind, inherent_args) =
934
+ + self.convert_inherent_self_to_impl(goal.param_env, goal.predicate.projection_term)?;
935
+
936
+ // Check both where clauses on the impl and IAT
937
+ //
938
+ @@ -53,25 +42,28 @@ where
939
+ .map(|clause| goal.with(cx, clause)),
940
+ )?;
941
+
942
+ - let normalized: I::Term = match inherent.kind {
943
+ + let normalized: I::Term = match inherent_kind {
944
+ ty::AliasTermKind::InherentTy { def_id } => {
945
+ let inherent = cx.type_of(def_id.into()).instantiate(cx, inherent_args);
946
+ let inherent = self.normalize(GoalSource::Misc, goal.param_env, inherent)?;
947
+ inherent.into()
948
+ }
949
+ - ty::AliasTermKind::InherentConst { def_id } if cx.is_type_const(def_id.into()) => {
950
+ + ty::AliasTermKind::InherentConstImpl { def_id } if cx.is_type_const(def_id.into()) => {
951
+ let inherent = cx.const_of_item(def_id.into()).instantiate(cx, inherent_args);
952
+ let inherent = self.normalize(GoalSource::Misc, goal.param_env, inherent)?;
953
+ inherent.into()
954
+ }
955
+ - ty::AliasTermKind::InherentConst { .. } => {
956
+ - // FIXME(gca): This is dead code at the moment. It should eventually call
957
+ - // self.evaluate_const like projected consts do in consider_impl_candidate in
958
+ - // normalizes_to/mod.rs. However, how generic args are represented for IACs is up in
959
+ - // the air right now.
960
+ - // Will self.evaluate_const eventually take the inherent_args or the impl_args form
961
+ - // of args? It might be either.
962
+ - panic!("References to inherent associated consts should have been blocked");
963
+ + ty::AliasTermKind::InherentConstImpl { .. } => {
964
+ + let term = ty::AliasTerm::new_from_args(cx, inherent_kind, inherent_args);
965
+ + // NOTE: we intentionally pass in the `InherentConstImpl` form as the term to
966
+ + // instantiate to upon too-generic CTFE failure, as we ought to consistently compare
967
+ + // identities via `InherentConstImpl` rather than `InherentConstSelf`.
968
+ + return self.evaluate_const_and_instantiate_projection_term(
969
+ + goal.param_env,
970
+ + term,
971
+ + goal.predicate.term,
972
+ + term.expect_ct(),
973
+ + );
974
+ }
975
+ kind => panic!("expected inherent alias, found {kind:?}"),
976
+ };
977
+ @@ -84,4 +76,43 @@ where
978
+ self.eq(goal.param_env, goal.predicate.term, normalized)?;
979
+ self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
980
+ }
981
+ +
982
+ + fn convert_inherent_self_to_impl(
983
+ + &mut self,
984
+ + param_env: I::ParamEnv,
985
+ + term: ty::AliasTerm<I>,
986
+ + ) -> Result<(ty::AliasTermKind<I>, I::GenericArgs), NoSolutionOrRerunNonErased> {
987
+ + match term.kind {
988
+ + ty::AliasTermKind::InherentTy { .. } | ty::AliasTermKind::InherentConstSelf { .. } => {
989
+ + let cx = self.cx();
990
+ + let def_id = term.expect_inherent_def_id();
991
+ + let impl_def_id = cx.inherent_alias_term_parent(def_id);
992
+ + let impl_args = self.fresh_args_for_item(impl_def_id.into());
993
+ +
994
+ + // Equate impl header and add impl where clauses
995
+ + self.eq(
996
+ + param_env,
997
+ + term.self_ty(),
998
+ + cx.type_of(impl_def_id.into()).instantiate(cx, impl_args).skip_norm_wip(),
999
+ + )?;
1000
+ +
1001
+ + // Equate IAT with the RHS of the project goal
1002
+ + let inherent_args = term.rebase_inherent_args_onto_impl(impl_args, cx);
1003
+ +
1004
+ + let kind = match term.kind {
1005
+ + ty::AliasTermKind::InherentTy { def_id } => {
1006
+ + ty::AliasTermKind::InherentTy { def_id }
1007
+ + }
1008
+ + ty::AliasTermKind::InherentConstSelf { def_id } => {
1009
+ + ty::AliasTermKind::InherentConstImpl { def_id }
1010
+ + }
1011
+ + _ => unreachable!(),
1012
+ + };
1013
+ +
1014
+ + Ok((kind, inherent_args))
1015
+ + }
1016
+ + ty::AliasTermKind::InherentConstImpl { .. } => Ok((term.kind, term.args)),
1017
+ + kind => panic!("expected inherent alias, found {kind:?}"),
1018
+ + }
1019
+ + }
1020
+ }
1021
+ diff --git a/compiler/rustc_next_trait_solver/src/solve/project_goals/mod.rs b/compiler/rustc_next_trait_solver/src/solve/project_goals/mod.rs
1022
+ index 6ec82aefb523f477a1eb54cb958bbee557d2986b..db326e6d736a4c451dcaca7493742165b2d0bdca 100644
1023
+ --- a/compiler/rustc_next_trait_solver/src/solve/project_goals/mod.rs
1024
+ +++ b/compiler/rustc_next_trait_solver/src/solve/project_goals/mod.rs
1025
+ @@ -27,7 +27,9 @@ where
1026
+ ty::AliasTermKind::ProjectionTy { .. } | ty::AliasTermKind::ProjectionConst { .. } => {
1027
+ self.normalize_associated_term(goal)
1028
+ }
1029
+ - ty::AliasTermKind::InherentTy { .. } | ty::AliasTermKind::InherentConst { .. } => {
1030
+ + ty::AliasTermKind::InherentTy { .. }
1031
+ + | ty::AliasTermKind::InherentConstSelf { .. }
1032
+ + | ty::AliasTermKind::InherentConstImpl { .. } => {
1033
+ self.normalize_inherent_associated_term(goal)
1034
+ }
1035
+ ty::AliasTermKind::OpaqueTy { .. } => self.normalize_opaque_type(goal),
1036
+ diff --git a/compiler/rustc_public/src/unstable/convert/stable/ty.rs b/compiler/rustc_public/src/unstable/convert/stable/ty.rs
1037
+ index e142cb26447a87040ce6307a33bcb1aa9136ec93..17ce015d4ce108102c67a63f8da6ad671d10852d 100644
1038
+ --- a/compiler/rustc_public/src/unstable/convert/stable/ty.rs
1039
+ +++ b/compiler/rustc_public/src/unstable/convert/stable/ty.rs
1040
+ @@ -60,7 +60,8 @@ impl<'tcx> Stable<'tcx> for ty::AliasTerm<'tcx> {
1041
+ | ty::AliasTermKind::AnonConst { def_id }
1042
+ | ty::AliasTermKind::ProjectionConst { def_id }
1043
+ | ty::AliasTermKind::FreeConst { def_id }
1044
+ - | ty::AliasTermKind::InherentConst { def_id } => def_id,
1045
+ + | ty::AliasTermKind::InherentConstSelf { def_id }
1046
+ + | ty::AliasTermKind::InherentConstImpl { def_id } => def_id,
1047
+ };
1048
+ crate::ty::AliasTerm { def_id: tables.alias_def(def_id), args: args.stable(tables, cx) }
1049
+ }
1050
+ diff --git a/compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/transform.rs b/compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/transform.rs
1051
+ index 8a44589f5052ca79934ad5615f19f4950a597dcc..2019f7e15dc7023eb3b7fc0ce1e5dcba9b095830 100644
1052
+ --- a/compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/transform.rs
1053
+ +++ b/compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/transform.rs
1054
+ @@ -250,6 +250,7 @@ fn trait_object_ty<'tcx>(tcx: TyCtxt<'tcx>, poly_trait_ref: ty::PolyTraitRef<'tc
1055
+ tcx,
1056
+ assoc_item.def_id,
1057
+ super_trait_ref.args,
1058
+ + ty::AliasConstInherentArgsKind::WithSelf,
1059
+ );
1060
+ let term = tcx.normalize_erasing_regions(
1061
+ ty::TypingEnv::fully_monomorphized(),
1062
+ diff --git a/compiler/rustc_symbol_mangling/src/v0.rs b/compiler/rustc_symbol_mangling/src/v0.rs
1063
+ index cf08d3e858ec516b4d5d4a1a1044e4a6eb3f8f15..5ed41ac45603118a47292552b38e1203236b28f7 100644
1064
+ --- a/compiler/rustc_symbol_mangling/src/v0.rs
1065
+ +++ b/compiler/rustc_symbol_mangling/src/v0.rs
1066
+ @@ -749,7 +749,8 @@ impl<'tcx> Printer<'tcx> for V0SymbolMangler<'tcx> {
1067
+ // logic sometimes passing identity-substituted impl headers.
1068
+ ty::ConstKind::Alias(_, ty::AliasConst { kind, args, .. }) => match kind {
1069
+ ty::AliasConstKind::Projection { def_id }
1070
+ - | ty::AliasConstKind::Inherent { def_id }
1071
+ + | ty::AliasConstKind::InherentSelf { def_id }
1072
+ + | ty::AliasConstKind::InherentImpl { def_id }
1073
+ | ty::AliasConstKind::Free { def_id }
1074
+ | ty::AliasConstKind::Anon { def_id } => {
1075
+ return self.print_def_path(def_id, args);
1076
+ diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs
1077
+ index 1210a3ef57e328eee13e40c3757af5c086b9b1d8..34df03e2584e654419114e9d60860569cd416f76 100644
1078
+ --- a/compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs
1079
+ +++ b/compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs
1080
+ @@ -1613,7 +1613,8 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
1081
+ ty::AliasTermKind::AnonConst { def_id } => def_id.into(),
1082
+ ty::AliasTermKind::ProjectionConst { def_id } => def_id.into(),
1083
+ ty::AliasTermKind::FreeConst { def_id } => def_id.into(),
1084
+ - ty::AliasTermKind::InherentConst { def_id } => def_id.into(),
1085
+ + ty::AliasTermKind::InherentConstSelf { def_id } => def_id.into(),
1086
+ + ty::AliasTermKind::InherentConstImpl { def_id } => def_id.into(),
1087
+ };
1088
+ (false, Mismatch::Fixed(self.tcx.def_descr(def_id)))
1089
+ }
1090
+ diff --git a/compiler/rustc_trait_selection/src/traits/fulfill.rs b/compiler/rustc_trait_selection/src/traits/fulfill.rs
1091
+ index bca336c2a044961b46472094a61bf8dd415814b1..ddbb56affcff1b9cf502800744153cecdb52ab5e 100644
1092
+ --- a/compiler/rustc_trait_selection/src/traits/fulfill.rs
1093
+ +++ b/compiler/rustc_trait_selection/src/traits/fulfill.rs
1094
+ @@ -720,7 +720,8 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
1095
+ && matches!(
1096
+ a.kind,
1097
+ ty::AliasConstKind::Projection { .. }
1098
+ - | ty::AliasConstKind::Inherent { .. }
1099
+ + | ty::AliasConstKind::InherentSelf { .. }
1100
+ + | ty::AliasConstKind::InherentImpl { .. }
1101
+ ) =>
1102
+ {
1103
+ if let Ok(new_obligations) = infcx
1104
+ diff --git a/compiler/rustc_trait_selection/src/traits/normalize.rs b/compiler/rustc_trait_selection/src/traits/normalize.rs
1105
+ index f00b300c7e9717ad20059c05121efc3a9292a544..0d22ca49735115bb7f7c4fe3db040820d7faa02a 100644
1106
+ --- a/compiler/rustc_trait_selection/src/traits/normalize.rs
1107
+ +++ b/compiler/rustc_trait_selection/src/traits/normalize.rs
1108
+ @@ -491,7 +491,7 @@ impl<'a, 'b, 'tcx> TypeFolder<TyCtxt<'tcx>> for AssocTypeNormalizer<'a, 'b, 'tcx
1109
+ ty::AliasConstKind::Projection { .. } => {
1110
+ self.normalize_trait_projection(alias_const.into()).expect_const()
1111
+ }
1112
+ - ty::AliasConstKind::Inherent { .. } => {
1113
+ + ty::AliasConstKind::InherentSelf { .. } | ty::AliasConstKind::InherentImpl { .. } => {
1114
+ self.normalize_inherent_projection(alias_const.into()).expect_const()
1115
+ }
1116
+ ty::AliasConstKind::Free { .. } => {
1117
+ diff --git a/compiler/rustc_trait_selection/src/traits/project.rs b/compiler/rustc_trait_selection/src/traits/project.rs
1118
+ index eaaf082b105c273818bd2b2b27b62d87bbdd2a63..9d0daa3a8672b8b7be5e2b5867fb8746562db319 100644
1119
+ --- a/compiler/rustc_trait_selection/src/traits/project.rs
1120
+ +++ b/compiler/rustc_trait_selection/src/traits/project.rs
1121
+ @@ -470,18 +470,7 @@ fn normalize_to_error<'a, 'tcx>(
1122
+ depth: usize,
1123
+ ) -> NormalizedTerm<'tcx> {
1124
+ let trait_ref = ty::Binder::dummy(projection_term.trait_ref(selcx.tcx()));
1125
+ - let new_value = match projection_term.kind {
1126
+ - ty::AliasTermKind::ProjectionTy { .. }
1127
+ - | ty::AliasTermKind::InherentTy { .. }
1128
+ - | ty::AliasTermKind::OpaqueTy { .. }
1129
+ - | ty::AliasTermKind::FreeTy { .. } => selcx.infcx.next_ty_var(cause.span).into(),
1130
+ - ty::AliasTermKind::FreeConst { .. }
1131
+ - | ty::AliasTermKind::InherentConst { .. }
1132
+ - | ty::AliasTermKind::AnonConst { .. }
1133
+ - | ty::AliasTermKind::ProjectionConst { .. } => {
1134
+ - selcx.infcx.next_const_var(cause.span).into()
1135
+ - }
1136
+ - };
1137
+ + let new_value = selcx.infcx.next_term_var_of_alias_kind(projection_term, cause.span);
1138
+ let mut obligations = PredicateObligations::new();
1139
+ obligations.push(Obligation {
1140
+ cause,
1141
+ @@ -608,7 +597,13 @@ pub fn compute_inherent_assoc_term_args<'a, 'b, 'tcx>(
1142
+ ) -> ty::GenericArgsRef<'tcx> {
1143
+ let tcx = selcx.tcx();
1144
+
1145
+ - let alias_def_id = alias_term.expect_inherent_def_id();
1146
+ + let alias_def_id = match alias_term.kind {
1147
+ + ty::AliasTermKind::InherentTy { def_id } => def_id,
1148
+ + ty::AliasTermKind::InherentConstSelf { def_id } => def_id,
1149
+ + ty::AliasTermKind::InherentConstImpl { .. } => return alias_term.args,
1150
+ + kind => panic!("expected inherent alias, found {kind:?}"),
1151
+ + };
1152
+ +
1153
+ let impl_def_id = tcx.parent(alias_def_id);
1154
+ let impl_args = selcx.infcx.fresh_args_for_item(cause.span, impl_def_id);
1155
+
1156
+ @@ -2101,13 +2096,13 @@ fn confirm_impl_candidate<'cx, 'tcx>(
1157
+ let args = obligation.predicate.args.rebase_onto(tcx, trait_def_id, args);
1158
+ let args = translate_args(selcx.infcx, param_env, impl_def_id, args, assoc_term.defining_node);
1159
+
1160
+ - let term = if obligation.predicate.kind.is_type() {
1161
+ - tcx.type_of(assoc_term.item.def_id).map_bound(|ty| ty.into())
1162
+ + let term_kind = if obligation.predicate.kind.is_type() {
1163
+ + ty::AliasTermKind::ProjectionTy { def_id: assoc_term.item.def_id }
1164
+ } else {
1165
+ - tcx.const_of_item(assoc_term.item.def_id).map_bound(|ct| ct.into())
1166
+ + ty::AliasTermKind::ProjectionConst { def_id: assoc_term.item.def_id }
1167
+ };
1168
+
1169
+ - let progress = if !tcx.check_args_compatible(assoc_term.item.def_id, args) {
1170
+ + let progress = if !tcx.check_alias_term_args_compatible(term_kind, args) {
1171
+ let msg = "impl item and trait item have different parameters";
1172
+ let span = obligation.cause.span;
1173
+ let err = if obligation.predicate.kind.is_type() {
1174
+ @@ -2117,6 +2112,12 @@ fn confirm_impl_candidate<'cx, 'tcx>(
1175
+ };
1176
+ Progress { term: ty::Unnormalized::dummy(err), obligations: nested }
1177
+ } else {
1178
+ + let term = if obligation.predicate.kind.is_type() {
1179
+ + tcx.type_of(assoc_term.item.def_id).map_bound(|ty| ty.into())
1180
+ + } else {
1181
+ + tcx.const_of_item(assoc_term.item.def_id).map_bound(|ct| ct.into())
1182
+ + };
1183
+ +
1184
+ assoc_term_own_obligations(selcx, obligation, &mut nested);
1185
+ let instantiated_term = term.instantiate(tcx, args);
1186
+ let term_for_obligation = instantiated_term.skip_norm_wip();
1187
+ diff --git a/compiler/rustc_trait_selection/src/traits/query/normalize.rs b/compiler/rustc_trait_selection/src/traits/query/normalize.rs
1188
+ index 489e4f7a93d539cde46bdce83ae0a998db774656..96e41f89be573b448e488d1844c8fa58c8fafbb4 100644
1189
+ --- a/compiler/rustc_trait_selection/src/traits/query/normalize.rs
1190
+ +++ b/compiler/rustc_trait_selection/src/traits/query/normalize.rs
1191
+ @@ -331,7 +331,9 @@ impl<'a, 'tcx> QueryNormalizer<'a, 'tcx> {
1192
+ ty::AliasTermKind::FreeTy { .. } | ty::AliasTermKind::FreeConst { .. } => {
1193
+ tcx.normalize_canonicalized_free_alias(c_term)
1194
+ }
1195
+ - ty::AliasTermKind::InherentTy { .. } | ty::AliasTermKind::InherentConst { .. } => {
1196
+ + ty::AliasTermKind::InherentTy { .. }
1197
+ + | ty::AliasTermKind::InherentConstSelf { .. }
1198
+ + | ty::AliasTermKind::InherentConstImpl { .. } => {
1199
+ tcx.normalize_canonicalized_inherent_projection(c_term)
1200
+ }
1201
+ kind @ (ty::AliasTermKind::OpaqueTy { .. } | ty::AliasTermKind::AnonConst { .. }) => {
1202
+ diff --git a/compiler/rustc_trait_selection/src/traits/query/type_op/ascribe_user_type.rs b/compiler/rustc_trait_selection/src/traits/query/type_op/ascribe_user_type.rs
1203
+ index e8814c56c50164e526492e1dcfdcbc24d04873e5..4dda9ca5646eaf533d9d214ea0c37054d8fbb9f9 100644
1204
+ --- a/compiler/rustc_trait_selection/src/traits/query/type_op/ascribe_user_type.rs
1205
+ +++ b/compiler/rustc_trait_selection/src/traits/query/type_op/ascribe_user_type.rs
1206
+ @@ -1,4 +1,3 @@
1207
+ -use rustc_hir::def::DefKind;
1208
+ use rustc_hir::def_id::{CRATE_DEF_ID, DefId};
1209
+ use rustc_infer::traits::Obligation;
1210
+ use rustc_middle::traits::query::NoSolution;
1211
+ @@ -99,27 +98,6 @@ fn relate_mir_and_user_args<'tcx>(
1212
+ let tcx = ocx.infcx.tcx;
1213
+ let cause = ObligationCause::dummy_with_span(span);
1214
+
1215
+ - // For IACs, the user args are in the format [SelfTy, GAT_args...] but type_of expects [impl_args..., GAT_args...].
1216
+ - // We need to infer the impl args by equating the impl's self type with the user-provided self type.
1217
+ - let is_inherent_assoc_const = matches!(tcx.def_kind(def_id), DefKind::AssocConst { .. })
1218
+ - && tcx.def_kind(tcx.parent(def_id)) == DefKind::Impl { of_trait: false }
1219
+ - && tcx.is_type_const(def_id);
1220
+ -
1221
+ - let args = if is_inherent_assoc_const {
1222
+ - let impl_def_id = tcx.parent(def_id);
1223
+ - let impl_args = ocx.infcx.fresh_args_for_item(span, impl_def_id);
1224
+ - let impl_self_ty =
1225
+ - ocx.normalize(&cause, param_env, tcx.type_of(impl_def_id).instantiate(tcx, impl_args));
1226
+ - let user_self_ty =
1227
+ - ocx.normalize(&cause, param_env, Unnormalized::new_wip(args[0].expect_ty()));
1228
+ - ocx.eq(&cause, param_env, impl_self_ty, user_self_ty)?;
1229
+ -
1230
+ - let gat_args = &args[1..];
1231
+ - tcx.mk_args_from_iter(impl_args.iter().chain(gat_args.iter().copied()))
1232
+ - } else {
1233
+ - args
1234
+ - };
1235
+ -
1236
+ let ty = tcx.type_of(def_id).instantiate(tcx, args);
1237
+ let ty = ocx.normalize(&cause, param_env, ty);
1238
+ debug!("relate_type_and_user_type: ty of def-id is {:?}", ty);
1239
+ diff --git a/compiler/rustc_trait_selection/src/traits/select/mod.rs b/compiler/rustc_trait_selection/src/traits/select/mod.rs
1240
+ index f1eaa50797c49fc615b385d651220597af2b3d0b..a2785a7ca75dccbde4ff4fa67b01ef2cdd066fd7 100644
1241
+ --- a/compiler/rustc_trait_selection/src/traits/select/mod.rs
1242
+ +++ b/compiler/rustc_trait_selection/src/traits/select/mod.rs
1243
+ @@ -876,7 +876,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
1244
+ && matches!(
1245
+ a.kind,
1246
+ ty::AliasConstKind::Projection { .. }
1247
+ - | ty::AliasConstKind::Inherent { .. }
1248
+ + | ty::AliasConstKind::InherentSelf { .. }
1249
+ + | ty::AliasConstKind::InherentImpl { .. }
1250
+ ) =>
1251
+ {
1252
+ if let Ok(InferOk { obligations, value: () }) = self
1253
+ diff --git a/compiler/rustc_trait_selection/src/traits/wf.rs b/compiler/rustc_trait_selection/src/traits/wf.rs
1254
+ index 5427d14c55af9efbcbfd41e4171c513b84eb73b0..dc29b6311cc7e9cc69b7dce3aff3554585d66b08 100644
1255
+ --- a/compiler/rustc_trait_selection/src/traits/wf.rs
1256
+ +++ b/compiler/rustc_trait_selection/src/traits/wf.rs
1257
+ @@ -1095,10 +1095,14 @@ impl<'a, 'tcx> TypeVisitor<TyCtxt<'tcx>> for WfPredicates<'a, 'tcx> {
1258
+ }
1259
+
1260
+ match alias_const.kind {
1261
+ - ty::AliasConstKind::Inherent { .. } => {
1262
+ + ty::AliasConstKind::InherentSelf { .. } => {
1263
+ self.add_wf_preds_for_inherent_projection(alias_const.into());
1264
+ return; // Subtree is handled by above function
1265
+ }
1266
+ + // please ping khyperia and/or BoxyUwU if this `bug!` fires
1267
+ + ty::AliasConstKind::InherentImpl { .. } => bug!(
1268
+ + "This ought to be unreachable, the entrypoints of WF should still have InherentSelf-form alias consts."
1269
+ + ),
1270
+ ty::AliasConstKind::Projection { def_id }
1271
+ | ty::AliasConstKind::Free { def_id }
1272
+ | ty::AliasConstKind::Anon { def_id } => {
1273
+ diff --git a/compiler/rustc_traits/src/normalize_projection_ty.rs b/compiler/rustc_traits/src/normalize_projection_ty.rs
1274
+ index 3710d41dba0d9b4825e8bfb6efe1aad7145f638d..f826b2641bb15c7861212184956617fdcd038faa 100644
1275
+ --- a/compiler/rustc_traits/src/normalize_projection_ty.rs
1276
+ +++ b/compiler/rustc_traits/src/normalize_projection_ty.rs
1277
+ @@ -147,12 +147,6 @@ fn normalize_canonicalized_inherent_projection<'tcx>(
1278
+ 0,
1279
+ &mut obligations,
1280
+ );
1281
+ - obligations.extend(const_arg_has_type_obligation(
1282
+ - tcx,
1283
+ - param_env,
1284
+ - normalized_term,
1285
+ - goal,
1286
+ - ));
1287
+ ocx.register_obligations(obligations);
1288
+
1289
+ Ok(NormalizationResult { normalized_term })
1290
+ diff --git a/compiler/rustc_ty_utils/src/consts.rs b/compiler/rustc_ty_utils/src/consts.rs
1291
+ index cd35423c5ef14fad7a1cc8cfb640e9a08d375af6..d48438819040aa8125a93e7783b1006b8da9fa4c 100644
1292
+ --- a/compiler/rustc_ty_utils/src/consts.rs
1293
+ +++ b/compiler/rustc_ty_utils/src/consts.rs
1294
+ @@ -70,8 +70,15 @@ fn recurse_build<'tcx>(
1295
+ }
1296
+ &ExprKind::ZstLiteral { user_ty: _ } => ty::Const::zero_sized(tcx, node.ty),
1297
+ &ExprKind::NamedConst { def_id, args, user_ty: _ } => {
1298
+ - let uneval =
1299
+ - ty::AliasConst::new(tcx, ty::AliasConstKind::new_from_def_id(tcx, def_id), args);
1300
+ + let uneval = ty::AliasConst::new(
1301
+ + tcx,
1302
+ + ty::AliasConstKind::new_from_def_id(
1303
+ + tcx,
1304
+ + def_id,
1305
+ + ty::AliasConstInherentArgsKind::Impl,
1306
+ + ),
1307
+ + args,
1308
+ + );
1309
+ ty::Const::new_alias(tcx, ty::IsRigid::No, uneval)
1310
+ }
1311
+ ExprKind::ConstParam { param, .. } => ty::Const::new_param(tcx, *param),
1312
+ diff --git a/compiler/rustc_type_ir/src/const_kind.rs b/compiler/rustc_type_ir/src/const_kind.rs
1313
+ index 29c65974d8b281a1569d90d42d74640d2a661c30..26a4edccd0134e2e49c8dcdf0c39f8a00cb4504b 100644
1314
+ --- a/compiler/rustc_type_ir/src/const_kind.rs
1315
+ +++ b/compiler/rustc_type_ir/src/const_kind.rs
1316
+ @@ -73,13 +73,7 @@ impl<I: Interner> AliasConst<I> {
1317
+ #[inline]
1318
+ pub fn new(interner: I, kind: AliasConstKind<I>, args: I::GenericArgs) -> AliasConst<I> {
1319
+ if cfg!(debug_assertions) {
1320
+ - let def_id = match kind {
1321
+ - ty::AliasConstKind::Projection { def_id } => def_id.into(),
1322
+ - ty::AliasConstKind::Inherent { def_id } => def_id.into(),
1323
+ - ty::AliasConstKind::Free { def_id } => def_id.into(),
1324
+ - ty::AliasConstKind::Anon { def_id } => def_id.into(),
1325
+ - };
1326
+ - interner.debug_assert_args_compatible(def_id, args);
1327
+ + interner.debug_assert_alias_term_args_compatible(kind.into(), args);
1328
+ }
1329
+ AliasConst { kind, args, _use_alias_new_instead: () }
1330
+ }
1331
+ @@ -87,7 +81,12 @@ impl<I: Interner> AliasConst<I> {
1332
+ pub fn type_of(self, interner: I) -> ty::Unnormalized<I, I::Ty> {
1333
+ let def_id = match self.kind {
1334
+ ty::AliasConstKind::Projection { def_id } => def_id.into(),
1335
+ - ty::AliasConstKind::Inherent { def_id } => def_id.into(),
1336
+ + ty::AliasConstKind::InherentSelf { .. } => {
1337
+ + panic!(
1338
+ + "AliasConst::type_of got InherentSelf - args should always be InherentImpl at this point"
1339
+ + )
1340
+ + }
1341
+ + ty::AliasConstKind::InherentImpl { def_id } => def_id.into(),
1342
+ ty::AliasConstKind::Free { def_id } => def_id.into(),
1343
+ ty::AliasConstKind::Anon { def_id } => def_id.into(),
1344
+ };
1345
+ @@ -107,23 +106,65 @@ impl<I: Interner> AliasConst<I> {
1346
+ pub enum AliasConstKind<I: Interner> {
1347
+ /// A projection `<Type as Trait>::AssocConst`
1348
+ Projection { def_id: I::TraitAssocConstId },
1349
+ - /// An associated constant in an inherent `impl`
1350
+ - Inherent { def_id: I::InherentAssocConstId },
1351
+ + /// An associated const in an inherent `impl`.
1352
+ + ///
1353
+ + /// The generic args are in "Self form", i.e.
1354
+ + /// there is a single `Self` type parameter, followed by any GAT args on the inherent const
1355
+ + /// itself.
1356
+ + ///
1357
+ + /// The "impl form" args can be obtained by generating fresh vars for each of the impl params,
1358
+ + /// instantiating the impl block's Self type with the fresh vars, equating the resulting type
1359
+ + /// with the `Self` generic argument, and using the result of what the fresh vars resolved to as
1360
+ + /// the "impl form" args. Doing so without considering the extra predicates generated by the
1361
+ + /// equate is a lossy operation, consider the following impl block:
1362
+ + ///
1363
+ + /// ```rust,ignore (illustrative)
1364
+ + /// impl<T> Struct<'static, T> {
1365
+ + /// const ASSOC<A>: () = ();
1366
+ + /// }
1367
+ + /// ```
1368
+ + ///
1369
+ + /// If we have `Struct::<'a, u32>::Assoc<usize>`, the Self args form would be `[Struct<'a, u32>,
1370
+ + /// usize]`. The "impl form" args would be `[u32, usize]`, with an extra constraint generated
1371
+ + /// that `'a == 'static`. Disregarding this extra constraint would be wrong.
1372
+ + ///
1373
+ + /// Hence, when HIR lowering wants to construct an inherent alias, it must use the "Self form"
1374
+ + /// to let the trait solver do the equate and consider additional constraints.
1375
+ + ///
1376
+ + /// FIXME(inherent_associated_types): This ideally ought be a list of candidate DefIds that a
1377
+ + /// path could resolve to, then the trait solver does the above-written routine to figure out
1378
+ + /// which exact impl to use. `InherentSelf` could be conceptually be thought of as corresponding
1379
+ + /// to `Projection` where the def_id is a trait, and `InherentImpl` is `Projection` where the
1380
+ + /// def_id is an impl.
1381
+ + InherentSelf { def_id: I::InherentAssocConstId },
1382
+ + /// An associated const in an inherent `impl`. See [`Self::InherentSelf`] for a description on
1383
+ + /// the difference between `InherentSelf` and `InherentImpl`.
1384
+ + InherentImpl { def_id: I::InherentAssocConstId },
1385
+ /// A free constant, outside an impl block.
1386
+ Free { def_id: I::FreeConstAliasId },
1387
+ /// Anonymous constant, e.g. the `1 + 2` in `[u8; 1 + 2]`.
1388
+ Anon { def_id: I::AnonConstId },
1389
+ }
1390
+
1391
+ +pub enum AliasConstInherentArgsKind {
1392
+ + WithSelf,
1393
+ + Impl,
1394
+ +}
1395
+ +
1396
+ impl<I: Interner> AliasConstKind<I> {
1397
+ - pub fn new_from_def_id(interner: I, def_id: I::DefId) -> Self {
1398
+ - interner.alias_const_kind_from_def_id(def_id)
1399
+ + pub fn new_from_def_id(
1400
+ + interner: I,
1401
+ + def_id: I::DefId,
1402
+ + inherent_args: AliasConstInherentArgsKind,
1403
+ + ) -> Self {
1404
+ + interner.alias_const_kind_from_def_id(def_id, inherent_args)
1405
+ }
1406
+
1407
+ pub fn is_type_const(self, interner: I) -> bool {
1408
+ match self {
1409
+ AliasConstKind::Projection { def_id } => interner.is_type_const(def_id.into()),
1410
+ - AliasConstKind::Inherent { def_id } => interner.is_type_const(def_id.into()),
1411
+ + AliasConstKind::InherentSelf { def_id } => interner.is_type_const(def_id.into()),
1412
+ + AliasConstKind::InherentImpl { def_id } => interner.is_type_const(def_id.into()),
1413
+ AliasConstKind::Free { def_id } => interner.is_type_const(def_id.into()),
1414
+ AliasConstKind::Anon { def_id } => interner.is_type_const(def_id.into()),
1415
+ }
1416
+ @@ -132,7 +173,8 @@ impl<I: Interner> AliasConstKind<I> {
1417
+ pub fn def_span(self, interner: I) -> I::Span {
1418
+ match self {
1419
+ AliasConstKind::Projection { def_id } => interner.def_span(def_id.into()),
1420
+ - AliasConstKind::Inherent { def_id } => interner.def_span(def_id.into()),
1421
+ + AliasConstKind::InherentSelf { def_id } => interner.def_span(def_id.into()),
1422
+ + AliasConstKind::InherentImpl { def_id } => interner.def_span(def_id.into()),
1423
+ AliasConstKind::Free { def_id } => interner.def_span(def_id.into()),
1424
+ AliasConstKind::Anon { def_id } => interner.def_span(def_id.into()),
1425
+ }
1426
+ @@ -141,7 +183,8 @@ impl<I: Interner> AliasConstKind<I> {
1427
+ pub fn opt_def_id(self) -> Option<I::DefId> {
1428
+ match self {
1429
+ AliasConstKind::Projection { def_id } => Some(def_id.into()),
1430
+ - AliasConstKind::Inherent { def_id } => Some(def_id.into()),
1431
+ + AliasConstKind::InherentSelf { def_id } => Some(def_id.into()),
1432
+ + AliasConstKind::InherentImpl { def_id } => Some(def_id.into()),
1433
+ AliasConstKind::Free { def_id } => Some(def_id.into()),
1434
+ AliasConstKind::Anon { def_id } => Some(def_id.into()),
1435
+ }
1436
+ diff --git a/compiler/rustc_type_ir/src/interner.rs b/compiler/rustc_type_ir/src/interner.rs
1437
+ index d2307913045272f6c5d4a5b6ad604d01ee7256c6..7060bae7d12ec4e99aec8f82a33126222c4e12c6 100644
1438
+ --- a/compiler/rustc_type_ir/src/interner.rs
1439
+ +++ b/compiler/rustc_type_ir/src/interner.rs
1440
+ @@ -21,8 +21,8 @@ use crate::solve::{
1441
+ };
1442
+ use crate::visit::{Flags, TypeVisitable};
1443
+ use crate::{
1444
+ - self as ty, BoundRegion, BoundVar, CanonicalParamEnvCache, DebruijnIndex, Region, RegionKind,
1445
+ - TraitRef, search_graph,
1446
+ + self as ty, AliasTermKind, BoundRegion, BoundVar, CanonicalParamEnvCache, DebruijnIndex,
1447
+ + Region, RegionKind, TraitRef, search_graph,
1448
+ };
1449
+
1450
+ /// The central trait in the shared abstraction layer, specifying all implementation-specific
1451
+ @@ -275,10 +275,18 @@ pub trait Interner:
1452
+ type AdtDef: AdtDef<Self>;
1453
+ fn adt_def(self, adt_def_id: Self::AdtId) -> Self::AdtDef;
1454
+
1455
+ - fn alias_const_kind_from_def_id(self, def_id: Self::DefId) -> ty::AliasConstKind<Self>;
1456
+ + fn alias_const_kind_from_def_id(
1457
+ + self,
1458
+ + def_id: Self::DefId,
1459
+ + inherent_args: ty::AliasConstInherentArgsKind,
1460
+ + ) -> ty::AliasConstKind<Self>;
1461
+
1462
+ // FIXME: remove in favor of explicit construction
1463
+ - fn alias_term_kind_from_def_id(self, def_id: Self::DefId) -> ty::AliasTermKind<Self>;
1464
+ + fn alias_term_kind_from_def_id(
1465
+ + self,
1466
+ + def_id: Self::DefId,
1467
+ + inherent_args: ty::AliasConstInherentArgsKind,
1468
+ + ) -> ty::AliasTermKind<Self>;
1469
+
1470
+ fn trait_ref_and_own_args_for_alias(
1471
+ self,
1472
+ @@ -293,9 +301,18 @@ pub trait Interner:
1473
+ I: Iterator<Item = T>,
1474
+ T: CollectAndApply<Self::GenericArg, Self::GenericArgs>;
1475
+
1476
+ - fn check_args_compatible(self, def_id: Self::DefId, args: Self::GenericArgs) -> bool;
1477
+ + fn check_alias_term_args_compatible(
1478
+ + self,
1479
+ + term_kind: AliasTermKind<Self>,
1480
+ + args: Self::GenericArgs,
1481
+ + ) -> bool;
1482
+
1483
+ fn debug_assert_args_compatible(self, def_id: Self::DefId, args: Self::GenericArgs);
1484
+ + fn debug_assert_alias_term_args_compatible(
1485
+ + self,
1486
+ + term_kind: AliasTermKind<Self>,
1487
+ + args: Self::GenericArgs,
1488
+ + );
1489
+
1490
+ /// Assert that the args from an `ExistentialTraitRef` or `ExistentialProjection`
1491
+ /// are compatible with the `DefId`.
1492
+ diff --git a/compiler/rustc_type_ir/src/predicate.rs b/compiler/rustc_type_ir/src/predicate.rs
1493
+ index 7d281663d50338cad4b6d807a2b107c28a61254c..7ad23d3e5432a70616af61b4992e75433617ab7f 100644
1494
+ --- a/compiler/rustc_type_ir/src/predicate.rs
1495
+ +++ b/compiler/rustc_type_ir/src/predicate.rs
1496
+ @@ -502,7 +502,10 @@ impl<I: Interner> ExistentialProjection<I> {
1497
+ ProjectionClause {
1498
+ projection_term: ty::AliasTerm::new(
1499
+ interner,
1500
+ - interner.alias_term_kind_from_def_id(self.def_id.into()),
1501
+ + interner.alias_term_kind_from_def_id(
1502
+ + self.def_id.into(),
1503
+ + ty::AliasConstInherentArgsKind::WithSelf,
1504
+ + ),
1505
+ [self_ty.into()].iter().chain(self.args.iter()),
1506
+ ),
1507
+ term: self.term,
1508
+ diff --git a/compiler/rustc_type_ir/src/relate.rs b/compiler/rustc_type_ir/src/relate.rs
1509
+ index 98d251c6f1d64b473c3466e0620e2e703799dd10..f6491bac642e354cd7a4c9ed5ea892ea66b6dc35 100644
1510
+ --- a/compiler/rustc_type_ir/src/relate.rs
1511
+ +++ b/compiler/rustc_type_ir/src/relate.rs
1512
+ @@ -262,7 +262,8 @@ impl<I: Interner> Relate<I> for ty::AliasTerm<I> {
1513
+ | ty::AliasTermKind::FreeConst { .. }
1514
+ | ty::AliasTermKind::FreeTy { .. }
1515
+ | ty::AliasTermKind::InherentTy { .. }
1516
+ - | ty::AliasTermKind::InherentConst { .. }
1517
+ + | ty::AliasTermKind::InherentConstSelf { .. }
1518
+ + | ty::AliasTermKind::InherentConstImpl { .. }
1519
+ | ty::AliasTermKind::AnonConst { .. }
1520
+ | ty::AliasTermKind::ProjectionConst { .. } => {
1521
+ relate_args_invariantly(relation, a.args, b.args)?
1522
+ @@ -281,8 +282,14 @@ impl<I: Interner> Relate<I> for ty::ExistentialProjection<I> {
1523
+ ) -> RelateResult<I, ty::ExistentialProjection<I>> {
1524
+ if a.def_id != b.def_id {
1525
+ Err(TypeError::ProjectionMismatched(ExpectedFound::new(
1526
+ - relation.cx().alias_term_kind_from_def_id(a.def_id.into()),
1527
+ - relation.cx().alias_term_kind_from_def_id(b.def_id.into()),
1528
+ + relation.cx().alias_term_kind_from_def_id(
1529
+ + a.def_id.into(),
1530
+ + ty::AliasConstInherentArgsKind::WithSelf,
1531
+ + ),
1532
+ + relation.cx().alias_term_kind_from_def_id(
1533
+ + b.def_id.into(),
1534
+ + ty::AliasConstInherentArgsKind::WithSelf,
1535
+ + ),
1536
+ )))
1537
+ } else {
1538
+ let term = relation.relate_with_variance(
1539
+ diff --git a/compiler/rustc_type_ir/src/term_kind.rs b/compiler/rustc_type_ir/src/term_kind.rs
1540
+ index aed634d4f3a2178c0894ca03bccdf5938316b0f3..bb4ebf054d263b9855d16b8f64f2526116cd605f 100644
1541
+ --- a/compiler/rustc_type_ir/src/term_kind.rs
1542
+ +++ b/compiler/rustc_type_ir/src/term_kind.rs
1543
+ @@ -66,8 +66,12 @@ pub enum AliasTermKind<I: Interner> {
1544
+ ProjectionConst { def_id: I::TraitAssocConstId },
1545
+ /// A top level const item not part of a trait or impl.
1546
+ FreeConst { def_id: I::FreeConstAliasId },
1547
+ - /// An associated const in an inherent `impl`
1548
+ - InherentConst { def_id: I::InherentAssocConstId },
1549
+ + /// An associated const in an inherent `impl`. See [`ty::AliasConstKind::InherentSelf`] for a
1550
+ + /// description on the difference between `InherentConstSelf` and `InherentConstImpl`.
1551
+ + InherentConstSelf { def_id: I::InherentAssocConstId },
1552
+ + /// An associated const in an inherent `impl`. See [`ty::AliasConstKind::InherentSelf`] for a
1553
+ + /// description on the difference between `InherentConstSelf` and `InherentConstImpl`.
1554
+ + InherentConstImpl { def_id: I::InherentAssocConstId },
1555
+ }
1556
+
1557
+ impl<I: Interner> AliasTermKind<I> {
1558
+ @@ -76,7 +80,9 @@ impl<I: Interner> AliasTermKind<I> {
1559
+ AliasTermKind::ProjectionTy { .. } => "associated type",
1560
+ AliasTermKind::ProjectionConst { .. } => "associated const",
1561
+ AliasTermKind::InherentTy { .. } => "inherent associated type",
1562
+ - AliasTermKind::InherentConst { .. } => "inherent associated const",
1563
+ + AliasTermKind::InherentConstSelf { .. } | AliasTermKind::InherentConstImpl { .. } => {
1564
+ + "inherent associated const"
1565
+ + }
1566
+ AliasTermKind::OpaqueTy { .. } => "opaque type",
1567
+ AliasTermKind::FreeTy { .. } => "type alias",
1568
+ AliasTermKind::FreeConst { .. } => "const alias",
1569
+ @@ -93,7 +99,8 @@ impl<I: Interner> AliasTermKind<I> {
1570
+
1571
+ AliasTermKind::AnonConst { .. }
1572
+ | AliasTermKind::ProjectionConst { .. }
1573
+ - | AliasTermKind::InherentConst { .. }
1574
+ + | AliasTermKind::InherentConstSelf { .. }
1575
+ + | AliasTermKind::InherentConstImpl { .. }
1576
+ | AliasTermKind::FreeConst { .. } => false,
1577
+ }
1578
+ }
1579
+ @@ -106,7 +113,8 @@ impl<I: Interner> AliasTermKind<I> {
1580
+ | AliasTermKind::FreeTy { .. }
1581
+ | AliasTermKind::AnonConst { .. }
1582
+ | AliasTermKind::FreeConst { .. }
1583
+ - | AliasTermKind::InherentConst { .. } => false,
1584
+ + | AliasTermKind::InherentConstSelf { .. }
1585
+ + | AliasTermKind::InherentConstImpl { .. } => false,
1586
+ }
1587
+ }
1588
+ }
1589
+ @@ -126,7 +134,12 @@ impl<I: Interner> From<ty::AliasConstKind<I>> for AliasTermKind<I> {
1590
+ fn from(value: ty::AliasConstKind<I>) -> Self {
1591
+ match value {
1592
+ ty::AliasConstKind::Projection { def_id } => AliasTermKind::ProjectionConst { def_id },
1593
+ - ty::AliasConstKind::Inherent { def_id } => AliasTermKind::InherentConst { def_id },
1594
+ + ty::AliasConstKind::InherentSelf { def_id } => {
1595
+ + AliasTermKind::InherentConstSelf { def_id }
1596
+ + }
1597
+ + ty::AliasConstKind::InherentImpl { def_id } => {
1598
+ + AliasTermKind::InherentConstImpl { def_id }
1599
+ + }
1600
+ ty::AliasConstKind::Free { def_id } => AliasTermKind::FreeConst { def_id },
1601
+ ty::AliasConstKind::Anon { def_id } => AliasTermKind::AnonConst { def_id },
1602
+ }
1603
+ @@ -140,17 +153,7 @@ impl<I: Interner> AliasTerm<I> {
1604
+ args: I::GenericArgs,
1605
+ ) -> AliasTerm<I> {
1606
+ if cfg!(debug_assertions) {
1607
+ - let def_id = match kind {
1608
+ - AliasTermKind::ProjectionTy { def_id } => def_id.into(),
1609
+ - AliasTermKind::InherentTy { def_id } => def_id.into(),
1610
+ - AliasTermKind::OpaqueTy { def_id } => def_id.into(),
1611
+ - AliasTermKind::FreeTy { def_id } => def_id.into(),
1612
+ - AliasTermKind::AnonConst { def_id } => def_id.into(),
1613
+ - AliasTermKind::ProjectionConst { def_id } => def_id.into(),
1614
+ - AliasTermKind::FreeConst { def_id } => def_id.into(),
1615
+ - AliasTermKind::InherentConst { def_id } => def_id.into(),
1616
+ - };
1617
+ - interner.debug_assert_args_compatible(def_id, args);
1618
+ + interner.debug_assert_alias_term_args_compatible(kind, args);
1619
+ }
1620
+ AliasTerm { kind, args, _use_alias_new_instead: () }
1621
+ }
1622
+ @@ -164,8 +167,13 @@ impl<I: Interner> AliasTerm<I> {
1623
+ Self::new_from_args(interner, kind, args)
1624
+ }
1625
+
1626
+ - pub fn new_from_def_id(interner: I, def_id: I::DefId, args: I::GenericArgs) -> AliasTerm<I> {
1627
+ - let kind = interner.alias_term_kind_from_def_id(def_id);
1628
+ + pub fn new_from_def_id(
1629
+ + interner: I,
1630
+ + def_id: I::DefId,
1631
+ + args: I::GenericArgs,
1632
+ + inherent_args: ty::AliasConstInherentArgsKind,
1633
+ + ) -> AliasTerm<I> {
1634
+ + let kind = interner.alias_term_kind_from_def_id(def_id, inherent_args);
1635
+ Self::new_from_args(interner, kind, args)
1636
+ }
1637
+
1638
+ @@ -175,7 +183,8 @@ impl<I: Interner> AliasTerm<I> {
1639
+ AliasTermKind::InherentTy { def_id } => ty::AliasTyKind::Inherent { def_id },
1640
+ AliasTermKind::OpaqueTy { def_id } => ty::AliasTyKind::Opaque { def_id },
1641
+ AliasTermKind::FreeTy { def_id } => ty::AliasTyKind::Free { def_id },
1642
+ - kind @ (AliasTermKind::InherentConst { .. }
1643
+ + kind @ (AliasTermKind::InherentConstSelf { .. }
1644
+ + | AliasTermKind::InherentConstImpl { .. }
1645
+ | AliasTermKind::FreeConst { .. }
1646
+ | AliasTermKind::AnonConst { .. }
1647
+ | AliasTermKind::ProjectionConst { .. }) => {
1648
+ @@ -187,7 +196,12 @@ impl<I: Interner> AliasTerm<I> {
1649
+
1650
+ pub fn expect_ct(self) -> ty::AliasConst<I> {
1651
+ let kind = match self.kind {
1652
+ - AliasTermKind::InherentConst { def_id } => ty::AliasConstKind::Inherent { def_id },
1653
+ + AliasTermKind::InherentConstSelf { def_id } => {
1654
+ + ty::AliasConstKind::InherentSelf { def_id }
1655
+ + }
1656
+ + AliasTermKind::InherentConstImpl { def_id } => {
1657
+ + ty::AliasConstKind::InherentImpl { def_id }
1658
+ + }
1659
+ AliasTermKind::FreeConst { def_id } => ty::AliasConstKind::Free { def_id },
1660
+ AliasTermKind::AnonConst { def_id } => ty::AliasConstKind::Anon { def_id },
1661
+ AliasTermKind::ProjectionConst { def_id } => ty::AliasConstKind::Projection { def_id },
1662
+ @@ -212,8 +226,11 @@ impl<I: Interner> AliasTerm<I> {
1663
+ };
1664
+ match self.kind {
1665
+ AliasTermKind::FreeConst { def_id } => alias_const(ty::AliasConstKind::Free { def_id }),
1666
+ - AliasTermKind::InherentConst { def_id } => {
1667
+ - alias_const(ty::AliasConstKind::Inherent { def_id })
1668
+ + AliasTermKind::InherentConstSelf { def_id } => {
1669
+ + alias_const(ty::AliasConstKind::InherentSelf { def_id })
1670
+ + }
1671
+ + AliasTermKind::InherentConstImpl { def_id } => {
1672
+ + alias_const(ty::AliasConstKind::InherentImpl { def_id })
1673
+ }
1674
+ AliasTermKind::AnonConst { def_id } => alias_const(ty::AliasConstKind::Anon { def_id }),
1675
+ AliasTermKind::ProjectionConst { def_id } => {
1676
+ @@ -305,7 +322,8 @@ impl<I: Interner> AliasTerm<I> {
1677
+ pub fn expect_inherent_def_id(self) -> I::InherentAssocTermId {
1678
+ match self.kind {
1679
+ AliasTermKind::InherentTy { def_id } => def_id.into(),
1680
+ - AliasTermKind::InherentConst { def_id } => def_id.into(),
1681
+ + AliasTermKind::InherentConstSelf { def_id } => def_id.into(),
1682
+ + AliasTermKind::InherentConstImpl { def_id } => def_id.into(),
1683
+ kind => panic!("expected inherent alias, found {kind:?}"),
1684
+ }
1685
+ }
1686
+ @@ -327,7 +345,7 @@ impl<I: Interner> AliasTerm<I> {
1687
+ ) -> I::GenericArgs {
1688
+ debug_assert!(matches!(
1689
+ self.kind,
1690
+ - AliasTermKind::InherentTy { .. } | AliasTermKind::InherentConst { .. }
1691
+ + AliasTermKind::InherentTy { .. } | AliasTermKind::InherentConstSelf { .. }
1692
+ ));
1693
+ interner.mk_args_from_iter(impl_args.iter().chain(self.args.iter().skip(1)))
1694
+ }
1695
+ diff --git a/compiler/rustc_type_ir/src/ty_kind.rs b/compiler/rustc_type_ir/src/ty_kind.rs
1696
+ index 94e6be03c766f7d5d38687fa09a456197d366cc2..3b84c8e9a1c358e2961c0eb4f52e0480a2cf4eee 100644
1697
+ --- a/compiler/rustc_type_ir/src/ty_kind.rs
1698
+ +++ b/compiler/rustc_type_ir/src/ty_kind.rs
1699
+ @@ -483,13 +483,7 @@ impl<I: Interner> fmt::Debug for TyKind<I> {
1700
+ impl<I: Interner> AliasTy<I> {
1701
+ pub fn new_from_args(interner: I, kind: AliasTyKind<I>, args: I::GenericArgs) -> AliasTy<I> {
1702
+ if cfg!(debug_assertions) {
1703
+ - let def_id = match kind {
1704
+ - AliasTyKind::Projection { def_id } => def_id.into(),
1705
+ - AliasTyKind::Inherent { def_id } => def_id.into(),
1706
+ - AliasTyKind::Opaque { def_id } => def_id.into(),
1707
+ - AliasTyKind::Free { def_id } => def_id.into(),
1708
+ - };
1709
+ - interner.debug_assert_args_compatible(def_id, args);
1710
+ + interner.debug_assert_alias_term_args_compatible(kind.into(), args);
1711
+ }
1712
+ AliasTy { kind, args, _use_alias_new_instead: () }
1713
+ }
1714
+ @@ -551,7 +545,10 @@ impl<I: Interner> ProjectionAliasTy<I> {
1715
+ kind: I::TraitAssocTyId,
1716
+ args: I::GenericArgs,
1717
+ ) -> Self {
1718
+ - interner.debug_assert_args_compatible(kind.into(), args);
1719
+ + interner.debug_assert_alias_term_args_compatible(
1720
+ + ty::AliasTermKind::ProjectionTy { def_id: kind },
1721
+ + args,
1722
+ + );
1723
+ Self { kind, args, _use_alias_new_instead: () }
1724
+ }
1725
+
1726
+ @@ -622,7 +619,10 @@ impl<I: Interner> InherentAliasTy<I> {
1727
+ kind: I::InherentAssocTyId,
1728
+ args: I::GenericArgs,
1729
+ ) -> Self {
1730
+ - interner.debug_assert_args_compatible(kind.into(), args);
1731
+ + interner.debug_assert_alias_term_args_compatible(
1732
+ + ty::AliasTermKind::InherentTy { def_id: kind },
1733
+ + args,
1734
+ + );
1735
+ Self { kind, args, _use_alias_new_instead: () }
1736
+ }
1737
+
1738
+ @@ -637,7 +637,10 @@ impl<I: Interner> InherentAliasTy<I> {
1739
+
1740
+ impl<I: Interner> OpaqueAliasTy<I> {
1741
+ pub fn new_opaque_from_args(interner: I, kind: I::OpaqueTyId, args: I::GenericArgs) -> Self {
1742
+ - interner.debug_assert_args_compatible(kind.into(), args);
1743
+ + interner.debug_assert_alias_term_args_compatible(
1744
+ + ty::AliasTermKind::OpaqueTy { def_id: kind },
1745
+ + args,
1746
+ + );
1747
+ Self { kind, args, _use_alias_new_instead: () }
1748
+ }
1749
+
1750
+ @@ -652,7 +655,10 @@ impl<I: Interner> OpaqueAliasTy<I> {
1751
+
1752
+ impl<I: Interner> FreeAliasTy<I> {
1753
+ pub fn new_free_from_args(interner: I, kind: I::FreeTyAliasId, args: I::GenericArgs) -> Self {
1754
+ - interner.debug_assert_args_compatible(kind.into(), args);
1755
+ + interner.debug_assert_alias_term_args_compatible(
1756
+ + ty::AliasTermKind::FreeTy { def_id: kind },
1757
+ + args,
1758
+ + );
1759
+ Self { kind, args, _use_alias_new_instead: () }
1760
+ }
1761
+
1762
+ diff --git a/src/librustdoc/clean/utils.rs b/src/librustdoc/clean/utils.rs
1763
+ index d13a3fdb864bf0f686231294b683df440de1abe8..012c4997db9c1575fd5f3e4b5304024abffef1eb 100644
1764
+ --- a/src/librustdoc/clean/utils.rs
1765
+ +++ b/src/librustdoc/clean/utils.rs
1766
+ @@ -358,7 +358,8 @@ pub(crate) fn print_const(tcx: TyCtxt<'_>, n: ty::Const<'_>) -> String {
1767
+ ty::ConstKind::Alias(_, ty::AliasConst { kind, .. }) => {
1768
+ let def_id: DefId = match kind {
1769
+ ty::AliasConstKind::Projection { def_id } => def_id.into(),
1770
+ - ty::AliasConstKind::Inherent { def_id } => def_id.into(),
1771
+ + ty::AliasConstKind::InherentSelf { def_id } => def_id.into(),
1772
+ + ty::AliasConstKind::InherentImpl { def_id } => def_id.into(),
1773
+ ty::AliasConstKind::Free { def_id } => def_id.into(),
1774
+ ty::AliasConstKind::Anon { def_id } => def_id.into(),
1775
+ };
1776
+ diff --git a/tests/ui/const-generics/gca/path-to-non-type-const.rs b/tests/ui/const-generics/gca/path-to-non-type-const.rs
1777
+ index 9deb517095cbd548da3f51455a68fe917a837fdf..53382fe4aa2471af480530a14b9e6ce3d138005f 100644
1778
+ --- a/tests/ui/const-generics/gca/path-to-non-type-const.rs
1779
+ +++ b/tests/ui/const-generics/gca/path-to-non-type-const.rs
1780
+ @@ -1,7 +1,12 @@
1781
+ //@ check-pass
1782
+ //@ compile-flags: -Znext-solver
1783
+
1784
+ -#![feature(min_generic_const_args, macroless_generic_const_args, generic_const_args)]
1785
+ +#![feature(
1786
+ + min_generic_const_args,
1787
+ + macroless_generic_const_args,
1788
+ + generic_const_args,
1789
+ + inherent_associated_types
1790
+ +)]
1791
+ #![expect(incomplete_features)]
1792
+
1793
+ trait Trait {
1794
+ @@ -21,6 +26,14 @@ impl<const A: usize> Trait for GenericStructImpl<A> {
1795
+ const PROJECTED: usize = A;
1796
+ }
1797
+
1798
+ +impl StructImpl {
1799
+ + const INHERENT: usize = 1;
1800
+ +}
1801
+ +
1802
+ +impl<const A: usize> GenericStructImpl<A> {
1803
+ + const INHERENT: usize = A;
1804
+ +}
1805
+ +
1806
+ struct Struct<const N: usize>;
1807
+
1808
+ fn f<T: Trait>() {
1809
+ @@ -31,4 +44,6 @@ fn main() {
1810
+ let _ = Struct::<FREE>;
1811
+ let _ = Struct::<{ <StructImpl as Trait>::PROJECTED }>;
1812
+ let _ = Struct::<{ <GenericStructImpl<2> as Trait>::PROJECTED }>;
1813
+ + let _ = Struct::<{ StructImpl::INHERENT }>;
1814
+ + let _ = Struct::<{ GenericStructImpl::<2>::INHERENT }>;
1815
+ }
1816
+ diff --git a/tests/ui/const-generics/gca/path-to-non-type-inherent-associated-const.rs b/tests/ui/const-generics/gca/path-to-non-type-inherent-associated-const.rs
1817
+ deleted file mode 100644
1818
+ index d15341836e493ce303163311070c6629736e72de..0000000000000000000000000000000000000000
1819
+ --- a/tests/ui/const-generics/gca/path-to-non-type-inherent-associated-const.rs
1820
+ +++ /dev/null
1821
+ @@ -1,31 +0,0 @@
1822
+ -//! This test should be part of path-to-non-type-const.rs, and should pass. However, we are holding
1823
+ -//! off on implementing paths to IACs until a refactoring of how IAC generics are represented.
1824
+ -//@ compile-flags: -Znext-solver
1825
+ -
1826
+ -#![feature(
1827
+ - inherent_associated_types,
1828
+ - min_generic_const_args,
1829
+ - generic_const_args,
1830
+ - macroless_generic_const_args
1831
+ -)]
1832
+ -#![expect(incomplete_features)]
1833
+ -
1834
+ -struct StructImpl;
1835
+ -struct GenericStructImpl<const A: usize>;
1836
+ -
1837
+ -impl StructImpl {
1838
+ - const INHERENT: usize = 1;
1839
+ -}
1840
+ -
1841
+ -impl<const A: usize> GenericStructImpl<A> {
1842
+ - const INHERENT: usize = A;
1843
+ -}
1844
+ -
1845
+ -struct Struct<const N: usize>;
1846
+ -
1847
+ -fn main() {
1848
+ - let _ = Struct::<{ StructImpl::INHERENT }>;
1849
+ - //~^ ERROR use of `const` in the type system not defined as `type const`
1850
+ - let _ = Struct::<{ GenericStructImpl::<2>::INHERENT }>;
1851
+ - //~^ ERROR use of `const` in the type system not defined as `type const`
1852
+ -}
1853
+ diff --git a/tests/ui/const-generics/gca/path-to-non-type-inherent-associated-const.stderr b/tests/ui/const-generics/gca/path-to-non-type-inherent-associated-const.stderr
1854
+ deleted file mode 100644
1855
+ index af671fb614e31aa6587df47de4f9a13238cf5ba9..0000000000000000000000000000000000000000
1856
+ --- a/tests/ui/const-generics/gca/path-to-non-type-inherent-associated-const.stderr
1857
+ +++ /dev/null
1858
+ @@ -1,24 +0,0 @@
1859
+ -error: use of `const` in the type system not defined as `type const`
1860
+ - --> $DIR/path-to-non-type-inherent-associated-const.rs:27:24
1861
+ - |
1862
+ -LL | let _ = Struct::<{ StructImpl::INHERENT }>;
1863
+ - | ^^^^^^^^^^^^^^^^^^^^
1864
+ - |
1865
+ -help: add `type` before `const` for `StructImpl::INHERENT`
1866
+ - |
1867
+ -LL | type const INHERENT: usize = 1;
1868
+ - | ++++
1869
+ -
1870
+ -error: use of `const` in the type system not defined as `type const`
1871
+ - --> $DIR/path-to-non-type-inherent-associated-const.rs:29:24
1872
+ - |
1873
+ -LL | let _ = Struct::<{ GenericStructImpl::<2>::INHERENT }>;
1874
+ - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1875
+ - |
1876
+ -help: add `type` before `const` for `GenericStructImpl::<A>::INHERENT`
1877
+ - |
1878
+ -LL | type const INHERENT: usize = A;
1879
+ - | ++++
1880
+ -
1881
+ -error: aborting due to 2 previous errors
1882
+ -
patches/20261028T105419Z/rust-lang--rust-part009/9670dfaf1574b3417e0404af4524c686d6be7aef.patch ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ diff --git a/compiler/rustc_feature/src/builtin_attrs.rs b/compiler/rustc_feature/src/builtin_attrs.rs
2
+ index 7403a0eb0adbd4f5469461e8b7f0f29fae5ed513..89d87937cea5d6b1d12c8f856d7ed96a6d2fdd40 100644
3
+ --- a/compiler/rustc_feature/src/builtin_attrs.rs
4
+ +++ b/compiler/rustc_feature/src/builtin_attrs.rs
5
+ @@ -61,13 +61,15 @@ pub fn find_gated_cfg(pred: impl Fn(Symbol) -> bool) -> Option<&'static GatedCfg
6
+
7
+ #[derive(Clone, Debug, Copy)]
8
+ pub enum AttributeStability {
9
+ - /// An attribute that is unstable behind a specified feature fagte
10
+ + /// An attribute that is unstable behind a specified feature gate.
11
+ Unstable {
12
+ /// The feature gate, for example `rustc_attrs` for rustc_* attributes.
13
+ gate_name: Symbol,
14
+ - /// Check function to be called during the `PostExpansionVisitor` pass, which will be one of the `Features::*` functions
15
+ - gate_check: fn(&Features) -> bool,
16
+ - /// Notes to be displayed when an attempt is made to use the attribute without its feature gate.
17
+ + /// Check function to be called during the `PostExpansionVisitor` pass, which will be one
18
+ + /// of the `Features::*` functions
19
+ + gate_check: GateFn,
20
+ + /// Notes to be displayed when an attempt is made to use the attribute without its feature
21
+ + /// gate.
22
+ notes: &'static [&'static str],
23
+ },
24
+ /// A stable attribute, can be used on all release channels