Commit Graph

48659 Commits

Author SHA1 Message Date
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
bjorn3
332f1b1bdd Pass in autodiff items when starting the coordinator thread
As opposed to sending a message to the coordinator thread.
2025-07-03 15:39:19 +00:00
Camille GILLOT
3380bfd1a0 Replace kw_span by full span. 2025-07-03 14:59:27 +00:00
bjorn3
797084dc92 Split generate_lto_work between fat and thin-LTO cases 2025-07-03 14:50:28 +00:00
bjorn3
ee280a596d Fat LTO always produces a single object file, so -Zcombine-cgu has no effect 2025-07-03 14:44:26 +00:00
bjorn3
7fd78df346 Move dcx creation into WriteBackendMethods::codegen 2025-07-03 14:43:09 +00:00
bjorn3
653bb64c75 Remove LtoModuleCodegen
Most uses of it either contain a fat or thin lto module. Only
WorkItem::LTO could contain both, but splitting that enum variant
doesn't complicate things much.
2025-07-03 14:28:18 +00:00
Scott Schafer
6bef238b63 refactor: Make -Ztrack-diagnostics emit like a note 2025-07-03 07:19:25 -06:00
bjorn3
47caa0a927 Make most CrateLocator fields private
This ensures they don't get out of sync
2025-07-03 11:57:56 +00:00
bjorn3
57d6c1bab8 Have a separate code path for -Zdual-proc-macro
This makes it clearer when the locator and when crate_rejections is updated
2025-07-03 11:55:40 +00:00
bjorn3
87633054dc Pass CrateRejections separately from CrateLocator
This allows all CrateLocator methods to take &self.
2025-07-03 11:55:39 +00:00
bjorn3
121dac5cbb Deduplicate getting the path of a lib candidate 2025-07-03 11:52:19 +00:00
Jana Dönszelmann
0aaac883de Rollup merge of #143038 - Qelxiros:142676-private-dependency-traits, r=tgross35
avoid suggesting traits from private dependencies

fixes rust-lang/rust#142676
fixes rust-lang/rust#138191

r? ``@tgross35``
2025-07-03 13:29:36 +02:00
Jana Dönszelmann
5026d0cd8e Rollup merge of #142876 - JonathanBrouwer:target_feature_parser, r=oli-obk
Port `#[target_feature]` to new attribute parsing infrastructure

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

r? ``@jdonszelmann``
2025-07-03 13:29:36 +02: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
Jonathan Brouwer
3d5d72b761 Port #[target_feature] to the new attribute parsing infrastructure
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-07-03 07:54:19 +02:00
Matthias Krüger
bc0262d0f1 Rollup merge of #143327 - RalfJung:miri-type-validity-error, r=oli-obk
miri: improve errors for type validity assertion failures

Miri has pretty nice errors for type validity violations, printing which field in the type the problem occurs at and so on.

However, we don't see these errors when using e.g. `mem::zeroed` as that uses `assert_zero_valid` to bail out before Miri can detect the UB.

Similar to what we did with `@saethlin's` UB checks, I think we should disable such language UB checks in Miri so that we can get better error messages. If we go for this we should probably say this in the intrinsic docs as well so that people don't think they can rely on these intrinsics catching anything.

Furthermore, I slightly changed `MaybeUninit::assume_init` so that the `.value` field does not show up in error messages any more.

`@rust-lang/miri` what do you think?
2025-07-03 05:21:36 +02:00
Matthias Krüger
7e600de3c8 Rollup merge of #143324 - RalfJung:native-call-prep, r=oli-obk
interpret: move the native call preparation logic into Miri

`@nia-e` has to do a bunch of changes to this logic for her native call ptrace work, and it's getting annoying that the logic is split between Miri and rustc. So this moves the logic to Miri, keeping just the generic traversal part in rustc. It is unfortunate that this means we have to expose `get_alloc_raw`/`get_alloc_raw_mut`... I hope the function name is scary enough to reduce the risk of misuse.

r? `@oli-obk`
2025-07-03 05:21:35 +02:00