Commit Graph

46605 Commits

Author SHA1 Message Date
Matthias Krüger
cc0ee34b43
Rollup merge of #141285 - compiler-errors:tick, r=lcnr
Add tick to `RePlaceholder` debug output

Present when debug printing canonical queries

r? lcnr
2025-05-20 16:50:43 +02:00
Matthias Krüger
3b9ccbbaf1
Rollup merge of #141279 - nnethercote:lower_to_hir, r=compiler-errors
`lower_to_hir` cleanups

Some minor cleanups I made when reading this code.

r? `@Nadrieril`
2025-05-20 16:50:42 +02:00
Matthias Krüger
ac500add80
Rollup merge of #141275 - dianne:gather-guard-pat-locals-once, r=compiler-errors
`gather_locals`: only visit guard pattern guards when checking the guard

When checking a pattern with guards in it, `GatherLocalsVisitor` will visit both the pattern (when type-checking the let, arm, or param containing it) and local declarations in the guard expression (when checking the guard itself). This keeps it from visiting the guard when visiting the pattern, since otherwise it would gather locals from the guard twice, which would lead to a delayed bug: "evaluated expression more than once".

Tracking issue for guard patterns: #129967
2025-05-20 16:50:41 +02:00
Matthias Krüger
5364668fb5
Rollup merge of #141253 - azhogin:azhogin/async-drop-feature-inconsistency-warning, r=oli-obk
Warning added when dependency crate has async drop types, and the feature is disabled

In continue of https://github.com/rust-lang/rust/pull/141031.

When dependency crate has non-empty `adt_async_destructor` table in metadata, and `async_drop` feature is disabled for local crate, warning will be emitted.

Test `dependency-dropped` has two revisions - with and without feature enabled. With feature enabled, async drop for dropee is executed ("Async drop" printed). Without the feature enabled, sync drop is executed ("Sync drop" printed) and warning is emitted.

Warning example:
```
warning: found async drop types in dependecy `async_drop_dep`, but async_drop feature is disabled for `dependency_dropped`
  --> $DIR/dependency-dropped.rs:7:1
   |
LL | #![cfg_attr(with_feature, feature(async_drop))]
   | ^
   |
   = help: if async drop type will be dropped in a crate without `feature(async_drop)`, sync Drop will be used
```
2025-05-20 16:50:40 +02:00
Matthias Krüger
42ed69c756
Rollup merge of #141236 - jagunter:issue-140823, r=compiler-errors
Resolved issue with mismatched types triggering ICE in certain scenarios

## Background

The function `annotate_mut_binding_to_immutable_binding` called in `emit_coerce_suggestions` performs a type comparison between the `expected` and `found` types from `ExpectedFound` in the `TypeError`. This can fail if the `found` type contains a region variable that's been rolled back.

## What is being changed?

This updates `annotate_mut_binding_to_immutable_binding` to use `expr_ty` and `expected` from the parent function instead of the types from the `TypeError`. This sidesteps the issue of using `found` from `TypeError` which may leak lingering inference region variables.

This does change the diagnostic behavior to _only_ support cases where the expected outermost type is `&T`, but that seems to be the intended functionality.

Also fixed the example in the `annotate_mut_binding_to_immutable_binding` rustdocs.

r? rust-lang/types

Fixes #140823
2025-05-20 16:50:39 +02:00
Michael Goulet
1d8db54f76 Add tick to RePlaceholder debug output 2025-05-20 10:30:07 +00:00
Michael Goulet
47b9e373cb Revert "Fix stack overflow in exhaustiveness due to recursive HIR opaque type values"
This reverts commit b08e9c2a60.
2025-05-20 10:09:01 +00:00
Michael Goulet
7e7c2c3947 Just error on recursive opaque ty in HIR typeck 2025-05-20 10:08:56 +00:00
dianne
c343b2a47c gather_locals: only visit guard pattern guards when checking the guard
When checking a pattern with guards in it, `GatherLocalsVisitor` will
visit both the pattern (when type-checking the let, arm, or param
containing it) and the guard expression (when checking the guard
itself). This keeps it from visiting the guard when visiting the
pattern, since otherwise it would gather locals from the guard twice,
which would lead to a delayed bug: "evaluated expression more than
once".
2025-05-19 23:18:08 -07:00
Nicholas Nethercote
8a927e63ff Inline and remove lower_* methods.
They are all short and have a single call site.
2025-05-20 14:13:33 +10:00
Nicholas Nethercote
7c62e78cf9 Hoist ItemLowerer out of a loop. 2025-05-20 14:04:24 +10:00
Nicholas Nethercote
0c0b2cbcb5 Remove unused return value from lower_node. 2025-05-20 14:01:58 +10:00
Stuart Cook
6461160e8d
Rollup merge of #141261 - RalfJung:current_dll_path, r=Noratrieb
current_dll_path: fix mistake in assertion message

Follow-up to https://github.com/rust-lang/rust/pull/141239
r? `@Noratrieb`
2025-05-20 12:53:15 +10:00
Andrew Zhogin
4a99cbbf6b Warning when dependency crate has async drop types, and the feature is disabled - typo fixed 2025-05-20 04:36:33 +07:00
Ralf Jung
c99c4b17b2 current_dll_path: fix mistake in assertion message 2025-05-19 20:20:54 +02:00
Josh Gunter
db1ac98081
Fixed possible ICE in annotate_mut_binding_to_immutable_binding 2025-05-19 10:16:29 -07:00
bors
59372f2c81 Auto merge of #141255 - matthiaskrgr:rollup-ravsgen, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #131200 (Handle `rustc_query_system` cases of `rustc::potential_query_instability` lint)
 - #141244 (windows: document that we rely on an undocumented property of GetUserProfileDirectoryW)
 - #141247 (skip compiler tools sanity checks on certain commands)
 - #141248 (fix data race in ReentrantLock fallback for targets without 64bit atomics)
 - #141249 (introduce common macro for `MutVisitor` and `Visitor` to dedup code)
 - #141253 (Warning added when dependency crate has async drop types, and the feature is disabled)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-05-19 16:15:35 +00:00
Matthias Krüger
e95315d37a
Rollup merge of #141253 - azhogin:azhogin/async-drop-feature-inconsistency-warning, r=oli-obk
Warning added when dependency crate has async drop types, and the feature is disabled

In continue of https://github.com/rust-lang/rust/pull/141031.

When dependency crate has non-empty `adt_async_destructor` table in metadata, and `async_drop` feature is disabled for local crate, warning will be emitted.

Test `dependency-dropped` has two revisions - with and without feature enabled. With feature enabled, async drop for dropee is executed ("Async drop" printed). Without the feature enabled, sync drop is executed ("Sync drop" printed) and warning is emitted.

Warning example:
```
warning: found async drop types in dependecy `async_drop_dep`, but async_drop feature is disabled for `dependency_dropped`
  --> $DIR/dependency-dropped.rs:7:1
   |
LL | #![cfg_attr(with_feature, feature(async_drop))]
   | ^
   |
   = help: if async drop type will be dropped in a crate without `feature(async_drop)`, sync Drop will be used
```
2025-05-19 18:08:43 +02:00
Matthias Krüger
421230fce7
Rollup merge of #141249 - fee1-dead-contrib:push-mwxxsvrsotvs, r=oli-obk
introduce common macro for `MutVisitor` and `Visitor` to dedup code

helps with #127615.

I can do everything in one go but I figured it might be worth it to open a PR first for vibeck.

r? oli-obk
2025-05-19 18:08:43 +02:00
Matthias Krüger
8f13cbf1a5
Rollup merge of #131200 - ismailarilik:handle-potential-query-instability-lint-for-rustc-query_system, r=fee1-dead
Handle `rustc_query_system` cases of `rustc::potential_query_instability` lint

This PR removes `#![allow(rustc::potential_query_instability)]` line from [`compiler/rustc_query_system/src/lib.rs`](https://github.com/rust-lang/rust/blob/master/compiler/rustc_query_system/src/lib.rs#L2) and converts `FxHash{Map,Set}` types into `FxIndex{Map,Set}` to suppress lint errors.

A somewhat tracking issue: https://github.com/rust-lang/rust/issues/84447

r? `@compiler-errors`
2025-05-19 18:08:41 +02:00
Andrew Zhogin
61059282eb Warning added when dependency crate has async drop types, and the feature is disabled 2025-05-19 21:38:07 +07:00
Deadbeef
c5bab6e9aa introduce common macro for MutVisitor and Visitor to dedup code 2025-05-19 21:21:03 +08:00
Stuart Cook
b86de538ce
Rollup merge of #141239 - RalfJung:dladdr-fname, r=Noratrieb
dladdr cannot leave dli_fname to be null

There are two places in the repo calling `dladdr`, and they are inconsistent wrt their assumption of whether the `dli_fname` field can be null. Let's make them consistent. I see nothing in the docs that allows it to be null, but just to be on the safe side let's make this an assertion so hopefully we get a report if that ever happens.
2025-05-19 21:10:44 +10:00
Stuart Cook
3b22c21dd8
Rollup merge of #140847 - Zalathar:unused-local-file, r=SparrowLii
coverage: Detect unused local file IDs to avoid an LLVM assertion

Each function's coverage metadata contains a *local file table* that maps local file IDs (used by the function's mapping regions) to global file IDs (shared by all functions in the same CGU).

LLVM requires all local file IDs to have at least one mapping region, and has an assertion that will fail if it detects a local file ID with no regions. To make sure that assertion doesn't fire, we need to detect and skip functions whose metadata would trigger it.

(This can't actually happen yet, because currently all of a function's spans must belong to the same file and expansion. But this will be an important edge case when adding expansion region support.)
2025-05-19 21:10:42 +10:00
Ralf Jung
d22f53b970 dladdr cannot leave dli_fname to be null 2025-05-19 08:27:54 +02:00
Stuart Cook
599b08ada8
Rollup merge of #140874 - mejrs:rads, r=WaffleLapkin
make `rustc_attr_parsing` less dominant in the rustc crate graph

It has/had a glob re-export of `rustc_attr_data_structures`, which is a crate much lower in the graph, and a lot of crates were using it *just* (or *mostly*) for that re-export, while they can rely on `rustc_attr_data_structures` directly.

Previous graph:
![graph_1](https://github.com/user-attachments/assets/f4a5f13c-4222-4903-b56d-28c83511fcbd)

Graph with this PR:
![graph_2](https://github.com/user-attachments/assets/1e053d9c-75cc-402b-84df-86229c98277a)

The first commit keeps the re-export, and just changes the dependency if possible. The second commit is the "breaking change" which removes the re-export, and "explicitly" adds the `rustc_attr_data_structures` dependency where needed. It also switches over some src/tools/*.

The second commit is actually a lot more involved than I expected. Please let me know if it's a better idea to back it out and just keep the first commit.
2025-05-19 13:24:54 +10:00
Stuart Cook
0513e3b463
Rollup merge of #140049 - haenoe:fix-autodiff-generics, r=ZuseZ4
fix autodiff macro on generic functions

heloo there!
This short PR allows applying the `autodiff` macro to generic functions like this one.
It only touches the frontend part, since the `rustc_autodiff` macro can already handle generics.
```rust
#[autodiff(d_square, Reverse, Duplicated, Active)]
fn square<T: std::ops::Mul<Output = T> + Copy>(x: &T) -> T {
    *x * *x
}
```
Thanks to Manuel for creating an issue on this. For more information on this see #140032
r? `@ZuseZ4`

As always: thanks for any piece of feedback!!

Fixes: #140032
Tracking issue for autodiff: https://github.com/rust-lang/rust/issues/124509
2025-05-19 13:24:53 +10:00
bors
e42bbfe1f7 Auto merge of #140154 - Berrysoft:cygwin-host, r=jieyouxu
Cygwin support in rustc

This PR builds host rustc targeting cygwin.

- [x] https://github.com/rust-lang/stacker/pull/122
- [x] https://github.com/nagisa/rust_libloading/pull/173
- [x] https://github.com/Detegr/rust-ctrlc/pull/131
- [x] https://github.com/rust-random/getrandom/pull/654
- [x] https://github.com/msys2/MSYS2-packages/issues/5350
- [x] https://github.com/rust-lang/rust/pull/140886
- [x] https://github.com/rust-lang/rust/pull/140921
- [x] https://github.com/rust-lang/rust/pull/140973

Currently supported:
* rustc
* rustdoc
* rustfmt
* clippy

Blocking:
* cargo: blocked by https://github.com/rust-lang/socket2/pull/568
* rust-analyzer: needs `cargo update`, fixed upstream

```
$ rustc --version --verbose
rustc 1.88.0-dev
binary: rustc
commit-hash: unknown
commit-date: unknown
host: x86_64-pc-cygwin
release: 1.88.0-dev
LLVM version: 20.1.4
```
2025-05-18 23:53:04 +00:00
León Orell Valerian Liehr
50b20b73da
Rollup merge of #141218 - dianqk:gvn-overlapping, r=oli-obk
gvn: avoid creating overlapping assignments

Quick fix #141038, as I couldn't find a way to avoid in-place modification. I'm considering handling all `ravlue` modifications within the `visit_statement` function.

r? mir-opt
2025-05-18 18:44:14 +02:00
León Orell Valerian Liehr
20bd5977ed
Rollup merge of #141127 - klensy:windows-bump-61, r=albertlarsan68,jieyouxu
bump windows crate for compiler,bootstrap and tools

This dedupes crate versions. For `x86_64-pc-windows-msvc` stage1 cuts few kb from `rustc_driver.dll`, nice.
2025-05-18 18:44:13 +02:00
León Orell Valerian Liehr
3af0c43f06
Rollup merge of #140926 - azhogin:azhogin/async-drop-coroutine-layout-returns-layout-error, r=oli-obk
Return value of coroutine_layout fn changed to Result with LayoutError

Continue of https://github.com/rust-lang/rust/pull/140902:
`coroutine_layout` fn is now returns `Result` with `LayoutError` to have consistent error with `layout_of_uncached`.
`async_drop_coroutine_layout` fn is now return `LayoutError::TooGeneric` in case of not-fully-specialized `async_drop_in_place<T>::{closure}` coroutine.
2025-05-18 18:44:12 +02:00
León Orell Valerian Liehr
4e5b1aa055
Rollup merge of #140746 - dianne:guard-pat-res, r=oli-obk
name resolution for guard patterns

This PR provides an initial implementation of name resolution for guard patterns [(RFC 3637)](https://github.com/rust-lang/rfcs/blob/master/text/3637-guard-patterns.md). This does not change the requirement that the bindings on either side of an or-pattern must be the same [(proposal here)](https://github.com/rust-lang/rfcs/blob/master/text/3637-guard-patterns.md#allowing-mismatching-bindings-when-possible); the code that handles that is separate from what this PR touches, so I'm saving it for a follow-up.

On a technical level, this separates "collecting the bindings in a pattern" (which was already done for or-patterns) from "introducing those bindings into scope". I believe the approach used here can be extended straightforwardly in the future to work with `if let` guard patterns, but I haven't tried it myself since we don't allow those yet.

Tracking issue for guard patterns: #129967

cc ``@Nadrieril``
2025-05-18 18:44:11 +02:00
León Orell Valerian Liehr
2f0c6e217f
Rollup merge of #140490 - folkertdev:asm-parser-changes, r=Amanieu,traviscross
split `asm!` parsing and validation

This PR splits `asm!` parsing and validation into two separate steps.

The parser constructs a `Vec<RawAsmArg>`, with each element corresponding to an argument to one of the `asm!` macros.
The validation then checks things like ordering of arguments or that options are not provided twice.

The motivation is https://github.com/rust-lang/rust/issues/140279, which wants to add `#[cfg(...)]` support to these arguments. This support can now be added in a straightforward way by adding an `attributes: ast::AttrVec` field to `RawAsmArg`.

An extra reason for this split is that `rustfmt` probably wants to format the assembly at some point (currently that appears to be stubbed out, and the formatting is unstable https://github.com/rust-lang/style-team/issues/152).

r? ``@ghost`` (just want to look at CI for now)

cc ``@ytmimi`` we discussed asm formatting a little while ago in https://github.com/rust-lang/rustfmt/issues/6526. Am I correct in assuming that `AsmArgs` does not give enough information for formatting, but that `RawAsmArgs` would (it e.g. does not join information from multiple lines). This must have been an issue before?

try-job: aarch64-apple
2025-05-18 18:44:10 +02:00
León Orell Valerian Liehr
2f6811eff8
Rollup merge of #138940 - sayantn:stabilize-avx512, r=Amanieu,traviscross
Stabilize the avx512 target features

This PR stabilizes the AVX512 target features - see [this comment](https://github.com/rust-lang/rust/issues/111137#issuecomment-2745821279).

Tracking Issue - #44839

The target feature UI tests have been changed to `x87` (chosen because this is very unlikely to stablize ever, please comment if some other feature will be better)

related: #111137
2025-05-18 18:44:10 +02:00
mejrs
178e09ed37 Remove rustc_attr_data_structures re-export from rustc_attr_parsing 2025-05-18 18:14:43 +02:00
bors
b53e5c9db0 Auto merge of #141216 - fmease:rollup-pa5mvx3, r=fmease
Rollup of 8 pull requests

Successful merges:

 - #140113 (Add per page TOC in the `rustc` book)
 - #140511 (Stabilize `#![feature(non_null_from_ref)]`)
 - #140924 (Make some `f32`/`f64` tests also run in const-context)
 - #140966 (Remove #![feature(let_chains)] from library and src/librustdoc)
 - #141045 ([win][arm64] Remove 'Arm64 Hazard' undocumented MSVC option and instead disable problematic test)
 - #141071 (Enable [behind-upstream] triagebot option for rust-lang/rust)
 - #141132 (Use `crate::` prefix for root macro suggestions)
 - #141139 (Fix Rust for Linux ping group label)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-05-18 12:05:55 +00:00
dianne
f0b8ec1d71 name resolution for guard patterns 2025-05-18 04:21:57 -07:00
dianqk
d2e5a3d131
gvn: avoid creating overlapping assignments 2025-05-18 18:42:00 +08:00
Folkert de Vries
26e3a5041a
add AsmOptions with some named fields 2025-05-18 11:28:31 +02:00
Folkert de Vries
85053d1cd1
rename to get rid of the 'raw' concept 2025-05-18 11:28:31 +02:00
Folkert de Vries
e12d675739
delay error for unsupported options 2025-05-18 11:28:31 +02:00
Folkert de Vries
7ec06fc3b1
attempt to have rustfmt use the new logic
apparently it doesn't really use the asm parsing at present, so this may work?
2025-05-18 11:28:31 +02:00
Folkert de Vries
de8e305ba8
a new parser generating the exact same error messages
Co-authored-by: Travis Cross <tc@traviscross.com>
2025-05-18 11:28:19 +02:00
León Orell Valerian Liehr
b89118aed8
Rollup merge of #141132 - bvanjoi:issue-141082, r=fmease
Use `crate::` prefix for root macro suggestions

Fixes #141082

I've changed the prefix to `crate` directly, since it's compatible across all editions.
2025-05-18 11:03:47 +02:00
León Orell Valerian Liehr
e323c64fa4
Rollup merge of #141045 - dpaoliello:noarmhazard, r=jieyouxu
[win][arm64] Remove 'Arm64 Hazard' undocumented MSVC option and instead disable problematic test

PR #140758 added the undocumented `/arm64hazardfree` MSVC linker flag to work around a test failure where LLVM generated code that would trip a hazard in an outdated ARM processor.

Adding this flag caused issues with LLD, as it doesn't recognize it.

Rethinking the issue, using the undocumented flag seems like the incorrect solution: there's no guarantee that the flag won't be removed in the future, or change its meaning.

Instead, I've disabled the problematic test for Arm64 Windows and have filed a bug with the MSVC team to have the check removed: <https://developercommunity.microsoft.com/t/Remove-checking-for-and-fixing-Cortex-A/10905134>

This PR supersedes #140977

r? ```@jieyouxu```
2025-05-18 11:03:46 +02:00
León Orell Valerian Liehr
eb21b252c6
Rollup merge of #140966 - est31:let_chains_library, r=tgross35
Remove #![feature(let_chains)] from library and src/librustdoc

PR https://github.com/rust-lang/rust/pull/132833 has stabilized the `let_chains` feature. This PR removes the last occurences from the library, the compiler, and librustdoc (also because #140887 missed the conditional in one of the crates as it was behind the "rustc" feature).

We keep `core` as exercise for the future as updating it is non-trivial (see PR thread).
2025-05-18 11:03:45 +02:00
bors
7205fc537d Auto merge of #141129 - compiler-errors:register-region-obl, r=oli-obk
Fast path for `register_region_obligation`

If a type has no params, infer, placeholder, or non-`'static` free regions, then we can skip registering outlives obligations since the type has no components which affect lifetime checking in an interesting way.
2025-05-18 08:56:48 +00:00
sayantn
cf7caded0b
Stabilize avx512_target_feature 2025-05-18 11:12:15 +05:30
bors
ac17c3486c Auto merge of #141039 - lqd:expensive-sanity, r=compiler-errors
move expensive layout sanity check to debug assertions

It is [hard to fix](https://github.com/rust-lang/rust/issues/141006#issuecomment-2883415000) the slowness in the uninhabitedness computation for very big types but we can fix the very specific case of them being called during the layout sanity checks, as described in #140944.

So this PR moves this uninhabitedness check to the other expensive layout sanity checks that are ran under `debug_assertions`.

It makes building the `lemmy_api_routes` crate's self-profile `layout_of` query go from

```
+--------------------------------------------------------+-----------+-----------------+----------+------------+---------------------------------+
| Item                                                   | Self time | % of total time | Time     | Item count | Incremental result hashing time |
+--------------------------------------------------------+-----------+-----------------+----------+------------+---------------------------------+
| layout_of                                              | 63.02s    | 41.895          | 244.26s  | 123703     | 50.30ms                         |
+--------------------------------------------------------+-----------+-----------------+----------+------------+---------------------------------+
```

on master (2m17s total), to

```
| layout_of                                              | 330.21ms  | 0.372           | 26.90s   | 123703     | 53.19ms                         |
```

with this PR (1m15s total).

(Note that the [perf run results](https://github.com/rust-lang/rust/pull/141039#issuecomment-2884688756) below look a bit better than [an earlier run](https://perf.rust-lang.org/compare.html?start=4eca99a18eab3d4e28ed1ce3ee620d442955a470&end=c4a00993f8ee02c7565e7be652608817ea2fb97d&stat=instructions:u) I did in another PR. There may be some positive noise there, or post-merge results could differ a bit)

Since we discussed this today, r? `@compiler-errors` — and cc `@lcnr` and `@RalfJung.`
2025-05-18 01:30:48 +00:00
bors
16244bc37a Auto merge of #140856 - oli-obk:merge-queries2, r=nnethercote
Merge mir query analysis invocations

r? `@ghost`

same thing as https://github.com/rust-lang/rust/pull/140854 just a different set of queries

Doing this in general has some bad cache coherence issues because the query caches are laid out in Vec<QueryResult> lists per query where each index refers to a DefId in the same order as we're iterating. Iterating two or more lists at the same time does have cache issues, so I want to poke a bit at it to see if we can't merge just a few of them at a time.
2025-05-17 22:31:43 +00:00