308152 Commits

Author SHA1 Message Date
Dawid Lachowicz
aeae085dc3
Add contract variable declarations
Contract variables can be declared in the `requires` clause and
can be referenced both in `requires` and `ensures`, subject to usual
borrow checking rules.

This allows any setup common to both the `requires` and `ensures`
clauses to only be done once.
2025-10-18 15:00:34 +01:00
bors
a41214f9bd Auto merge of #147779 - flip1995:clippy-subtree-update, r=Manishearth
Clippy subtree update

r? `@Manishearth`

`Cargo.lock` update, because `clippy_utils` is now also using `itertools`
2025-10-17 07:57:20 +00:00
bors
28c4c7d7ab Auto merge of #147508 - nnethercote:TaskDeps-improvements, r=saethlin
`TaskDeps` improvements

Some cleanups and minor perf improvements relating to `TaskDeps`.

r? `@saethlin`
2025-10-17 04:47:43 +00:00
Philipp Krones
4b0cfb6a83
Update Cargo.lock 2025-10-16 20:38:32 +02:00
Philipp Krones
50561837de
Merge commit 'd9fb15c4b1ebe9e7dc419e07f53af681d7860cbe' into clippy-subtree-update 2025-10-16 20:38:28 +02:00
bors
53a741fc4b Auto merge of #147782 - matthiaskrgr:rollup-9728xqu, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - rust-lang/rust#144438 (Guard HIR lowered contracts with `contract_checks`)
 - rust-lang/rust#147000 (std: Add Motor OS std library port)
 - rust-lang/rust#147576 (Fix ICE on offsetted ZST pointer)
 - rust-lang/rust#147732 (remove duplicate inline macro)
 - rust-lang/rust#147738 (Don't highlight `let` expressions as having type `bool` in let-chain error messages)
 - rust-lang/rust#147744 (miri subtree update)
 - rust-lang/rust#147751 (Use `bit_set::Word` in a couple more places.)
 - rust-lang/rust#147752 (style-guide: fix typo for empty struct advice)
 - rust-lang/rust#147773 (`is_ascii` on an empty string or slice returns true)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-10-16 18:35:29 +00:00
Matthias Krüger
f337e28bd9
Rollup merge of #147773 - timvisee:docs-empty-is-ascii, r=Noratrieb
`is_ascii` on an empty string or slice returns true

Update the description of the [`is_ascii`](https://doc.rust-lang.org/std/primitive.str.html#method.is_ascii) functions - an empty string or slice also returns `true`.

This follows the pattern of [`all()`](https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.all). Clippy currently suggests to change `string.chars().all(|c| c.is_ascii())` into `string.is_ascii()`. This suggestion therefore seems fitting.

I've already questioned the behavior for this multiple times. I've always had to check the internals to conclude how it works. That's why I'm opening this PR to add it directly in the documentation.
2025-10-16 19:35:28 +02:00
Matthias Krüger
3a993f7458
Rollup merge of #147752 - fee1-dead-contrib:sgtypo, r=chenyukang
style-guide: fix typo for empty struct advice

the advice appears to apply to empty structs with braces (parens/blocks), and a unit struct in the comment does not make sense. Fix the typo.
2025-10-16 19:35:28 +02:00
Matthias Krüger
7604d12e05
Rollup merge of #147751 - nnethercote:bit_set-Word, r=Zalathar
Use `bit_set::Word` in a couple more places.

It's a synonym for `u64` and there are a couple of places where we use `u64` where we should use `Word`, which this commit fixes.

I found this when I tried changing `Word` to `u128` (which made performance worse).

r? `````@Zalathar`````
2025-10-16 19:35:27 +02:00
Matthias Krüger
6f66f3baf5
Rollup merge of #147744 - RalfJung:miri, r=RalfJung
miri subtree update

Subtree update of `miri` to 50ba3a7de8.

Created using https://github.com/rust-lang/josh-sync.

r? ``````@ghost``````
2025-10-16 19:35:26 +02:00
Matthias Krüger
d8dd468ff1
Rollup merge of #147738 - pommicket:issue-147665, r=madsmtm
Don't highlight `let` expressions as having type `bool` in let-chain error messages

Fixes rust-lang/rust#147665.
2025-10-16 19:35:25 +02:00
Matthias Krüger
42cf0bd006
Rollup merge of #147732 - h3nryc0ding:master, r=chenyukang
remove duplicate inline macro
2025-10-16 19:35:25 +02:00
Matthias Krüger
5408ec3069
Rollup merge of #147576 - Mark-Simulacrum:fix-offset-zst, r=nnethercote,RalfJung
Fix ICE on offsetted ZST pointer

I'm not sure this is the *right* fix, but it's simple enough and does roughly what I'd expect. Like with the previous optimization to codegen usize rather than a zero-sized static, there's no guarantee that we continue returning a particular value from the offsetting.

A grep for `const_usize.*align` found the same code copied to rustc_codegen_gcc and cranelift but a quick skim didn't find other cases of similar 'optimization'. That said, I'm not convinced I caught everything, it's not trivial to search for this.

Closes rust-lang/rust#147516
2025-10-16 19:35:24 +02:00
Matthias Krüger
91f48d8ba7
Rollup merge of #147000 - moturus:motor-os_stdlib_pr, r=tgross35
std: Add Motor OS std library port

Motor OS was added as a no-std Tier-3 target in
[PR 146848](https://github.com/rust-lang/rust/pull/146848) as x86_64-unknown-motor.

This PR adds the std library for Motor OS.

While the PR may seem large, all it does is proxy
std pal calls to [moto-rt](https://crates.io/crates/moto-rt). Where there is some non-trivial
code (e.g. thread::spawn), it is quite similar, often
identical, to what other platforms do.
2025-10-16 19:35:23 +02:00
Matthias Krüger
334b3af42c
Rollup merge of #144438 - dawidl022:contracts/guarded-lowering, r=oli-obk
Guard HIR lowered contracts with `contract_checks`

Refactor contract HIR lowering to ensure no contract code is executed when contract-checks are disabled.

The call to `contract_checks` is moved to inside the lowered fn body, and contract closures are built conditionally, ensuring no side-effects present in contracts occur when those are disabled. This partially addresses rust-lang/rust#139548, i.e. the bad behavior no longer happens with contract checks disabled (`-Zcontract-checks=no`).

The change is made in preparation for adding contract variable declarations - variables declared before the `requires` assertion, and accessible from both `requires` and `ensures`, but not in the function body (PR rust-lang/rust#144444). As those declarations may also have side-effects, it's good to guard them with `contract_checks` - the new lowering approach allows for this to be done easily.

Contracts tracking issue: rust-lang/rust#128044

**Known limiatations**:

- It is still possible to early return from the *function* from within a contract, e.g.

  ```rust
  #[ensures({if x > 0 { return 0 }; |_| true})]
  fn foo(x: u32) -> i32 {
      42
  }
  ```

  When `foo` is called with an argument greater than 0, instead of `42`, `0` will be returned.

  As this is not a regression, it is not addressed in this PR. However, it may be worth revisiting later down the line, as users may expect a form of early return from *contract specifications*, and so returning from the entire *function* could cause confusion.

- ~Contracts are still not optimised out when disabled. Currently, even when contracts are disabled, the code generated causes existing optimisations to fail, meaning even disabled contracts could impact runtime performance. This issue is blocking rust-lang/rust#136578, and has not been addressed in this PR, i.e. the `mir-opt` and `codegen` tests that fail in rust-lang/rust#136578 still fail with these new HIR lowering changes.~ Contracts should now be optimised out when disabled, however some regressions tests still need to be added to be sure that is indeed the case.
2025-10-16 19:35:22 +02:00
bors
779e19d8ba Auto merge of #147644 - cjgillot:bitsetvec, r=jackh726
Use regular Vec in BitSet.

That code is hot enough for the branch in all accesses to `SmallVec` to appear in profiles.
2025-10-16 14:06:35 +00:00
Philipp Krones
d9fb15c4b1
Rustup (#15892)
r? @ghost

changelog: none
2025-10-16 14:03:44 +00:00
Philipp Krones
9aa70f2bdd
Bump nightly version -> 2025-10-16 2025-10-16 15:57:16 +02:00
Philipp Krones
cf7aaa5ecf
Merge remote-tracking branch 'upstream/master' into rustup 2025-10-16 15:57:00 +02:00
timvisee
7a11c72db0
is_ascii on an empty string or slice returns true 2025-10-16 10:52:51 +02:00
bors
f5242367f4 Auto merge of #146221 - camsteffen:ast-boxes, r=cjgillot
Remove boxes from ast list elements

Less indirection should be better perf.
2025-10-16 02:31:44 +00:00
Deadbeef
74ac3ec91a style-guide: fix typo for empty struct advice
the advice appears to apply to empty structs with braces (parens/blocks), and
a unit struct in the comment does not make sense. Fix the typo.
2025-10-16 01:03:56 +00:00
Nicholas Nethercote
8787c0b863 Use bit_set::Word in a couple more places.
It's a synonym for `u64` and there are a couple of places where we use
`u64` where we should use `Word`, which this commit fixes.

I found this when I tried changing `Word` to `u128` (which made
performance worse).
2025-10-16 11:45:07 +11:00
Mark Rousskov
a8c79b876b Fix ICE on offsetted ZST pointer
A grep for `const_usize.*align` found the same code copied to
rustc_codegen_gcc but I don't see other cases where we get this wrong.
2025-10-15 20:06:46 -04:00
bors
402ce0ef07 Auto merge of #147745 - matthiaskrgr:rollup-b4kftk9, r=matthiaskrgr
Rollup of 11 pull requests

Successful merges:

 - rust-lang/rust#143191 (Stabilize `rwlock_downgrade` library feature)
 - rust-lang/rust#147444 (Allow printing a fully-qualified path in `def_path_str`)
 - rust-lang/rust#147527 (Update t-compiler beta nomination Zulip msg)
 - rust-lang/rust#147670 (some `ErrorGuaranteed` cleanups)
 - rust-lang/rust#147676 (Return spans out of `is_doc_comment` to reduce reliance on `.span()` on attributes)
 - rust-lang/rust#147708 (const `mem::drop`)
 - rust-lang/rust#147710 (Fix ICE when using contracts on async functions)
 - rust-lang/rust#147716 (Fix some comments)
 - rust-lang/rust#147718 (miri: use allocator_shim_contents codegen helper)
 - rust-lang/rust#147729 (ignore boring locals when explaining why a borrow contains a point due to drop of a live local under polonius)
 - rust-lang/rust#147742 (Revert unintentional whitespace changes to rustfmt-excluded file)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-10-15 23:20:53 +00:00
Matthias Krüger
a4d2811b88
Rollup merge of #147742 - Diggsey:db-fix-miri-whitespace, r=RalfJung
Revert unintentional whitespace changes to rustfmt-excluded file

Accidentally introduced in https://github.com/rust-lang/rust/pull/143548
2025-10-15 23:41:07 +02:00
Matthias Krüger
33c29520ca
Rollup merge of #147729 - lqd:polonius-diagnostics, r=jackh726
ignore boring locals when explaining why a borrow contains a point due to drop of a live local under polonius

Polonius liveness has to contain boring locals, and we ignore them in diagnostics, to match NLL diagnostics that never involve any boring locals. When explaining why a borrow contains a point, I ignored these boring locals when it was due to a use of a live var, but forgot to do so when the cause was because of a drop of a live var.

This is what was causing the last two (known) diagnostics differences under the polonius compare-mode:
- `tests/ui/dropck/dropck_trait_cycle_checked.rs`
- `tests/ui/unboxed-closures/unboxed-closures-failed-recursive-fn-1.rs`

r? `@jackh726`
2025-10-15 23:41:06 +02:00
Matthias Krüger
212826db7d
Rollup merge of #147718 - RalfJung:miri-allocator_shim_contents, r=bjorn3
miri: use allocator_shim_contents codegen helper

r? `@bjorn3`

Follow-up to https://github.com/rust-lang/rust/pull/147526, also using that new infrastructure in Miri.
2025-10-15 23:41:05 +02:00
Matthias Krüger
d7b9e66728
Rollup merge of #147716 - zhetaicheleba:master, r=jdonszelmann
Fix some comments

Fix some comments
2025-10-15 23:41:05 +02:00
Matthias Krüger
6908bca90f
Rollup merge of #147710 - chenyukang:yukang-fix-ice-contracts-async, r=jackh726
Fix ICE when using contracts on async functions

Fixes rust-lang/rust#145333

contract is not supported for async functions right now, it's not properly lowered and getting HirId will ICE.

This PR adds checking for async function in expanding AST phase, it's better until we want to fully support async for contracts feature.
2025-10-15 23:41:04 +02:00
Matthias Krüger
9bd8aa5e7c
Rollup merge of #147708 - clarfonthey:const-drop, r=oli-obk
const `mem::drop`

I'm putting this under the `const Destruct` feature flag since it doesn't really feel relevant to put it elsewhere… it's just an empty function body, so, it doesn't have any particular weirdness attached to it (unlike `drop_in_place`, for example).

r? wg-const-eval
2025-10-15 23:41:04 +02:00
Matthias Krüger
c607de5508
Rollup merge of #147676 - jdonszelmann:span-is-doc-comment, r=GuillaumeGomez
Return spans out of `is_doc_comment` to reduce reliance on `.span()` on attributes

r? `@GuillaumeGomez`
2025-10-15 23:41:03 +02:00
Matthias Krüger
e7c1e19a6b
Rollup merge of #147670 - lcnr:no-ok-ret-guar, r=BoxyUwU
some `ErrorGuaranteed` cleanups

If we've got an `ErrorGuaranteed`, use it.
2025-10-15 23:41:02 +02:00
Matthias Krüger
a71cd41155
Rollup merge of #147527 - apiraino:update-beta-nom-zulip-msg, r=Kobzol
Update t-compiler beta nomination Zulip msg

Sister patch of [triagebot#2191](https://github.com/rust-lang/triagebot/pull/2191)
Follow-up to rust-lang/rust#147263

The triagebot now triggers a different message when a PR is nominated for backport, making it look like more a suggestion to evaluate for the author/reviewers than a mandatory decision for the team to take.

The wording (as per [triagebot#2191](https://github.com/rust-lang/triagebot/pull/2191)) is open to suggestions.

Thanks
2025-10-15 23:41:02 +02:00
Matthias Krüger
88efae3db9
Rollup merge of #147444 - jyn514:fully-qualified-paths, r=nnethercote
Allow printing a fully-qualified path in `def_path_str`

Previously, the local crate would always be printed as a leading `crate::`. Allow resolving it to the crate name instead.

This allows printing a fully qualified path with:
```rust
let qualified_name = with_no_visible_paths!(with_resolve_crate_name!(
    with_no_trimmed_paths!(tcx.def_path_str(def_id))
));
```

I found this useful for an out-of-tree rustc-driver. I do not currently have a usecase in mind upstream; I'm ok if you don't want this PR for that reason. See [#t-compiler/help > print a fully qualified path name? @ 💬](https://rust-lang.zulipchat.com/#narrow/channel/182449-t-compiler.2Fhelp/topic/print.20a.20fully.20qualified.20path.20name.3F/near/541560961) for additional context.

This does not currently have tests. I am not aware of an easy way to test def-id printing, since it requires having access to a TyCtxt.
2025-10-15 23:41:01 +02:00
Matthias Krüger
8d6356b8d8
Rollup merge of #143191 - connortsui20:stabilize-rwlock-downgrade, r=tgross35
Stabilize `rwlock_downgrade` library feature

Tracking Issue: https://github.com/rust-lang/rust/issues/128203

Method to be stabilized:

```rust
impl<'a, T: ?Sized> RwLockWriteGuard<'a, T> {
    pub fn downgrade(s: Self) -> RwLockReadGuard<'a, T> {}
}
```

~~I would like to point out that my documentation comment is longer than ideal, but at the same time I don't really know how else to show why `downgrade` is actually necessary (instead of just unlocking and relocking). If anyone has ideas for making this more concise that would be great!~~ I have made the documentation a bit more clear.

Stabilization report: https://github.com/rust-lang/rust/issues/128203#issuecomment-3016682463
2025-10-15 23:41:00 +02:00
Ralf Jung
2f04473551 update lockfile 2025-10-15 23:30:28 +02:00
Diggory Blake
87e0f43c56
Revert unintentional whitespace changes to rustfmt-excluded file 2025-10-15 21:34:38 +01:00
Ralf Jung
d458363e26
Merge pull request #4635 from RalfJung/rustup
Rustup
2025-10-15 20:32:00 +00:00
llogiq
00e5e1b838
refactor(match_like_matches_macro): disentangle the if-let and match cases (#15854)
As discussed in [#clippy > &#96;match_like_matches_macro&#96; does the
work
of&#96;match_same_arms&#96;](https://rust-lang.zulipchat.com/#narrow/channel/257328-clippy/topic/.60match_like_matches_macro.60.20does.20the.20work.20of.60match_same_arms.60/with/544003831)

Sorry for the large number of commits -- I could've gotten away just
three ("clean-up", and one for each inlining of `find_matches_sugg` and
subsequent simplifications), but I found the diff of that quite
difficult to understand.

changelog: none
2025-10-15 20:31:28 +00:00
llogiq
869753389b
overhaul mutex_{atomic,integer} (#15632)
- only lint on definitions of offending mutexes, not all their uses
(fixes https://github.com/rust-lang/rust-clippy/issues/13378)
- give more orderly help messages
- stop linting on `Mutex<*const T>` (see the corresponding commit for
context)
- offer (partial) suggestions

The last change might be deemed a bit too much for the feature freeze,
but it can be easily extracted out into a separate PR.

changelog: [`mutex_atomic`]: only lint the definitions, not uses
changelog: [`mutex_atomic`]: better help messages, and suggestions
changelog: [`mutex_atomic`]: don't lint `Mutex<*const T>`
changelog: [`mutex_integer`]: only lint the definitions, not uses
changelog: [`mutex_integer`]: better help messages, and suggestions
2025-10-15 20:29:59 +00:00
bors
57ef8d642d Auto merge of #144064 - davidtwco:prefer-alias-over-env-for-sizedness, r=lcnr
prefer alias candidates for sizedness + auto trait goals

Fixes rust-lang/rust#143992

- abd07dec44437554520453f929c2b12d4eb8b11e: Reverts rust-lang/rust#144016 so that `MetaSized` bounds are checked properly, and updates all the tests accordingly, including making `tests/ui/sized-hierarchy/incomplete-inference-issue-143992.rs` fail when it shouldn't
- 90e61db9745f53d9aef21e3ebce0df19cc1389d7: Prefer alias candidates over parameter environment candidates for sizedness, auto and default traits. `tests/ui/sized-hierarchy/incomplete-inference-issue-143992.rs` passes again, but `tests/ui/generic-associated-types/issue-93262.rs` starts failing when it shouldn't
- e412062171925d0b40fdbeb5765c45087bdf0fe7: No longer require that predicates of aliases hold in well-formedness checking of the alias. `tests/ui/generic-associated-types/issue-93262.rs` passes again

Each commit updates all the tests to their new output so it should be easy enough to see what the impact of each change individually is. After all of the changes, tests that pass when they didn't before or vice versa:

- `tests/ui/extern/extern-types-size_of_val.rs`
    - Previously passing, but only because of rust-lang/rust#144016, now correctly errors
- `tests/ui/sized-hierarchy/incomplete-inference-issue-143992.rs`
    - Previously failing on next solver, only because rust-lang/rust#144016 only applied to the old solver, passing now with 90e61db9745f53d9aef21e3ebce0df19cc1389d7
- `tests/ui/sized-hierarchy/overflow.rs`
    - Previously passing, but only because of rust-lang/rust#144016, now correctly errors
- `tests/ui/generic-associated-types/issue-92096.rs`
    - Previously passing, due to e412062171925d0b40fdbeb5765c45087bdf0fe7
    - Fails to prove `C::Connecting<'placeholder>: Send` which is required when proving that the generator is `Send`. This is an instance of rust-lang/rust#110338.
- `tests/ui/higher-ranked/trait-bounds/normalize-under-binder/norm-before-method-resolution-opaque-type.rs`
    - Previously passing, now failing in the next solver, due to 03e0fdab6196e81b44356f42f03b6a0a224cf451
    - Expected that this test now fails as ambigious, see [Zulip](https://rust-lang.zulipchat.com/#narrow/channel/144729-t-types/topic/sizedness.20bounds.20in.20explicit_implied_predicates_of.20.28.23142712.29/near/526987384)

This had a crater run in https://github.com/rust-lang/rust/pull/142712#issuecomment-3050358772 alongside some other changes.

r? `@lcnr`
cc rust-lang/rust#142712 (this extracts part of that change)
2025-10-15 20:15:46 +00:00
Ralf Jung
952be8e886 fix genmc build 2025-10-15 21:58:02 +02:00
pommicket
984542c4e2 Don't highlight let expressions as having type bool 2025-10-15 15:54:55 -04:00
Ralf Jung
804af99457 miri: use allocator_shim_contents codegen helper 2025-10-15 21:23:14 +02:00
Ralf Jung
7c28d96b7a Merge ref '28d0a4a205f9' from rust-lang/rust
Pull recent changes from https://github.com/rust-lang/rust via Josh.

Upstream ref: 28d0a4a205f9e511ad2f51ee79a4aa19a704a455
Filtered ref: 310e49750b70768361f78966c10be9716a300784
Upstream diff: 235a4c083e...28d0a4a205

This merge was created using https://github.com/rust-lang/josh-sync.
2025-10-15 21:16:40 +02:00
llogiq
ab9eb10ef7
feat: manual_rotate also recognize non-consts (#15402)
changelog: [`manual_rotate`]: also recognize non-consts

fixes https://github.com/rust-lang/rust-clippy/issues/13028

r? @llogiq
2025-10-15 19:12:24 +00:00
Ralf Jung
0ecee8c1b8 Prepare for merging from rust-lang/rust
This updates the rust-version file to 28d0a4a205f9e511ad2f51ee79a4aa19a704a455.
2025-10-15 21:01:18 +02:00
bors
3f2a5921a4 Auto merge of #147730 - Muscraft:update-cargo, r=Muscraft
Update cargo

17 commits in 81c3f77a467359c8be6bc747dc93ec66a6e4ce11..367fd9f213750cd40317803dd0a5a3ce3f0c676d
2025-10-10 18:41:02 +0000 to 2025-10-15 15:01:32 +0000
- test: Don't look for a specfic ANSI color (rust-lang/cargo#16118)
- docs(guide): Clarify where to set config (rust-lang/cargo#16107)
- test(rustfix): re-enable disabled test due to unused variables (rust-lang/cargo#16114)
- Convert the "manifest has no things" warning to annotate_snippets. (rust-lang/cargo#16113)
- doc: make it clearer that `target.&lt;cfg&gt;.linker` is supported (rust-lang/cargo#16112)
- docs(guide): Cover feature-unification (rust-lang/cargo#16108)
- fix(gctx): types are unsupported not unknown (rust-lang/cargo#16109)
- fix(script): Tweak cargo script build-dir / target-dir (rust-lang/cargo#16086)
- docs(gctx): explain Value deserialization step-by-step (rust-lang/cargo#16105)
- docs(guide): Talk about removing unused features (rust-lang/cargo#16085)
- test(config): exercise unsupported TOML types (rust-lang/cargo#16100)
- docs(gctx): a bit more of how config deserialization works (rust-lang/cargo#16094)
- Refactor `Layout` into `BuildDirLayout` and `ArtifactDirLayout` (rust-lang/cargo#16092)
- Add alternative linker to the build performance guide (rust-lang/cargo#15991)
- refactor(gctx): extract error to a module (rust-lang/cargo#16091)
- fix: Fixed nightly tests failing due to unused_variables lint (rust-lang/cargo#16098)
- fix(script): Store cargo script lockfiles in build-dir (rust-lang/cargo#16087)

r? ghost
2025-10-15 17:07:35 +00:00
h3nryc0ding
1de9b49f24 remove duplicate inline macro 2025-10-15 18:48:25 +02:00