51056 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
Yotam Ofek
9361d64712 Move Vec of locals instead of pushing every element 2025-10-15 22:09:27 +03: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
Chayim Refael Friedman
4efd70d5f0 Make more new-trait-solver-things have specific ID type 2025-10-15 16:31:03 +03: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
bors
4f08307f6e Auto merge of #147619 - nnethercote:union-ne-check, r=Zalathar
Add a `!=` check to `ChunkedBitSet::union`.

It's a big speed win for `cranelift-codegen-0.119.0`.

r? `@Zalathar`
2025-10-15 10:04:49 +00:00
David Wood
676d9cfa8b trait_sel: prefer only nested alias bounds 2025-10-15 09:35:05 +01:00
David Wood
c50aebba78 trait_sel: don't require predicates of aliases hold
No longer require that we prove that the predicates of aliases hold when
checking the well-formedness of the alias. This permits more uses of GATs
and changes the output of yet more tests.
2025-10-15 09:35:05 +01:00
David Wood
321a47eb2c trait_sel: sizedness goals prefer alias candidates
For sizedness, default and auto trait predicates, now prefer non-param
candidates if any exist. As these traits do not have generic parameters,
it never makes sense to prefer an non-alias candidate, as there can
never be a more permissive candidate.
2025-10-15 09:35:04 +01:00
David Wood
efaeacfc96 revert: PR144016 - MetaSized does not always hold 2025-10-15 09:35:04 +01:00
zhetaicheleba
07df2adbdf Fix some comments
Signed-off-by: zhetaicheleba <taicheleba@outlook.com>
2025-10-15 14:23:28 +08:00
Matthias Krüger
e389ffa763 Rollup merge of #147699 - aDotInTheVoid:doc-comment-doc-comment, r=jdonszelmann
Clairify docs for `AttributeKind::DocComment`

Makes it clear that this represents `#[doc = "content"]`, but not `#[doc(hidden)]` (or other uses of the `#[doc(...)]` attribute).

r? `@jdonszelmann`
2025-10-15 07:09:56 +02:00
Matthias Krüger
72030511bb Rollup merge of #147685 - jdonszelmann:deprecated-no-span, r=JonathanBrouwer
remove span calls from deprecated attribute checking

r? `@JonathanBrouwer`
2025-10-15 07:09:56 +02:00
Matthias Krüger
33b1e92d4f Rollup merge of #147539 - petrochenkov:cmresolve, r=eholk
resolve: Use primitives for conditional mutability more consistently

No bare `(Ref)Cell`s remain in `rustc_resolve`, only `Cm(Ref)Cell`s checking that nothing is modified during speculative resolution, and `Cache(Ref)Cell` aliases for cells that need to be migrated to mutexes/atomics.

cc `@LorrensP-2158466`
2025-10-15 07:09:55 +02:00
Matthias Krüger
041ecb124a Rollup merge of #146949 - pmur:murp/improve-ppc-inline-asm, r=Amanieu
Add vsx register support for ppc inline asm, and implement preserves_flag option

This should address the last(?) missing pieces of inline asm for ppc:

* Explicit VSX register support. ISA 2.06 (POWER7) added a 64x128b register overlay extending the fpr's to 128b, and unifies them with the vmx (altivec) registers. Implementations details within gcc/llvm percolate up, and require using the `x` template modifier. I have updated the inline asm to implicitly include this for vsx arguments which do not specify it. ~~Support for the gcc codegen backend is still a todo.~~

* Implement the `preserves_flags` option. All ABI's, and all ISAs store their flags in `cr`, and the carry bit lives inside `xer`. The other status registers hold sticky bits or control bits which do not affect branch instructions.

There is some interest in the e500 (powerpcspe) port. Architecturally, it has a very different FP ISA, and includes a simd extension called SPR (which is not IBM's cell SPE). Notably, it does not have altivec/fpr/vsx registers. It also has an SPE accumulator register which its ABI marks as volatile, but I am not sure if the compiler uses it.
2025-10-15 07:09:54 +02:00
Nicholas Nethercote
60481827f6 Add a != check to ChunkedBitSet::union.
It's a big speed win for cranelift-codegen-0.119.0.
2025-10-15 13:49:38 +11:00
Nicholas Nethercote
facb9aca79 Refactor some ChunkedBitSet operations.
For less indentation, mostly.
2025-10-15 13:49:05 +11:00
yukang
0935df7829 Fix ICE when using contracts on async functions 2025-10-15 09:09:23 +08:00
Alona Enraght-Moony
ff95799e09 Clairify docs for AttributeKind::DocComment
Makes it clear that this represents `#[doc = "content"]`, but not
`#[doc(hidden)]` (or other uses of the `#[doc(...)]` attribute).
2025-10-14 19:47:58 +00:00
Matthias Krüger
545ee6fe6b Rollup merge of #147683 - jdonszelmann:less-duplicate-checking, r=JonathanBrouwer
only check duplicates on old/unparsed attributes

r? ``@JonathanBrouwer``

This was effectively already what we were doing, but this was implicit because `.name()` etc were just returning None when dealing with a parsed attribute.... this makes it explicit
2025-10-14 19:47:35 +02:00
Matthias Krüger
ea0c8d8e73 Rollup merge of #147682 - jdonszelmann:convert-rustc-main, r=JonathanBrouwer
convert `rustc_main` to the new attribute parsing infrastructure

r? ``@JonathanBrouwer``
2025-10-14 19:47:34 +02:00
Matthias Krüger
3856d0b4fd Rollup merge of #147680 - chenyukang:yukang-fix-ice-147325, r=estebank
Fix ICE caused by associated_item_def_ids on wrong type in resolve diag

Fixes rust-lang/rust#147325

r? ``@estebank``
2025-10-14 19:47:34 +02:00
Matthias Krüger
783307c4c3 Rollup merge of #147677 - jdonszelmann:fewer-span-exceptions, r=WaffleLapkin
Fewer exceptions in `span()` on parsed attributes

r? ``@JonathanBrouwer``
2025-10-14 19:47:33 +02:00
Matthias Krüger
5a2c639a23 Rollup merge of #147673 - jdonszelmann:u128-pp, r=JonathanBrouwer
pretty print u128 with display

r? ```@JonathanBrouwer```
2025-10-14 19:47:33 +02:00
Matthias Krüger
10e535a163 Rollup merge of #147638 - alessandrod:indirect-res, r=wesleywiser
bpf: return results larger than one register indirectly

Fixes triggering the "only small returns supported" error in the BPF target.
2025-10-14 19:47:30 +02:00
Matthias Krüger
b134c9c135 Rollup merge of #147630 - nnethercote:bitset-cleanups, r=cjgillot,Zalathar
Bitset cleanups

Some minor cleanups I did while working on rust-lang/rust#147619.

r? ```@Zalathar```
2025-10-14 19:47:30 +02:00
Matthias Krüger
f8b65f7bc7 Rollup merge of #147526 - bjorn3:alloc_shim_weak_shape, r=petrochenkov,RalfJung
Move computation of allocator shim contents to cg_ssa

In the future this should make it easier to use weak symbols for the allocator shim on platforms that properly support weak symbols. And it would allow reusing the allocator shim code for handling default implementations of the upcoming externally implementable items feature on platforms that don't properly support weak symbols.

In addition to make this possible, the alloc error handler is now handled in a way such that it is possible to avoid using the allocator shim when liballoc is compiled without `no_global_oom_handling` if you use `#[alloc_error_handler]`. Previously this was only possible if you avoided liballoc entirely or compiled it with `no_global_oom_handling`. You still need to avoid libstd and to define the symbol that indicates that avoiding the allocator shim is unstable.
2025-10-14 19:47:29 +02:00
Jana Dönszelmann
43d915c426 remove span calls from deprecated attribute checking 2025-10-14 18:44:22 +02:00
Jana Dönszelmann
047c37cf23 convert rustc_main to the new attribute parsing infrastructure 2025-10-14 17:55:00 +02:00
bjorn3
cf0256008b Add comment to AllocatorKind and AllocatorMethod 2025-10-14 15:53:40 +00:00
Jana Dönszelmann
a51a793472 only check duplicates on old/unparsed attributes 2025-10-14 17:32:05 +02:00