Compare commits

..

122 Commits

Author SHA1 Message Date
Manuel Drehwald 4233695fea initial instructions for gpu offload 2025-06-18 17:22:50 -07:00
Tshepang Mbambo 33eaf36815
Merge pull request #2476 from rust-lang/tshepang-patch-1
fix markup
2025-06-19 00:04:36 +02:00
Tshepang Mbambo 980acc5eee
fix markup
That was intended to be a list.

Also, the order is not relevant.
2025-06-19 00:03:33 +02:00
Boxy e0a39188f1
Merge pull request #2474 from BoxyUwU/ambig_unambig_ty_consts
Document Ambig vs Unambig Type/Consts
2025-06-18 15:30:14 +01:00
Boxy 9d7ba8573d Reviews 2025-06-18 15:28:44 +01:00
Boxy c963b4ad93 Add links 2025-06-17 18:09:06 +01:00
Boxy a02af2f135 Write chapter on Unambig vs Ambig Types/Consts 2025-06-17 18:09:06 +01:00
Boxy 4185dca095 Stub chapter and consolidate under `/hir/` 2025-06-17 18:09:02 +01:00
nora a2c80e6e23
Merge pull request #2475 from lolbinarycat/patch-3
Profiling with perf: specify the section of bootstrap settings.
2025-06-17 18:34:03 +02:00
lolbinarycat 7b921990fc
Profiling with perf: specify the section of bootstrap settings. 2025-06-17 11:31:04 -05:00
Boxy 2078906630
Merge pull request #2472 from cbloodsworth/fix/tytable_parens
Remove hanging parenthesis from example signature.
2025-06-16 22:59:37 +01:00
Chris Bloodsworth ae0a09eae1 Remove hanging parenthesis from example signature.
Also replaced '→' symbol with '->' for consistency across the table.
2025-06-16 16:08:21 -04:00
nora 2c7a4bdb49
Merge pull request #2471 from Darksonn/patch-1
Use stage 1 for building docs
2025-06-16 19:45:23 +02:00
Alice Ryhl 38f01f117c
Use stage 1 for building docs 2025-06-16 17:03:33 +02:00
Tshepang Mbambo 59756939d5
Merge pull request #2468 from rust-lang/query-cleaning
Query cleaning
2025-06-14 23:52:29 +02:00
Tshepang Mbambo 288ea6e730 do not inline links 2025-06-14 22:56:10 +02:00
Tshepang Mbambo 754e07e449 title case 2025-06-14 22:49:46 +02:00
Tshepang Mbambo 19766701f6
Merge pull request #2467 from rust-lang/tshepang-patch-1
use sentence case
2025-06-14 22:46:18 +02:00
Tshepang Mbambo 43cc7cb922
use sentence case 2025-06-14 22:44:47 +02:00
Tshepang Mbambo 5a82d2f82f
Merge pull request #2466 from rust-lang/tshepang-moved
content has moved to another chapter
2025-06-14 22:17:51 +02:00
Tshepang Mbambo febe3e6cab content has moved to another chapter 2025-06-14 22:16:51 +02:00
Tshepang Mbambo 91ede12d31
Merge pull request #2465 from xizheyin/rustc-query
Adjust some doc for Query System
2025-06-14 21:39:25 +02:00
Tshepang Mbambo a6f2d67eb4
Merge pull request #2441 from rust-lang/tshepang-remove-title-case
use consistent title capitalization
2025-06-14 19:52:41 +02:00
xizheyin 1b289a860b Adjust some doc for Query System
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-06-13 22:51:25 +08:00
Tshepang Mbambo 6966390e79
Merge pull request #2464 from rust-lang/rustc-pull
Rustc pull update
2025-06-12 13:30:15 +02:00
The rustc-dev-guide Cronjob Bot ee03ec2984 Merge from rustc 2025-06-12 04:06:44 +00:00
The rustc-dev-guide Cronjob Bot bf475d08f2 Preparing for merge from rustc 2025-06-12 04:06:27 +00:00
bors edd1cc758d Auto merge of #136594 - pascaldekloe:fmt-int128, r=tgross35
Faster fmt::Display of 128-bit integers, without unsafe pointer

In followup of #135265, hereby the 128-bit part.

* Batches per 16 instead of 19 digits
* Buffer access as array insteaf of unsafe pointer
* Added test coverage for i128 and u128

r? tgross35 ChrisDenton
2025-06-12 01:02:55 +00:00
bors 3a1d821625 Auto merge of #142358 - matthiaskrgr:rollup-fxe6m7k, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - rust-lang/rust#141967 (Configure bootstrap backport nominations through triagebot)
 - rust-lang/rust#142042 (Make E0621 missing lifetime suggestion verbose)
 - rust-lang/rust#142272 (tests: Change ABIs in tests to more future-resilient ones)
 - rust-lang/rust#142282 (Only run `citool` tests on the `auto` branch)
 - rust-lang/rust#142297 (Implement `//@ needs-target-std` compiletest directive)
 - rust-lang/rust#142298 (Make loongarch-none target maintainers more easily pingable)
 - rust-lang/rust#142306 (Dont unwrap and re-wrap typing envs)
 - rust-lang/rust#142324 (Remove unneeded `FunctionCx` from some codegen methods)
 - rust-lang/rust#142328 (feat: Add `bit_width` for unsigned integer types)

Failed merges:

 - rust-lang/rust#141639 (Expose discriminant values in stable_mir)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-06-11 17:51:57 +00:00
Matthias Krüger e3a84c8848
Rollup merge of #142328 - sorairolake:feature/uint-bit-width, r=tgross35
feat: Add `bit_width` for unsigned integer types

- Accepted ACP: rust-lang/libs-team#598
- Tracking issue: rust-lang/rust#142326

This PR adds methods to the primitive unsigned integer types that return the minimum number of bits required to represent an unsigned integer.
2025-06-11 13:48:13 +02:00
Matthias Krüger 4eb6b2e0b7
Rollup merge of #142324 - scottmcm:less-functioncx, r=workingjubilee
Remove unneeded `FunctionCx` from some codegen methods

No changes; just removing the `self` that wasn't needed.

r? workingjubilee
cc https://github.com/rust-lang/rust/pull/138759#issuecomment-2920860686
2025-06-11 13:48:13 +02:00
Matthias Krüger 13b10d6cbb
Rollup merge of #142306 - compiler-errors:nit-reveal-param-env-query, r=lcnr
Dont unwrap and re-wrap typing envs

Just a tiny tweak to make the query less awkward.

r? lcnr
2025-06-11 13:48:12 +02:00
Matthias Krüger f912b863e6
Rollup merge of #142298 - jieyouxu:loongarch-maintainer-list, r=fee1-dead
Make loongarch-none target maintainers more easily pingable

In the same style as rust-lang/rust#139028.
r? compiler
2025-06-11 13:48:12 +02:00
Matthias Krüger 87514bfa86
Rollup merge of #142297 - jieyouxu:needs-target-std, r=Kobzol
Implement `//@ needs-target-std` compiletest directive

Closes rust-lang/rust#141863.
Needed to unblock rust-lang/rust#139244 and rust-lang/rust#141856.

### Summary

This PR implements a `//@ needs-target-std` compiletest directive that gates test execution based on whether the target supports std or not. For some cases, this should be preferred over e.g. some combination of `//@ ignore-none`, `//@ ignore-nvptx` and more[^none-limit].

### Implementation limitation

Unfortunately, since there is currently [no reliable way to determine from metadata whether a given target supports std or not](https://github.com/rust-lang/rust/issues/142296), we have to resort to a hack. Bootstrap currently determines whether or not a target supports std by a naive target tuple substring comparison: a target supports std if its target tuple does *not* contain one of `["-none", "nvptx", "switch"]` substrings. This PR simply pulls that hack out into `build_helpers` to avoid reimplementing the same hack in compiletest, and uses that logic to inform `//@ needs-target-std`.

### Auxiliary changes

This PR additionally changes a few run-make tests to use `//@ needs-target-std` over an inconsistent combination of target-based `ignore`s. This should help with rust-lang/rust#139244.

---

r? bootstrap

[^none-limit]: Notably, `target_os = "none"` is **not** a sufficient condition for "target does not support std"
2025-06-11 13:48:11 +02:00
Matthias Krüger b6cfb66f4c
Rollup merge of #141967 - jieyouxu:bootstrap-backports, r=Kobzol
Configure bootstrap backport nominations through triagebot

Following the discussion in [#t-infra/bootstrap > ✔ Have triagebot create backport nomination threads?](https://rust-lang.zulipchat.com/#narrow/channel/326414-t-infra.2Fbootstrap/topic/.E2.9C.94.20Have.20triagebot.20create.20backport.20nomination.20threads.3F/with/521876500) where we noticed that bootstrap backport nominations were difficult to track, since:

- We don't really have a dedicated person / group of people checking for bootstrap backport nominations.
- We don't really have an establish way of handling bootstrap backports.

This PR configures triagebot to open backport nominations threads (indicated for bootstrap team if a given PR has the suitable team label, https://github.com/rust-lang/rust/labels/T-bootstrap) in [#t-infra/bootstrap/backports](https://rust-lang.zulipchat.com/#narrow/channel/507486-t-infra.2Fbootstrap.2Fbackports). The current configuration is such that **the whole bootstrap team will be pinged for bootstrap backport nominations**[^diverges].

### Steps

- [x] ~~Ping members who opt-in subscribe to backport channel, or ping the whole bootstrap team?~~
    - Poll: [#t-infra/bootstrap > Have triagebot create backport nomination threads? @ 💬](https://rust-lang.zulipchat.com/#narrow/channel/326414-t-infra.2Fbootstrap/topic/Have.20triagebot.20create.20backport.20nomination.20threads.3F/near/522141337)
    - Votes (as of 2025-06-10): 3 votes "no preference", 1 vote "in favor".
- [x] ~~(Best for follow-up) Maybe also document bootstrap team's backport process / decision process in Forge? It's a bit different from [compiler team's backport process](https://forge.rust-lang.org/compiler/backports.html) because we don't have weekly bootstrap triage meetings and thus don't have sync backport decisions.~~
    - Tracked as follow-up in Forge: https://github.com/rust-lang/rust-forge/issues/889.

---

r? Kobzol

[^diverges]: Note that this configuration is similar to the types team backport nominations, but diverges from the compiler team.
2025-06-11 13:48:08 +02:00
bors e5c3298acc Auto merge of #141763 - lcnr:fixme-gamer, r=BoxyUwU
`FIXME(-Znext-solver)` triage

r? `@BoxyUwU`
2025-06-11 11:47:05 +00:00
bors 346acc73ce Auto merge of #141942 - ShoyuVanilla:smir-repr, r=oli-obk
Implement representation options to smir

Resolves rust-lang/project-stable-mir#89
2025-06-11 07:45:07 +00:00
Tshepang Mbambo 4289e66663
Merge pull request #2463 from rust-lang/tshepang-patch-1
that was phrased like a separate sentence
2025-06-11 07:15:36 +02:00
Tshepang Mbambo 23604cd1a3
that was phrased like a separate sentence 2025-06-11 07:14:12 +02:00
bors 2b9304e59b Auto merge of #142090 - compiler-errors:perf-stable-root-var, r=lcnr
Make root vars more stable

Never resolve a ty/ct vid to a higher vid as its root. This should make the optimization in rust-lang/rust#141500 more "stable" when there are a lot of vars flying around.

r? `@ghost`
2025-06-11 03:34:30 +00:00
许杰友 Jieyou Xu (Joe) 57b4d5c3ac
Merge pull request #2462 from lolbinarycat/patch-2 2025-06-11 02:26:34 +08:00
lolbinarycat aa0516b863
Using git § I changed a submodule by accident: be explicit
Rewriting git history is something that is often difficult for new contributors,
and we're already explaining the `<foo>` placeholder syntax,
so I think it makes sense to be explicit about what exactly the paths mean.
2025-06-10 12:48:05 -05:00
bors 1bec1127f0 Auto merge of #141485 - dianqk:early_otherwise_branch_loop, r=oli-obk
mir-opt: Do not create storage marks in EarlyOtherwiseBranch

Fixes #141212.

The first commit add `StorageDead` by creating new indirect BB that makes CFG more complicated, but I think it's better to just not create storage marks.

r? mir-opt
2025-06-10 14:50:54 +00:00
Jieyou Xu b8b2ca49e0
Document `//@ needs-target-std` in rustc-dev-guide 2025-06-10 22:17:57 +08:00
bors dd01be4a8a Auto merge of #141451 - lcnr:canonicalize-env-cache, r=compiler-errors
cache `param_env` canonicalization

BLocked on rust-lang/rust#141581
2025-06-10 10:42:35 +00:00
bors 688810cb7f Auto merge of #142109 - weihanglo:update-cargo, r=weihanglo
Update cargo

18 commits in 64a12460708cf146e16cc61f28aba5dc2463bbb4..fc1518ef02b77327d70d4026b95ea719dd9b8c51
2025-05-30 18:25:08 +0000 to 2025-06-06 04:49:44 +0000
- fix: Make UI tests handle hyperlinks consistently (rust-lang/cargo#15640)
- Update "time out" to "timeout" (rust-lang/cargo#15637)
- fix(workspace): reload current manifest path member only (rust-lang/cargo#15633)
- Update dependencies (rust-lang/cargo#15635)
- fix(publish): Don't tell people to ctrl-c without knowing consequences  (rust-lang/cargo#15632)
- refactor: clean up `clippy::perf` lint warnings (rust-lang/cargo#15631)
- fix(package): Skip registry check if its not needed (rust-lang/cargo#15629)
- Add --offline for comp (rust-lang/cargo#15623)
- cargo-credential-libsecret: load libsecret only once (rust-lang/cargo#15295)
- test(publish): Improvements in prep for `-Zpackage-workspace` stabilization (rust-lang/cargo#15628)
- fix(package): Allow packaging of self-cycles with -Zpackage-workspace (rust-lang/cargo#15626)
- docs: clarify `--all-features` not available for all commmands (rust-lang/cargo#15572)
- Remove double reference in Shell::print_json (rust-lang/cargo#15460)
- fix(trim-paths): remap all paths to `build.build-dir` (rust-lang/cargo#15614)
- test(trim-paths): enable more tests for windows-msvc (rust-lang/cargo#15621)
- fix(fingerprint): explicit reason rather than "stale; unknown reason" (rust-lang/cargo#15617)
- Fix cargo add overwriting symlinked Cargo.toml files (rust-lang/cargo#15281)
- chore(deps): update alpine docker tag to v3.22 (rust-lang/cargo#15616)

r? ghost
2025-06-10 05:56:54 +00:00
bors bc0cb02510 Auto merge of #142250 - lnicola:sync-from-ra, r=lnicola
Subtree update of `rust-analyzer`

r? `@ghost`
2025-06-10 01:52:18 +00:00
bors b51c88f4c1 Auto merge of #138062 - LorrensP-2158466:miri-enable-float-nondet, r=RalfJung
Enable Non-determinism of float operations in Miri and change std tests

Links to [#4208](https://github.com/rust-lang/miri/issues/4208) and [#3555](https://github.com/rust-lang/miri/issues/3555) in Miri.

Non-determinism of floating point operations was disabled in rust-lang/rust#137594 because it breaks the tests and doc-tests in core/coretests and std. This PR enables some of them.

This pr includes the following changes:

- Enables the float non-determinism but with a lower relative error of 4ULP instead of 16ULP
- These operations now have a fixed output based on the C23 standard, except the pow operations, this is tracked in [#4286](https://github.com/rust-lang/miri/issues/4286#issue-3010677983)
- Changes tests that made incorrect assumptions about the operations, not to make that assumption anymore (from `assert_eq!` to `assert_approx_eq!`.
- Changed the doctests of the stdlib of these operations to compare against fixed constants instead of `f*::EPSILON`, which now succeed with Miri and `-Zmiri-many-seeds`
- Added a constant `APPROX_DELTA` in `std/tests/floats/f32.rs` which is used for approximation tests, but with a different value when run in Miri. This is to make these tests succeed.
- Added tests in the float tests of Miri to test the C23 behaviour.

Fixes https://github.com/rust-lang/miri/issues/4208
2025-06-09 21:21:58 +00:00
bors d94c57e43d Auto merge of #142241 - Kobzol:disable-ci-rustc-on-ci, r=jieyouxu
Disable download-rustc on CI

Should resolve https://rust-lang.zulipchat.com/#narrow/channel/326414-t-infra.2Fbootstrap/topic/aarch64-apple.20try.20job.20doesn.27t.20work/with/522659759.

r? `@jieyouxu`
2025-06-09 15:21:07 +00:00
Laurențiu Nicola 92f36d9dae
Merge pull request #19954 from lnicola/sync-from-rust
minor: Sync from downstream
2025-06-09 12:55:47 +00:00
Laurențiu Nicola a1f2e0c345 Merge from rust-lang/rust 2025-06-09 15:44:40 +03:00
bors f7d75a5769 Auto merge of #142242 - matthiaskrgr:rollup-1sgx0ji, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - rust-lang/rust#129121 (Stabilize `tcp_quickack`)
 - rust-lang/rust#142192 (De-duplicate f16 & f128 doctest attributes)
 - rust-lang/rust#142193 (add tests for pattern binding drop order edge cases)
 - rust-lang/rust#142222 (Dont make `ObligationCtxt`s with diagnostics unnecessarily)
 - rust-lang/rust#142228 (rustc-dev-guide subtree update)
 - rust-lang/rust#142231 (Run `calculate_matrix` job on `master` to cache citool builds)
 - rust-lang/rust#142232 (add `Cargo.lock` to CI-rustc allowed list for non-CI env)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-06-09 12:21:14 +00:00
Matthias Krüger cfdc5f1ea9
Rollup merge of #142232 - onur-ozkan:141986, r=Kobzol
add `Cargo.lock` to CI-rustc allowed list for non-CI env

Changes to dependencies usually require modifying `Cargo.toml`, which would already invalidate the CI-rustc cache if done in non-allowed paths. On non-CI environment, it should be safe to add `Cargo.lock` to the list of allowed paths as there is no real risk aside from a very rare false positive in cases like minor bumps to non-allowed path dependencies without modifying the `Cargo.toml` files.

Fixes rust-lang/rust#141986
2025-06-09 13:55:36 +02:00
Matthias Krüger b1a6a2a83a
Rollup merge of #142231 - Kobzol:master-cache-ci, r=marcoieni
Run `calculate_matrix` job on `master` to cache citool builds

As discussed in https://rust-lang.zulipchat.com/#narrow/channel/242791-t-infra/topic/PR.20ci.20seems.20much.20to.20slow/with/523028903, the current `rust-cache` solution for `citool` doesn't work, because we don't ever write to the cache from `master`, so the cache is empty on PR CI jobs.

This PR runs the `calculate_matrix` job on `master`, with the only motivation to actually prime the cache.

r? `@marcoieni`
2025-06-09 13:55:35 +02:00
Matthias Krüger 866d1f57f9
Rollup merge of #142228 - tshepang:rust-push, r=jieyouxu
rustc-dev-guide subtree update

r? `@ghost`
2025-06-09 13:55:35 +02:00
Tshepang Mbambo 06ddcae4be
Merge pull request #2461 from rust-lang/rustc-pull
Rustc pull update
2025-06-09 07:19:50 +02:00
The rustc-dev-guide Cronjob Bot 4cc3df21eb Merge from rustc 2025-06-09 04:09:17 +00:00
The rustc-dev-guide Cronjob Bot 1aa9e7592c Preparing for merge from rustc 2025-06-09 04:08:59 +00:00
León Orell Valerian Liehr d68b8d6280
Merge pull request #2460 from cyrgani/icebreaker
remove the archived ICE ping groups
2025-06-08 21:55:09 +02:00
cyrgani ea2377504f remove the archived ICE ping groups 2025-06-08 21:49:54 +02:00
bors 85315be387 Auto merge of #142095 - joshtriplett:optimize-veccache, r=SparrowLii
Simplify and optimize `VecCache`'s `SlotIndex::from_index`

Simplify and optimize `SlotIndex::from_index`

Break out bucket 0 (containing `idx < 4096`) as an early return, which
simplifies the remainder of the function, and allows optimizing the
`checked_ilog2` since it can no longer return `None`.

This reduces the runtime of `vec_cache::tests::slot_index_exhaustive`
(which calls `SlotIndex::from_index` for every `u32`, twice) from ~15.5s
to ~13.3s.

Separately, simplify the test case as well. (The old and new code passes with
the old and new test case.)

---

Noticed because `slot_index_exhaustive` stood out as taking unusually long compared to other tests, so I started investigating what it was doing.
2025-06-08 15:26:49 +00:00
bors 1ed89341b2 Auto merge of #142085 - compiler-errors:perf-self-obl, r=lcnr
Don't walk into `Certainty::Yes` goals

Don't walk into `Certainty::Yes` goals in the pending obligation finding code, since they will not have been stalled on an infer var anyways
2025-06-08 05:30:59 +00:00
bors ce4eeb853e Auto merge of #142074 - oli-obk:its-finally-gone, r=petrochenkov
Remove CollectItemTypesVisitor

I always felt like we were very unnecessarily walking the HIR, let's see if perf agrees

There is lots to ~~improve~~ consolidate further here, as we still have 3 item wfchecks:

* check_item (matching on the hir::ItemKind)
    * actually doing trait solver based checks (by using HIR spans)
* lower_item (matching on the hir::ItemKind after loading it again??)
    * just ensure_ok-ing a bunch of queries
* check_item_type (matching on DefKind)
    * some type based checks, mostly ensure_ok-ing a bunch of queries

fixes rust-lang/rust#121429
2025-06-08 02:04:41 +00:00
bors 3f1e0c2eda Auto merge of #141950 - oli-obk:big-body-owner-loop, r=compiler-errors
Move coroutine_by_move_body_def_id into the big check_crate body owner loop

This avoids starting a parallel loop in sequence and instead runs all the queries for a specific DefId together.
2025-06-07 20:06:23 +00:00
León Orell Valerian Liehr 2263a5f027
Merge pull request #2458 from fmease/followup-type-rustdoc-test-suite
Follow up: Fix typo
2025-06-07 19:00:46 +02:00
León Orell Valerian Liehr 3eb40c40b7
Fix typo 2025-06-07 18:58:41 +02:00
León Orell Valerian Liehr 99626a308d
Merge pull request #2298 from fmease/rustdoc-testing-addendum
rustdoc: Further improve chapters and sections on testing
2025-06-07 18:36:45 +02:00
León Orell Valerian Liehr f5e1a73fb5
rustdoc: Further improve chapters and sections on testing 2025-06-07 18:35:40 +02:00
bors b4abd5bc56 Auto merge of #141964 - sayantn:update-stdarch, r=Amanieu
Update stdarch submodule

Updates the stdarch submodule.

## Merged PRs

 - rust-lang/stdarch#1797
 - rust-lang/stdarch#1758
 - rust-lang/stdarch#1798
 - rust-lang/stdarch#1811
 - rust-lang/stdarch#1810
 - rust-lang/stdarch#1807
 - rust-lang/stdarch#1806
 - rust-lang/stdarch#1812
 - rust-lang/stdarch#1795
 - rust-lang/stdarch#1796
 - rust-lang/stdarch#1813
 - rust-lang/stdarch#1816
 - rust-lang/stdarch#1818
 - rust-lang/stdarch#1820
 - rust-lang/stdarch#1819

r? `@Amanieu`
`@rustbot` label T-libs-api

Closes rust-lang/rust#111137
2025-06-07 12:25:59 +00:00
bors ff0ba0bc72 Auto merge of #141917 - petrochenkov:nobinroot, r=jieyouxu
bootstrap: Remove `rustc_snapshot_libdir` from PATH in one more place

Same as https://github.com/rust-lang/rust/pull/141657 but in a different part of the build system, with the same goal of addressing [#t-infra/bootstrap > Build broken in MSYS2 @ 💬](https://rust-lang.zulipchat.com/#narrow/channel/326414-t-infra.2Fbootstrap/topic/Build.20broken.20in.20MSYS2/near/520709527).

It seems to work on windows-{gnu,msvc} and linux-gnu at least.

r? jieyouxu
2025-06-07 09:21:38 +00:00
bors c4c3ee0f6d Auto merge of #141910 - Kobzol:new-bors-try-branch-name-doc, r=marcoieni
Fix `create-docs-artifacts.sh` with new bors

The slashes in the branch name (`automation/bors/try`) were causing issues for this script (https://github.com/rust-lang/rust/actions/runs/15391908130/job/43303193243).

r? `@marcoieni`

try-job: `mingw-check*`
2025-06-07 03:21:09 +00:00
bors 2f34718dcc Auto merge of #141800 - workingjubilee:build-std-with-less-leaf-pointers, r=saethlin
bootstrap: build std sans leaf frame pointers

Sometimes leaf frame-pointers can impact LLVM inlining choices, and that can be a real problem for things like `mul_add`.
2025-06-06 21:21:59 +00:00
bors af3b7ffbc0 Auto merge of #141774 - oli-obk:naked-fn-queries, r=petrochenkov
Change per-module naked fn checks to happen during typeck instead

cc `@Lokathor` `@Amanieu` `@folkertdev`

just seems nicer this way
2025-06-06 18:22:10 +00:00
bors 48c62c3c0d Auto merge of #141681 - compiler-errors:fast-path-stalled, r=lcnr
Fast path for stalled obligations on self ty

If we see that the `self` type of a goal is an infer var, then don't try to compute the goal at all, since we know that it'll be forced ambiguous.

This is currently only implemented when there are no opaques in the environment. We could extend it to check that the self type is not related to any already defined opaques via subtyping, but I'll leave that as a follow-up.

---

Also stall coerce and subtype predicates if both of their vars are not resolved to concrete types.

---

~~Also, we don't care if the goal is higher-ranked for the sized and copy/clone fast path.~~ pulling this out into another PR.

r? lcnr
2025-06-06 15:20:21 +00:00
bors 41985fb8b4 Auto merge of #141272 - Shourya742:2025-05-18-modularize-config-module, r=Kobzol
modularize the config module bootstrap

Currently, our `config` module is quite large over 3,000 lines, and handles a wide range of responsibilities. This PR aims to break it down into smaller, more focused submodules to improve readability and maintainability:

* **`toml`**: Introduces a dedicated `toml` submodule within the `config` module. Its sole purpose is to define configuration-related structs along with their corresponding deserialization logic. It also contains the `parse_inner` method, which serves as the central function for extracting relevant information from the TOML structs and constructing the final configuration.

* **`rust`, `dist`, `install`, `llvm`, `build`, `gcc`, and others**: Each of these modules contains TOML subsections specific to their domain, along with the logic necessary to convert them into parts of the final configuration struct.

* **`config/mod.rs`**: Contains shared types and enums used across multiple TOML subsections.

* **`config/config.rs`**: Houses the logic that integrates all the TOML subsections into the complete configuration struct.

r? `@kobzol`
2025-06-06 04:32:56 +00:00
bors 4b740a3b8b Auto merge of #140872 - bjorn3:elf_use_used_linker, r=nikic
Make #[used(linker)] the default on ELF too

`#[used]` currently is an alias for `#[used(linker)]` on all platforms except ELF based ones where it is an alias for `#[used(compiler)]`. The latter has surprising behavior and the LLVM LangRef explicitly states that it "should only be used in rare circumstances, and should not be exposed to source languages." [^2]

The reason `#[used]` still was an alias to `#[used(compiler)]` on ELF is because the gold linker has issues with it. Luckily gold has been deprecated with GCC 15 [^1] and seems to be unable to bootstrap rustc anyway [^3]. As such we shouldn't really care about supporting gold.

This would also allow re-enabling start-stop-gc with lld.

cc https://github.com/rust-lang/rust/issues/93798
Likely fixes https://github.com/rust-lang/rust/issues/85045

[^1]: https://lists.gnu.org/archive/html/info-gnu/2025-02/msg00001.html
[^2]: https://llvm.org/docs/LangRef.html#the-llvm-compiler-used-global-variable
[^3]: https://github.com/rust-lang/rust/issues/139425
2025-06-05 22:52:17 +00:00
bors 36cc2ce2e8 Auto merge of #138677 - shepmaster:consistent-elided-lifetime-syntax, r=traviscross,jieyouxu
Add a new `mismatched-lifetime-syntaxes` lint

The lang-team [discussed this](https://hackmd.io/nf4ZUYd7Rp6rq-1svJZSaQ) and I attempted to [summarize](https://github.com/rust-lang/rust/pull/120808#issuecomment-2701863833) their decision. The summary-of-the-summary is:

- Using two different kinds of syntax for elided lifetimes is confusing. In rare cases, it may even [lead to unsound code](https://github.com/rust-lang/rust/issues/48686)! Some examples:

    ```rust
    // Lint will warn about these
    fn(v: ContainsLifetime) -> ContainsLifetime<'_>;
    fn(&'static u8) -> &u8;
    ```

- Matching up references with no lifetime syntax, references with anonymous lifetime syntax, and paths with anonymous lifetime syntax is an exception to the simplest possible rule:

    ```rust
    // Lint will not warn about these
    fn(&u8) -> &'_ u8;
    fn(&'_ u8) -> &u8;
    fn(&u8) -> ContainsLifetime<'_>;
    ```

- Having a lint for consistent syntax of elided lifetimes will make the [future goal](https://github.com/rust-lang/rust/issues/91639) of warning-by-default for paths participating in elision much simpler.

---

This new lint attempts to accomplish the goal of enforcing consistent syntax. In the process, it supersedes and replaces the existing `elided-named-lifetimes` lint, which means it starts out life as warn-by-default.
2025-06-05 19:49:30 +00:00
bors 2f3d5a37f0 Auto merge of #142081 - matthiaskrgr:rollup-secpezz, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - rust-lang/rust#141709 (jsondocck: Refactor directive handling)
 - rust-lang/rust#141974 (`tests/ui`: A New Order [4/N])
 - rust-lang/rust#141989 (rustdoc-json-type: Depend on `serde` and `serde_derive` seperately)
 - rust-lang/rust#142015 (Report the actual item that evaluation failed for)
 - rust-lang/rust#142026 (bootstrap: Fix file permissions when dereferencing symlinks)
 - rust-lang/rust#142032 (Fix parsing of frontmatters with inner hyphens)
 - rust-lang/rust#142036 (Update the `compiler-builtins` subtree)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-06-05 16:46:32 +00:00
Matthias Krüger 359984fa69
Rollup merge of #142032 - matthewjasper:frontmatter-lexing, r=fee1-dead
Fix parsing of frontmatters with inner hyphens

closes rust-lang/rust#141483

r? fee1-dead
2025-06-05 16:02:04 +02:00
Matthias Krüger 9a6f10d82a
Rollup merge of #141709 - aDotInTheVoid:split-for-docs, r=GuillaumeGomez
jsondocck: Refactor directive handling

Best reviewed commit by commit.

1. Moves directive handling into its own file. This makes it easier to link to in the dev-guide (https://github.com/rust-lang/rustc-dev-guide/pull/2422#discussion_r2112724234), but also makes the code nicer in it's own right
2. Renames command to directive. This is what compiletest uses, and it's nice to not have 2 words for this.

r? ``@GuillaumeGomez``
2025-06-05 16:02:00 +02:00
bors 6a80b8e4c7 Auto merge of #142070 - matthiaskrgr:rollup-e7lxtuo, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - rust-lang/rust#140638 (UnsafePinned: also include the effects of UnsafeCell)
 - rust-lang/rust#141777 (Do not run PGO/BOLT in x64 Linux alt builds)
 - rust-lang/rust#141938 (update rust offload bootstrap)
 - rust-lang/rust#141962 (rustc-dev-guide subtree update)
 - rust-lang/rust#141965 (`tests/ui`: A New Order [3/N])
 - rust-lang/rust#141970 (implement new `x` flag: `--skip-std-check-if-no-download-rustc`)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-06-05 13:44:43 +00:00
Matthias Krüger 0c371e20ad
Rollup merge of #141970 - onur-ozkan:skip-stage1-std, r=Kobzol
implement new `x` flag: `--skip-std-check-if-no-download-rustc`

One of our developers (``@RalfJung)`` [reported](https://rust-lang.zulipchat.com/#narrow/channel/326414-t-infra.2Fbootstrap/topic/Surprising.20stages.20for.20check.20build.20after.20stage.20reorg/with/521925606)[#t-infra/bootstrap > Surprising stages for check build after stage reorg](https://rust-lang.zulipchat.com/#narrow/channel/326414-t-infra.2Fbootstrap/topic/Surprising.20stages.20for.20check.20build.20after.20stage.20reorg/with/521925606) that working on both the compiler and the library simultaneously with RA enabled is extremely difficult because checking library creates a heavy load on machines (by building stage1 compiler) on each modification. `--skip-std-check-if-no-download-rustc` flag is intended to reduce this heavy load on their IDE integration as much as possible.

Fixes: rust-lang/rust#141955
2025-06-05 12:21:34 +02:00
Matthias Krüger 662e7599dc
Rollup merge of #141965 - Kivooeo:test-reform, r=jieyouxu
`tests/ui`: A New Order [3/N]

Some `tests/ui/` housekeeping, to trim down number of tests directly under `tests/ui/`. Part of rust-lang/rust#133895.

r? ``@jieyouxu``
2025-06-05 12:21:33 +02:00
Matthias Krüger 1791bfb958
Rollup merge of #141962 - BoxyUwU:rdg-push, r=jieyouxu
rustc-dev-guide subtree update

r? ``@jieyouxu``
2025-06-05 12:21:32 +02:00
Matthias Krüger 7bce560b6c
Rollup merge of #141938 - ZuseZ4:offload-updates, r=Kobzol
update rust offload bootstrap

r? ``@ghost``
2025-06-05 12:21:31 +02:00
Matthias Krüger 7f12261d49
Rollup merge of #141777 - Kobzol:dist-linux-alt-no-pgo-bolt, r=marcoieni
Do not run PGO/BOLT in x64 Linux alt builds

Should unblock https://github.com/rust-lang/rust/pull/131077 and also reduce our CI costs. It seems to run ~1.5h on the x64 larger runner (free runner runs out of disk space, sadly).

Discussed [here](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Utility.20of.20the.20.60dist-x86_64-linux-alt.60.20job/with/521324477).

r? ``@marcoieni``

try-job: `dist-x86_64-linux*`
2025-06-05 12:21:30 +02:00
Matthias Krüger 65b423bfbc
Rollup merge of #140638 - RalfJung:unsafe-pinned-shared-aliased, r=workingjubilee
UnsafePinned: also include the effects of UnsafeCell

This tackles https://github.com/rust-lang/rust/issues/137750 by including an `UnsafeCell` in `UnsafePinned`, thus imbuing it with all the usual properties of interior mutability (no `noalias` nor `dereferenceable` on shared refs, special treatment by Miri's aliasing model). The soundness issue is not fixed yet because coroutine lowering does not use `UnsafePinned`.

The RFC said that `UnsafePinned` would not permit mutability on shared references, but since then, https://github.com/rust-lang/rust/issues/137750 has demonstrated that this is not tenable. In the face of those examples, I propose that we do the "obvious" thing and permit shared mutable state inside `UnsafePinned`. This seems loosely consistent with the fact that we allow going from `Pin<&mut T>` to `&T` (where the former can be aliased with other pointers that perform mutation, and hence the same goes for the latter) -- but the `as_ref` example shows that we in fact would need to add this `UnsafeCell` even if we didn't have a safe conversion to `&T`, since for the compiler and Miri, `&T` and `Pin<&T>` are basically the same type.

To make this possible, I had to remove the `Copy` and `Clone` impls for `UnsafePinned`.

Tracking issue: https://github.com/rust-lang/rust/issues/125735
Cc ``@rust-lang/lang`` ``@rust-lang/opsem``  ``@Sky9x``
I don't think this needs FCP since the type is still unstable -- we'll finally decide whether we like this approach when `UnsafePinned` is moved towards stabilization (IOW, this PR is reversible). However, I'd still like to make sure that the lang team is okay with the direction I am proposing here.
2025-06-05 12:21:29 +02:00
bors 7cc927ff7d Auto merge of #140466 - amandasystems:move-to-preprocessing-step, r=lcnr
Move placeholder handling to a proper preprocessing step

This commit breaks out the logic of placheolder rewriting into its own preprocessing step. It's one of the more boring
parts of #130227.

The only functional change from this is that the preprocessing step (where extra `r: 'static` constraints are added) is performed upstream of Polonius legacy, finally affecting Polonius. That is mostly a by-product, though.

This should be reviewable by anyone in the compiler team, so
r? rust-lang/compiler
2025-06-05 05:27:41 +00:00
许杰友 Jieyou Xu (Joe) 0cb136492c
Merge pull request #2456 from jieyouxu/pr-message-nit 2025-06-04 21:26:33 +08:00
Jieyou Xu 5404fd07ff
triagebot: avoid unnecessary line break in PR welcome message 2025-06-04 21:25:15 +08:00
onur-ozkan cda721a97f document `skip-std-check-if-no-download-rustc` in rustc-dev-guide
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2025-06-04 15:23:58 +03:00
许杰友 Jieyou Xu (Joe) 90529c8e54
Merge pull request #2454 from rust-lang/tshepang-expand 2025-06-04 16:46:11 +08:00
许杰友 Jieyou Xu (Joe) 8527bb5aef
Merge pull request #2455 from Rageking8/fix-incorrect-use-of-recommend-over-recommended 2025-06-04 16:44:12 +08:00
Rageking8 9120682212
Fix incorrect use of "recommend" over "recommended" 2025-06-04 16:30:02 +08:00
Tshepang Mbambo d159211d5c expand meaning of ~? diagnostic annotation 2025-06-04 00:26:47 +02:00
bors e54dd40288 Auto merge of #141229 - tgross35:builtins-josh-subtree, r=Kobzol
Merge `compiler-builtins` as a Josh subtree

Use the Josh [1] utility to add `compiler-builtins` as a subtree, which
will allow us to stop using crates.io for updates. This is intended to
help resolve some problems when unstable features change and require
code changes in `compiler-builtins`, which sometimes gets trapped in a
bootstrap cycle.

This was done using `josh-filter` built from the r24.10.04 tag:

    git fetch https://github.com/rust-lang/compiler-builtins.git 233434412fe7eced8f1ddbfeddabef1d55e493bd
    josh-filter ":prefix=library/compiler-builtins" FETCH_HEAD
    git merge --allow-unrelated FILTERED_HEAD

The HEAD in the `compiler-builtins` repository is 233434412f ("fix an if
statement that can be collapsed").

[1]: https://github.com/josh-project/josh
2025-06-03 19:52:05 +00:00
许杰友 Jieyou Xu (Joe) c51adbd12d
Merge pull request #2450 from jieyouxu/pr_message 2025-06-03 21:13:05 +08:00
bors 7eded778ab Auto merge of #136942 - Kobzol:stage0-sccache, r=jieyouxu
Use ccache for stage0 tool builds

Now after the stage0 redesign, we can actually start ccaching the build of the compiler itself. We can also cache the bootstrap tools, since these are also built with the stage0 compiler.

Stage0 compiler builds are now being cached: https://github.com/rust-lang/rust/actions/runs/15397246267#summary-43321151192 (`..bootstrap::core::build_steps::compile::Rustc	483.10s	40.41s	-91.6%`). It's not a gigantic win everywhere, but it should help. It seems to make the Linux jobs ~10 minute faster. It should be especially useful on PR builds after https://github.com/rust-lang/rust/pull/141948.

r? `@jieyouxu`

try-job: `x86_64-gnu-llvm-19*`
try-job: `x86_64-msvc*`
try-job: `x86_64-apple*`
try-job: `dist-x86_64-linux`
2025-06-03 13:09:57 +00:00
许杰友 Jieyou Xu (Joe) e058df17c8
Merge pull request #2451 from jieyouxu/rustc-pull 2025-06-03 20:19:44 +08:00
Jieyou Xu 88e0085b00 Merge from rustc 2025-06-03 20:17:50 +08:00
Jieyou Xu 91be3cb103 Preparing for merge from rustc 2025-06-03 20:16:00 +08:00
Jieyou Xu 36a33414f5
triagebot: configure PR welcome message for no auto/explicit reviewer 2025-06-03 20:05:19 +08:00
bors c911e7d730 Auto merge of #141210 - RalfJung:miri-std-doctests, r=saethlin
tools-aux ci runner: also cross-test doctests in Miri

Miri now supports running doctests across different targets. Let's use that to run the std doctests on aarch64-apple-darwin, i686-pc-windows-msvc.

try-job: x86_64-gnu-aux
2025-06-03 03:14:19 +00:00
bors c58f4830a2 Auto merge of #141750 - Noratrieb:gold-rush, r=bjorn3
Warn when gold was used as the linker

gold has been deprecated recently and is known to behave incorrectly around Rust programs, including miscompiling `#[used(linker)]`. Tell people to switch to a different linker instead.

closes rust-lang/rust#141748

r? bjorn3
2025-06-02 23:56:54 +00:00
bors 7a2568217a Auto merge of #141912 - Kobzol:rollup-wurlnsx, r=Kobzol
Rollup of 5 pull requests

Successful merges:

 - rust-lang/rust#141767 (ci: use free runner for aarch64-gnu-llvm-19-1 PR job)
 - rust-lang/rust#141858 (Fix typo in `StructuralPartialEq` docs)
 - rust-lang/rust#141865 (Optionally don't steal the THIR)
 - rust-lang/rust#141874 (add f16_epsilon and f128_epsilon diagnostic items)
 - rust-lang/rust#141904 (test-float-parse: apply `cfg(not(bootstrap))`)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-06-02 19:35:39 +00:00
bors 93a0856493 Auto merge of #141906 - chenyukang:rollup-k6v59ty, r=chenyukang
Rollup of 6 pull requests

Successful merges:

 - rust-lang/rust#141884 (allow macro_use as first segment)
 - rust-lang/rust#141885 ([RTE-484] Update SGX maintainers)
 - rust-lang/rust#141892 (Fix false positive lint error from no_implicit_prelude attr)
 - rust-lang/rust#141894 (rustc-dev-guide subtree update)
 - rust-lang/rust#141895 (tshepang has a new email)
 - rust-lang/rust#141897 (Fix citool tests when executed locally)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-06-02 16:15:30 +00:00
Jakub Beránek 3d1cba7bd7
Rollup merge of #141874 - usamoi:eps, r=tgross35
add f16_epsilon and f128_epsilon diagnostic items

cc https://github.com/rust-lang/rust/issues/116909
r? ``@tgross35``
2025-06-02 15:19:19 +02:00
Jakub Beránek e8e58652a4
Rollup merge of #141865 - Nadrieril:dont-steal-thir, r=oli-obk
Optionally don't steal the THIR

The THIR being stolen is a recurrent pain for authors of rustc drivers. This makes it optional, so that the `thir_body` query can still be used after analysis of the crate has completed.
2025-06-02 15:19:19 +02:00
Jakub Beránek 33a8bdd102
Rollup merge of #141858 - zacryol:spe-docs-typo, r=aDotInTheVoid
Fix typo in `StructuralPartialEq` docs

`equialent` => `equivalent`
2025-06-02 15:19:18 +02:00
Jakub Beránek 12566038b2
Rollup merge of #141767 - marcoieni:free-pr-job, r=Kobzol
ci: use free runner for aarch64-gnu-llvm-19-1 PR job
2025-06-02 15:19:17 +02:00
Yukang afd0380599
Rollup merge of #141897 - Kobzol:fix-citool-tests, r=marcoieni
Fix citool tests when executed locally

They couldn't be executed locally before due to some additional environment reads.

I also investigated the annoying rebuilds that we see on CI all the time, and they are caused by `ring`'s build script. It should be fixed in the next ring release (https://github.com/briansmith/ring/issues/2525), so we can just wait for that and then update `ring`.

r? `@marcoieni`
2025-06-02 20:57:44 +08:00
Yukang 81595902af
Rollup merge of #141895 - tshepang:new-address, r=jieyouxu
tshepang has a new email
2025-06-02 20:57:43 +08:00
Yukang 1a9be0c862
Rollup merge of #141894 - tshepang:rdg-push, r=jieyouxu
rustc-dev-guide subtree update

r? `@ghost`
2025-06-02 20:57:42 +08:00
Yukang f0267f227f
Rollup merge of #141892 - chenyukang:yukang-fix-141785-extern-crate, r=petrochenkov
Fix false positive lint error from no_implicit_prelude attr

Fixes rust-lang/rust#141785

r? `@petrochenkov`
2025-06-02 20:57:42 +08:00
Yukang d7a817beb2
Rollup merge of #141885 - raoulstrackx:raoul/rte-484-update_sgx_maintainers, r=Noratrieb
[RTE-484] Update SGX maintainers

`@mzohreva` is no longer with Fortanix. We need to change the SGX maintainers accordingly.
2025-06-02 20:57:41 +08:00
Yukang 4462c99c97
Rollup merge of #141884 - bvanjoi:issue-140255, r=petrochenkov
allow macro_use as first segment

Fixes rust-lang/rust#140255

This issue may raise a question: It's reasonable an external crate name or import target be legally named `macro_use`?
2025-06-02 20:57:41 +08:00
bors 3b3df39a7f Auto merge of #141814 - flip1995:clippy-subtree-update, r=Manishearth
Clippy subtree update

r? `@Manishearth`
2025-06-02 12:56:24 +00:00
Tshepang Mbambo 1f2bdb5526 use consistent title capitalization 2025-06-02 12:35:52 +02:00
bors 592a101be3 Auto merge of #119899 - onur-ozkan:redesign-stage0-std, r=albertlarsan68,jieyouxu,mark-simulacrum,kobzol,jyn514,Noratrieb,WaffleLapkin,RalfJung,bjorn3
redesign stage 0 std

### Summary

**Blog post: https://blog.rust-lang.org/inside-rust/2025/05/29/redesigning-the-initial-bootstrap-sequence/**

This PR changes how bootstrap builds the stage 1 compiler by switching to precompiled stage 0 standard library instead of building the in-tree one. The goal was to update bootstrap to use the beta standard library at stage 0 rather than compiling it from source (see the motivation at https://github.com/rust-lang/compiler-team/issues/619).

Previously, to build a stage 1 compiler bootstrap followed this path:

```
download stage0 compiler -> build in-tree std -> compile stage1 compiler with in-tree std
```

With this PR, the new path is:

```
download stage0 compiler -> compile stage1 compiler with precompiled stage0 std
```

This also means that `cfg(bootstrap)`/`cfg(not(bootstrap))` is no longer needed for library development.

### Building "library"

Since stage0 `std` is no longer in-tree `x build/test/check library --stage 0` is now no-op. The minimum supported stage to build `std` is now 1. For the same reason, default stage values in the library profile is no longer 0.

Because building the in-tree library now requires a stage1 compiler, I highly recommend library developers to enable `download-rustc` to speed up compilation time.

<hr>

**Blog post: https://blog.rust-lang.org/inside-rust/2025/05/29/redesigning-the-initial-bootstrap-sequence/**

If you encounter a bug or unexpected results please open a topic in the [#t-infra/bootstrap](https://rust-lang.zulipchat.com/#narrow/channel/326414-t-infra.2Fbootstrap) Zulip channel or create a [bootstrap issue](https://github.com/rust-lang/rust/issues/new?template=bootstrap.md).

(Review thread: https://rust-lang.zulipchat.com/#narrow/channel/326414-t-infra.2Fbootstrap/topic/Review.20thread.3A.20stage.200.20redesign.20PR/with/508271433)

~~Blocked on https://github.com/rust-lang/rust/pull/122709~~

try-job: dist-x86_64-linux
try-job: `x86_64-msvc*`
try-job: `x86_64-apple-*`
try-job: `aarch64-apple`
try-job: x86_64-gnu
try-job: `x86_64-gnu-llvm*`
2025-06-02 07:49:18 +00:00
onur-ozkan 257e73f3a3 improve comments and docs
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2025-05-30 21:04:14 +03:00
onur-ozkan 09eb3b3f78 update dev guidelines
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2025-05-30 21:04:08 +03:00
onur-ozkan 19a333ad0f split `mingw-check` into two
Signed-off-by: onur-ozkan <work@onurozkan.dev>
2025-05-30 21:04:05 +03:00
42 changed files with 531 additions and 505 deletions

View File

@ -1 +1 @@
99e7c15e81385b38a8186b51edc4577d5d7b5bdd
14346303d760027e53214e705109a62c0f00b214

View File

@ -63,10 +63,8 @@
- [Notification groups](notification-groups/about.md)
- [Apple](notification-groups/apple.md)
- [ARM](notification-groups/arm.md)
- [Cleanup Crew](notification-groups/cleanup-crew.md)
- [Emscripten](notification-groups/emscripten.md)
- [Fuchsia](notification-groups/fuchsia.md)
- [LLVM](notification-groups/llvm.md)
- [RISC-V](notification-groups/risc-v.md)
- [Rust for Linux](notification-groups/rust-for-linux.md)
- [WASI](notification-groups/wasi.md)
@ -101,6 +99,10 @@
- [Rustdoc internals](./rustdoc-internals.md)
- [Search](./rustdoc-internals/search.md)
- [The `rustdoc` test suite](./rustdoc-internals/rustdoc-test-suite.md)
- [The `rustdoc-gui` test suite](./rustdoc-internals/rustdoc-gui-test-suite.md)
- [The `rustdoc-json` test suite](./rustdoc-internals/rustdoc-json-test-suite.md)
- [GPU offload internals](./offload/internals.md)
- [Installation](./offload/installation.md)
- [Autodiff internals](./autodiff/internals.md)
- [Installation](./autodiff/installation.md)
- [How to debug](./autodiff/debugging.md)
@ -121,8 +123,9 @@
- [Feature gate checking](./feature-gate-ck.md)
- [Lang Items](./lang-items.md)
- [The HIR (High-level IR)](./hir.md)
- [Lowering AST to HIR](./ast-lowering.md)
- [Debugging](./hir-debugging.md)
- [Lowering AST to HIR](./hir/lowering.md)
- [Ambig/Unambig Types and Consts](./hir/ambig-unambig-ty-and-consts.md)
- [Debugging](./hir/debugging.md)
- [The THIR (Typed High-level IR)](./thir.md)
- [The MIR (Mid-level IR)](./mir/index.md)
- [MIR construction](./mir/construction.md)
@ -181,7 +184,7 @@
- [Significant changes and quirks](./solve/significant-changes.md)
- [`Unsize` and `CoerceUnsized` traits](./traits/unsize.md)
- [Type checking](./type-checking.md)
- [Method Lookup](./method-lookup.md)
- [Method lookup](./method-lookup.md)
- [Variance](./variance.md)
- [Coherence checking](./coherence.md)
- [Opaque types](./opaque-types-type-alias-impl-trait.md)
@ -189,7 +192,7 @@
- [Return Position Impl Trait In Trait](./return-position-impl-trait-in-trait.md)
- [Region inference restrictions][opaque-infer]
- [Const condition checking](./effects.md)
- [Pattern and Exhaustiveness Checking](./pat-exhaustive-checking.md)
- [Pattern and exhaustiveness checking](./pat-exhaustive-checking.md)
- [Unsafety checking](./unsafety-checking.md)
- [MIR dataflow](./mir/dataflow.md)
- [Drop elaboration](./mir/drop-elaboration.md)
@ -209,7 +212,7 @@
- [Closure capture inference](./closure.md)
- [Async closures/"coroutine-closures"](coroutine-closures.md)
# MIR to Binaries
# MIR to binaries
- [Prologue](./part-5-intro.md)
- [MIR optimizations](./mir/optimizations.md)
@ -218,15 +221,15 @@
- [Interpreter](./const-eval/interpret.md)
- [Monomorphization](./backend/monomorph.md)
- [Lowering MIR](./backend/lowering-mir.md)
- [Code Generation](./backend/codegen.md)
- [Code generation](./backend/codegen.md)
- [Updating LLVM](./backend/updating-llvm.md)
- [Debugging LLVM](./backend/debugging.md)
- [Backend Agnostic Codegen](./backend/backend-agnostic.md)
- [Implicit Caller Location](./backend/implicit-caller-location.md)
- [Libraries and Metadata](./backend/libs-and-metadata.md)
- [Profile-guided Optimization](./profile-guided-optimization.md)
- [LLVM Source-Based Code Coverage](./llvm-coverage-instrumentation.md)
- [Sanitizers Support](./sanitizers.md)
- [Implicit caller location](./backend/implicit-caller-location.md)
- [Libraries and metadata](./backend/libs-and-metadata.md)
- [Profile-guided optimization](./profile-guided-optimization.md)
- [LLVM source-based code coverage](./llvm-coverage-instrumentation.md)
- [Sanitizers support](./sanitizers.md)
- [Debugging support in the Rust compiler](./debugging-support-in-rustc.md)
---

View File

@ -1,4 +1,4 @@
# Implicit Caller Location
# Implicit caller location
<!-- toc -->
@ -8,7 +8,7 @@ adds the [`#[track_caller]`][attr-reference] attribute for functions, the
[`caller_location`][intrinsic] intrinsic, and the stabilization-friendly
[`core::panic::Location::caller`][wrapper] wrapper.
## Motivating Example
## Motivating example
Take this example program:
@ -39,7 +39,7 @@ These error messages are achieved through a combination of changes to `panic!` i
of `core::panic::Location::caller` and a number of `#[track_caller]` annotations in the standard
library which propagate caller information.
## Reading Caller Location
## Reading caller location
Previously, `panic!` made use of the `file!()`, `line!()`, and `column!()` macros to construct a
[`Location`] pointing to where the panic occurred. These macros couldn't be given an overridden
@ -51,7 +51,7 @@ was expanded. This function is itself annotated with `#[track_caller]` and wraps
[`caller_location`][intrinsic] compiler intrinsic implemented by rustc. This intrinsic is easiest
explained in terms of how it works in a `const` context.
## Caller Location in `const`
## Caller location in `const`
There are two main phases to returning the caller location in a const context: walking up the stack
to find the right location and allocating a const value to return.
@ -138,7 +138,7 @@ fn main() {
}
```
### Dynamic Dispatch
### Dynamic dispatch
In codegen contexts we have to modify the callee ABI to pass this information down the stack, but
the attribute expressly does *not* modify the type of the function. The ABI change must be
@ -156,7 +156,7 @@ probably the best we can do without modifying fully-stabilized type signatures.
> whether we'll be called in a const context (safe to ignore shim) or in a codegen context (unsafe
> to ignore shim). Even if we did know, the results from const and codegen contexts must agree.
## The Attribute
## The attribute
The `#[track_caller]` attribute is checked alongside other codegen attributes to ensure the
function:

View File

@ -1,4 +1,4 @@
# Libraries and Metadata
# Libraries and metadata
When the compiler sees a reference to an external crate, it needs to load some
information about that crate. This chapter gives an overview of that process,

View File

@ -55,7 +55,7 @@ Bootstrap will conditionally build `tracing` support and enable `tracing` output
Example basic usage[^just-trace]:
[^just-trace]: It is not recommend to use *just* `BOOTSTRAP_TRACING=TRACE` because that will dump *everything* at `TRACE` level, including logs intentionally gated behind custom targets as they are too verbose even for `TRACE` level by default.
[^just-trace]: It is not recommended to use *just* `BOOTSTRAP_TRACING=TRACE` because that will dump *everything* at `TRACE` level, including logs intentionally gated behind custom targets as they are too verbose even for `TRACE` level by default.
```bash
$ BOOTSTRAP_TRACING=bootstrap=TRACE ./x build library --stage 1

View File

@ -45,13 +45,13 @@ compiler.
```mermaid
graph TD
s0c["stage0 compiler (1.63)"]:::downloaded -->|A| s0l("stage0 std (1.64)"):::with-s0c;
s0c["stage0 compiler (1.86.0-beta.1)"]:::downloaded -->|A| s0l("stage0 std (1.86.0-beta.1)"):::downloaded;
s0c & s0l --- stepb[ ]:::empty;
stepb -->|B| s0ca["stage0 compiler artifacts (1.64)"]:::with-s0c;
s0ca -->|copy| s1c["stage1 compiler (1.64)"]:::with-s0c;
s1c -->|C| s1l("stage1 std (1.64)"):::with-s1c;
stepb -->|B| s0ca["stage0 compiler artifacts (1.87.0-dev)"]:::with-s0c;
s0ca -->|copy| s1c["stage1 compiler (1.87.0-dev)"]:::with-s0c;
s1c -->|C| s1l("stage1 std (1.87.0-dev)"):::with-s1c;
s1c & s1l --- stepd[ ]:::empty;
stepd -->|D| s1ca["stage1 compiler artifacts (1.64)"]:::with-s1c;
stepd -->|D| s1ca["stage1 compiler artifacts (1.87.0-dev)"]:::with-s1c;
s1ca -->|copy| s2c["stage2 compiler"]:::with-s1c;
classDef empty width:0px,height:0px;
@ -62,19 +62,21 @@ graph TD
### Stage 0: the pre-compiled compiler
The stage0 compiler is usually the current _beta_ `rustc` compiler and its
The stage0 compiler is by default the very recent _beta_ `rustc` compiler and its
associated dynamic libraries, which `./x.py` will download for you. (You can
also configure `./x.py` to use something else.)
also configure `./x.py` to change stage0 to something else.)
The stage0 compiler is then used only to compile [`src/bootstrap`],
[`library/std`], and [`compiler/rustc`]. When assembling the libraries and
binaries that will become the stage1 `rustc` compiler, the freshly compiled
`std` and `rustc` are used. There are two concepts at play here: a compiler
(with its set of dependencies) and its 'target' or 'object' libraries (`std` and
`rustc`). Both are staged, but in a staggered manner.
The precompiled stage0 compiler is then used only to compile [`src/bootstrap`] and [`compiler/rustc`]
with precompiled stage0 std.
Note that to build the stage1 compiler we use the precompiled stage0 compiler and std.
Therefore, to use a compiler with a std that is freshly built from the tree, you need to
build the stage2 compiler.
There are two concepts at play here: a compiler (with its set of dependencies) and its
'target' or 'object' libraries (`std` and `rustc`). Both are staged, but in a staggered manner.
[`compiler/rustc`]: https://github.com/rust-lang/rust/tree/master/compiler/rustc
[`library/std`]: https://github.com/rust-lang/rust/tree/master/library/std
[`src/bootstrap`]: https://github.com/rust-lang/rust/tree/master/src/bootstrap
### Stage 1: from current code, by an earlier compiler
@ -84,16 +86,14 @@ The rustc source code is then compiled with the `stage0` compiler to produce the
### Stage 2: the truly current compiler
We then rebuild our `stage1` compiler with itself to produce the `stage2`
We then rebuild the compiler using `stage1` compiler with in-tree std to produce the `stage2`
compiler.
In theory, the `stage1` compiler is functionally identical to the `stage2`
compiler, but in practice there are subtle differences. In particular, the
`stage1` compiler itself was built by `stage0` and hence not by the source in
your working directory. This means that the ABI generated by the `stage0`
compiler may not match the ABI that would have been made by the `stage1`
compiler, which can cause problems for dynamic libraries, tests, and tools using
`rustc_private`.
The `stage1` compiler itself was built by precompiled `stage0` compiler and std
and hence not by the source in your working directory. This means that the ABI
generated by the `stage0` compiler may not match the ABI that would have been made
by the `stage1` compiler, which can cause problems for dynamic libraries, tests
and tools using `rustc_private`.
Note that the `proc_macro` crate avoids this issue with a `C` FFI layer called
`proc_macro::bridge`, allowing it to be used with `stage1`.
@ -101,9 +101,10 @@ Note that the `proc_macro` crate avoids this issue with a `C` FFI layer called
The `stage2` compiler is the one distributed with `rustup` and all other install
methods. However, it takes a very long time to build because one must first
build the new compiler with an older compiler and then use that to build the new
compiler with itself. For development, you usually only want the `stage1`
compiler, which you can build with `./x build library`. See [Building the
compiler](../how-to-build-and-run.html#building-the-compiler).
compiler with itself.
For development, you usually only want to use `--stage 1` flag to build things.
See [Building the compiler](../how-to-build-and-run.html#building-the-compiler).
### Stage 3: the same-result test
@ -114,10 +115,11 @@ something has broken.
### Building the stages
The script [`./x`] tries to be helpful and pick the stage you most likely meant
for each subcommand. These defaults are as follows:
for each subcommand. Here are some `x` commands with their default stages:
- `check`: `--stage 0`
- `doc`: `--stage 0`
- `check`: `--stage 1`
- `clippy`: `--stage 1`
- `doc`: `--stage 1`
- `build`: `--stage 1`
- `test`: `--stage 1`
- `dist`: `--stage 2`
@ -191,8 +193,8 @@ include, but are not limited to:
without building `rustc` from source ('build with `stage0`, then test the
artifacts'). If you're working on the standard library, this is normally the
test command you want.
- `./x build --stage 0` means to build with the beta `rustc`.
- `./x doc --stage 0` means to document using the beta `rustdoc`.
- `./x build --stage 0` means to build with the stage0 `rustc`.
- `./x doc --stage 0` means to document using the stage0 `rustdoc`.
#### Examples of what *not* to do
@ -208,9 +210,6 @@ include, but are not limited to:
### Building vs. running
Note that `build --stage N compiler/rustc` **does not** build the stage N
compiler: instead it builds the stage N+1 compiler _using_ the stage N compiler.
In short, _stage 0 uses the `stage0` compiler to create `stage0` artifacts which
will later be uplifted to be the stage1 compiler_.
@ -268,23 +267,6 @@ However, when cross-compiling, `stage1` `std` will only run on the host. So the
(See in the table how `stage2` only builds non-host `std` targets).
### Why does only libstd use `cfg(bootstrap)`?
For docs on `cfg(bootstrap)` itself, see [Complications of
Bootstrapping](#complications-of-bootstrapping).
The `rustc` generated by the `stage0` compiler is linked to the freshly-built
`std`, which means that for the most part only `std` needs to be `cfg`-gated, so
that `rustc` can use features added to `std` immediately after their addition,
without need for them to get into the downloaded `beta` compiler.
Note this is different from any other Rust program: `stage1` `rustc` is built by
the _beta_ compiler, but using the _master_ version of `libstd`!
The only time `rustc` uses `cfg(bootstrap)` is when it adds internal lints that
use diagnostic items, or when it uses unstable library features that were
recently changed.
### What is a 'sysroot'?
When you build a project with `cargo`, the build artifacts for dependencies are
@ -459,7 +441,6 @@ compiler itself uses to run. These aren't actually used by artifacts the new
compiler generates. This step also copies the `rustc` and `rustdoc` binaries we
generated into `build/$HOST/stage/bin`.
The `stage1/bin/rustc` is a fully functional compiler, but it doesn't yet have
any libraries to link built binaries or libraries to. The next 3 steps will
provide those libraries for it; they are mostly equivalent to constructing the
`stage1/bin` compiler so we don't go through them individually here.
The `stage1/bin/rustc` is a fully functional compiler built with stage0 (precompiled) compiler and std.
To use a compiler built entirely from source with the in-tree compiler and std, you need to build the
stage2 compiler, which is compiled using the stage1 (in-tree) compiler and std.

View File

@ -217,7 +217,6 @@ probably the best "go to" command for building a local compiler:
This may *look* like it only builds the standard library, but that is not the case.
What this command does is the following:
- Build `std` using the stage0 compiler
- Build `rustc` using the stage0 compiler
- This produces the stage1 compiler
- Build `std` using the stage1 compiler
@ -241,8 +240,7 @@ build. The **full** `rustc` build (what you get with `./x build
--stage 2 compiler/rustc`) has quite a few more steps:
- Build `rustc` with the stage1 compiler.
- The resulting compiler here is called the "stage2" compiler.
- Build `std` with stage2 compiler.
- The resulting compiler here is called the "stage2" compiler, which uses stage1 std from the previous command.
- Build `librustdoc` and a bunch of other things with the stage2 compiler.
You almost never need to do this.
@ -250,14 +248,14 @@ You almost never need to do this.
### Build specific components
If you are working on the standard library, you probably don't need to build
the compiler unless you are planning to use a recently added nightly feature.
Instead, you can just build using the bootstrap compiler.
every other default component. Instead, you can build a specific component by
providing its name, like this:
```bash
./x build --stage 0 library
./x build --stage 1 library
```
If you choose the `library` profile when running `x setup`, you can omit `--stage 0` (it's the
If you choose the `library` profile when running `x setup`, you can omit `--stage 1` (it's the
default).
## Creating a rustup toolchain
@ -271,7 +269,6 @@ you will likely need to build at some point; for example, if you want
to run the entire test suite).
```bash
rustup toolchain link stage0 build/host/stage0-sysroot # beta compiler + stage0 std
rustup toolchain link stage1 build/host/stage1
rustup toolchain link stage2 build/host/stage2
```

View File

@ -85,7 +85,7 @@ Look for existing targets to use as examples.
After adding your target to the `rustc_target` crate you may want to add
`core`, `std`, ... with support for your new target. In that case you will
probably need access to some `target_*` cfg. Unfortunately when building with
stage0 (the beta compiler), you'll get an error that the target cfg is
stage0 (a precompiled compiler), you'll get an error that the target cfg is
unexpected because stage0 doesn't know about the new target specification and
we pass `--check-cfg` in order to tell it to check.
@ -174,8 +174,8 @@ compiler, you can use it instead of the JSON file for both arguments.
## Promoting a target from tier 2 (target) to tier 2 (host)
There are two levels of tier 2 targets:
a) Targets that are only cross-compiled (`rustup target add`)
b) Targets that [have a native toolchain][tier2-native] (`rustup toolchain install`)
- Targets that are only cross-compiled (`rustup target add`)
- Targets that [have a native toolchain][tier2-native] (`rustup toolchain install`)
[tier2-native]: https://doc.rust-lang.org/nightly/rustc/target-tier-policy.html#tier-2-with-host-tools

View File

@ -59,6 +59,14 @@ always overrides the inner ones.
## Configuring `rust-analyzer` for `rustc`
### Checking the "library" tree
Checking the "library" tree requires a stage1 compiler, which can be a heavy process on some computers.
For this reason, bootstrap has a flag called `--skip-std-check-if-no-download-rustc` that skips checking the
"library" tree if `rust.download-rustc` isn't available. If you want to avoid putting a heavy load on your computer
with `rust-analyzer`, you can add the `--skip-std-check-if-no-download-rustc` flag to your `./x check` command in
the `rust-analyzer` configuration.
### Project-local rust-analyzer setup
`rust-analyzer` can help you check and format your code whenever you save a
@ -307,51 +315,15 @@ lets you use `cargo fmt`.
[the section on vscode]: suggested.md#configuring-rust-analyzer-for-rustc
[the section on rustup]: how-to-build-and-run.md?highlight=rustup#creating-a-rustup-toolchain
## Faster builds with `--keep-stage`.
## Faster Builds with CI-rustc
Sometimes just checking whether the compiler builds is not enough. A common
example is that you need to add a `debug!` statement to inspect the value of
some state or better understand the problem. In that case, you don't really need
a full build. By bypassing bootstrap's cache invalidation, you can often get
these builds to complete very fast (e.g., around 30 seconds). The only catch is
this requires a bit of fudging and may produce compilers that don't work (but
that is easily detected and fixed).
The sequence of commands you want is as follows:
- Initial build: `./x build library`
- As [documented previously], this will build a functional stage1 compiler as
part of running all stage0 commands (which include building a `std`
compatible with the stage1 compiler) as well as the first few steps of the
"stage 1 actions" up to "stage1 (sysroot stage1) builds std".
- Subsequent builds: `./x build library --keep-stage 1`
- Note that we added the `--keep-stage 1` flag here
[documented previously]: ./how-to-build-and-run.md#building-the-compiler
As mentioned, the effect of `--keep-stage 1` is that we just _assume_ that the
old standard library can be re-used. If you are editing the compiler, this is
almost always true: you haven't changed the standard library, after all. But
sometimes, it's not true: for example, if you are editing the "metadata" part of
the compiler, which controls how the compiler encodes types and other states
into the `rlib` files, or if you are editing things that wind up in the metadata
(such as the definition of the MIR).
**The TL;DR is that you might get weird behavior from a compile when using
`--keep-stage 1`** -- for example, strange [ICEs](../appendix/glossary.html#ice)
or other panics. In that case, you should simply remove the `--keep-stage 1`
from the command and rebuild. That ought to fix the problem.
You can also use `--keep-stage 1` when running tests. Something like this:
- Initial test run: `./x test tests/ui`
- Subsequent test run: `./x test tests/ui --keep-stage 1`
### Iterating the standard library with `--keep-stage`
If you are making changes to the standard library, you can use `./x build
--keep-stage 0 library` to iteratively rebuild the standard library without
rebuilding the compiler.
If you are not working on the compiler, you often don't need to build the compiler tree.
For example, you can skip building the compiler and only build the `library` tree or the
tools under `src/tools`. To achieve that, you have to enable this by setting the `download-rustc`
option in your configuration. This tells bootstrap to use the latest nightly compiler for `stage > 0`
steps, meaning it will have two precompiled compilers: stage0 compiler and `download-rustc` compiler
for `stage > 0` steps. This way, it will never need to build the in-tree compiler. As a result, your
build time will be significantly reduced by not building the in-tree compiler.
## Using incremental compilation

View File

@ -364,7 +364,7 @@ To find documentation-related issues, use the [A-docs label].
You can find documentation style guidelines in [RFC 1574].
To build the standard library documentation, use `x doc --stage 0 library --open`.
To build the standard library documentation, use `x doc --stage 1 library --open`.
To build the documentation for a book (e.g. the unstable book), use `x doc src/doc/unstable-book.`
Results should appear in `build/host/doc`, as well as automatically open in your default browser.
See [Building Documentation](./building/compiler-documenting.md#building-documentation) for more

View File

@ -553,7 +553,7 @@ compiler](#linting-early-in-the-compiler).
[AST nodes]: the-parser.md
[AST lowering]: ast-lowering.md
[AST lowering]: ./hir/lowering.md
[HIR nodes]: hir.md
[MIR nodes]: mir/index.md
[macro expansion]: macro-expansion.md

View File

@ -158,9 +158,6 @@ feel comfortable jumping straight into the large `rust-lang/rust` codebase.
The following tasks are doable without much background knowledge but are
incredibly helpful:
- [Cleanup crew][iceb]: find minimal reproductions of ICEs, bisect
regressions, etc. This is a way of helping that saves a ton of time for
others to fix an error later.
- [Writing documentation][wd]: if you are feeling a bit more intrepid, you could try
to read a part of the code and write doc comments for it. This will help you
to learn some part of the compiler while also producing a useful artifact!
@ -179,7 +176,6 @@ incredibly helpful:
[users]: https://users.rust-lang.org/
[so]: http://stackoverflow.com/questions/tagged/rust
[community-library]: https://github.com/rust-lang/rfcs/labels/A-community-library
[iceb]: ./notification-groups/cleanup-crew.md
[wd]: ./contributing.md#writing-documentation
[wg]: https://rust-lang.github.io/compiler-team/working-groups/
[triage]: ./contributing.md#issue-triage

View File

@ -142,7 +142,8 @@ The most common cause is that you rebased after a change and ran `git add .` wit
`x` to update the submodules. Alternatively, you might have run `cargo fmt` instead of `x fmt`
and modified files in a submodule, then committed the changes.
To fix it, do the following things:
To fix it, do the following things (if you changed a submodule other than cargo,
replace `src/tools/cargo` with the path to that submodule):
1. See which commit has the accidental changes: `git log --stat -n1 src/tools/cargo`
2. Revert the changes to that commit: `git checkout <my-commit>~ src/tools/cargo`. Type `~`

View File

@ -5,7 +5,7 @@
The HIR "High-Level Intermediate Representation" is the primary IR used
in most of rustc. It is a compiler-friendly representation of the abstract
syntax tree (AST) that is generated after parsing, macro expansion, and name
resolution (see [Lowering](./ast-lowering.html) for how the HIR is created).
resolution (see [Lowering](./hir/lowering.md) for how the HIR is created).
Many parts of HIR resemble Rust surface syntax quite closely, with
the exception that some of Rust's expression forms have been desugared away.
For example, `for` loops are converted into a `loop` and do not appear in

View File

@ -0,0 +1,63 @@
# Ambig/Unambig Types and Consts
Types and Consts args in the HIR can be in two kinds of positions ambiguous (ambig) or unambiguous (unambig). Ambig positions are where
it would be valid to parse either a type or a const, unambig positions are where only one kind would be valid to
parse.
```rust
fn func<T, const N: usize>(arg: T) {
// ^ Unambig type position
let a: _ = arg;
// ^ Unambig type position
func::<T, N>(arg);
// ^ ^
// ^^^^ Ambig position
let _: [u8; 10];
// ^^ ^^ Unambig const position
// ^^ Unambig type position
}
```
Most types/consts in ambig positions are able to be disambiguated as either a type or const during parsing. Single segment paths are always represented as types in the AST but may get resolved to a const parameter during name resolution, then lowered to a const argument during ast-lowering. The only generic arguments which remain ambiguous after lowering are inferred generic arguments (`_`) in path segments. For example, in `Foo<_>` it is not clear whether the `_` argument is an inferred type argument, or an inferred const argument.
In unambig positions, inferred arguments are represented with [`hir::TyKind::Infer`][ty_infer] or [`hir::ConstArgKind::Infer`][const_infer] depending on whether it is a type or const position respectively.
In ambig positions, inferred arguments are represented with `hir::GenericArg::Infer`.
A naive implementation of this would result in there being potentially 5 places where you might think an inferred type/const could be found in the HIR from looking at the structure of the HIR:
1. In unambig type position as a `hir::TyKind::Infer`
2. In unambig const arg position as a `hir::ConstArgKind::Infer`
3. In an ambig position as a [`GenericArg::Type(TyKind::Infer)`][generic_arg_ty]
4. In an ambig position as a [`GenericArg::Const(ConstArgKind::Infer)`][generic_arg_const]
5. In an ambig position as a [`GenericArg::Infer`][generic_arg_infer]
Note that places 3 and 4 would never actually be possible to encounter as we always lower to `GenericArg::Infer` in generic arg position.
This has a few failure modes:
- People may write visitors which check for `GenericArg::Infer` but forget to check for `hir::TyKind/ConstArgKind::Infer`, only handling infers in ambig positions by accident.
- People may write visitors which check for `hir::TyKind/ConstArgKind::Infer` but forget to check for `GenericArg::Infer`, only handling infers in unambig positions by accident.
- People may write visitors which check for `GenerArg::Type/Const(TyKind/ConstArgKind::Infer)` and `GenerigArg::Infer`, not realising that we never represent inferred types/consts in ambig positions as a `GenericArg::Type/Const`.
- People may write visitors which check for *only* `TyKind::Infer` and not `ConstArgKind::Infer` forgetting that there are also inferred const arguments (and vice versa).
To make writing HIR visitors less error prone when caring about inferred types/consts we have a relatively complex system:
1. We have different types in the compiler for when a type or const is in an unambig or ambig position, `hir::Ty<AmbigArg>` and `hir::Ty<()>`. [`AmbigArg`][ambig_arg] is an uninhabited type which we use in the `Infer` variant of `TyKind` and `ConstArgKind` to selectively "disable" it if we are in an ambig position.
2. The [`visit_ty`][visit_ty] and [`visit_const_arg`][visit_const_arg] methods on HIR visitors only accept the ambig position versions of types/consts. Unambig types/consts are implicitly converted to ambig types/consts during the visiting process, with the `Infer` variant handled by a dedicated [`visit_infer`][visit_infer] method.
This has a number of benefits:
- It's clear that `GenericArg::Type/Const` cannot represent inferred type/const arguments
- Implementors of `visit_ty` and `visit_const_arg` will never encounter inferred types/consts making it impossible to write a visitor that seems to work right but handles edge cases wrong
- The `visit_infer` method handles *all* cases of inferred type/consts in the HIR making it easy for visitors to handle inferred type/consts in one dedicated place and not forget cases
[ty_infer]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/hir/enum.TyKind.html#variant.Infer
[const_infer]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/hir/enum.ConstArgKind.html#variant.Infer
[generic_arg_ty]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/hir/enum.GenericArg.html#variant.Type
[generic_arg_const]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/hir/enum.GenericArg.html#variant.Const
[generic_arg_infer]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/hir/enum.GenericArg.html#variant.Infer
[ambig_arg]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/hir/enum.AmbigArg.html
[visit_ty]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/intravisit/trait.Visitor.html#method.visit_ty
[visit_const_arg]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/intravisit/trait.Visitor.html#method.visit_const_arg
[visit_infer]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/intravisit/trait.Visitor.html#method.visit_infer

View File

@ -1,6 +1,6 @@
# AST lowering
The AST lowering step converts AST to [HIR](hir.html).
The AST lowering step converts AST to [HIR](../hir.md).
This means many structures are removed if they are irrelevant
for type analysis or similar syntax agnostic analyses. Examples
of such structures include but are not limited to

View File

@ -1,4 +1,4 @@
# LLVM Source-Based Code Coverage
# LLVM source-based code coverage
<!-- toc -->

View File

@ -21,9 +21,7 @@ search for existing issues that haven't been claimed yet.
Here's the list of the notification groups:
- [Apple](./apple.md)
- [ARM](./arm.md)
- [Cleanup Crew](./cleanup-crew.md)
- [Emscripten](./emscripten.md)
- [LLVM Icebreakers](./llvm.md)
- [RISC-V](./risc-v.md)
- [WASI](./wasi.md)
- [WebAssembly](./wasm.md)
@ -64,9 +62,7 @@ Example PRs:
* [Example of adding yourself to the Apple group.](https://github.com/rust-lang/team/pull/1434)
* [Example of adding yourself to the ARM group.](https://github.com/rust-lang/team/pull/358)
* [Example of adding yourself to the Cleanup Crew.](https://github.com/rust-lang/team/pull/221)
* [Example of adding yourself to the Emscripten group.](https://github.com/rust-lang/team/pull/1579)
* [Example of adding yourself to the LLVM group.](https://github.com/rust-lang/team/pull/140)
* [Example of adding yourself to the RISC-V group.](https://github.com/rust-lang/team/pull/394)
* [Example of adding yourself to the WASI group.](https://github.com/rust-lang/team/pull/1580)
* [Example of adding yourself to the WebAssembly group.](https://github.com/rust-lang/team/pull/1581)
@ -81,9 +77,7 @@ group. For example:
```text
@rustbot ping apple
@rustbot ping arm
@rustbot ping cleanup-crew
@rustbot ping emscripten
@rustbot ping icebreakers-llvm
@rustbot ping risc-v
@rustbot ping wasi
@rustbot ping wasm
@ -92,12 +86,12 @@ group. For example:
To make some commands shorter and easier to remember, there are aliases,
defined in the [`triagebot.toml`] file. For example, all of these commands
are equivalent and will ping the Cleanup Crew:
are equivalent and will ping the Apple group:
```text
@rustbot ping cleanup
@rustbot ping bisect
@rustbot ping reduce
@rustbot ping apple
@rustbot ping macos
@rustbot ping ios
```
Keep in mind that these aliases are meant to make humans' life easier.

View File

@ -1,90 +0,0 @@
# Cleanup Crew
**Github Label:** [ICEBreaker-Cleanup-Crew] <br>
**Ping command:** `@rustbot ping cleanup-crew`
[ICEBreaker-Cleanup-Crew]: https://github.com/rust-lang/rust/labels/ICEBreaker-Cleanup-Crew
The "Cleanup Crew" are focused on improving bug reports. Specifically,
the goal is to try to ensure that every bug report has all the
information that will be needed for someone to fix it:
* a minimal, standalone example that shows the problem
* links to duplicates or related bugs
* if the bug is a regression (something that used to work, but no longer does),
then a bisection to the PR or nightly that caused the regression
This kind of cleanup is invaluable in getting bugs fixed. Better
still, it can be done by anybody who knows Rust, without any
particularly deep knowledge of the compiler.
Let's look a bit at the workflow for doing "cleanup crew" actions.
## Finding a minimal, standalone example
Here the ultimate goal is to produce an example that reproduces the same
problem but without relying on any external crates. Such a test ought to contain
as little code as possible, as well. This will make it much easier to isolate the problem.
However, even if the "ultimate minimal test" cannot be achieved, it's
still useful to post incremental minimizations. For example, if you
can eliminate some of the external dependencies, that is helpful, and
so forth.
It's particularly useful to reduce to an example that works
in the [Rust playground](https://play.rust-lang.org/), rather than
requiring people to checkout a cargo build.
There are many resources for how to produce minimized test cases. Here
are a few:
* The [rust-reduce](https://github.com/jethrogb/rust-reduce) tool can try to reduce
code automatically.
* The [C-reduce](https://github.com/csmith-project/creduce) tool also works
on Rust code, though it requires that you start from a single
file. (A post explaining how to do it can be found [here](https://insaneinside.net/2017/09/12/whole-crate-bug-reduction-with-creduce.html).)
* pnkfelix's [Rust Bug Minimization Patterns] blog post
* This post focuses on "heavy bore" techniques, where you are
starting with a large, complex cargo project that you wish to
narrow down to something standalone.
[Rust Bug Minimization Patterns]: http://blog.pnkfx.org/blog/2019/11/18/rust-bug-minimization-patterns/
## Links to duplicate or related bugs
If you are on the "Cleanup Crew", you will sometimes see multiple bug
reports that seem very similar. You can link one to the other just by
mentioning the other bug number in a Github comment. Sometimes it is
useful to close duplicate bugs. But if you do so, you should always
copy any test case from the bug you are closing to the other bug that
remains open, as sometimes duplicate-looking bugs will expose
different facets of the same problem.
## Bisecting regressions
For regressions (something that used to work, but no longer does), it
is super useful if we can figure out precisely when the code stopped
working. The gold standard is to be able to identify the precise
**PR** that broke the code, so we can ping the author, but even
narrowing it down to a nightly build is helpful, especially as that
then gives us a range of PRs. (One other challenge is that we
sometimes land "rollup" PRs, which combine multiple PRs into one.)
### cargo-bisect-rustc
To help in figuring out the cause of a regression we have a tool
called [cargo-bisect-rustc]. It will automatically download and test
various builds of rustc. For recent regressions, it is even able to
use the builds from our CI to track down the regression to a specific
PR; for older regressions, it will simply identify a nightly.
To learn to use [cargo-bisect-rustc], check out [this blog post][learn], which
gives a quick introduction to how it works. Additionally, there is a [Guide]
which goes into more detail on how to use it. You can also ask questions at
the Zulip stream [`#t-compiler/cargo-bisect-rustc`][zcbr], or help in
improving the tool.
[cargo-bisect-rustc]: https://github.com/rust-lang/cargo-bisect-rustc/
[learn]: https://blog.rust-lang.org/inside-rust/2019/12/18/bisecting-rust-compiler.html
[zcbr]: https://rust-lang.zulipchat.com/#narrow/stream/217417-t-compiler.2Fcargo-bisect-rustc
[Guide]: https://rust-lang.github.io/cargo-bisect-rustc/

View File

@ -1,38 +0,0 @@
# LLVM Icebreakers Notification group
**Github Label:** [A-LLVM] <br>
**Ping command:** `@rustbot ping icebreakers-llvm`
[A-LLVM]: https://github.com/rust-lang/rust/labels/A-LLVM
*Note*: this notification group is *not* the same as the LLVM working group
(WG-llvm).
The "LLVM Icebreakers Notification Group" are focused on bugs that center around
LLVM. These bugs often arise because of LLVM optimizations gone awry, or as the
result of an LLVM upgrade. The goal here is:
- to determine whether the bug is a result of us generating invalid LLVM IR,
or LLVM misoptimizing;
- if the former, to fix our IR;
- if the latter, to try and file a bug on LLVM (or identify an existing bug).
The group may also be asked to weigh in on other sorts of LLVM-focused
questions.
## Helpful tips and options
The ["Debugging LLVM"][d] section of the
rustc-dev-guide gives a step-by-step process for how to help debug bugs
caused by LLVM. In particular, it discusses how to emit LLVM IR, run
the LLVM IR optimization pipelines, and so forth. You may also find
it useful to look at the various codegen options listed under `-C help`
and the internal options under `-Z help` -- there are a number that
pertain to LLVM (just search for LLVM).
[d]: ../backend/debugging.md
## If you do narrow to an LLVM bug
The ["Debugging LLVM"][d] section also describes what to do once
you've identified the bug.

View File

@ -8,7 +8,7 @@ First you need to clone and configure the Rust repository:
```bash
git clone --depth=1 git@github.com:rust-lang/rust.git
cd rust
./configure --enable-llvm-link-shared --release-channel=nightly --enable-llvm-assertions --enable-offload --enable-clang --enable-lld --enable-option-checking --enable-ninja --disable-docs
./configure --enable-llvm-link-shared --release-channel=nightly --enable-llvm-assertions --enable-offload --enable-enzyme --enable-clang --enable-lld --enable-option-checking --enable-ninja --disable-docs
```
Afterwards you can build rustc using:
@ -18,7 +18,7 @@ Afterwards you can build rustc using:
Afterwards rustc toolchain link will allow you to use it through cargo:
```
rustup toolchain link enzyme build/host/stage1
rustup toolchain link offload build/host/stage1
rustup toolchain install nightly # enables -Z unstable-options
```
@ -35,3 +35,37 @@ ninja
ninja install
```
This gives you a working LLVM build.
## Testing
run
```
./x.py test --stage 1 tests/codegen/gpu_offload
```
## Usage
It is important to use a clang compiler build on the same llvm as rustc. Just calling clang without the full path will likely use your system clang, which probably will be incompatible.
```
/absolute/path/to/rust/build/x86_64-unknown-linux-gnu/stage1/bin/rustc --edition=2024 --crate-type cdylib src/main.rs --emit=llvm-ir -O -C lto=fat -Cpanic=abort -Zoffload=Enable
/absolute/path/to/rust/build/x86_64-unknown-linux-gnu/llvm/bin/clang++ -fopenmp --offload-arch=native -g -O3 main.ll -o main -save-temps
LIBOMPTARGET_INFO=-1 ./main
```
The first step will generate a `main.ll` file, which has enough instructions to cause the offload runtime to move data to and from a gpu.
The second step will use clang as the compilation driver to compile our IR file down to a working binary. Only a very small Rust subset will work out of the box here, unless
you use features like build-std, which are not covered by this guide. Look at the codegen test to get a feeling for how to write a working example.
In the last step you can run your binary, if all went well you will see a data transfer being reported:
```
omptarget device 0 info: Entering OpenMP data region with being_mapper at unknown:0:0 with 1 arguments:
omptarget device 0 info: tofrom(unknown)[1024]
omptarget device 0 info: Creating new map entry with HstPtrBase=0x00007fffffff9540, HstPtrBegin=0x00007fffffff9540, TgtAllocBegin=0x0000155547200000, TgtPtrBegin=0x0000155547200000, Size=1024, DynRefCount=1, HoldRefCount=0, Name=unknown
omptarget device 0 info: Copying data from host to device, HstPtr=0x00007fffffff9540, TgtPtr=0x0000155547200000, Size=1024, Name=unknown
omptarget device 0 info: OpenMP Host-Device pointer mappings after block at unknown:0:0:
omptarget device 0 info: Host Ptr Target Ptr Size (B) DynRefCount HoldRefCount Declaration
omptarget device 0 info: 0x00007fffffff9540 0x0000155547200000 1024 1 0 unknown at unknown:0:0
// some other output
omptarget device 0 info: Exiting OpenMP data region with end_mapper at unknown:0:0 with 1 arguments:
omptarget device 0 info: tofrom(unknown)[1024]
omptarget device 0 info: Mapping exists with HstPtrBegin=0x00007fffffff9540, TgtPtrBegin=0x0000155547200000, Size=1024, DynRefCount=0 (decremented, delayed deletion), HoldRefCount=0
omptarget device 0 info: Copying data from device to host, TgtPtr=0x0000155547200000, HstPtr=0x00007fffffff9540, Size=1024, Name=unknown
omptarget device 0 info: Removing map entry with HstPtrBegin=0x00007fffffff9540, TgtPtrBegin=0x0000155547200000, Size=1024, Name=unknown
```

9
src/offload/internals.md Normal file
View File

@ -0,0 +1,9 @@
# std::offload
This module is under active development. Once upstream, it should allow Rust developers to run Rust code on GPUs.
We aim to develop a `rusty` GPU programming interface, which is safe, convenient and sufficiently fast by default.
This includes automatic data movement to and from the GPU, in a efficient way. We will (later)
also offer more advanced, possibly unsafe, interfaces which allow a higher degree of control.
The implementation is based on LLVM's "offload" project, which is already used by OpenMP to run Fortran or C++ code on GPUs.
While the project is under development, users will need to call other compilers like clang to finish the compilation process.

View File

@ -410,7 +410,7 @@ For more details on bootstrapping, see
- Guide: [The HIR](hir.md)
- Guide: [Identifiers in the HIR](hir.md#identifiers-in-the-hir)
- Guide: [The `HIR` Map](hir.md#the-hir-map)
- Guide: [Lowering `AST` to `HIR`](ast-lowering.md)
- Guide: [Lowering `AST` to `HIR`](./hir/lowering.md)
- How to view `HIR` representation for your code `cargo rustc -- -Z unpretty=hir-tree`
- Rustc `HIR` definition: [`rustc_hir`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/index.html)
- Main entry point: **TODO**

View File

@ -1,4 +1,4 @@
# From MIR to Binaries
# From MIR to binaries
All of the preceding chapters of this guide have one thing in common:
we never generated any executable machine code at all!

View File

@ -1,4 +1,4 @@
# Pattern and Exhaustiveness Checking
# Pattern and exhaustiveness checking
In Rust, pattern matching and bindings have a few very helpful properties. The
compiler will check that bindings are irrefutable when made and that match arms

View File

@ -1,4 +1,4 @@
# Profile Guided Optimization
# Profile-guided optimization
<!-- toc -->
@ -6,7 +6,7 @@
This chapter describes what PGO is and how the support for it is
implemented in `rustc`.
## What Is Profiled-Guided Optimization?
## What is profiled-guided optimization?
The basic concept of PGO is to collect data about the typical execution of
a program (e.g. which branches it is likely to take) and then use this data
@ -52,7 +52,7 @@ instrumentation, via the experimental option
[`-C instrument-coverage`](./llvm-coverage-instrumentation.md), but using these
coverage results for PGO has not been attempted at this time.
### Overall Workflow
### Overall workflow
Generating a PGO-optimized program involves the following four steps:
@ -62,12 +62,12 @@ Generating a PGO-optimized program involves the following four steps:
4. Compile the program again, this time making use of the profiling data
(e.g. `rustc -C profile-use=merged.profdata main.rs`)
### Compile-Time Aspects
### Compile-time aspects
Depending on which step in the above workflow we are in, two different things
can happen at compile time:
#### Create Binaries with Instrumentation
#### Create binaries with instrumentation
As mentioned above, the profiling instrumentation is added by LLVM.
`rustc` instructs LLVM to do so [by setting the appropriate][pgo-gen-passmanager]
@ -88,7 +88,7 @@ runtime are not removed [by marking the with the right export level][pgo-gen-sym
[pgo-gen-symbols]:https://github.com/rust-lang/rust/blob/1.34.1/src/librustc_codegen_ssa/back/symbol_export.rs#L212-L225
#### Compile Binaries Where Optimizations Make Use Of Profiling Data
#### Compile binaries where optimizations make use of profiling data
In the final step of the workflow described above, the program is compiled
again, with the compiler using the gathered profiling data in order to drive
@ -106,7 +106,7 @@ LLVM does the rest (e.g. setting branch weights, marking functions with
`cold` or `inlinehint`, etc).
### Runtime Aspects
### Runtime aspects
Instrumentation-based approaches always also have a runtime component, i.e.
once we have an instrumented program, that program needs to be run in order
@ -134,7 +134,7 @@ instrumentation artifacts show up in LLVM IR.
[rmake-tests]: https://github.com/rust-lang/rust/tree/master/tests/run-make
[codegen-test]: https://github.com/rust-lang/rust/blob/master/tests/codegen/pgo-instrumentation.rs
## Additional Information
## Additional information
Clang's documentation contains a good overview on [PGO in LLVM][llvm-pgo].

View File

@ -7,8 +7,8 @@ This is a guide for how to profile rustc with [perf](https://perf.wiki.kernel.or
- Get a clean checkout of rust-lang/master, or whatever it is you want
to profile.
- Set the following settings in your `bootstrap.toml`:
- `debuginfo-level = 1` - enables line debuginfo
- `jemalloc = false` - lets you do memory use profiling with valgrind
- `rust.debuginfo-level = 1` - enables line debuginfo
- `rust.jemalloc = false` - lets you do memory use profiling with valgrind
- leave everything else the defaults
- Run `./x build` to get a full build
- Make a rustup toolchain pointing to that result

View File

@ -1,4 +1,4 @@
# Incremental Compilation in detail
# Incremental compilation in detail
<!-- toc -->
@ -66,7 +66,7 @@ because it reads the up-to-date version of `Hir(bar)`. Also, we re-run
`type_check_item(bar)` because result of `type_of(bar)` might have changed.
## The Problem With The Basic Algorithm: False Positives
## The problem with the basic algorithm: false positives
If you read the previous paragraph carefully you'll notice that it says that
`type_of(bar)` *might* have changed because one of its inputs has changed.
@ -93,7 +93,7 @@ of examples like this and small changes to the input often potentially affect
very large parts of the output binaries. As a consequence, we had to make the
change detection system smarter and more accurate.
## Improving Accuracy: The red-green Algorithm
## Improving accuracy: the red-green algorithm
The "false positives" problem can be solved by interleaving change detection
and query re-evaluation. Instead of walking the graph all the way to the
@ -191,7 +191,7 @@ then itself involve recursively invoking more queries, which can mean we come ba
to the `try_mark_green()` algorithm for the dependencies recursively.
## The Real World: How Persistence Makes Everything Complicated
## The real world: how persistence makes everything complicated
The sections above described the underlying algorithm for incremental
compilation but because the compiler process exits after being finished and
@ -258,7 +258,7 @@ the `LocalId`s within it are still the same.
### Checking Query Results For Changes: HashStable And Fingerprints
### Checking query results for changes: `HashStable` and `Fingerprint`s
In order to do red-green-marking we often need to check if the result of a
query has changed compared to the result it had during the previous
@ -306,7 +306,7 @@ This approach works rather well but it's not without flaws:
their stable equivalents while doing the hashing.
### A Tale Of Two DepGraphs: The Old And The New
### A tale of two `DepGraph`s: the old and the new
The initial description of dependency tracking glosses over a few details
that quickly become a head scratcher when actually trying to implement things.
@ -344,7 +344,7 @@ new graph is serialized out to disk, alongside the query result cache, and can
act as the previous dep-graph in a subsequent compilation session.
### Didn't You Forget Something?: Cache Promotion
### Didn't you forget something?: cache promotion
The system described so far has a somewhat subtle property: If all inputs of a
dep-node are green then the dep-node itself can be marked as green without
@ -374,7 +374,7 @@ the result cache doesn't unnecessarily shrink again.
# Incremental Compilation and the Compiler Backend
# Incremental compilation and the compiler backend
The compiler backend, the part involving LLVM, is using the query system but
it is not implemented in terms of queries itself. As a consequence it does not
@ -406,7 +406,7 @@ would save.
## Query Modifiers
## Query modifiers
The query system allows for applying [modifiers][mod] to queries. These
modifiers affect certain aspects of how the system treats the query with
@ -472,7 +472,7 @@ respect to incremental compilation:
[mod]: ../query.html#adding-a-new-kind-of-query
## The Projection Query Pattern
## The projection query pattern
It's interesting to note that `eval_always` and `no_hash` can be used together
in the so-called "projection query" pattern. It is often the case that there is
@ -516,7 +516,7 @@ because we have the projections to take care of keeping things green as much
as possible.
# Shortcomings of the Current System
# Shortcomings of the current system
There are many things that still can be improved.

View File

@ -2,7 +2,7 @@
<!-- toc -->
As described in [the high-level overview of the compiler][hl], the Rust compiler
As described in [Overview of the compiler], the Rust compiler
is still (as of <!-- date-check --> July 2021) transitioning from a
traditional "pass-based" setup to a "demand-driven" system. The compiler query
system is the key to rustc's demand-driven organization.
@ -13,7 +13,7 @@ there is a query called `type_of` that, given the [`DefId`] of
some item, will compute the type of that item and return it to you.
[`DefId`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_span/def_id/struct.DefId.html
[hl]: ./compiler-src.md
[Overview of the compiler]: overview.md#queries
Query execution is *memoized*. The first time you invoke a
query, it will go do the computation, but the next time, the result is
@ -37,12 +37,15 @@ will in turn demand information about that crate, starting from the
actual parsing.
Although this vision is not fully realized, large sections of the
compiler (for example, generating [MIR](./mir/index.md)) currently work exactly like this.
compiler (for example, generating [MIR]) currently work exactly like this.
[^incr-comp-detail]: The ["Incremental Compilation in Detail](queries/incremental-compilation-in-detail.md) chapter gives a more
[^incr-comp-detail]: The [Incremental compilation in detail] chapter gives a more
in-depth description of what queries are and how they work.
If you intend to write a query of your own, this is a good read.
[Incremental compilation in detail]: queries/incremental-compilation-in-detail.md
[MIR]: mir/index.md
## Invoking queries
Invoking a query is simple. The [`TyCtxt`] ("type context") struct offers a method
@ -67,9 +70,15 @@ are cheaply cloneable; insert an `Rc` if necessary).
### Providers
If, however, the query is *not* in the cache, then the compiler will
try to find a suitable **provider**. A provider is a function that has
been defined and linked into the compiler somewhere that contains the
code to compute the result of the query.
call the corresponding **provider** function. A provider is a function
implemented in a specific module and **manually registered** into the
[`Providers`][providers_struct] struct during compiler initialization.
The macro system generates the [`Providers`][providers_struct] struct,
which acts as a function table for all query implementations, where each
field is a function pointer to the actual provider.
**Note:** The `Providers` struct is generated by macros and acts as a function table for all query implementations.
It is **not** a Rust trait, but a plain struct with function pointer fields.
**Providers are defined per-crate.** The compiler maintains,
internally, a table of providers for every crate, at least
@ -97,62 +106,6 @@ fn provider<'tcx>(
Providers take two arguments: the `tcx` and the query key.
They return the result of the query.
### How providers are setup
When the tcx is created, it is given the providers by its creator using
the [`Providers`][providers_struct] struct. This struct is generated by
the macros here, but it is basically a big list of function pointers:
[providers_struct]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/query/struct.Providers.html
```rust,ignore
struct Providers {
type_of: for<'tcx> fn(TyCtxt<'tcx>, DefId) -> Ty<'tcx>,
...
}
```
At present, we have one copy of the struct for local crates, and one
for external crates, though the plan is that we may eventually have
one per crate.
These `Providers` structs are ultimately created and populated by
`rustc_driver`, but it does this by distributing the work
throughout the other `rustc_*` crates. This is done by invoking
various [`provide`][provide_fn] functions. These functions tend to look
something like this:
[provide_fn]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/hir/fn.provide.html
```rust,ignore
pub fn provide(providers: &mut Providers) {
*providers = Providers {
type_of,
..*providers
};
}
```
That is, they take an `&mut Providers` and mutate it in place. Usually
we use the formulation above just because it looks nice, but you could
as well do `providers.type_of = type_of`, which would be equivalent.
(Here, `type_of` would be a top-level function, defined as we saw
before.) So, if we want to add a provider for some other query,
let's call it `fubar`, into the crate above, we might modify the `provide()`
function like so:
```rust,ignore
pub fn provide(providers: &mut Providers) {
*providers = Providers {
type_of,
fubar,
..*providers
};
}
fn fubar<'tcx>(tcx: TyCtxt<'tcx>, key: DefId) -> Fubar<'tcx> { ... }
```
N.B. Most of the `rustc_*` crates only provide **local
providers**. Almost all **extern providers** wind up going through the
[`rustc_metadata` crate][rustc_metadata], which loads the information
@ -164,6 +117,63 @@ they define both a `provide` and a `provide_extern` function, through
[rustc_metadata]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_metadata/index.html
[wasm_import_module_map]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_codegen_ssa/back/symbol_export/fn.wasm_import_module_map.html
### How providers are set up
When the tcx is created, it is given the providers by its creator using
the [`Providers`][providers_struct] struct. This struct is generated by
the macros here, but it is basically a big list of function pointers:
[providers_struct]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/query/struct.Providers.html
```rust,ignore
struct Providers {
type_of: for<'tcx> fn(TyCtxt<'tcx>, DefId) -> Ty<'tcx>,
// ... one field for each query
}
```
#### How are providers registered?
The `Providers` struct is filled in during compiler initialization, mainly by the `rustc_driver` crate.
But the actual provider functions are implemented in various `rustc_*` crates (like `rustc_middle`, `rustc_hir_analysis`, etc).
To register providers, each crate exposes a [`provide`][provide_fn] function that looks like this:
[provide_fn]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/hir/fn.provide.html
```rust,ignore
pub fn provide(providers: &mut Providers) {
*providers = Providers {
type_of,
// ... add more providers here
..*providers
};
}
```
- This function takes a mutable reference to the `Providers` struct and sets the fields to point to the correct provider functions.
- You can also assign fields individually, e.g. `providers.type_of = type_of;`.
#### Adding a new provider
Suppose you want to add a new query called `fubar`. You would:
1. Implement the provider function:
```rust,ignore
fn fubar<'tcx>(tcx: TyCtxt<'tcx>, key: DefId) -> Fubar<'tcx> { ... }
```
2. Register it in the `provide` function:
```rust,ignore
pub fn provide(providers: &mut Providers) {
*providers = Providers {
fubar,
..*providers
};
}
```
---
## Adding a new query
How do you add a new query?

View File

@ -270,35 +270,6 @@ in `test.rs` is the function `make_test`, which is where hand-written
Some extra reading about `make_test` can be found
[here](https://quietmisdreavus.net/code/2018/02/23/how-the-doctests-get-made/).
## Dotting i's And Crossing t's
So that's `rustdoc`'s code in a nutshell, but there's more things in the
compiler that deal with it. Since we have the full `compiletest` suite at hand,
there's a set of tests in `tests/rustdoc` that make sure the final `HTML` is
what we expect in various situations. These tests also use a supplementary
script, `src/etc/htmldocck.py`, that allows it to look through the final `HTML`
using `XPath` notation to get a precise look at the output. The full
description of all the commands available to `rustdoc` tests (e.g. [`@has`] and
[`@matches`]) is in [`htmldocck.py`].
To use multiple crates in a `rustdoc` test, add `//@ aux-build:filename.rs`
to the top of the test file. `filename.rs` should be placed in an `auxiliary`
directory relative to the test file with the comment. If you need to build
docs for the auxiliary file, use `//@ build-aux-docs`.
In addition, there are separate tests for the search index and `rustdoc`'s
ability to query it. The files in `tests/rustdoc-js` each contain a
different search query and the expected results, broken out by search tab.
These files are processed by a script in `src/tools/rustdoc-js` and the `Node.js`
runtime. These tests don't have as thorough of a writeup, but a broad example
that features results in all tabs can be found in `basic.js`. The basic idea is
that you match a given `QUERY` with a set of `EXPECTED` results, complete with
the full item path of each item.
[`@has`]: https://github.com/rust-lang/rust/blob/master/src/etc/htmldocck.py#L39
[`@matches`]: https://github.com/rust-lang/rust/blob/master/src/etc/htmldocck.py#L44
[`htmldocck.py`]: https://github.com/rust-lang/rust/blob/master/src/etc/htmldocck.py
## Testing Locally
Some features of the generated `HTML` documentation might require local

View File

@ -0,0 +1,14 @@
# The `rustdoc-gui` test suite
> **FIXME**: This section is a stub. Please help us flesh it out!
This page is about the test suite named `rustdoc-gui` used to test the "GUI" of `rustdoc` (i.e., the HTML/JS/CSS as rendered in a browser).
For other rustdoc-specific test suites, see [Rustdoc test suites].
These use a NodeJS-based tool called [`browser-UI-test`] that uses [puppeteer] to run tests in a headless browser and check rendering and interactivity. For information on how to write this form of test, see [`tests/rustdoc-gui/README.md`][rustdoc-gui-readme] as well as [the description of the `.goml` format][goml-script]
[Rustdoc test suites]: ../tests/compiletest.md#rustdoc-test-suites
[`browser-UI-test`]: https://github.com/GuillaumeGomez/browser-UI-test/
[puppeteer]: https://pptr.dev/
[rustdoc-gui-readme]: https://github.com/rust-lang/rust/blob/master/tests/rustdoc-gui/README.md
[goml-script]: https://github.com/GuillaumeGomez/browser-UI-test/blob/master/goml-script.md

View File

@ -0,0 +1,3 @@
# The `rustdoc-json` test suite
> **FIXME**: This section is a stub. It will be populated by [PR #2422](https://github.com/rust-lang/rustc-dev-guide/pull/2422/).

View File

@ -1,112 +1,191 @@
# The `rustdoc` test suite
This page is specifically about the test suite named `rustdoc`.
For other test suites used for testing rustdoc, see [Rustdoc tests](../rustdoc.md#tests).
This page is about the test suite named `rustdoc` used to test the HTML output of `rustdoc`.
For other rustdoc-specific test suites, see [Rustdoc test suites].
The `rustdoc` test suite is specifically used to test the HTML output of rustdoc.
Each test file in this test suite is simply a Rust source file `file.rs` sprinkled with
so-called *directives* located inside normal Rust code comments.
These come in two flavors: *Compiletest* and *HtmlDocCk*.
This is achieved by means of `htmldocck.py`, a custom checker script that leverages [XPath].
To learn more about the former, read [Compiletest directives].
For the latter, continue reading.
[XPath]: https://en.wikipedia.org/wiki/XPath
Internally, [`compiletest`] invokes the supplementary checker script [`htmldocck.py`].
## Directives
Directives to htmldocck are similar to those given to `compiletest` in that they take the form of `//@` comments.
[Rustdoc test suites]: ../tests/compiletest.md#rustdoc-test-suites
[`compiletest`]: ../tests/compiletest.md
[`htmldocck.py`]: https://github.com/rust-lang/rust/blob/master/src/etc/htmldocck.py
In addition to the directives listed here,
`rustdoc` tests also support most
[compiletest directives](../tests/directives.html).
## HtmlDocCk Directives
All `PATH`s in directives are relative to the rustdoc output directory (`build/TARGET/test/rustdoc/TESTNAME`),
so it is conventional to use a `#![crate_name = "foo"]` attribute to avoid
having to write a long crate name multiple times.
To avoid repetition, `-` can be used in any `PATH` argument to re-use the previous `PATH` argument.
Directives to HtmlDocCk are assertions that place constraints on the generated HTML.
They look similar to those given to `compiletest` in that they take the form of `//@` comments
but ultimately, they are completey distinct and processed by different programs.
All arguments take the form of quoted strings
(both single and double quotes are supported),
[XPath] is used to query parts of the HTML document tree.
**Introductory example**:
```rust,ignore (illustrative)
//@ has file/type.Alias.html
//@ has - '//*[@class="rust item-decl"]//code' 'type Alias = Option<i32>;'
pub type Alias = Option<i32>;
```
Here, we check that documentation generated for crate `file` contains a page for the
public type alias `Alias` where the code block that is found at the top contains the
expected rendering of the item. The `//*[@class="rust item-decl"]//code` is an XPath
expression.
Conventionally, you place these directives directly above the thing they are meant to test.
Technically speaking however, they don't need to be as HtmlDocCk only looks for the directives.
All directives take a `PATH` argument.
To avoid repetition, `-` can be passed to it to re-use the previous `PATH` argument.
Since the path contains the name of the crate, it is conventional to add a
`#![crate_name = "foo"]` attribute to the crate root to shorten the resulting path.
All arguments take the form of shell-style (single or double) quoted strings,
with the exception of `COUNT` and the special `-` form of `PATH`.
Directives are assertions that place constraints on the generated HTML.
All directives (except `files`) can be negated by putting a `!` in front of their name.
All directives (except `files`) can be *negated* by putting a `!` in front of their name.
Before you add negated directives, please read about [their caveats](#caveats).
Similar to shell commands,
directives can extend across multiple lines if their last char is `\`.
In this case, the start of the next line should be `//`, with no `@`.
For example, `//@ !has 'foo/struct.Bar.html'` checks that crate `foo` does not have a page for a struct named `Bar` in the crate root.
Use the special string `{{channel}}` in XPaths, `PATTERN` arguments and [snapshot files](#snapshot)
if you'd like to refer to the URL `https://doc.rust-lang.org/CHANNEL` where `CHANNEL` refers to the
current release channel (e.g, `stable` or `nightly`).
Listed below are all possible directives:
[XPath]: https://en.wikipedia.org/wiki/XPath
### `has`
Usage 1: `//@ has PATH`
Usage 2: `//@ has PATH XPATH PATTERN`
> Usage 1: `//@ has PATH`
In the first form, `has` checks that a given file exists.
Check that the file given by `PATH` exists.
In the second form, `has` is an alias for `matches`,
except `PATTERN` is a whitespace-normalized[^1] string instead of a regex.
> Usage 2: `//@ has PATH XPATH PATTERN`
### `matches`
Checks that the text of each element / attribute / text selected by `XPATH` in the
whitespace-normalized[^1] file given by `PATH` matches the
(also whitespace-normalized) string `PATTERN`.
Usage: `//@ matches PATH XPATH PATTERN`
Checks that the text of each element selected by `XPATH` in `PATH` matches the python-flavored regex `PATTERN`.
### `matchesraw`
Usage: `//@ matchesraw PATH PATTERN`
Checks that the contents of the file `PATH` matches the regex `PATTERN`.
**Tip**: If you'd like to avoid whitespace normalization and/or if you'd like to match with a regex,
use `matches` instead.
### `hasraw`
Usage: `//@ hasraw PATH PATTERN`
> Usage: `//@ hasraw PATH PATTERN`
Same as `matchesraw`, except `PATTERN` is a whitespace-normalized[^1] string instead of a regex.
Checks that the contents of the whitespace-normalized[^1] file given by `PATH`
matches the (also whitespace-normalized) string `PATTERN`.
**Tip**: If you'd like to avoid whitespace normalization and / or if you'd like to match with a
regex, use `matchesraw` instead.
### `matches`
> Usage: `//@ matches PATH XPATH PATTERN`
Checks that the text of each element / attribute / text selected by `XPATH` in the
file given by `PATH` matches the Python-flavored[^2] regex `PATTERN`.
### `matchesraw`
> Usage: `//@ matchesraw PATH PATTERN`
Checks that the contents of the file given by `PATH` matches the
Python-flavored[^2] regex `PATTERN`.
### `count`
Usage: `//@ count PATH XPATH COUNT`
> Usage: `//@ count PATH XPATH COUNT`
Checks that there are exactly `COUNT` matches for `XPATH` within the file `PATH`.
Checks that there are exactly `COUNT` matches for `XPATH` within the file given by `PATH`.
### `snapshot`
Usage: `//@ snapshot NAME PATH XPATH`
> Usage: `//@ snapshot NAME PATH XPATH`
Creates a snapshot test named NAME.
A snapshot test captures a subtree of the DOM, at the location
determined by the XPath, and compares it to a pre-recorded value
in a file. The file's name is the test's name with the `.rs` extension
replaced with `.NAME.html`, where NAME is the snapshot's name.
Checks that the element / text selected by `XPATH` in the file given by `PATH` matches the
pre-recorded subtree or text (the "snapshot") in file `FILE_STEM.NAME.html` where `FILE_STEM`
is the file stem of the test file.
htmldocck supports the `--bless` option to accept the current subtree
as expected, saving it to the file determined by the snapshot's name.
compiletest's `--bless` flag is forwarded to htmldocck.
Pass the `--bless` option to `compiletest` to accept the current subtree/text as expected.
This will overwrite the aforementioned file (or create it if it doesn't exist). It will
automatically normalize the channel-dependent URL `https://doc.rust-lang.org/CHANNEL` to
the special string `{{channel}}`.
### `has-dir`
Usage: `//@ has-dir PATH`
> Usage: `//@ has-dir PATH`
Checks for the existence of directory `PATH`.
Checks for the existence of the directory given by `PATH`.
### `files`
Usage: `//@ files PATH ENTRIES`
> Usage: `//@ files PATH ENTRIES`
Checks that the directory `PATH` contains exactly `ENTRIES`.
`ENTRIES` is a python list of strings inside a quoted string,
as if it were to be parsed by `eval`.
(note that the list is actually parsed by `shlex.split`,
so it cannot contain arbitrary python expressions).
Checks that the directory given by `PATH` contains exactly `ENTRIES`.
`ENTRIES` is a Python-like list of strings inside a quoted string.
Example: `//@ files "foo/bar" '["index.html", "sidebar-items.js"]'`
**Example**: `//@ files "foo/bar" '["index.html", "sidebar-items.js"]'`
[^1]: Whitespace normalization means that all spans of consecutive whitespace are replaced with a single space. The files themselves are also whitespace-normalized.
[^1]: Whitespace normalization means that all spans of consecutive whitespace are replaced with a single space.
[^2]: They are Unicode aware (flag `UNICODE` is set), match case-sensitively and in single-line mode.
## Compiletest Directives (Brief)
As mentioned in the introduction, you also have access to [compiletest directives].
Most importantly, they allow you to register auxiliary crates and
to pass flags to the `rustdoc` binary under test.
It's *strongly recommended* to read that chapter if you don't know anything about them yet.
Here are some details that are relevant to this test suite specifically:
* While you can use both `//@ compile-flags` and `//@ doc-flags` to pass flags to `rustdoc`,
prefer to user the latter to show intent. The former is meant for `rustc`.
* Add `//@ build-aux-docs` to the test file that has auxiliary crates to not only compile the
auxiliaries with `rustc` but to also document them with `rustdoc`.
## Caveats
Testing for the absence of an element or a piece of text is quite fragile and not very future proof.
It's not unusual that the *shape* of the generated HTML document tree changes from time to time.
This includes for example renamings of CSS classes.
Whenever that happens, *positive* checks will either continue to match the intended element /
attribute / text (if their XPath expression is general / loose enough) and
thus continue to test the correct thing or they won't in which case they would fail thereby
forcing the author of the change to look at them.
Compare that to *negative* checks (e.g., `//@ !has PATH XPATH PATTERN`) which won't fail if their
XPath expression "no longer" matches. The author who changed "the shape" thus won't get notified and
as a result someone else can unintentionally reintroduce `PATTERN` into the generated docs without
the original negative check failing.
**Note**: Please avoid the use of *negated* checks!
**Tip**: If you can't avoid it, please **always** pair it with an analogous positive check in the
immediate vicinity, so people changing "the shape" have a chance to notice and to update the
negated check!
## Limitations
`htmldocck.py` uses the xpath implementation from the standard library.
HtmlDocCk uses the XPath implementation from the Python standard library.
This leads to several limitations:
* All `XPATH` arguments must start with `//` due to a flaw in the implementation.
* Many XPath features (functions, axies, etc.) are not supported.
* Only well-formed HTML can be parsed (hopefully rustdoc doesn't output mismatched tags).
Furthmore, compiletest [revisions] are not supported.
[revisions]: ../tests/compiletest.md#revisions
[compiletest directives]: ../tests/directives.md

View File

@ -67,43 +67,29 @@ does is call the `main()` that's in this crate's `lib.rs`, though.)
## Code structure
* All paths in this section are relative to `src/librustdoc` in the rust-lang/rust repository.
All paths in this section are relative to `src/librustdoc/` in the rust-lang/rust repository.
* Most of the HTML printing code is in `html/format.rs` and `html/render/mod.rs`.
It's in a bunch of `fmt::Display` implementations and supplementary
functions.
* The types that got `Display` impls above are defined in `clean/mod.rs`, right
next to the custom `Clean` trait used to process them out of the rustc HIR.
It's in a bunch of functions returning `impl std::fmt::Display`.
* The data types that get rendered by the functions mentioned above are defined in `clean/types.rs`.
The functions responsible for creating them from the `HIR` and the `rustc_middle::ty` IR
live in `clean/mod.rs`.
* The bits specific to using rustdoc as a test harness are in
`doctest.rs`.
* The Markdown renderer is loaded up in `html/markdown.rs`, including functions
for extracting doctests from a given block of Markdown.
* Frontend CSS and JavaScript are stored in `html/static/`.
* Re. JavaScript, type annotations are written using [TypeScript-flavored JSDoc]
comments and an external `.d.ts` file.
This way, the code itself remains plain, valid JavaScript.
We only use `tsc` as a linter.
[TypeScript-flavored JSDoc]: https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html
## Tests
* Tests on search engine and index are located in `tests/rustdoc-js` and `tests/rustdoc-js-std`.
The format is specified
[in the search guide](rustdoc-internals/search.md#testing-the-search-engine).
* Tests on the "UI" of rustdoc (the terminal output it produces when run) are in
`tests/rustdoc-ui`
* Tests on the "GUI" of rustdoc (the HTML, JS, and CSS as rendered in a browser)
are in `tests/rustdoc-gui`. These use a [NodeJS tool called
browser-UI-test](https://github.com/GuillaumeGomez/browser-UI-test/) that uses
puppeteer to run tests in a headless browser and check rendering and
interactivity. For information on how to write this form of test,
see [`tests/rustdoc-gui/README.md`][rustdoc-gui-readme]
as well as [the description of the `.goml` format][goml-script]
* Tests on the structure of rustdoc HTML output are located in `tests/rustdoc`,
where they're handled by the test runner of bootstrap and
the supplementary script `src/etc/htmldocck.py`.
[These tests have several extra directives available to them](./rustdoc-internals/rustdoc-test-suite.md).
* Additionally, JavaScript type annotations are written using [TypeScript-flavored JSDoc]
comments and an external d.ts file. The code itself is plain, valid JavaScript; we only
use tsc as a linter.
[TypeScript-flavored JSDoc]: https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html
[rustdoc-gui-readme]: https://github.com/rust-lang/rust/blob/master/tests/rustdoc-gui/README.md
[goml-script]: https://github.com/GuillaumeGomez/browser-UI-test/blob/master/goml-script.md
`rustdoc`'s integration tests are split across several test suites.
See [Rustdoc tests suites](tests/compiletest.md#rustdoc-test-suites) for more details.
## Constraints

View File

@ -1,4 +1,4 @@
# Sanitizers Support
# Sanitizers support
The rustc compiler contains support for following sanitizers:

View File

@ -66,9 +66,9 @@ kinds of builds (sets of jobs).
### Pull Request builds
After each push to a pull request, a set of `pr` jobs are executed. Currently,
these execute the `x86_64-gnu-llvm-X`, `x86_64-gnu-tools`, `mingw-check` and
`mingw-check-tidy` jobs, all running on Linux. These execute a relatively short
(~30 minutes) and lightweight test suite that should catch common issues. More
these execute the `x86_64-gnu-llvm-X`, `x86_64-gnu-tools`, `mingw-check-1`, `mingw-check-2`
and `mingw-check-tidy` jobs, all running on Linux. These execute a relatively short
(~40 minutes) and lightweight test suite that should catch common issues. More
specifically, they run a set of lints, they try to perform a cross-compile check
build to Windows mingw (without producing any artifacts) and they test the
compiler using a *system* version of LLVM. Unfortunately, it would take too many

View File

@ -56,6 +56,9 @@ incremental compilation. The various suites are defined in
The following test suites are available, with links for more information:
[`tests`]: https://github.com/rust-lang/rust/blob/master/tests
[`src/tools/compiletest/src/common.rs`]: https://github.com/rust-lang/rust/tree/master/src/tools/compiletest/src/common.rs
### Compiler-specific test suites
| Test suite | Purpose |
@ -71,6 +74,7 @@ The following test suites are available, with links for more information:
| [`mir-opt`](#mir-opt-tests) | Check MIR generation and optimizations |
| [`coverage`](#coverage-tests) | Check coverage instrumentation |
| [`coverage-run-rustdoc`](#coverage-tests) | `coverage` tests that also run instrumented doctests |
| [`crashes`](#crashes-tests) | Check that the compiler ICEs/panics/crashes on certain inputs to catch accidental fixes |
### General purpose test suite
@ -78,19 +82,23 @@ The following test suites are available, with links for more information:
### Rustdoc test suites
See [Rustdoc tests](../rustdoc.md#tests) for more details.
| Test suite | Purpose |
|--------------------------------------|--------------------------------------------------------------------------|
| [`rustdoc`][rustdoc-html-tests] | Check HTML output of `rustdoc` |
| [`rustdoc-gui`][rustdoc-gui-tests] | Check `rustdoc`'s GUI using a web browser |
| [`rustdoc-js`][rustdoc-js-tests] | Check `rustdoc`'s search engine and index |
| [`rustdoc-js-std`][rustdoc-js-tests] | Check `rustdoc`'s search engine and index on the std library docs |
| [`rustdoc-json`][rustdoc-json-tests] | Check JSON output of `rustdoc` |
| `rustdoc-ui` | Check terminal output of `rustdoc` ([see also](ui.md)) |
| Test suite | Purpose |
|------------------|--------------------------------------------------------------------------|
| `rustdoc` | Check `rustdoc` generated files contain the expected documentation |
| `rustdoc-gui` | Check `rustdoc`'s GUI using a web browser |
| `rustdoc-js` | Check `rustdoc` search is working as expected |
| `rustdoc-js-std` | Check rustdoc search is working as expected specifically on the std docs |
| `rustdoc-json` | Check JSON output of `rustdoc` |
| `rustdoc-ui` | Check terminal output of `rustdoc` |
Some rustdoc-specific tests can also be found in `ui/rustdoc/`.
These check rustdoc-related or -specific lints that (also) run as part of `rustc`, not (only) `rustdoc`.
Run-make tests pertaining to rustdoc are typically named `run-make/rustdoc-*/`.
[`tests`]: https://github.com/rust-lang/rust/blob/master/tests
[`src/tools/compiletest/src/common.rs`]: https://github.com/rust-lang/rust/tree/master/src/tools/compiletest/src/common.rs
[rustdoc-html-tests]: ../rustdoc-internals/rustdoc-test-suite.md
[rustdoc-gui-tests]: ../rustdoc-internals/rustdoc-gui-test-suite.md
[rustdoc-js-tests]: ../rustdoc-internals/search.md#testing-the-search-engine
[rustdoc-json-tests]: ../rustdoc-internals/rustdoc-json-test-suite.md
### Pretty-printer tests
@ -107,7 +115,7 @@ default behavior without any commands is to:
2. Run `rustc -Zunpretty=normal` on the output of the previous step.
3. The output of the previous two steps should be the same.
4. Run `rustc -Zno-codegen` on the output to make sure that it can type check
(this is similar to running `cargo check`).
(similar to `cargo check`).
If any of the commands above fail, then the test fails.

View File

@ -202,6 +202,7 @@ settings:
`//@ needs-crate-type: cdylib, proc-macro` will cause the test to be ignored
on `wasm32-unknown-unknown` target because the target does not support the
`proc-macro` crate type.
- `needs-target-std` — ignores if target platform does not have std support.
The following directives will check LLVM support:
@ -261,7 +262,7 @@ Consider writing the test as a proper incremental test instead.
| Directive | Explanation | Supported test suites | Possible values |
|-------------|--------------------------------------------------------------|------------------------------------------|---------------------------|
| `doc-flags` | Flags passed to `rustdoc` when building the test or aux file | `rustdoc`, `rustdoc-js`, `rustdoc-json` | Any valid `rustdoc` flags |
| `doc-flags` | Flags passed to `rustdoc` when building the test or aux file | `rustdoc`, `rustdoc-js`, `rustdoc-json` | Any valid `rustdoc` flags |
<!--
**FIXME(rustdoc)**: what does `check-test-line-numbers-match` do?
@ -269,6 +270,17 @@ Asked in
<https://rust-lang.zulipchat.com/#narrow/stream/266220-t-rustdoc/topic/What.20is.20the.20.60check-test-line-numbers-match.60.20directive.3F>.
-->
#### Test-suite-specific directives
The test suites [`rustdoc`][rustdoc-html-tests], [`rustdoc-js`/`rustdoc-js-std`][rustdoc-js-tests]
and [`rustdoc-json`][rustdoc-json-tests] each feature an additional set of directives whose basic
syntax resembles the one of compiletest directives but which are ultimately read and checked by
separate tools. For more information, please read their respective chapters as linked above.
[rustdoc-html-tests]: ../rustdoc-internals/rustdoc-test-suite.md
[rustdoc-js-tests]: ../rustdoc-internals/search.html#testing-the-search-engine
[rustdoc-json-tests]: ../rustdoc-internals/rustdoc-json-test-suite.md
### Pretty printing
See [Pretty-printer](compiletest.md#pretty-printer-tests).

View File

@ -220,8 +220,12 @@ negligible (i.e. there is no semantic difference between `//~ ERROR` and
`//~ERROR` although the former is more common in the codebase).
`~? <diagnostic kind>` (example being `~? ERROR`)
is used to match diagnostics without line information.
These can be placed on any line in the test file, but are conventionally placed at the end.
is used to match diagnostics _without_ line info at all,
or where the line info is outside the main test file[^main test file].
These annotations can be placed on any line in the test file.
[^main test file]: This is a file that has the `~?` annotations,
as distinct from aux files, or sources that we have no control over.
### Error annotation examples

View File

@ -62,8 +62,8 @@ Here is a summary:
| Describe the *syntax* of a type: what the user wrote (with some desugaring). | Describe the *semantics* of a type: the meaning of what the user wrote. |
| Each `rustc_hir::Ty` has its own spans corresponding to the appropriate place in the program. | Doesnt correspond to a single place in the users program. |
| `rustc_hir::Ty` has generics and lifetimes; however, some of those lifetimes are special markers like [`LifetimeKind::Implicit`][implicit]. | `ty::Ty` has the full type, including generics and lifetimes, even if the user left them out |
| `fn foo(x: u32) u32 { }` - Two `rustc_hir::Ty` representing each usage of `u32`, each has its own `Span`s, and `rustc_hir::Ty` doesnt tell us that both are the same type | `fn foo(x: u32) u32 { }` - One `ty::Ty` for all instances of `u32` throughout the program, and `ty::Ty` tells us that both usages of `u32` mean the same type. |
| `fn foo(x: &u32) -> &u32)` - Two `rustc_hir::Ty` again. Lifetimes for the references show up in the `rustc_hir::Ty`s using a special marker, [`LifetimeKind::Implicit`][implicit]. | `fn foo(x: &u32) -> &u32)`- A single `ty::Ty`. The `ty::Ty` has the hidden lifetime param. |
| `fn foo(x: u32) -> u32 { }` - Two `rustc_hir::Ty` representing each usage of `u32`, each has its own `Span`s, and `rustc_hir::Ty` doesnt tell us that both are the same type | `fn foo(x: u32) -> u32 { }` - One `ty::Ty` for all instances of `u32` throughout the program, and `ty::Ty` tells us that both usages of `u32` mean the same type. |
| `fn foo(x: &u32) -> &u32 { }` - Two `rustc_hir::Ty` again. Lifetimes for the references show up in the `rustc_hir::Ty`s using a special marker, [`LifetimeKind::Implicit`][implicit]. | `fn foo(x: &u32) -> &u32 { }`- A single `ty::Ty`. The `ty::Ty` has the hidden lifetime param. |
[implicit]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/hir/enum.LifetimeKind.html#variant.Implicit

View File

@ -72,6 +72,23 @@ days-threshold = 7
# Documentation at: https://forge.rust-lang.org/triagebot/pr-assignment.html
[assign]
# NOTE: do not add `[assign.owners]` if we still wish to keep the opt-in
# reviewer model, as `[assign.owners]` will cause triagebot auto-reviewer
# assignment to kick in.
# Custom PR welcome message for when no auto reviewer assignment is performed
# and no explicit manual reviewer selection is made.
# Documentation at: https://forge.rust-lang.org/triagebot/pr-assignment.html#custom-welcome-messages
[assign.custom_welcome_messages]
welcome-message = ""
welcome-message-no-reviewer = """\
Thanks for the PR. If you have write access, feel free to merge this PR if it \
does not need reviews. You can request a review using `r? rustc-dev-guide` or \
`r? <username>`.
"""
# Groups for `r? <group>`.
# Documentation at: https://forge.rust-lang.org/triagebot/pr-assignment.html#usage
# Keep members alphanumerically sorted.
[assign.adhoc_groups]
rustc-dev-guide = [