Commit Graph

21219 Commits

Author SHA1 Message Date
Guillaume Gomez
49044d0d40 Add support for trait associated items 2025-08-10 12:00:08 +02:00
Stuart Cook
934cb10f1b Rollup merge of #145191 - dianne:fix-borrow-suggestion-args, r=compiler-errors
`suggest_borrow_generic_arg`: use the correct generic args

The suggestion now gets calls' generic arguments from the callee's type to handle cases where the callee isn't an identifier expression. Fixes rust-lang/rust#145164.
2025-08-10 19:45:56 +10:00
Stuart Cook
baa35853a9 Rollup merge of #145112 - dpaoliello:raw-dylib-link-ordinal, r=jieyouxu
[win][arm64ec] Partial fix for raw-dylib-link-ordinal on Arm64EC

These are the test fixes required to get `raw-dylib-link-ordinal` working on Arm64EC.

For the test to completely pass, we also need an updated `ar_archive_writer` with <https://github.com/rust-lang/ar_archive_writer/pull/24> merged in.
2025-08-10 19:45:50 +10:00
Stuart Cook
62b406d4b1 Rollup merge of #144403 - Kivooeo:issue4, r=jieyouxu
`tests/ui/issues/`: The Issues Strike Back [4/N]

Some `tests/ui/issues/` housekeeping, to trim down number of tests directly under `tests/ui/issues/`. Part of https://github.com/rust-lang/rust/issues/133895.

r? ````````@jieyouxu````````
2025-08-10 19:45:48 +10:00
Stuart Cook
5955f005e5 Rollup merge of #144402 - heiher:stabilize-loong32-asm, r=Amanieu
Stabilize loongarch32 inline asm

r? ````````@Amanieu````````
2025-08-10 19:45:47 +10:00
Stuart Cook
e5b98a9c21 Rollup merge of #143093 - lqd:polonius-pre-alpha, r=jackh726
Simplify polonius location-sensitive analysis

This PR reworks the location-sensitive analysis into what we think is a worthwhile subset of the datalog analysis. A sort of polonius alpha analysis that handles NLL problem case 3 and more, but is still using the faster "reachability as an approximation of liveness", as well as the same loans-in-scope computation as NLLs -- and thus doesn't handle full flow-sensitivity like the datalog implementation.

In the last few months, we've identified this subset as being actionable:
- we believe we can make a stabilizable version of this analysis
- it is an improvement over the status quo
- it can also be modeled in a-mir-formality, or some other formalism, for assurances about soundness, and I believe ````````@nikomatsakis```````` is interested in looking into this during H2.
- and we've identified the areas of work we wish to explore later to gradually expand the supported cases: the differences between reachability and liveness, support of kills, and considerations of time-traveling, for example.

The approach in this PR is to try less to have the graph only represent live paths, by checking whether we reach a live region during traversal and recording the loan as live there, instead of equating traversal with liveness like today because it has subtleties with the typeck edges in statements (that could forward loans to the successor point without ensuring their liveness). We can then also simplify these typeck stmt edges. And we also can simplify traversal by removing looking at kills, because that's enough to handle a bunch of NLL problem 3 cases -- and we can gradually support them more and more in traversal in the future, to reduce the approximation of liveness.

There's still some in-progress pieces of work w/r/t opaque types that I'm expecting [lcnr's opaque types rework](https://github.com/rust-lang/rust/pull/139587), and [amanda's SCCs rework](https://github.com/rust-lang/rust/pull/130227) to handle. That didn't seem to show up in tests until I rebased today (and shows lack of test coverage once again) when https://github.com/rust-lang/rust/pull/142255 introduced a couple of test failures with the new captures rules from edition 2024. It's not unexpected since we know more work is needed with member constraints (and we're not even using SCCs in this prototype yet)

I'll look into these anyways, both for future work, and checking how these other 2 PRs would change things.

---

I'm not sure the following means a lot until we have some formalism in-place, but:
- I've changed the polonius compare-mode to use this analysis: the tests pass with it, except 2 cases with minor diagnostics differences, and the 2 edition 2024 opaque types one I mentioned above and need to investigate
- things that are expected to work still do work: it bootstraps, can run our rustc-perf benchmarks (and the results are not even that bad), and a crater run didn't find any regressions (forgetting that crater currently fails to test around a quarter of all crates 👼)
- I've added tests with improvements, like the NLL problem case 3 and others, as well as some that behave the same as NLLs today and are thus worse than the datalog implementation

r? ````````@jackh726````````

(no rush I know you're deep in phd work and "implmentating" the new trait solver for r-a :p <3)

This also fixes rust-lang/rust#135646, a diagnostics ICE from the previous implementation.
2025-08-10 19:45:46 +10:00
bors
7f7b8ef27d Auto merge of #145144 - scottmcm:unsigned_overflow_intr, r=nikic
Stop using uadd.with.overflow

As discussed in [#t-compiler/llvm > &#96;uadd.with.overflow&#96; (again) @ 💬](https://rust-lang.zulipchat.com/#narrow/channel/187780-t-compiler.2Fllvm/topic/.60uadd.2Ewith.2Eoverflow.60.20.28again.29/near/533041085), stop emitting `uadd.with.overflow` in favour of `add`+`icmp` instead.

r? nikic
2025-08-10 09:24:56 +00:00
Jonathan Brouwer
b2b4bd41fa Start reporting future breakage for ILL_FORMED_ATTRIBUTE_INPUT in dependencies
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-08-10 10:48:08 +02:00
Michael Goulet
b4aa629186 Ignore coroutine witness type region args in auto trait confirmation 2025-08-10 02:21:48 +00:00
dianne
a70a312f17 suggest_borrow_generic_arg: use the correct generic args 2025-08-09 18:31:35 -07:00
bors
41ede7bd9b Auto merge of #145146 - fee1-dead-contrib:push-zmqrkurlzrxy, r=nnethercote
remove `P`

Previous work: rust-lang/rust#141603
MCP: https://github.com/rust-lang/compiler-team/issues/878

cc `@nnethercote`
2025-08-09 23:27:55 +00:00
Kivooeo
16765639b3 comments 2025-08-09 16:27:20 +05:00
bors
ca77504943 Auto merge of #145142 - Zalathar:rollup-oi6s8kg, r=Zalathar
Rollup of 23 pull requests

Successful merges:

 - rust-lang/rust#141658 (rustdoc search: prefer stable items in search results)
 - rust-lang/rust#141828 (Add diagnostic explaining STATUS_STACK_BUFFER_OVERRUN not only being used for stack buffer overruns if link.exe exits with that exit code)
 - rust-lang/rust#144823 (coverage: Extract HIR-related helper code out of the main module)
 - rust-lang/rust#144883 (Remove unneeded `drop_in_place` calls)
 - rust-lang/rust#144923 (Move several more float tests to floats/mod.rs)
 - rust-lang/rust#144988 (Add annotations to the graphviz region graph on region origins)
 - rust-lang/rust#145010 (Couple of minor abi handling cleanups)
 - rust-lang/rust#145017 (Explicitly disable vector feature on s390x baseline of bad-reg test)
 - rust-lang/rust#145027 (Optimize `char::is_alphanumeric`)
 - rust-lang/rust#145050 (add member constraints tests)
 - rust-lang/rust#145073 (update enzyme submodule to handle llvm 21)
 - rust-lang/rust#145080 (Escape diff strings in MIR dataflow graphviz)
 - rust-lang/rust#145082 (Fix some bad formatting in `-Zmacro-stats` output.)
 - rust-lang/rust#145083 (Fix cross-compilation of Cargo)
 - rust-lang/rust#145096 (Fix wasm target build with atomics feature)
 - rust-lang/rust#145097 (remove unnecessary `TypeFoldable` impls)
 - rust-lang/rust#145100 (Rank doc aliases lower than equivalently matched items)
 - rust-lang/rust#145103 (rustc_metadata: remove unused private trait impls)
 - rust-lang/rust#145115 (defer opaque type errors, generally greatly reduce tainting)
 - rust-lang/rust#145119 (rustc_public: fix missing parenthesis in pretty discriminant)
 - rust-lang/rust#145124 (Recover `for PAT = EXPR {}`)
 - rust-lang/rust#145132 (Refactor map_unit_fn lint)
 - rust-lang/rust#145134 (Reduce indirect assoc parent queries)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-08-09 08:57:23 +00:00
Deadbeef
ad1113f87e remove P 2025-08-09 15:47:01 +08:00
Connor Tsui
4b7e904fa4 add nonpoison::rwlock implementation
Adds the equivalent `nonpoison` types to the `poison::rwlock` module.
These types and implementations are gated under the `nonpoison_rwlock`
feature gate.

Also blesses the ui tests that now have a name conflicts (because these
types no longer have unique names). The full path distinguishes the
different types.
2025-08-09 08:41:26 +02:00
WANG Rui
0246245420 rustc_target: Add the 32s target feature for LoongArch 2025-08-09 13:54:09 +08:00
Scott McMurray
8831c5b994 Stop using uadd.with.overflow 2025-08-08 21:59:28 -07:00
Stuart Cook
aea608c751 Rollup merge of #145124 - compiler-errors:for-eq, r=lqd
Recover `for PAT = EXPR {}`

I type this constantly, and the existing suggestion to put `in` before the `=` is misleading.
2025-08-09 13:58:54 +10:00
Stuart Cook
a56142cbfb Rollup merge of #145119 - makai410:pretty-fix, r=compiler-errors
rustc_public: fix missing parenthesis in pretty discriminant
2025-08-09 13:58:54 +10:00
Stuart Cook
9d989bf1cf Rollup merge of #145115 - lcnr:less-borrowck-tainting, r=compiler-errors
defer opaque type errors, generally greatly reduce tainting

fixes the test for rust-lang/rust#135528, does not actually fix that issue properly.

This is useful as it causes the migration to rust-lang/rust#139587 to be a lot easier.
2025-08-09 13:58:53 +10:00
Stuart Cook
cd1e82ac72 Rollup merge of #145100 - GuillaumeGomez:rank-doc-alias-lower, r=lolbinarycat
Rank doc aliases lower than equivalently matched items

Follow-up of https://github.com/rust-lang/rust/pull/143988.

cc `@lolbinarycat`
2025-08-09 13:58:52 +10:00
Stuart Cook
d0ddeb5bfc Rollup merge of #145082 - nnethercote:macro-stats-fix-widths, r=petrochenkov
Fix some bad formatting in `-Zmacro-stats` output.

r? `@petrochenkov`
2025-08-09 13:58:49 +10:00
Stuart Cook
50ad4c8b44 Rollup merge of #145050 - lcnr:add-opaque-type-tests, r=lqd
add member constraints tests

taken from rust-lang/rust#139587.
2025-08-09 13:58:48 +10:00
Stuart Cook
aa7cb5396e Rollup merge of #145017 - pmur:murp/s390x-improve-asm-test, r=nnethercote
Explicitly disable vector feature on s390x baseline of bad-reg test

If the baseline s390x cpu is changed to a newer variant, such as z13, the vector feature may be enabled by default. When rust is packaged on fedora 38 and newer, it is set to z13.

Explicitly disable vector support on the baseline test for consistent results across s390x cpus.
2025-08-09 13:58:47 +10:00
Stuart Cook
e63e769c9b Rollup merge of #144883 - scottmcm:remove-unneeded-drop_in_place, r=nnethercote
Remove unneeded `drop_in_place` calls

Might as well pull this out from rust-lang/rust#144561 because this is still used in things like `Vec::truncate` where it'd be nice to allow it be removed if inlined enough to see that the type is `Copy`.

So long as perf says it's ok, at least 🤞
2025-08-09 13:58:44 +10:00
Stuart Cook
48f5929604 Rollup merge of #141658 - lolbinarycat:rustdoc-search-stability-rank-138067, r=GuillaumeGomez
rustdoc search: prefer stable items in search results

fixes https://github.com/rust-lang/rust/issues/138067

this does add a new field to the search index, but since we're only listing unstable items instead of adding a boolean flag to every item, it should only increase the search index size of sysroot crates, since those are the only ones using the `staged_api` feature, at least as far as the rust project is concerned.
2025-08-09 13:58:42 +10:00
bors
2de2456fb7 Auto merge of #143376 - dianne:guard-scope, r=matthewjasper
add a scope for `if let` guard temporaries and bindings

This fixes my concern with `if let` guard drop order, namely that the guard's bindings and temporaries were being dropped after their arm's pattern's bindings, instead of before (https://github.com/rust-lang/rust/pull/141295#issuecomment-2968975596). The guard's bindings and temporaries now live in a new scope, which extends until (but not past) the end of the arm, guaranteeing they're dropped before the arm's pattern's bindings.

This only introduces a new scope for match arms with guards. Perf results (https://github.com/rust-lang/rust/pull/143376#issuecomment-3034922617) seemed to indicate there wasn't a significant hit to introduce a new scope on all match arms, but guard patterns (rust-lang/rust#129967) will likely benefit from only adding new scopes when necessary (with some patterns requiring multiple nested scopes).

Tracking issue for `if_let_guard`: rust-lang/rust#51114

Tests are adapted from examples by `@traviscross,` `@est31,` and myself on rust-lang/rust#141295.
2025-08-09 03:19:26 +00:00
bors
4c7749e8c8 Auto merge of #145086 - jdonszelmann:revert-allow-internal-unsafe, r=Kobzol
Revert "Port `#[allow_internal_unsafe]` to the new attribute system"

This reverts commit 4f7a6ace9e (PR: https://github.com/rust-lang/rust/pull/144857)

r? `@Kobzol`
cc: `@scrabsha`

clean revert it seems :3
2025-08-09 00:04:35 +00:00
Guillaume Gomez
a34bd2baf5 Add regression test for doc alias matching vs equivalently matched items 2025-08-09 01:23:10 +02:00
Trevor Gross
d47f8ade58 Rollup merge of #144649 - estebank:issue-144602, r=lcnr
Account for bare tuples and `Pin` methods in field searching logic

When looking for the field names and types of a given type, account for tuples. This allows suggestions for incorrectly nested field accesses and field name typos to trigger as intended. Previously these suggestions only worked on `ty::Adt`, including tuple structs which are no different to tuples, so they should behave the same in suggestions.

When suggesting field access which would encounter a method not found, do not suggest pinning when those methods are on `impl Pin` itself.

```
error[E0599]: no method named `get_ref` found for tuple `(BufReader<File>,)` in the current scope
  --> $DIR/missing-field-access.rs:11:15
   |
LL |     let x = f.get_ref();
   |               ^^^^^^^ method not found in `(BufReader<File>,)`
   |
help: one of the expressions' fields has a method of the same name
   |
LL |     let x = f.0.get_ref();
   |               ++
```
instead of
```
error[E0599]: no method named `get_ref` found for tuple `(BufReader<File>,)` in the current scope
  --> $DIR/missing-field-access.rs:11:15
   |
LL |     let x = f.get_ref();
   |               ^^^^^^^ method not found in `(BufReader<File>,)`
   |
help: consider pinning the expression
   |
LL ~     let mut pinned = std::pin::pin!(f);
LL ~     let x = pinned.as_ref().get_ref();
   |
```

Fix rust-lang/rust#144602.
2025-08-08 14:22:46 -05:00
Trevor Gross
804d1a194e Rollup merge of #144579 - joshtriplett:mbe-attr, r=petrochenkov
Implement declarative (`macro_rules!`) attribute macros (RFC 3697)

This implements [RFC 3697](https://github.com/rust-lang/rust/issues/143547), "Declarative (`macro_rules!`) attribute macros".

I would suggest reading this commit-by-commit. This first introduces the
feature gate, then adds parsing for attribute rules (doing nothing with them),
then adds the ability to look up and apply `macro_rules!` attributes by path,
then adds support for local attributes, then adds a test, and finally makes
various improvements to errors.
2025-08-08 14:22:45 -05:00
Trevor Gross
18abf3aa44 Rollup merge of #144545 - ChayimFriedman2:bool-witness-order, r=Nadrieril
In rustc_pattern_analysis, put `true` witnesses before `false` witnesses

In rustc it doesn't really matter what the order of the witnesses is, but I'm planning to use the witnesses for implementing the "add missing match arms" assist in rust-analyzer, and there `true` before `false` is the natural order (like `Some` before `None`), and also what the current assist does.

The current order doesn't seem to be intentional; the code was created when bool ctors became their own thing, not just int ctors, but for integer, 0 before 1 is indeed the natural order.

r? `@Nadrieril`
2025-08-08 14:22:44 -05:00
Trevor Gross
6fa6a854cd Rollup merge of #144192 - RalfJung:atomicrmw-ptr, r=nikic
atomicrmw on pointers: move integer-pointer cast hacks into backend

Conceptually, we want to have atomic operations on pointers of the form `fn atomic_add(ptr: *mut T, offset: usize, ...)`. However, LLVM does not directly support such operations (https://github.com/llvm/llvm-project/issues/120837), so we have to cast the `offset` to a pointer somewhere.

This PR moves that hack into the LLVM backend, so that the standard library, intrinsic, and Miri all work with the conceptual operation we actually want. Hopefully, one day LLVM will gain a way to represent these operations without integer-pointer casts, and then the hack will disappear entirely.

Cc ```@nikic``` -- this is the best we can do right now, right?
Fixes https://github.com/rust-lang/rust/issues/134617
2025-08-08 14:22:44 -05:00
Trevor Gross
f5dda19775 Rollup merge of #144039 - estebank:short-paths, r=fee1-dead
Use `tcx.short_string()` in more diagnostics

`TyCtxt::short_string` ensures that user visible type paths aren't overwhelming on the terminal output, and properly saves the long name to disk as a side-channel. We already use these throughout the compiler and have been using them as needed when users find cases where the output is verbose. This is a proactive search of some cases to use `short_string`.

We add support for shortening the path of "trait path only".

Every manual use of `short_string` is a bright marker that that error should be using structured diagnostics instead (as they have proper handling of long types without the maintainer having to think abou tthem).
2025-08-08 14:22:43 -05:00
Michael Goulet
560e5dcbcf Add test for upvar breakage 2025-08-08 18:53:18 +00:00
Michael Goulet
d47150111d Check coroutine upvars and in dtorck constraint 2025-08-08 18:53:18 +00:00
Michael Goulet
b2d524c43d Recover for PAT = EXPR {} 2025-08-08 18:46:09 +00:00
Josh Triplett
f88839d2ab mbe: Add a test checking for infinite recursion in macro attributes 2025-08-08 11:01:12 -07:00
Josh Triplett
489734cd08 mbe: Add a test confirming that a macro attribute can apply itself recursively
This allows a macro attribute to implement default arguments by
reapplying itself with the defaults filled in, for instance.
2025-08-08 11:01:12 -07:00
Josh Triplett
9a9ccc0edb mbe: Add parser test for macro attribute recovery 2025-08-08 11:01:12 -07:00
Josh Triplett
1500195799 mbe: Add a test for calling a macro with no function-like rules 2025-08-08 11:01:12 -07:00
Josh Triplett
bd5206ee18 mbe: Add test for attribute expansion with compile_error! 2025-08-08 11:01:12 -07:00
Josh Triplett
4f999f72de mbe: Add test for macro_rules attributes
Test macros via path and local macros.
2025-08-08 11:01:12 -07:00
Josh Triplett
f0a5e70507 mbe: Fix error message for using a macro with no attr rules as an attribute
Avoid saying "a declarative macro cannot be used as an attribute macro";
instead, say that the macro has no `attr` rules.
2025-08-08 11:01:12 -07:00
Josh Triplett
bad0d45b2d mbe: Parse macro attribute rules
This handles various kinds of errors, but does not allow applying the
attributes yet.

This adds the feature gate `macro_attr`.
2025-08-08 11:00:54 -07:00
Makai
c44fe70d03 fix missing parenthesis in pretty discriminant 2025-08-09 01:35:50 +08:00
Josh Triplett
2054a0c56b mbe: In error messages, don't assume attributes are always proc macros
Now that `macro_rules` macros can define attribute rules, make sure
error messages account for that.
2025-08-08 10:35:47 -07:00
lcnr
4eee55691a borrowck: defer opaque type errors 2025-08-08 19:24:53 +02:00
Daniel Paoliello
dcc1605fba [win][arm64ec] Partial fix for raw-dylib-link-ordinal on Arm64EC 2025-08-08 09:17:35 -07:00
Rémy Rakic
b99fe2b720 mark polonius=next's NLL imprecisions as known-bugs
- linked-list cursor-like patterns
- issue-46589

These are known-bugs for the polonius alpha, where they show the same
imprecision as NLLs, but are supported by the old datalog
implementation.
2025-08-08 15:15:09 +00:00