2850 Commits

Author SHA1 Message Date
Camille GILLOT
832207862a Check static is sized when building MIR. 2025-07-25 02:31:59 +00:00
Camille GILLOT
6b4181f1e3 Do not assert layout in KnownPanicsLint. 2025-07-25 02:27:30 +00:00
Camille GILLOT
0460c92d52 Remove useless lifetime parameter. 2025-07-23 23:54:37 +00:00
bors
ace6330903 Auto merge of #144233 - cjgillot:unsat-mir, r=oli-obk
Consider parent predicates in ImpossiblePredicates pass.

This pass is double edged. It avoids some ICEs (yay!) but also degrades diagnostics from constant evaluation.

Fixes rust-lang/rust#121363
Fixes rust-lang/rust#131507
Fixes rust-lang/rust#140100
Fixes rust-lang/rust#140365
2025-07-23 20:16:03 +00:00
Matthias Krüger
7ec557ce72
Rollup merge of #144298 - Zalathar:empty-span, r=wesleywiser
coverage: Enlarge empty spans during MIR instrumentation, not codegen

This re-lands the part of rust-lang/rust#140847 that was (hopefully) not responsible for the coverage-instrumentation regressions that caused that PR to be reverted.

---

Enlarging empty spans was historically performed during MIR instrumentation, but had to be moved to codegen as part of larger changes in rust-lang/rust#134497, leading to the status quo. But now there should be no reason not to move that step back to its more logical home in instrumentaion.
2025-07-23 15:59:32 +02:00
Guillaume Gomez
a27f3e3fd1 Rename tests/codegen into tests/codegen-llvm 2025-07-22 14:28:48 +02:00
Zalathar
f877aa7d14 coverage: Enlarge empty spans during MIR instrumentation, not codegen
This allows us to assume that coverage spans will only be discarded during
codegen in very unusual situations.
2025-07-22 19:49:54 +10:00
Camille GILLOT
b1d88ba086 Keep elaborating predicates. 2025-07-22 01:51:11 +00:00
许杰友 Jieyou Xu (Joe)
551cef9fc9
Rollup merge of #144212 - bjorn3:remove_unique_lang_item, r=oli-obk
Remove the ptr_unique lang item

Miri no longer uses it since https://github.com/rust-lang/miri/pull/4307.
2025-07-22 00:54:30 +08:00
bors
67819923ac Auto merge of #144238 - jhpratt:rollup-xb8aida, r=jhpratt
Rollup of 8 pull requests

Successful merges:

 - rust-lang/rust#144144 (tests: Skip supported-crate-types test on musl hosts)
 - rust-lang/rust#144159 (opt-dist: change build_dir field to be an actual build dir)
 - rust-lang/rust#144162 (Debug impls for DropElaborators)
 - rust-lang/rust#144189 (Add non-regression test for rust-lang/rust#144168)
 - rust-lang/rust#144216 (Don't consider unstable fields always-inhabited)
 - rust-lang/rust#144229 (Miri subtree update)
 - rust-lang/rust#144230 (Option::as_slice: fix comment)
 - rust-lang/rust#144235 (Fix run-make tests on musl hosts)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-07-21 08:42:52 +00:00
bjorn3
1fd06975d0 Remove Retag for Unique 2025-07-21 08:08:41 +00:00
Jacob Pratt
7d0c7b2dcf
Rollup merge of #144162 - beepster4096:drop_elaborator_debug_impls, r=compiler-errors
Debug impls for DropElaborators

It's a little weird that these just have a completely empty Debug impl. Now they're `ElaborateDropsCtxt { .. }` and `DropShimElaborator { .. }`.
2025-07-20 23:11:21 -04:00
Camille GILLOT
538b0004bc Also bail out if predicates contain errors. 2025-07-20 23:15:24 +00:00
Camille GILLOT
1987471d05 Consider parent predicates in ImpossiblePredicates pass. 2025-07-20 22:45:07 +00:00
Scott McMurray
41ce1ed252 Ban projecting into SIMD types [MCP838] 2025-07-20 10:22:09 -07:00
Scott McMurray
14d097f641 Give a message with a span on validation error 2025-07-19 14:14:12 -07:00
bors
12865ffd0d Auto merge of #144166 - matthiaskrgr:rollup-wccepuo, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - rust-lang/rust#141076 (fix Zip unsoundness (again))
 - rust-lang/rust#142444 (adding run-make test to autodiff)
 - rust-lang/rust#143704 (Be a bit more careful around exotic cycles in in the inliner)
 - rust-lang/rust#144073 (Don't test panic=unwind in panic_main.rs on Fuchsia)
 - rust-lang/rust#144083 (miri sleep tests: increase slack)
 - rust-lang/rust#144092 (bootstrap: Detect musl hosts)
 - rust-lang/rust#144098 (Do not lint private-in-public for RPITIT)
 - rust-lang/rust#144103 (Rename `emit_unless` to `emit_unless_delay`)
 - rust-lang/rust#144108 (Ignore tests/run-make/link-eh-frame-terminator/rmake.rs when cross-compiling)
 - rust-lang/rust#144115 (fix outdated comment)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-07-19 11:10:04 +00:00
beepster4096
2a037503ef debug impls for drop elaborators 2025-07-18 17:31:48 -07:00
Michael Goulet
3b9c16bc0e Be a bit more careful around exotic cycles in in the inliner 2025-07-18 16:35:55 +00:00
Oli Scherer
c65d3ce365 Generalize unsize and unsize_into destinations 2025-07-18 13:09:34 +00:00
Matthias Krüger
03734ae794
Rollup merge of #143891 - scrabsha:push-xxtttopqoprr, r=jdonszelmann
Port `#[coverage]` to the new attribute system

r? ``````@jdonszelmann``````
2025-07-18 04:27:52 +02:00
Matthias Krüger
b252014673
Rollup merge of #143271 - cjgillot:gvn-types, r=oli-obk
Store the type of each GVN value

MIR is fully typed, so type information is an integral part of what defines a value. GVN currently tries to circumvent storing types, which creates all sorts of complexities.

This PR stores the type along with the enum `Value` when defining a value index. This allows to simplify a lot of code.

Fixes rust-lang/rust#128094
Fixes rust-lang/rust#135128

r? ``````@ghost`````` for perf
2025-07-18 04:27:50 +02:00
Sasha Pourcelot
4e054fc4c4 Port #[coverage] to the new attribute system 2025-07-16 15:51:18 +02:00
Tomasz Miąsko
9681786409 Propagate from borrowed locals in CopyProp 2025-07-10 09:36:20 +02:00
bors
d350797b7e Auto merge of #142707 - ashivaram23:drop_wildcard, r=dianqk
Apply effects to `otherwise` edge in dataflow analysis

This allows `ElaborateDrops` to remove drops when a `match` wildcard arm covers multiple no-Drop enum variants. It modifies dataflow analysis to update the `MaybeUninitializedPlaces` and `MaybeInitializedPlaces` data for a block reached through an `otherwise` edge.

Fixes rust-lang/rust#142705.
2025-07-09 03:42:01 +00:00
Amogh Shivaram
c7ef03aeb7 Apply effects to otherwise edge in dataflow analysis 2025-07-08 18:15:05 -05:00
许杰友 Jieyou Xu (Joe)
b6015a68de
Rollup merge of #143551 - compiler-errors:root-sub, r=cjgillot
Dont resolve instance of root in `mir_callgraph_cyclic`

`Instance::try_resolve` on a default trait body method will always fail, since it's still possible to further substitute. This leads to a cycle, since in `tests/mir-opt/inline_default_trait_body.rs`, both `Trait::a` and `Trait::b` need to consider the other to be cyclical, but since we couldn't resolve a body, we'd just consider *nothing* to be cyclical.

The root instance we care about when computing `mir_callgraph_cyclic` is trivial to compute (it's just `InstanceKind::Item`), so just replace it with a call to `Instance::new_raw`.

r? `@cjgillot` `@oli-obk`

Fixes rust-lang/rust#143534
2025-07-07 19:45:41 +08:00
Michael Goulet
a40274d6cc Dont resolve instance of root in mir_callgraph_cyclic 2025-07-06 23:01:45 +00:00
Camille GILLOT
bab9c752e8 Do not unify borrowed locals in CopyProp. 2025-07-06 10:14:07 +00:00
bors
837c5dd7de Auto merge of #142890 - kornelski:unused-var-debug, r=saethlin
MIR inliner maintains unused var_debug_info

Only `full` debuginfo level promises variable-level debug information, but the MIR inline pass needlessly preserved the local variable debug info for the `limited` level too.
2025-07-03 23:17:03 +00:00
Jana Dönszelmann
f6d37a25a9
Rollup merge of #134006 - klensy:typos, r=nnethercote
setup typos check in CI

This allows to check typos in CI, currently for compiler only (to reduce commit size with fixes). With current setup, exclude list is quite short, so it worth trying?

Also includes commits with actual typo fixes.

MCP: https://github.com/rust-lang/compiler-team/issues/817

typos check currently turned for:
* ./compiler
* ./library
* ./src/bootstrap
* ./src/librustdoc

After merging, PRs which enables checks for other crates (tools) can be implemented too.

Found typos will **not break** other jobs immediately: (tests, building compiler for perf run). Job will be marked as red on completion in ~ 20 secs, so you will not forget to fix it whenever you want, before merging pr.

Check typos: `python x.py test tidy --extra-checks=spellcheck`
Apply typo fixes: `python x.py test tidy --extra-checks=spellcheck:fix` (in case if there only 1 suggestion of each typo)

Current fail in this pr is expected and shows how typo errors emitted. Commit with error will be removed after r+.
2025-07-03 13:29:35 +02:00
klensy
c76d032f01 setup CI and tidy to use typos for spellchecking and fix few typos 2025-07-03 10:51:06 +03:00
Matthias Krüger
ddda937701
Rollup merge of #143273 - 1c3t3a:enum-check-negative, r=SparrowLii
Make the enum check work for negative discriminants

The discriminant check was not working correctly for negative numbers. This change fixes that by masking out the relevant bits correctly.

Fixes rust-lang/rust#143218.
2025-07-03 05:21:32 +02:00
Matthias Krüger
2becacff8b
Rollup merge of #143261 - compiler-errors:explicit-pred, r=oli-obk
Feed `explicit_predicates_of` instead of `predicates_of`

Tiny nitpick, just avoiding needing to mark the `predicates_of` query as feedable since it's derived from `explicit_predicates_of`.
2025-07-02 19:29:38 +02:00
Bastian Kersting
8a0d8dde44 Make the enum check work for negative discriminants
The discriminant check was not working correctly for negative numbers.
This change fixes that by masking out the relevant bits correctly.
2025-07-02 20:02:27 +03:00
bors
085c24790e Auto merge of #143036 - compiler-errors:no-dyn-star, r=oli-obk
Remove support for `dyn*` from the compiler

This PR removes support for `dyn*` (https://github.com/rust-lang/rust/issues/102425), which are a currently un-RFC'd experiment that was opened a few years ago to explore a component that we thought was necessary for AFIDT (async fn in dyn trait).

It doesn't seem like we are going to need `dyn*` types -- even in an not-exposed-to-the-user way[^1] -- for us to implement AFIDT. Given that AFIDT was the original motivating purpose of `dyn*` types, I don't really see a compelling reason to have to maintain their implementation in the compiler.

[^1]: Compared to, e.g., generators whih are an unstable building block we use to implement stable syntax like `async {}`.

We've learned quite a lot from `dyn*`, but I think at this point its current behavior leads to more questions than answers. For example, `dyn*` support today remains somewhat fragile; it ICEs in many cases where the current "normal" `dyn Trait` types rely on their unsizedness for their vtable-based implementation to be sound I wouldn't be surprised if it's unsound in other ways, though I didn't play around with it too much. See the examples below.

```rust
#![feature(dyn_star)]

trait Foo {
    fn hello(self);
}

impl Foo for usize {
    fn hello(self) {
        println!("hello, world");
    }
}

fn main() {
    let x: dyn* Foo = 1usize;
    x.hello();
}
```

And:

```rust
#![feature(dyn_star)]

trait Trait {
    type Out where Self: Sized;
}

fn main() {
    let x: <dyn* Trait as Trait>::Out;
}
```

...and probably many more problems having to do with the intersection of dyn-compatibility and `Self: Sized` bounds that I was too lazy to look into like:
* GATs
* Methods with invalid signatures
* Associated consts

Generally, `dyn*` types also end up getting in the way of working with [normal `dyn` types](https://github.com/rust-lang/rust/issues/102425#issuecomment-1712604409) to an extent that IMO outweighs the benefit of experimentation.

I recognize that there are probably other, more creative usages of `dyn*` that are orthogonal to AFIDT. However, I think any work along those lines should first have to think through some of the more fundamental interactions between `dyn*` and dyn-compatibility before we think about reimplementing them in the type system.

---

I'm planning on removing the `DynKind` enum and the `PointerLike` built-in trait from the compiler after this PR lands.

Closes rust-lang/rust#102425.

cc `@eholk` `@rust-lang/lang` `@rust-lang/types`

Closes rust-lang/rust#116979.
Closes rust-lang/rust#119694.
Closes rust-lang/rust#134591.
Closes rust-lang/rust#104800.
2025-07-01 21:50:21 +00:00
Michael Goulet
2516c33982 Remove support for dyn* 2025-07-01 19:00:21 +00:00
Guillaume Gomez
b47008a7c2
Rollup merge of #143262 - dianqk:non_exhaustive, r=oli-obk
mir: Mark `Statement` and `BasicBlockData` as `#[non_exhaustive]`

Ensure they are always created using constructors.

r? oli-obk
2025-07-01 17:47:05 +02:00
Camille GILLOT
cbc3cf716e Avoid computing layouts inside coroutines. 2025-07-01 12:06:39 +00:00
Camille GILLOT
4750dff54e Remove extraneous types. 2025-07-01 11:40:44 +00:00
Camille GILLOT
be41333604 Store a full Ty with each Value. 2025-07-01 11:40:36 +00:00
Camille GILLOT
ac70dc85e7 Introduce Value::RawPtr as it behaves differently from other aggregates. 2025-07-01 11:38:50 +00:00
Camille GILLOT
fba4177d0f Simplify assignments. 2025-07-01 11:37:02 +00:00
Michael Goulet
96fea30d92 Feed explicit_predicates_of instead of predicates_of 2025-07-01 00:01:40 +00:00
dianqk
90e0835004
mir: Mark Statement and BasicBlockData as #[non_exhaustive]
Ensure they are always created using constructors.
2025-07-01 07:14:13 +08:00
Matthias Krüger
8292936d74
Rollup merge of #143140 - RalfJung:ptr-into-parts, r=oli-obk
give Pointer::into_parts a more scary name and offer a safer alternative

`into_parts` is a bit too innocent of a name for a somewhat subtle operation.
r? `@oli-obk`
2025-06-30 20:49:41 +02:00
dianqk
24e553e6bc
mir: Use the new method for BasicBlockData 2025-06-29 20:39:13 +08:00
dianqk
9f9cd5e283
mir: Add a new method to statement
Avoid introducing a large number of changes when adding optional initialization fields.
2025-06-29 20:13:36 +08:00
Ralf Jung
58dce8ca86 give Pointer::into_parts a more scary name and offer a safer alternative 2025-06-29 00:16:19 +02:00
bors
11ad40bb83 Auto merge of #142625 - cjgillot:inline-nocycle, r=oli-obk
Only compute recursive callees once.

Inlining MIR in a cyclic call graph may create query cycles, which are ICEs. The current implementation `mir_callgraph_reachable(inlining_candidate, being_optimized)` checks if calling `inlining_candidate` may cycle back to `being_optimized` that we are currently inlining into.

This PR replaces this device with query `mir_callgraph_cyclic(being_optimized)` which searches the call graph for all cycles going back to `being_optimized`, and returns the set of functions involved in those cycles.

This is a tradeoff:
- in the current implementation, we perform more walks, but shallower;
- in this new implementation, we perform fewer walks, but exhaust the graph.

I'd have liked to compute this using some kind of SCC, but generic parameters make resolution path-dependent, so usual graph algorithms do not apply.
2025-06-28 19:11:42 +00:00