Commit Graph

48471 Commits

Author SHA1 Message Date
Camille GILLOT
904bc2958f Lighten formatting. 2025-07-04 14:02:18 +00:00
Camille GILLOT
761d366415 Reuse metadata file from work products. 2025-07-04 14:02:17 +00:00
Camille GILLOT
c7ee3a5e3f Save metadata among work products. 2025-07-04 14:02:17 +00:00
Camille GILLOT
2d3ff91add Remove names_imported_by_glob_use query. 2025-07-04 14:01:09 +00:00
bors
556d20a834 Auto merge of #143247 - cjgillot:metadata-no-red, r=petrochenkov
Avoid depending on forever-red DepNode when encoding metadata.

Split from https://github.com/rust-lang/rust/pull/114669 for perf

r? `@petrochenkov`
2025-07-04 10:23:18 +00:00
klensy
e631555a48 bump termize dep 2025-07-04 11:43:43 +03:00
dianne
98659a339d treat box patterns as deref patterns in THIR and usefulness analysis
This removes special-casing of boxes from `rustc_pattern_analysis`, as a
first step in replacing `box_patterns` with `deref_patterns`.
Incidentally, it fixes a bug caused by box patterns being represented as
structs rather than pointers, where `exhaustive_patterns` could generate
spurious `unreachable_patterns` lints on arms required for
exhaustiveness; following the lint's advice would result in an error.
2025-07-04 01:28:35 -07:00
bors
1b61d43bdb Auto merge of #143237 - JonathanBrouwer:no_implicit_prelude_parser, r=jdonszelmann,oli-obk
Port `#[no_implicit_prelude]` to the new attribute parsing infrastructure

Ports no_implicit_prelude to the new attribute parsing infrastructure for https://github.com/rust-lang/rust/issues/131229#issuecomment-2971353197

r? `@oli-obk`
cc `@jdonszelmann`
2025-07-04 07:21:46 +00:00
Scott McMurray
caeacba78a Allow all MIR Aggregates to take the operand path (if layout permits) 2025-07-03 22:53:19 -07:00
Scott McMurray
5292554337 Block SIMD in transmute_immediate; delete OperandValueKind
See conversation in <https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Is.20transmuting.20a.20.60T.60.20to.20.60Tx1.60.20.28one-element.20SIMD.20vector.29.20UB.3F/near/526262799>.
2025-07-03 22:23:15 -07:00
Jens Reidel
a7eefc3fc4 Enable xgot feature for mips64 musl targets
This was missed in b65c2afdfd, which only
enabled it for the glibc targets.

I didn't feel comfortable touching the OpenWRT target, whoever maintains
that will probably want to take a look whether it is necessary there as
well.

Signed-off-by: Jens Reidel <adrian@travitia.xyz>
2025-07-04 07:04:54 +02:00
Josh Triplett
0403990000 mbe: Gracefully handle macro rules that end after =>
Add a test for various cases of invalid macro definitions.

Closes: https://github.com/rust-lang/rust/issues/143351
2025-07-03 20:56:05 -07:00
Jacob Pratt
e4e26d2acb Rollup merge of #143395 - Urgau:llvm-fallback-minimum-maximum, r=tgross35
Always use the pure Rust fallback instead of `llvm.{maximum,minimum}`

While https://github.com/llvm/llvm-project/pull/142170 was merged, it was reverted and next attempt (https://github.com/llvm/llvm-project/pull/140193) at fixing the LLVM implementation seems to have stall, so let's reverted back to pure Rust with the LLVM codegen.

cc [#t-compiler/llvm > &#96;llvm.minimum&#96;/&#96;llvm.maximum&#96; issues @ 💬](https://rust-lang.zulipchat.com/#narrow/channel/187780-t-compiler.2Fllvm/topic/.60llvm.2Eminimum.60.2F.60llvm.2Emaximum.60.20issues/near/527044712)

Fixes https://github.com/rust-lang/rust/issues/141087
r? `@tgross35`
2025-07-04 05:47:29 +02:00
Jacob Pratt
9852aceb4f Rollup merge of #143394 - workingjubilee:reorganize-hir-analysis-provide-fn, r=compiler-errors
compiler: Document and reduce `fn provide`s in hir crates

I found it hard to follow all these tiny micro-indirections. Much like you shouldn't pass around `&u32` if you can help it, you probably shouldn't use an indirection if the indirection overhead itself is literally bigger than the amount of data you are organizing. Generally a new `fn provide` amounts to around 3 LOC:
- the signature with opening brace
- the `rustc_middle::query::Providers` import
- an end brace

I am not even counting the cost in time and thought to go find the other `provide`, read it, understand, "Ah, yes, these functions", and then go to those. Thus I say we should collapse indirections of `provide` for modules that only export 1~2 queries. For higher-count indirections, I left them as-is, as I don't understand the crate well enough to judge their worth.

Then I dropped a pointer to the actual module of interest for all these instances of the same function. I think documenting them is important because the comment that it relates to the query system makes it obvious that they have **nothing** to do with the rest of the module's logic and I can carry on ignoring them. Actively doing so is another cognitive cost, but much more minimal.

There is also a small correctness issue in that all of these functions are technically mutating state. It's not a huge deal, but it's still easier to check all these mutations do not overlap if we have less instances of `fn provide` to check.
2025-07-04 05:47:28 +02:00
Jacob Pratt
05f5690d81 Rollup merge of #143380 - cjgillot:kw_span, r=compiler-errors
Replace kw_span by full span for generic const parameters.

Small simplification extracted from https://github.com/rust-lang/rust/pull/127241
2025-07-04 05:47:27 +02:00
Jacob Pratt
9de211b95a Rollup merge of #143307 - compiler-errors:fast-path-nitpicks, r=lcnr
Fast path nitpicks

Miscellaneous commits that I didn't really want to fold into anything else.

Fixes one theoretical bug with the fast path not considering polarity for `T: !Sized` bounds.
2025-07-04 05:47:24 +02:00
Makai
e26ae60be3 refactor: implement a new bridge trait Allocation 2025-07-04 01:57:47 +00:00
Makai
854292d589 refactor: rewrite adt_repr(), adt_discr_for_variant() and coroutine_discr_for_variant() 2025-07-04 01:57:47 +00:00
Makai
b7be9cd151 refactor: don't use rustc_type_ir directly 2025-07-04 01:57:47 +00:00
Makai
e3f2096849 refactor: avoid calling internal functions in predicates_of() and explicit_predicates_of() 2025-07-04 01:57:46 +00:00
Makai
a61e5080ec refactor: move convert to unstable
We want to keep StableMIR definitions and logic separate from any sort of conversion and usage of internal rustc code. So we bundle all unstable items that have no stability guarantees into `stable_mir::unstable`.
2025-07-04 01:57:46 +00:00
Makai
efa26e1d64 fix: resolve the unsoundness
add a new trait `InternalCx`, which defines the methods that are fine to call from `RustcInternal`. `RustcInternal::internal()` then takes a `impl InternalCx<'tcx>` instead of `TyCtxt<'tcx>`.

make `tcx` in `SmirCtxt` public, since we need to pass it to `RustcInternal::internal()` in `SmirInterface`.
2025-07-04 01:57:38 +00:00
Makai
b5a2e7d080 refactor: move IndexMap to rustc_smir
we should no longer keep `IndexMap` in `rustc_internal`, as we've decided to migrate `rustc_internal` to `stable_mir` under a feature.
2025-07-04 01:33:18 +00:00
Makai
62d60319d6 refactor: unify Tables implementation with bridge types and re-export IndexedVal
define bridge types for `***Def`s.
consolidate scattered `Tables` implementations into single inherent impl.
2025-07-04 01:33:18 +00:00
Makai
45cf29d651 refactor: remove the tcx field in Tables
the only functionality of `Tables` is caching results. this commit moves calls to rustc queries from `Tables` to `SmirCtxt`.
2025-07-04 01:33:18 +00:00
Makai
6916089d7c fix: rewrite some parts of rustc_smir::builder.rs 2025-07-04 01:33:18 +00:00
Makai
663e2b7e29 refactor: move convert module to stable_mir
note that this commit delete `convert/error.rs`, we would use `SmirError::from_internal` instead.

**Unresolved questions:**
- There are still a few direct calls to rustc's internals scattered across `impl Stable`s, but most of them appear to be relatively stable, e.g., `mir::interpret::ConstAllocation::inner(self)` and `mir::syntax::SwitchTargets::otherwise(self)`.
2025-07-04 01:33:17 +00:00
Makai
0f6f68313d refactor: rewrite the whole rustc_smir::context
This commit removes the `Tables` field from `SmirCtxt`, since borrows of `tables` should only be managed by `SmirInterface`.

This change prevents `SmirCtxt` from holding separate borrows and requires passing `tables` explicitly when needed.

We use the `traits.rs` file to define traits that are used for encapsulating the associated functions in the rustc's internals. This is much easier to use and maintain than directly cramming everything into `SmirCtxt`.
2025-07-04 01:33:17 +00:00
Makai
3b328e111a refactor: split rustc_smir::alloc into two parts
The previous `rustc_smir::alloc` had many direct calls to rustc queries.

This commit splits it into two parts: `rustc_smir::alloc` and `stable_mir::alloc`.

Following the same pattern as `SmirCtxt` and `SmirInterface`, the `rustc_smir::alloc` handles all direct interactions with rustc queries and performs the actual memory allocations, while the `stable_mir::alloc` is responsible for constructing stable components.
2025-07-04 01:33:17 +00:00
Makai
96ad388232 refactor: impl SmirError for stable_mir::Error 2025-07-04 01:33:17 +00:00
Makai
3a43ed2f37 refactor: move IndexedVal from stable_mir to rustc_smir 2025-07-04 01:33:17 +00:00
Makai
7f5e382df4 refactor: make SmirInterface a trait and impl it for SmirContainer
- rewrite all `SmirInterface` apis.
- add `BridgeTys` to impl those associated types in `Bridge`.
- move `**_def()` stuffs living in `impl Tables` from `rustc_internal` to `stable_mir`.
2025-07-04 01:33:09 +00:00
Scott McMurray
15286f220e Remove some unnecessary unsafe in VecCache 2025-07-03 17:42:43 -07: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
Makai
d0130ae186 refactor: add Tables<'tcx, B: Bridge> and SmirContainer 2025-07-03 22:50:52 +00:00
Pavel Grigorenko
ef4dece2cb Port #[rustc_pass_by_value] to the new attribute system 2025-07-04 00:07:56 +03:00
Jubilee Young
3b7f9f9d1b compiler: document all provide fn in hir_analysis and hir_typeck 2025-07-03 13:49:34 -07:00
Jubilee Young
f5fbb2c0a5 compiler: inline 1-2 query provide fn in hir_analysis and hir_typeck
Many small indirections with 1-2 items actively hinders understanding.
Inlines various tiny submodule provides into
- hir_analysis::provide
- hir_analysis::check::provide
- hir_typeck::provide
2025-07-03 13:48:32 -07:00
Michael Goulet
e2e3f5809b Remove PointerLike trait 2025-07-03 20:03:49 +00:00
Urgau
51857ade80 Always use the pure Rust fallback instead of llvm.{maximum,minimum} 2025-07-03 21:04:18 +02:00
Jonathan Brouwer
fee5e3c3aa Port #[no_implicit_prelude] to the new attribute parsing infrastructure
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-07-03 20:59:40 +02:00
Pavel Grigorenko
35453a854c Add tidy-alphabetical for cross-crate attribute match 2025-07-03 21:36:28 +03:00
Daniel Paoliello
2b22d0f0d2 Make __rust_alloc_error_handler_should_panic a function 2025-07-03 10:52:21 -07:00
Guillaume Gomez
62a7fb0fcb Rollup merge of #143369 - bjorn3:cleanup_metadata_loading, r=lcnr
Various refactorings to the metadata loader
2025-07-03 19:45:31 +02:00
bjorn3
21026cae8d Merge run_fat_lto, optimize_fat and autodiff into run_and_optimize_fat_lto 2025-07-03 16:22:32 +00:00
Esteban Küber
7603adc381 Rework logic and provide structured suggestion 2025-07-03 16:14:20 +00:00
bjorn3
8d63c7a1d6 Remove unused config param from WriteBackendMethods::autodiff 2025-07-03 16:13:25 +00:00
bjorn3
9a3aa8fdb1 Remove unnecessary check for fat LTO 2025-07-03 16:13:25 +00:00
bjorn3
779cb00311 Move run_fat_lto call into execute_fat_lto_work_item
This will allow merging all fat LTO steps together. In addition it
reduces the amount of work done on the coordinator thread without
jobserver token.
2025-07-03 16:10:13 +00:00
xizheyin
236b392904 Return early when self resolve failure because of let self = ...
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-07-03 23:47:19 +08:00