Commit graph

307643 commits

Author SHA1 Message Date
Guillaume Gomez
d808d28452
Rollup merge of #147623 - Zalathar:clear-mixed, r=nnethercote
Clear `ChunkedBitSet` without reallocating

There doesn't appear to be any reason to clear a ChunkedBitSet via its constructor (which allocates a new list of chunks), when we could just fill the existing allocation with `Chunk::Zeros` instead.

For comparison, the `insert_all` impl added by the same PR (rust-lang/rust#93984) does the simple thing here and just overwrites every chunk with `Chunk::Ones`.

(That fill was then made somewhat easier by rust-lang/rust#145480, which removes the chunk size from all-zero/all-one chunks.)

r? nnethercote (or compiler)
2025-10-13 11:25:23 +02:00
Guillaume Gomez
3938f42bb1
Rollup merge of #147608 - Zalathar:debuginfo, r=nnethercote
cg_llvm: Use `LLVMDIBuilderCreateGlobalVariableExpression`

- Part of rust-lang/rust#134001
- Follow-up to rust-lang/rust#146763

---

This PR dismantles the somewhat complicated `LLVMRustDIBuilderCreateStaticVariable` function, and replaces it with equivalent calls to `LLVMDIBuilderCreateGlobalVariableExpression` and `LLVMGlobalSetMetadata`.

A key difference is that the new code does not replicate the attempted downcast of `InitVal`. As far as I can tell, those downcasts were actually dead, because `llvm::ConstantInt` and `llvm::ConstantFP` are not subclasses of `llvm::GlobalVariable`. I tried replacing those code paths with fatal errors, and was unable to induce failure in any of the relevant test suites I ran.

I have also confirmed that if the calls to `create_static_variable` are commented out, debuginfo tests will fail, demonstrating some amount of relevant test coverage.

The new `DIBuilder` methods have been added via an extension trait, not as inherent methods, to avoid impeding rust-lang/rust#142897.
2025-10-13 11:25:23 +02:00
Guillaume Gomez
b7ea44a49d
Rollup merge of #147605 - Zalathar:from-str-radix, r=Mark-Simulacrum
Add doc links between `{integer}::from_str_radix` and `from_str`

When parsing base-10 numbers, it's easy to miss `<Self as FromStr>::from_str` and `str::parse` as potential alternatives to `from_str_radix`.

- A similar suggestion is given by https://rust-lang.github.io/rust-clippy/master/index.html#from_str_radix_10
2025-10-13 11:25:22 +02:00
Guillaume Gomez
4a7e152511
Rollup merge of #147514 - RalfJung:transparent-nonexhaustive-normalize, r=lcnr
repr_transparent_external_private_fields: normalize types during traversal

Determining whether a type is a 1-ZST will internally do full normalization, so we better do the same when scanning for non-exhaustive types.

r? ``@lcnr``
2025-10-13 11:25:21 +02:00
bors
35456985fa Auto merge of #147518 - dianqk:update-llvm, r=cuviper,Kobzol
Update LLVM to 21.1.3

Fixes https://github.com/rust-lang/rust/issues/146742.

After rust-lang/rust#146124, we need more space to run x86_64-gnu-distcheck if building LLVM from source. According to the building log, the space freed by `free-disk-space-linux.sh` is not entirely available.

```
You are running out of disk space.
The runner will stop working when the machine runs out of disk space.
Free space left: 98 MB

disk usage:
Filesystem      Size  Used Avail Use% Mounted on
/dev/root        72G   43G   29G  60% /
tmpfs           7.9G   84K  7.9G   1% /dev/shm
tmpfs           3.2G  1.2M  3.2G   1% /run
tmpfs           5.0M     0  5.0M   0% /run/lock
/dev/sda16      881M   60M  760M   8% /boot
/dev/sda15      105M  6.2M   99M   6% /boot/efi
/dev/sdb1        74G   28K   70G   1% /mnt
tmpfs           1.6G   12K  1.6G   1% /run/user/1001
```
2025-10-13 05:11:33 +00:00
Zalathar
9ff52bf332 Clear ChunkedBitSet without reallocating 2025-10-13 13:58:01 +11:00
bors
36e4f5d1fe Auto merge of #146096 - adwinwhite:handle_normalization_overflow_in_mono1, r=saethlin
Fix normalization overflow ICEs in monomorphization

Fixes rust-lang/rust#92004
Fixes rust-lang/rust#92470
Fixes rust-lang/rust#95134
Fixes rust-lang/rust#105275
Fixes rust-lang/rust#105937
Fixes rust-lang/rust#117696-2
Fixes rust-lang/rust#118590
Fixes rust-lang/rust#122823
Fixes rust-lang/rust#131342
Fixes rust-lang/rust#139659

## Analysis:
The causes of these issues are similar. They contain generic recursive functions that can be instantiated with different args infinitely at monomorphization stage.
Ideally this should be caught by the [`check_recursion_limit`](c0bb3b98bb/compiler/rustc_monomorphize/src/collector.rs (L468)) function. The reality is that normalization can reach recursion limit earlier than monomorphization's check because they calculate depths in different ways.
Since normalization is called everywhere, ICEs appear in different locations.

## Fix:
If we abort on overflow with `TypingMode::PostAnalysis` in the trait solver, it would also catch these errors.
The main challenge is providing good diagnostics for them. So it's quite natural to put the check right before these normalization happening.
I first tried to check the whole MIR body's normalization and `references_error`. (As elaborate_drop handles normalization failure by [returning `ty::Error`](c0bb3b98bb/compiler/rustc_mir_transform/src/elaborate_drop.rs (L514-L519)).)
It turns out that checking all `Local`s seems sufficient.
These types are gonna be normalized anyway. So with cache, these checks shouldn't be expensive.

This fixes these ICEs for both the next and old solver, though I'm not sure the change I made to the old solver is proper. Its overflow handling looks convoluted thus I didn't try to fix it more "upstream".
2025-10-13 00:20:10 +00:00
bors
2300c2aef7 Auto merge of #147612 - matthiaskrgr:rollup-5u2ledv, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - rust-lang/rust#147168 (Don't unconditionally build alloc for `no-std` targets)
 - rust-lang/rust#147178 ([DebugInfo] Improve formatting of MSVC enum struct variants)
 - rust-lang/rust#147495 (Update wasm-component-ld to 0.5.18)
 - rust-lang/rust#147592 (Add tidy to the target of ./x check)
 - rust-lang/rust#147597 (Add a regression test for rust-lang/rust#72207)
 - rust-lang/rust#147604 (Some clippy cleanups in compiler)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-10-12 17:09:34 +00:00
Matthias Krüger
3b1c58f672
Rollup merge of #147604 - Kivooeo:tear-prev-pr, r=nnethercote
Some clippy cleanups in compiler

This extracts some of the changes from https://github.com/rust-lang/rust/pull/147591 that were worth preserving in my opinion

r? compiler
2025-10-12 19:07:48 +02:00
Matthias Krüger
ae356cb673
Rollup merge of #147597 - JohnTitor:issue-72207, r=chenyukang
Add a regression test for #72207

Closes rust-lang/rust#72207
2025-10-12 19:07:48 +02:00
Matthias Krüger
13ef05d52f
Rollup merge of #147592 - Shunpoco:add-tidy-to-check, r=Zalathar
Add tidy to the target of ./x check

## Context
Discussion: https://rust-lang.zulipchat.com/#narrow/channel/326414-t-infra.2Fbootstrap/topic/tidy.20isn't.20in.20.2E.2Fx.20check/with/544323712

Currently `tidy` (src/tools/tidy) is not included in the list of `./x check`. It means that rust-analyzer doesn't work for codes in the directory if you use `./x check` as the analyzer on your IDE.

## Change

This PR adds src/tools/tidy into the target of `./x check`. It enables rust-analyzer highlight errors/warns on all codes in the directory.

Note that since tidy is implicitly checked by `./x test tidy`, this new check is off by default.
2025-10-12 19:07:47 +02:00
Matthias Krüger
6c71fcb8e2
Rollup merge of #147495 - alexcrichton:update-wasm-component-ld, r=Mark-Simulacrum
Update wasm-component-ld to 0.5.18

Keeping it up-to-date with upstream for the latest bug fixes and such related to wasm-tools-implemented internals.
2025-10-12 19:07:46 +02:00
Matthias Krüger
0988d2465d
Rollup merge of #147178 - Walnut356:msvc_enum_summary, r=Mark-Simulacrum
[DebugInfo] Improve formatting of MSVC enum struct variants

More robust handling mirroring the `TupleSummaryProvider` function

before:
<img width="1168" height="28" alt="image" src="https://github.com/user-attachments/assets/994f0884-55c2-4d3d-b1b2-97df17f0c9f0" />

after:
<img width="813" height="31" alt="image" src="https://github.com/user-attachments/assets/8ad3dfa0-3aa7-42a9-bf50-6f5eaf0365aa" />

This shouldn't affect any tests as we don't run debuginfo tests for MSVC afaik
2025-10-12 19:07:46 +02:00
Matthias Krüger
9d9ede81f5
Rollup merge of #147168 - jyn514:no-alloc, r=Mark-Simulacrum
Don't unconditionally build alloc for `no-std` targets

It's possible for targets to only support `core` and not `alloc`. Instead of building alloc unconditionally, pass a list of crates to build into `std_cargo`, and only pass `-p alloc` if the list of crates wasn't already filtered to a subset.

The original use case was to reuse `std_cargo` for a rustc_driver that doesn't emit metadata. But this seems like a reasonable change regardless.
2025-10-12 19:07:45 +02:00
bors
ff6dc928c5 Auto merge of #142390 - cjgillot:mir-liveness, r=davidtwco
Perform unused assignment and unused variables lints on MIR.

Rebase of https://github.com/rust-lang/rust/pull/101500

Fixes https://github.com/rust-lang/rust/issues/51003.

The first commit moves detection of uninhabited types from the current liveness pass to MIR building.

In order to keep the same level of diagnostics, I had to instrument MIR a little more:
- keep for which original local a guard local is created;
- store in the `VarBindingForm` the list of introducer places and whether this was a shorthand pattern.

I am not very proud of the handling of self-assignments. The proposed scheme is in two parts: first detect probable self-assignments, by pattern matching on MIR, and second treat them specially during dataflow analysis. I welcome ideas.

Please review carefully the changes in tests. There are many small changes to behaviour, and I'm not sure all of them are desirable.
2025-10-12 13:00:04 +00:00
Zalathar
1081d98551 Use LLVMDIBuilderCreateGlobalVariableExpression
Note that the code in `LLVMRustDIBuilderCreateStaticVariable` that tried to
downcast `InitVal` appears to have been dead, because `llvm::ConstantInt` and
`llvm::ConstantFP` are not subclasses of `llvm::GlobalVariable`.
2025-10-12 23:36:26 +11:00
Zalathar
1db7d41665 Extract DIBuilderExt::create_static_variable 2025-10-12 23:34:44 +11:00
Zalathar
45e9ebee31 Extract DIBuilderExt::create_expression 2025-10-12 23:34:44 +11:00
Zalathar
b6ea8242fd Hoist some stranded use declarations 2025-10-12 23:34:39 +11:00
Zalathar
2be88e39ea Add doc links between {integer}::from_str_radix and from_str 2025-10-12 22:54:50 +11:00
Zalathar
10393a8052 Add LLDB commands to tests/debuginfo/basic-types-globals.rs 2025-10-12 21:44:13 +11:00
bors
89276493d3 Auto merge of #147603 - matthiaskrgr:rollup-j6uae13, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - rust-lang/rust#138799 (core: simplify `Extend` for tuples)
 - rust-lang/rust#145897 (Rehome 30 `tests/ui/issues/` tests to other subdirectories under `tests/ui/` [rust-lang/rust#4 of Batch rust-lang/rust#2])
 - rust-lang/rust#146692 (Save x.py's help text for saving output time)
 - rust-lang/rust#147240 (Add an ACP list item to the library tracking issue template)
 - rust-lang/rust#147246 (Explain not existed key in BTreeMap::split_off)
 - rust-lang/rust#147393 (Extract most code from `define_feedable!`)
 - rust-lang/rust#147503 (Fix documentation of Instant::now on mac)
 - rust-lang/rust#147549 (Replace `LLVMRustContextCreate` with normal LLVM-C API calls)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-10-12 09:53:50 +00:00
Matthias Krüger
64b37b947f
Rollup merge of #147549 - AMS21:remove_llvm_rust_context_create, r=Zalathar
Replace `LLVMRustContextCreate` with normal LLVM-C API calls

Since `LLVMRustContextCreate` can easily be replaced with a call to `LLVMContextCreate` and `LLVMContextSetDiscardValueNames`.

Work towards https://github.com/rust-lang/rust/issues/46437
2025-10-12 10:13:17 +02:00
Matthias Krüger
f5a6b1bda9
Rollup merge of #147503 - stepancheg:instant-now-mac-doc, r=joboet
Fix documentation of Instant::now on mac

It is `CLOCK_UPTIME_RAW` on Apple.

b6f0945e46/library/std/src/sys/pal/unix/time.rs (L260-L264)
2025-10-12 10:13:17 +02:00
Matthias Krüger
0765b43b37
Rollup merge of #147393 - Zalathar:feed, r=cjgillot
Extract most code from `define_feedable!`

This PR extracts most of the non-trivial code from the `define_feedable!` macro (which defines the `TyCtxtFeed::$query` methods), and moves it to a helper function `query_feed_inner` written in ordinary non-macro code.

Doing so should make that code easier to read and modify, because it now gets proper IDE support and has explicit trait bounds.

---

There should be no change in compiler behaviour.

I've structured the commits so that the actual extraction part is mostly just whitespace changes, making it easier to review individually with whitespace changes hidden.
2025-10-12 10:13:16 +02:00
Matthias Krüger
b96bd11c54
Rollup merge of #147246 - Kivooeo:btree-map-split-off-doc, r=Mark-Simulacrum
Explain not existed key in BTreeMap::split_off

Fixes https://github.com/rust-lang/rust/issues/147174

r? libs
2025-10-12 10:13:15 +02:00
Matthias Krüger
8a2ec10bb3
Rollup merge of #147240 - tgross35:tracking-template, r=Mark-Simulacrum
Add an ACP list item to the library tracking issue template

Most new API has an associated ACP that is useful to reference, but it doesn't appear anywhere on the template for new tracking issues. Update this template to include a link to the ACP.
2025-10-12 10:13:15 +02:00
Matthias Krüger
f64f890b47
Rollup merge of #146692 - Shunpoco:issue-141903, r=Mark-Simulacrum
Save x.py's help text for saving output time

Fix rust-lang/rust#141903

Currently x.py help (--help) builds bootstrap binary everytime, so it takes some seconds to print help.
This PR does:
-  Saves current help text into a file (x.py run generate-help)
-  Changes bootstrap.py to print the help in the saved file and to exit without touching bootstrap binary
-  Modifies x.py test bootstrap to check if the help file is up-to-date
2025-10-12 10:13:14 +02:00
Matthias Krüger
f58eab74c6
Rollup merge of #145897 - Oneirical:uncountable-integer-11, r=jieyouxu
Rehome 30 `tests/ui/issues/` tests to other subdirectories under `tests/ui/` [#4 of Batch #2]

Part of rust-lang/rust#133895

Methodology:

1. Refer to the previously written `tests/ui/SUMMARY.md`
2. Find an appropriate category for the test, using the original issue thread and the test contents.
3. Add the issue URL at the bottom (not at the top, as that would mess up stderr line numbers)
4. Rename the tests to make their purpose clearer

Inspired by the methodology that `@Kivooeo` was using.

r? `@jieyouxu`
2025-10-12 10:13:13 +02:00
Matthias Krüger
817720c9a9
Rollup merge of #138799 - joboet:extend-tuple, r=Mark-Simulacrum
core: simplify `Extend` for tuples

This is an alternative to https://github.com/rust-lang/rust/pull/137400. The current macro is incredibly complicated and introduces subtle bugs like calling the `extend_one` of the individual collections in backwards order. This PR drastically simplifies the macro by removing recursion and moving the specialization out of the macro. It also fixes the ordering issue described above (I've stolen the test of the new behaviour from https://github.com/rust-lang/rust/pull/137400). Additionally, the 1-tuple is now special-cased to allow taking advantage of the well-optimized `Extend` implementations of the individual collection.
2025-10-12 10:13:12 +02:00
Kivooeo
dc05250c2f some cleanups in compiler 2025-10-12 08:08:30 +00:00
Shunpoco
d70857a1e0 Add tidy into ./x check
This commit adds src/tools/tidy into `./x check`. It enables rust-analyzer hightlights errors/warns on all codes in src/tools/tidy.
Since tidy is implicitly checked by `./x test tidy`, this new check is off by default.
2025-10-12 08:49:39 +01:00
Camille Gillot
be46a90a8b Bless x86_64 test. 2025-10-12 03:15:18 +00:00
bors
3be68033b6 Auto merge of #145513 - beepster4096:erasedereftemps, r=saethlin,cjgillot
Validate CopyForDeref and DerefTemps better and remove them from runtime MIR

(split from my WIP rust-lang/rust#145344)

This PR:
- Removes `Rvalue::CopyForDeref` and `LocalInfo::DerefTemp` from runtime MIR
    - Using a new mir pass `EraseDerefTemps`
    - `CopyForDeref(x)` is turned into `Use(Copy(x))`
    - `DerefTemp` is turned into `Boring`
        - Not sure if this part is actually necessary, it made more sense in rust-lang/rust#145344 with `DerefTemp` storing actual data that I wanted to keep from having to be kept in sync with the rest of the body in runtime MIR
- Checks in validation that `CopyForDeref` and `DerefTemp` are only used together
- Removes special handling for `CopyForDeref` from many places
- Removes `CopyForDeref` from `custom_mir` reverting rust-lang/rust#111587
    - In runtime MIR simple copies can be used instead
    - In post cleanup analysis MIR it was already wrong to use due to the lack of support for creating `DerefTemp` locals
    - Possibly this should be its own PR?
 - Adds an argument to `deref_finder` to avoid creating new `DerefTemp`s and `CopyForDeref` in runtime MIR.
     - Ideally we would just avoid making intermediate derefs instead of fixing it at the end of a pass / during shim building
 - Removes some usages of `deref_finder` that I found out don't actually do anything

r? oli-obk
2025-10-12 02:34:20 +00:00
Oneirical
6ca69812cd Add test batch 4 2025-10-11 21:59:51 -04:00
Yuki Okushi
e0b7b2350e Add a regression test for #72207 2025-10-12 08:24:39 +09:00
Adwin White
08f16a9c46 check normalization overflow in monomorphization 2025-10-12 06:59:10 +08:00
Shunpoco
340702c0c2 write x.py's help for saving output time
Currently x.py help (or x.py --help) builds bootstrap binary everytime, but it delays printing help.
This change saves the current top level help text into a file. x.py help prints the file and doesn't touch bootstrap binary.
x.py test bootstrap checks if the file is up to date.
Note that subcommand level helps (e.g., x.py check --help) aren't saved.
2025-10-11 23:16:18 +01:00
Camille Gillot
b198bf8060 Rebase fallout. 2025-10-11 20:56:10 +00:00
Camille Gillot
49922d5b96 Remove unreachable expression warning from std. 2025-10-11 20:50:21 +00:00
Camille Gillot
4419d890c6 Bless ui asm. 2025-10-11 20:50:21 +00:00
Camille GILLOT
f216ec23ba Silence warning in miri tests. 2025-10-11 20:50:21 +00:00
Camille GILLOT
72a04a7e0a Silence warning in r-a. 2025-10-11 20:50:21 +00:00
Camille Gillot
c653430714 Suggest unit struct and constants. 2025-10-11 20:50:21 +00:00
Camille GILLOT
ca0379d6cd Diagnose liveness on MIR. 2025-10-11 20:50:21 +00:00
Camille Gillot
96b70fc3a1 Always compile hir_id_validator.
Making this compilation conditional causes an unused crate dependency
warning.
2025-10-11 20:50:21 +00:00
Camille GILLOT
89191084d5 Correct binding scope when building MIR. 2025-10-11 20:50:20 +00:00
Camille GILLOT
f2535764d4 Introduce VarBindingIntroduction. 2025-10-11 20:50:20 +00:00
Camille GILLOT
9df2003860 Record for each MIR local where it has been introduced. 2025-10-11 20:50:20 +00:00
Camille GILLOT
aacf9a612a Add test for uninhabited std::mem::uninitialized uses. 2025-10-11 20:50:20 +00:00