about summary refs log tree commit diff
AgeCommit message (Collapse)AuthorLines
2025-07-04Rollup merge of #140643 - makai410:smir-refactor-migrate, r=oli-obk,celinvalMatthias Krüger-2224/+3598
Refactor StableMIR This PR refactors stable-mir according to the guidance in [this doc](https://hackmd.io/jBRkZLqAQL2EVgwIIeNMHg). It reverses the dependency between `rustc_smir` and `stable_mir`, making `rustc_smir` completely agnostic of `stable_mir`. Under the new architecture, the `rustc_smir` crate would retain direct access to rustc queries, while `stable_mir` should proxy all such requests through `rustc_smir` instead of accessing rustc's internals directly. `stable_mir` would only be responsible for the conversion between internal and stable constructs. This PR mainly introduces these changes: - **Bridge / Tables<'tcx, B: Bridge>** ```rust /// A trait defining types that are used to emulate StableMIR components, which is really /// useful when programming in stable_mir-agnostic settings. pub trait Bridge { type DefId: Copy + Debug + PartialEq + IndexedVal; type AllocId: Copy + Debug + PartialEq + IndexedVal; type Span: Copy + Debug + PartialEq + IndexedVal; type Ty: Copy + Debug + PartialEq + IndexedVal; type InstanceDef: Copy + Debug + PartialEq + IndexedVal; type TyConstId: Copy + Debug + PartialEq + IndexedVal; type MirConstId: Copy + Debug + PartialEq + IndexedVal; type Layout: Copy + Debug + PartialEq + IndexedVal; type Error: SmirError; } pub struct Tables<'tcx, B: Bridge> { tcx: TyCtxt<'tcx>, pub(crate) def_ids: IndexMap<DefId, B::DefId>, pub(crate) alloc_ids: IndexMap<AllocId, B::AllocId>, pub(crate) spans: IndexMap<rustc_span::Span, B::Span>, pub(crate) types: IndexMap<Ty<'tcx>, B::Ty>, pub(crate) instances: IndexMap<ty::Instance<'tcx>, B::InstanceDef>, pub(crate) ty_consts: IndexMap<ty::Const<'tcx>, B::TyConstId>, pub(crate) mir_consts: IndexMap<mir::Const<'tcx>, B::MirConstId>, pub(crate) layouts: IndexMap<rustc_abi::Layout<'tcx>, B::Layout>, } ``` Since `rustc_smir` needs these stable types somewhere, using associated types is a good approach. - **SmirContainer / SmirInterface** ```rust /// A container which is used for TLS. pub struct SmirContainer<'tcx, B: Bridge> { pub tables: RefCell<Tables<'tcx, B>>, pub cx: RefCell<SmirCtxt<'tcx, B>>, } impl<'tcx> SmirInterface for SmirContainer<'tcx, BridgeTys> { // ... } /// Provides direct access to rustc's internal queries. /// /// The [`crate::stable_mir::compiler_interface::SmirInterface`] must go through /// this context to obtain rustc-level information. pub struct SmirCtxt<'tcx, B: Bridge> { tcx: TyCtxt<'tcx>, _marker: PhantomData<B>, } ``` This PR moves `Tables` from `SmirCtxt` to a new `SmirContainer` struct, since mutable borrows of `tables` should only be managed by `SmirInterface`. This change prevents `SmirCtxt` from holding separate borrows and requires passing `tables` explicitly when needed: ```rust impl<'tcx, B: Bridge> SmirCtxt<'tcx, B> { // ... /// Get the body of an Instance which is already monomorphized. pub fn instance_body( &self, instance: ty::Instance<'tcx>, tables: &mut Tables<'tcx, B>, ) -> Option<Body<'tcx>> { tables .instance_has_body(instance) .then(|| BodyBuilder::new(self.tcx, instance).build(tables)) } // ... } ``` This PR introduces `SmirContainer` as a separate struct rather than bundling it into a `SmirInterface` struct. This separation makes the architecture more modular and easier to reason about. - **context/traits.rs** We use this 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`. Here is a real-world use case: ```rust impl RustcInternal for ExistentialTraitRef { type T<'tcx> = rustc_ty::ExistentialTraitRef<'tcx>; fn internal<'tcx>( &self, tables: &mut Tables<'_, BridgeTys>, cx: &SmirCtxt<'tcx, BridgeTys>, ) -> Self::T<'tcx> { use rustc_smir::context::SmirExistentialTraitRef; cx.new_from_args(self.def_id.0.internal(tables, cx), self.generic_args.internal(tables, cx)) } } ``` - **Separation of `rustc_smir::alloc`** The previous `rustc_smir::alloc` had many direct calls to rustc queries. This PR 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. - **Removal of `convert/error.rs`** We use `SmirError::from_internal` instead, since implementing `Stable` for these internal errors would be redundant—`tables` is not actually used. If we later need to add something like `LayoutError` to `stable_mir`, we could implement it as follows: ```rust impl SmirError for stable_mir::LayoutError { fn from_internal<T: Debug>(err: T) -> Self { // ... } } ``` **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)`. r? `@celinval`
2025-07-04Add comment and move assertion.Camille GILLOT-8/+12
2025-07-04Lighten formatting.Camille GILLOT-5/+4
2025-07-04Reuse metadata file from work products.Camille GILLOT-28/+83
2025-07-04Save metadata among work products.Camille GILLOT-4/+34
2025-07-04Remove names_imported_by_glob_use query.Camille GILLOT-1/+1
2025-07-04Remove names_imported_by_glob_use query.Camille GILLOT-8/+1
2025-07-04Update to nightly-2025-07-04Antoni Boucher-1/+1
2025-07-04Merge pull request #20170 from Veykril/push-vtsmzopsunswLaurențiu Nicola-3/+12
Improve flycheck and build script progress reporting
2025-07-04Merge branch 'master' into sync_from_rust_2025_07_04Antoni Boucher-53/+44
2025-07-04declare data race and weak memory support as non-experimentalRalf Jung-2/+2
2025-07-04Add test false-sealed-traits-note.rsxizheyin-0/+34
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-07-04Simplify clippy lints page further (#15208)Samuel Tardieu-15/+14
Follow-up of rust-lang/rust-clippy#15140. This time, I removed some unneeded `<span>` wrappings and some unneeded CSS classes. As usual, no changes in the UI. Before this PR: 1876091 With this PR: 1751097 Reduction: -6.6% r? @samueltardieu changelog: Reduce page size and number of DOM elements on clippy lints page
2025-07-04Merge pull request #2492 from rust-lang/tshepang-patch-1Tshepang Mbambo-3/+2
external-repos.md: small fixes
2025-07-04external-repos.md: small fixesTshepang Mbambo-3/+2
2025-07-04Simplify clippy lints page furtherGuillaume Gomez-15/+14
2025-07-04clippy fix: indentationMarijn Schouten-46/+47
2025-07-04clippy fix: rely on autoderefMarijn Schouten-7/+7
2025-07-04Merge pull request #2491 from Kobzol/switch-to-rustc-josh-sync许杰友 Jieyou Xu (Joe)-820/+57
2025-07-04Document `rustc-josh-sync`Jakub Beránek-30/+52
2025-07-04Auto merge of #143247 - cjgillot:metadata-no-red, r=petrochenkovbors-28/+23
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-04Reduce page size and number of DOM elements on clippy lints page (#15140)Samuel Tardieu-18/+29
This is the first pass of "reducing the size of the clippy lints page" I'm currently going through. This first one reduces the size page but mostly reduces the number of DOM elements. Page size change: * Before this PR: 1938957 * With this PR: 1876167 * Reduction: -3.2% r? @Alexendoo changelog: Reduce page size and number of DOM elements on clippy lints page
2025-07-04Improve flycheck and build script progress reportingLukas Wirth-3/+12
2025-07-04Merge pull request #20169 from Veykril/push-quvvsupnqqwvLukas Wirth-11/+49
Skip unnecessary `eq` work in `BodySourceMap`
2025-07-04Update CI workflow to use rustc-josh-syncJakub Beránek-5/+4
2025-07-04Remove `josh-sync` tooling and update READMEJakub Beránek-789/+5
2025-07-04Skip unnecessary `eq` work in `BodySourceMap`Lukas Wirth-11/+49
2025-07-04Merge pull request #20031 from jnyfah/some-branchLukas Wirth-35/+75
Fix: Resolve HIR display length issues and improve adjustment tooltips
2025-07-04Merge pull request #20168 from Veykril/push-wsozylrmsynsLukas Wirth-21/+11
minor: Handle match arm commas in `make::match_arm`
2025-07-04bump termize (#15207)Samuel Tardieu-1/+1
Bump termize to remove one more dep with winapi (https://github.com/JohnTitor/termize/releases/tag/v0.2.0) changelog: none
2025-07-04Merge pull request #2489 from Kobzol/pull许杰友 Jieyou Xu (Joe)-18912/+759820
2025-07-04minor: Handle match arm commas in `make::match_arm`Lukas Wirth-21/+11
Co-authored-by: Giga Bowser <45986823+Giga-Bowser@users.noreply.github.com>
2025-07-04Merge ref 'c96a69059ecc' from rust-lang/rustJakub Beránek-18911/+759816
Pull recent changes from https://github.com/rust-lang/rust via Josh. Upstream ref: c96a69059ecc618b519da385a6ccd03155aa0237 Filtered ref: 7b9552d4c39c31aabf6749629da2d4a7e6e1cd60 This merge was created using https://github.com/rust-lang/josh-sync.
2025-07-04Prepare for merging from rust-lang/rustJakub Beránek-1/+1
This updates the rust-version file to c96a69059ecc618b519da385a6ccd03155aa0237.
2025-07-04Add josh-sync config fileJakub Beránek-0/+3
2025-07-04bump termizeklensy-1/+1
2025-07-04Get rid of build-powerpc64le-toolchain.shJens Reidel-90/+7
The dist-powerpc64le-linux-musl runner never actually used the toolchain that the script produced, it instead used the one from crosstool-ng. The dist-powerpc64le-linux-gnu runner did use it, from what I can tell mainly to get a glibc 2.17 version with ppc64le support backported. Since crosstool-ng has the necessary patches, we can just use crosstool-ng to get an appropriate toolchain. While at it, use kernel 3.10 headers since that's the version documented in platform support for this target. Signed-off-by: Jens Reidel <adrian@travitia.xyz>
2025-07-04bump termize depklensy-5/+15
2025-07-04treat box patterns as deref patterns in THIR and usefulness analysisdianne-81/+55
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-04Merge pull request #20148 from ShoyuVanilla/sysroot-no-depsLukas Wirth-4/+15
fix: Honor `rust-analyzer.cargo.noDeps` option when fetching sysroot metadata
2025-07-04Merge pull request #20165 from Hmikihiro/migrate-unmerge_match_armLukas Wirth-22/+20
Migrate `unmerge_match_arm` Assist to use `SyntaxEditor`
2025-07-04Merge pull request #20167 from ChayimFriedman2/enum-derive-defaultLukas Wirth-72/+190
fix: Fix some things with builtin derives
2025-07-04Assign dependency bump PRs to meclubby789-0/+4
2025-07-04Auto merge of #143237 - JonathanBrouwer:no_implicit_prelude_parser, ↵bors-26/+77
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-04Merge pull request #4442 from rust-lang/rustup-2025-07-04Oli Scherer-1026/+2059
Automatic Rustup
2025-07-03Allow all MIR `Aggregate`s to take the operand path (if layout permits)Scott McMurray-75/+372
2025-07-03Block SIMD in transmute_immediate; delete `OperandValueKind`Scott McMurray-190/+101
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-04Merge from rustcThe Miri Cronjob Bot-1025/+2058
2025-07-04Enable xgot feature for mips64 musl targetsJens Reidel-2/+2
This was missed in b65c2afdfd9aaee977302516c9ef177861abfe74, 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-04Preparing for merge from rustcThe Miri Cronjob Bot-1/+1