Commit graph

308340 commits

Author SHA1 Message Date
dianqk
a673575b24
mir-opt: Simplify trivial constants in SimplifyConstCondition 2025-10-16 21:30:06 +08:00
Evan Jones
c4dc39be05
add link to Builder (code review improvement) 2025-10-16 09:07:57 -04:00
yukang
4a886add5c Fix ICE in pattern matching with generic const array length errors 2025-10-16 19:15:32 +08:00
timvisee
7a11c72db0
is_ascii on an empty string or slice returns true 2025-10-16 10:52:51 +02:00
beepster
5ffbec8f20 add regression test 2025-10-15 21:46:16 -07: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
Camille Gillot
fb38d75ca5 Simplify implementation. 2025-10-15 21:47:10 +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
beepster
f1b180a788
undo CopyForDeref assertion in const qualif 2025-10-15 14:28:03 -07:00
Camille Gillot
031929c369 deduced_param_attrs: check Freeze on monomorphic types. 2025-10-15 21:21:05 +00: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
Jonathan Brouwer
090dad00a9
Changes in uitests for cfg_attr
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-10-15 22:18:18 +02:00
Jonathan Brouwer
7113d58c8e
Port #[cfg_attr] to the new attribute parsing infrastructure
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-10-15 22:18:18 +02:00
Jonathan Brouwer
e0c190f681
Move parse_cfg_attr to rustc_attr_parsing
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-10-15 22:18:18 +02:00
Jonathan Brouwer
52cc311828
Rename some functions
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-10-15 22:18:17 +02: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 '28d0a4a205' from rust-lang/rust
Pull recent changes from https://github.com/rust-lang/rust via Josh.

Upstream ref: 28d0a4a205
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
Yotam Ofek
9361d64712 Move Vec of locals instead of pushing every element 2025-10-15 22:09:27 +03:00
Ralf Jung
0ecee8c1b8 Prepare for merging from rust-lang/rust
This updates the rust-version file to 28d0a4a205.
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
Scott Schafer
b5906362dd
Update cargo 2025-10-15 10:07:17 -06:00
Rémy Rakic
68080de4e3 ignore boring locals when explaining borrow due to drop
Polonius liveness has to contain boring locals, and we ignore them in
diagnostics to match NLL diagnostics, since they doesn't contain boring locals.

We ignored these when explaining why a loan contained a point due to
a use of a live var, but not when it contained a point due to a drop of
a live var.
2025-10-15 15:47:44 +00:00
bors
28d0a4a205 Auto merge of #143548 - Diggsey:db-limit-extern-crate-usage, r=oli-obk
Restrict sysroot crate imports to those defined in this repo.

It's common to import dependencies from the sysroot via `extern crate` rather than use an explicit cargo dependency, when it's necessary to use the same dependency version as used by rustc itself. However, this is dangerous for crates.io crates, since rustc may not pull in the dependency on some targets, or may pull in multiple versions. In both cases, the `extern crate` fails to resolve.

To address this, re-export all such dependencies from the appropriate `rustc_*` crates, and use this alias from crates which would otherwise need to use `extern crate`.

See https://github.com/rust-lang/rust/pull/143492 for an example of the kind of issue that can occur.
2025-10-15 13:32:03 +00:00
Ralf Jung
a084f45b6c
Merge pull request #4634 from nia-e/new-libffi
native-lib: bump libffi
2025-10-15 12:52:31 +00:00
Ralf Jung
51cab7c0df avoid some Vector allocations 2025-10-15 14:23:17 +02:00
Diggory Blake
e8fec08b9c Restrict sysroot crate imports to those defined in this repo.
It's common to import dependencies from the sysroot via `extern crate`
rather than use an explicit cargo dependency, when it's necessary to use
the same dependency version as used by rustc itself. However, this is
dangerous for crates.io crates, since rustc may not pull in the
dependency on some targets, or may pull in multiple versions. In both
cases, the `extern crate` fails to resolve.

To address this, re-export all such dependencies from the appropriate
`rustc_*` crates, and use this alias from crates which would otherwise
need to use `extern crate`.
2025-10-15 13:17:25 +01:00
Diggory Blake
c6a952159f
Restrict sysroot crate imports to those defined in this repo.
It's common to import dependencies from the sysroot via `extern crate`
rather than use an explicit cargo dependency, when it's necessary to use
the same dependency version as used by rustc itself. However, this is
dangerous for crates.io crates, since rustc may not pull in the
dependency on some targets, or may pull in multiple versions. In both
cases, the `extern crate` fails to resolve.

To address this, re-export all such dependencies from the appropriate
`rustc_*` crates, and use this alias from crates which would otherwise
need to use `extern crate`.
2025-10-15 13:17:25 +01:00