When checking a pattern with guards in it, `GatherLocalsVisitor` will
visit both the pattern (when type-checking the let, arm, or param
containing it) and the guard expression (when checking the guard
itself). This keeps it from visiting the guard when visiting the
pattern, since otherwise it would gather locals from the guard twice,
which would lead to a delayed bug: "evaluated expression more than
once".
make std::intrinsics functions actually be intrinsics
Most of the functions in `std::intrinsics` are actually intrinsics, but some are not: for historical reasons, `std::intrinsics::{copy,copy_nonoverlapping,write_bytes}` are accessible on stable, and the versions in `std::ptr` are just re-exports. These functions are not intrinsics, but wrappers around the intrinsic, because they add extra debug assertions.
This PR makes the functions in `std::intrinsics` actually be intrinsics.
- The advantage is that we can now use it in tests that need to directly call the intrinsic, thus removing a footgun for compiler development. We also remove the extended user-facing doc comments of these functions out of a file that should be largely internal documentation.
- The downside is that if users are using those functions directly, they will not get the debug assertions any more. Note however that those users are already ignoring a deprecation warning, so I think this is fine. Furthermore, if someone imports the `intrinsic` name of this function and turns that into a function pointer, that will no longer work, since only the wrapper functions can be turned into a function pointer. I would be rather surprised if anyone did this, though... and again, they must have already ignored a deprecation warning. Still, seems worth a crater run, if there's general agreement that we want to go ahead with this change.
(`intrinsics::drop_in_place` also remains not-an-intrinsic, which bugs me, but oh well, not much we can do about it; we can't remove it from the module as the path is accidentally-stable.)
Cc `@rust-lang/libs-api` `@saethlin`
Properly remove Noratrieb from review rotation
I've put myself on vacation a while ago, but really I just want to remove myself from the queue because I couldn't get around to reviewing all the PRs, I'm still here and available :3.
Update books
## rust-lang/book
4 commits in d33916341d480caede1d0ae57cbeae23aab23e88..230c68bc1e08f5f3228384a28cc228c81dfbd10d
2025-05-19 14:25:14 UTC to 2025-05-08 21:28:56 UTC
- Chapter 6 from tech review (rust-lang/book#4370)
- Chapter 5 from tech review (rust-lang/book#4359)
- Chapter 4 from tech review (rust-lang/book#4358)
- Chapter 3 from tech review (rust-lang/book#4353)
## rust-lang/reference
12 commits in 387392674d74656f7cb437c05a96f0c52ea8e601..acd0231ebc74849f6a8907b5e646ce86721aad76
2025-05-19 15:41:22 UTC to 2025-05-06 21:36:01 UTC
- Add doc for avx512 target features (rust-lang/reference#1778)
- Parse grammar without regexes (rust-lang/reference#1827)
- Parse optionals and repeats without regexes (rust-lang/reference#1826)
- Fix grammar for `RangePatternBound` regarding literals (rust-lang/reference#1825)
- Fix grammar for `LiteralPattern` regarding `-` (rust-lang/reference#1824)
- Doc: Add the LoongArch stabilized target features (rust-lang/reference#1707)
- Fix naked em-dash (rust-lang/reference#1820)
- Add missing attribute for statement macros (rust-lang/reference#1819)
- Make linked rules are clicked, highlight the color (rust-lang/reference#1817)
- Use the reference grammar for inline assembly (rust-lang/reference#1807)
- Fix typo in introduction (rust-lang/reference#1810)
- Add an example admonition (rust-lang/reference#1812)
## rust-lang/rust-by-example
2 commits in 8a8918c698534547fa8a1a693cb3e7277f0bfb2f..c9d151f9147c4808c77f0375ba3fa5d54443cb9e
2025-05-13 17:49:05 UTC to 2025-05-13 17:48:43 UTC
- fix(docs): standardize on `no_run` attribute for documentation examples (rust-lang/rust-by-example#1929)
- Fix typo in Japanese translation (rust-lang/rust-by-example#1928)
trim cache module in utils bootstrap
We don't use other variants of Interner in bootstrap, so this PR streamlines the bootstrap cache utils module.
r? `@onur-ozkan`
Replace `try_reserve_exact` with `try_with_capacity` in `std::fs::read`
This change restores the previous behavior prior to #117925. That PR was made to handle OOM errors that turn into a panic with `Vec::with_capacity`. `try_reserve_exact` was used for that since there was no `try_with_capacity` method at the time. It was added later in #120504. I think it'd a better fit here.
We resolve guard patterns' guards in `resolve_pattern_inner`, so to
avoid resolving them multiple times, we must avoid doing so earlier. To
accomplish this, `LateResolutionVisitor::visit_pat` contains a case for
guard patterns that avoids visiting their guards while walking patterns.
This fixes an ICE due to `visit::walk_pat` being used instead, which
meant guards at the top level of a pattern would be visited twice.
If a type is incomplete, for example if generic parameters are not
available yet, although they are not escaping, its layout may not be
computable. Calling `TyCtxt::layout_of()` would create a delayed bug in
the compiler.
changelog: [`zero_sized_map_values`]: fix ICE
Fixesrust-lang/rust-clippy#14822
r? @Jarcho
If a type is incomplete, for example if generic parameters are not
available yet, although they are not escaping, its layout may not
be computable. Calling `TyCtxt::layout_of()` would create a delayed bug
in the compiler.
The `explicit_into_iter_loop`, `explicit_iter_loop` and `iter_next_loop`
will now:
- trigger only when the triggering expression is not located into macro
code;
- properly expose code rewrite proposal with code coming from the root
context.
A `return` in an expression makes it divergent and cannot be removed
blindly. While this stripping might have been introduced as a way to
catch more cases, it was improperly used, and no tests exhibit a failure
when this special handling is removed.
changelog: [`needless_match`]: do not strip `return` as it might make
the `if let` or `match` divergent in some cases
Fixesrust-lang/rust-clippy#14754
This patch series makes heavy use of interned symbols when matching
against known method names:
- the first commit reorders the current list of symbols in
`clippy_utils::sym`
- the second commit adds symbol reordering and order checking to `clippy
dev fmt` / `clippy dev fmt --check`
- the third commit converts many uses of string matching during linting
to symbols matching
The symbols are kept as-is (not rendered as strings) as much as possible
to avoid needing locking the interner as much as possible. Static
strings have been kept when they are only used when emitting a
diagnostic, as there is no benefit in using interned strings for
de-interning them right after.
changelog: none
r? @Alexendoo
I've put myself on vacation a while ago, but really I just want to remove myself from the queue because I couldn't get around to reviewing all the PRs, I'm still here and available :3.
Items such as the `declare_tool_lint!()` macro are publicly reexported
from `rustc_lint_defs` to `rustc_session`. Use the latter for
consistency.
changelog: none
Rollup of 6 pull requests
Successful merges:
- #131200 (Handle `rustc_query_system` cases of `rustc::potential_query_instability` lint)
- #141244 (windows: document that we rely on an undocumented property of GetUserProfileDirectoryW)
- #141247 (skip compiler tools sanity checks on certain commands)
- #141248 (fix data race in ReentrantLock fallback for targets without 64bit atomics)
- #141249 (introduce common macro for `MutVisitor` and `Visitor` to dedup code)
- #141253 (Warning added when dependency crate has async drop types, and the feature is disabled)
r? `@ghost`
`@rustbot` modify labels: rollup
Warning added when dependency crate has async drop types, and the feature is disabled
In continue of https://github.com/rust-lang/rust/pull/141031.
When dependency crate has non-empty `adt_async_destructor` table in metadata, and `async_drop` feature is disabled for local crate, warning will be emitted.
Test `dependency-dropped` has two revisions - with and without feature enabled. With feature enabled, async drop for dropee is executed ("Async drop" printed). Without the feature enabled, sync drop is executed ("Sync drop" printed) and warning is emitted.
Warning example:
```
warning: found async drop types in dependecy `async_drop_dep`, but async_drop feature is disabled for `dependency_dropped`
--> $DIR/dependency-dropped.rs:7:1
|
LL | #![cfg_attr(with_feature, feature(async_drop))]
| ^
|
= help: if async drop type will be dropped in a crate without `feature(async_drop)`, sync Drop will be used
```
introduce common macro for `MutVisitor` and `Visitor` to dedup code
helps with #127615.
I can do everything in one go but I figured it might be worth it to open a PR first for vibeck.
r? oli-obk
fix data race in ReentrantLock fallback for targets without 64bit atomics
See [Zulip](https://rust-lang.zulipchat.com/#narrow/channel/269128-miri/topic/reentrant.20lock.20failure.20on.20musl) for details: the address used to identify a thread might get lazily allocated inside `tls_addr()`, so if we call that *after* doing the `tls_addr.load()` it is too late to establish synchronization with prior threads that used the same address -- the `load()` thus races with the `store()` by that prior thread, and might hence see outdated values, and then the entire logic breaks down.
r? `@joboet`