Commit Graph

47859 Commits

Author SHA1 Message Date
Trevor Gross
999967a57d Rename cfg_match! to cfg_select!
At [1] it was pointed out that `cfg_match!` syntax does not actually
align well with match syntax, which is a possible source of confusion.
The comment points out that usage is instead more similar to ecosystem
`select!` macros. Rename `cfg_match!` to `cfg_select!` to match this.

Tracking issue: https://github.com/rust-lang/rust/issues/115585

[1]: https://github.com/rust-lang/rust/issues/115585#issuecomment-2346307605
2025-05-20 21:16:23 +00:00
Santiago Pastorino
66d47c1687 Do not call name() on rpitit assoc_item 2025-05-20 17:30:08 -03:00
Matthias Krüger
221d6c734c Rollup merge of #140972 - Stypox:machine-tracing-flag, r=RalfJung
Add TRACING_ENABLED to Machine and add enter_trace_span!()

This PR adds the necessary infrastructure to make it possible to do tracing calls from within `rustc_const_eval` when running Miri, while making sure they don't impact the performance of normal compiler execution. This is done by adding a `const` boolean to `Machine`, false by default, but that will be set to true in Miri only. The tracing macro `enter_trace_span!()` checks if it is true before doing anything, and since the value of a `const` is known at compile time, if it it false it the whole tracing call should be optimized out.

I will soon open further PRs to add tracing macro calls similar to this one, so that afterwards it will be possible to learn more about Miri's time spent in the various interpretation steps:
```rs
let _guard = enter_trace_span!(M, "eval_statement", "{:?}", stmt);
```

r? `@RalfJung`
2025-05-20 20:57:26 +02:00
Nicholas Nethercote
e5c78de85c Rename MetaItemParser::path_without_args as MetaItemParser::path.
And avoid the clone.
2025-05-21 04:53:31 +10:00
Nicholas Nethercote
2cd2d24967 Remove MetaItemParser::{path,deconstruct}.
They're equivalent, and `path` is unused, and `deconstruct` has only one
call site outside of `path`.
2025-05-21 04:53:31 +10:00
Nicholas Nethercote
ea3b3fdcc1 Remove MetaItemParser::{word,word_without_args,path_is}.
They are unused.
2025-05-21 04:53:31 +10:00
Nicholas Nethercote
a822e557cd Remove an unnecessary lifetime. 2025-05-21 04:53:24 +10:00
bohan
097b7a2ac7 collect doc alias as tips during resolution 2025-05-21 00:47:36 +08:00
Stypox
28db348fdd Add enter_trace_span!() that checks if tracing is enabled 2025-05-20 17:28:30 +02:00
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
Marcelo Domínguez
b21c9e7bfb Split autodiff into autodiff_forward and autodiff_reverse
Pending fix.
```
error: cannot find a built-in macro with name `autodiff_forward`
    --> library\core\src\macros\mod.rs:1542:5
     |
1542 | /     pub macro autodiff_forward($item:item) {
1543 | |         /* compiler built-in */
1544 | |     }
     | |_____^

error: cannot find a built-in macro with name `autodiff_reverse`
    --> library\core\src\macros\mod.rs:1549:5
     |
1549 | /     pub macro autodiff_reverse($item:item) {
1550 | |         /* compiler built-in */
1551 | |     }
     | |_____^

error: could not compile `core` (lib) due to 2 previous errors
```
2025-05-20 11:58:26 +00:00
Michael Goulet
6555ef7f09 Querify coroutine_hidden_types 2025-05-20 11:50:25 +00:00
Michael Goulet
1d8db54f76 Add tick to RePlaceholder debug output 2025-05-20 10:30:07 +00:00
Michael Goulet
37260e1c5b Allow trailing comma after argument in query definition 2025-05-20 10:22:08 +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
Nicholas Nethercote
ee1c2d583a Remove MetaItemListParser::all_{word,path}_list, which are unused. 2025-05-20 11:58:11 +10:00
dianne
ed983c2184 only resolve top-level guard patterns' guards once
We resolve guard patterns' guards in `resolve_pattern_inner`, so to
avoid resolving them multiple times, we must avoid doing so earlier. To
accomplish this, `LateResolutionVisitor::visit_pat` contains a case for
guard patterns that avoids visiting their guards while walking patterns.
This fixes an ICE due to `visit::walk_pat` being used instead, which
meant guards at the top level of a pattern would be visited twice.
2025-05-19 18:02:54 -07:00
Nicholas Nethercote
354b1cbcca Avoid rustc_span:: qualifiers.
In several files they are entirely unnecessary, with the relevant names
already imported. And in a few I have added the necessary `use` item.
2025-05-20 09:20:27 +10:00
Nicholas Nethercote
1525f548bc Fix up some comments.
Some are too long (> 100 chars), some are too short, some are missing
full stops, some are missing upper-case letters at the start of
sentences.
2025-05-20 09:17:49 +10:00
Nicholas Nethercote
5b808b7da8 Simplify Accepts.
There only needs to be one `Fn` per symbol, not multiple.
2025-05-20 09:12:24 +10:00
Nicholas Nethercote
e139d268f0 Introduce some typedefs to improve readability. 2025-05-20 08:31:49 +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
Folkert de Vries
c24e1c378f add s390x z17 target features 2025-05-19 17:40:37 +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
dianqk
be5d6c5425 gvn: bail out unavoidable non-ssa locals in repeat
We cannot transform `*elem` to `array[idx1]` in the following code,
as `idx1` has already been modified.

```rust
    mir! {
        let array;
        let elem;
        {
            array = [*val; 5];
            elem = &array[idx1];
            idx1 = idx2;
            RET = *elem;
            Return()
        }
    }
```
2025-05-19 21:35:49 +08: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