303456 Commits

Author SHA1 Message Date
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 4f7a6ace9e2f2192af7b5d32f4b1664189e0e143 (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
339be84d9d Use new public libtest ERROR_EXIT_CODE constant in rustdoc 2025-08-09 01:31:23 +02:00
Guillaume Gomez
a34bd2baf5 Add regression test for doc alias matching vs equivalently matched items 2025-08-09 01:23:10 +02:00
Guillaume Gomez
b39357bbf3 Rank doc aliases lower than equivalently matched items 2025-08-09 01:23:10 +02:00
Cameron Steffen
eec8585f65 Reduce indirect assoc parent queries 2025-08-08 17:28:19 -05:00
bors
ffb9d94dcf Auto merge of #145126 - tgross35:rollup-6w87usd, r=tgross35
Rollup of 8 pull requests

Successful merges:

 - rust-lang/rust#139451 (Add `target_env = "macabi"` and `target_env = "sim"`)
 - rust-lang/rust#144039 (Use `tcx.short_string()` in more diagnostics)
 - rust-lang/rust#144192 (atomicrmw on pointers: move integer-pointer cast hacks into backend)
 - rust-lang/rust#144545 (In rustc_pattern_analysis, put `true` witnesses before `false` witnesses)
 - rust-lang/rust#144579 (Implement declarative (`macro_rules!`) attribute macros (RFC 3697))
 - rust-lang/rust#144649 (Account for bare tuples and `Pin` methods in field searching logic)
 - rust-lang/rust#144775 (more strongly dissuade use of `skip_binder`)
 - rust-lang/rust#144987 (Enable f16 and f128 on targets that were fixed in LLVM21)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-08-08 20:53:33 +00:00
Cameron Steffen
7670cdeb70 Refactor map_unit_fn lint 2025-08-08 15:01:01 -05:00
Trevor Gross
660bf919dc
Rollup merge of #144987 - tgross35:llvm21-f16-f128, r=nikic
Enable f16 and f128 on targets that were fixed in LLVM21

LLVM21 fixed the new float types on a number of targets:

* SystemZ gained f16 support  https://github.com/llvm/llvm-project/pull/109164
* Hexagon now uses soft f16 to avoid recursion bugs  https://github.com/llvm/llvm-project/pull/130977
* Mips now correctly handles f128 (actually since LLVM20) https://github.com/llvm/llvm-project/pull/117525
* f128 is now correctly aligned when passing the stack on x86  https://github.com/llvm/llvm-project/pull/138092

Thus, enable the types on relevant targets for LLVM > 21.0.0.

NVPTX also gained handling of f128 as a storage type, but it lacks support for basic math operations so is still disabled here.

try-job: dist-i586-gnu-i586-i686-musl
try-job: dist-i686-linux
try-job: dist-i686-msvc
try-job: dist-s390x-linux
try-job: dist-various-1
try-job: dist-various-2
try-job: dist-x86_64-linux
try-job: i686-gnu-1
try-job: i686-gnu-2
try-job: i686-msvc-1
try-job: i686-msvc-2
try-job: test-various
2025-08-08 14:22:47 -05:00
Trevor Gross
063e01b957
Rollup merge of #144775 - lcnr:skip_binder-comment, r=BoxyUwU
more strongly dissuade use of `skip_binder`

People unfortunately encounter `Binder` and `EarlyBinder` very early on when starting out. In these cases its often very easy to use `skip_binder` incorrectly. This makes it more explicit that it should generally not be used and points to the relevant `rustc-dev-guide` chapters.

r? `@BoxyUwU`
2025-08-08 14:22:47 -05: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
Trevor Gross
6674fe282b
Rollup merge of #139451 - madsmtm:apple-target-env-abi, r=wesleywiser
Add `target_env = "macabi"` and `target_env = "sim"`

[RFC 2992](https://github.com/rust-lang/rfcs/pull/2992) ([tracking issue](https://github.com/rust-lang/rust/issues/80970)) introduced `cfg(target_abi = ...)` with the original motivation being Mac Catalyst and Apple Simulator targets. These do not actually have a changed calling convention in the same sense that e.g. `cfg(target_abi = "eabihf")` or pointer authentication (`arm64e`) does, see https://github.com/rust-lang/rust/issues/133331.

Specifically, for Apple Simulator targets, the binary runs under the following conditions:
- Runs with the host macOS kernel (but in a mode configured for iOS/tvOS/...).
- Uses frameworks for the specific simulator version being targetted.
- System file accesses need to be made relative to the `IPHONE_SIMULATOR_ROOT` environment variable.
- Uses host GPUs directly.

And for Mac Catalyst:
- Runs with the host macOS kernel (but in a mode configured for iOS).
- Uses mostly host macOS frameworks (though with a few things changed, e.g. the [`NSImageResizingModeStretch`](https://developer.apple.com/documentation/appkit/nsimage/resizingmode-swift.enum/stretch?language=objc) enum has a different value).
- Uses host GPUs, camera and other peripherals directly.

As can be seen, these seem better suited as `target_env`s, since it really is the environment that the binary is running under that's changed (regardless of the Mac Catalyst "macabi" having "abi" in the name). So this PR adds `target_env = "sim"` and `target_env = "macabi"`, with the idea of possibly deprecating `target_abi = "sim"` and `target_abi = "macabi"` in the far future.

This affects iOS Tier 2 targets (`aarch64-apple-ios-sim`, `x86_64-apple-ios`, `aarch64-apple-ios-macabi` and `x86_64-apple-ios-macabi`), and probably needs a compiler FCP.

Fixes https://github.com/rust-lang/rust/issues/133331.
Reference PR: https://github.com/rust-lang/reference/pull/1781.
Cargo doc PR: https://github.com/rust-lang/cargo/pull/15404.

r? compiler
CC `@workingjubilee`
CC target maintainers `@deg4uss3r` `@thomcc` `@badboy` `@BlackHoleFox` `@madsmtm` `@agg23`
2025-08-08 14:22:42 -05:00
Daniel Paoliello
87a09b2ad5 [win][arm64ec] Add '/machine:arm64ec' when linking LLVM as Arm64EC 2025-08-08 12:21:57 -07:00
Aleksey Kliger
cba591871d bootstrap: x.py dist rustc-src should keep LLVM's siphash 2025-08-08 15:12:27 -04: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
549c2fee9f mbe: Handle local macro_rules attr resolution
Teach the resolver to consider `macro_rules` macros when looking for a
local attribute. When looking for an attribute and considering a
`macro_rules` macro, load the macro in order to see if it has attribute
rules.

Include a FIXME about tracking multiple macro kinds for a Def instead.
2025-08-08 11:01:12 -07:00
Josh Triplett
34be8abb70 mbe: Handle applying attribute rules with paths
Add infrastructure to apply an attribute macro given argument tokens and
body tokens.

Teach the resolver to consider `macro_rules` macros when looking for an
attribute via a path.

This does not yet handle local `macro_rules` attributes.
2025-08-08 11:01:12 -07:00
Josh Triplett
0cc0b11cce mbe: Emit an error if a macro call has no function-like rules
Add a FIXME for moving this error earlier.
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
bit-aloo
111a0e8f23
add parse_download_ci_llvm function and invoke from parse_inner 2025-08-08 23:21:57 +05:30
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
bors
de3efa79f9 Auto merge of #145116 - Kobzol:revert-143906, r=lqd
Revert #143906

This reverts commit 71f04692c32e181ab566c01942f1418dec8662d4, reversing changes made to 995ca3e532b48b689567533e6b736675e38b741e.

Reverts https://github.com/rust-lang/rust/pull/143906, which was merged in https://github.com/rust-lang/rust/pull/145043.

It seems like it is causing test failures on CI that block merges (https://github.com/rust-lang/rust/pull/144787#issuecomment-3168738836.

try-job: x86_64-gnu-aux
2025-08-08 17:32:52 +00:00
lcnr
4eee55691a borrowck: defer opaque type errors 2025-08-08 19:24:53 +02:00
Jakub Beránek
8fcfbcd868
Revert "Rollup merge of #143906 - LorrensP-2158466:miri-float-nondet-foreign-items, r=RalfJung"
This reverts commit 71f04692c32e181ab566c01942f1418dec8662d4, reversing
changes made to 995ca3e532b48b689567533e6b736675e38b741e.
2025-08-08 19:16:48 +02:00
lcnr
8b95291cd4 borrowck: move error tainting earlier 2025-08-08 19:16:03 +02:00
bit-aloo
b4675dcac8
add download_ci_rustc_commit function and invoke from parse_inner 2025-08-08 22:44:48 +05:30
binarycat
fdbc8d08a6 rustdoc search: add performance note about searchIndexUnstable check 2025-08-08 11:55:00 -05:00
binarycat
5e8ebd5ecd rustdoc: IndexItem::{stability -> is_unstable} 2025-08-08 11:40:03 -05:00
Daniel Paoliello
dcc1605fba [win][arm64ec] Partial fix for raw-dylib-link-ordinal on Arm64EC 2025-08-08 09:17:35 -07:00
binarycat
7af87d18d2 editorconfig: don't trim trailing whitespace in tests 2025-08-08 11:15:28 -05:00
Deadbeef
57dc64ea32 remove some unused private trait impls 2025-08-09 00:02:11 +08:00
Deadbeef
dbc6f5836c rustc_metadata: remove unused private trait impls 2025-08-08 23:19:09 +08: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
Rémy Rakic
9badbdf5f9 add cursor-like example that works
This is an example similar to the linked-list cursor examples
where the alpha shows the same imprecision as NLLs, but that can work due to
the loans not being live after the loop, or the constraint graph being
simple enough that the cfg/subset relationships are the same for
reachability and liveness.
2025-08-08 15:14:51 +00:00
Rémy Rakic
48ebae9cef add NLL-like imprecision example
This test showcases the same imprecision as NLLs, unlike the datalog
implementation, when using reachability as a liveness approximation.
2025-08-08 15:14:51 +00:00
Rémy Rakic
b172980d5c add some test cases for overlapping yielded items
These are just some sanity checks to ensure NLLs, the polonius alpha
analysis, and the datalog implementation behave the same on these common
examples.
2025-08-08 15:14:51 +00:00
Rémy Rakic
d4bbd681bb turn expensive assert into debug assertion 2025-08-08 15:14:51 +00:00