about summary refs log tree commit diff
path: root/compiler/rustc_smir/src/stable_mir
AgeCommit message (Collapse)AuthorLines
2025-07-06move `stable_mir` back to its own crate and move `rustc_internal` to ↵Makai-10529/+0
the`stable_mir` crate As part of this reorganization, some traits need to be moved from `rustc_smir::context::traits` to `stable_mir::unstable::internal_cx`. These traits are specifically designed for `InternalCx` to clarify the behavior of different functions that share the same name. This move is necessary to avoid orphan rule violations.
2025-07-04Same for typesMichael Goulet-8/+6
2025-07-04Remove Symbol for Named LateParam/Bound variantsMichael Goulet-9/+10
2025-07-04refactor: implement a new bridge trait `Allocation`Makai-10/+32
2025-07-04refactor: rewrite `adt_repr()`, `adt_discr_for_variant()` and ↵Makai-18/+62
`coroutine_discr_for_variant()`
2025-07-04refactor: avoid calling internal functions in `predicates_of()` and ↵Makai-47/+55
`explicit_predicates_of()`
2025-07-04refactor: move `convert` to `unstable`Makai-385/+316
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-04fix: resolve the unsoundnessMakai-199/+409
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-04refactor: unify `Tables` implementation with bridge types and re-export ↵Makai-142/+80
`IndexedVal` define bridge types for `***Def`s. consolidate scattered `Tables` implementations into single inherent impl.
2025-07-04refactor: remove the `tcx` field in `Tables`Makai-18/+13
the only functionality of `Tables` is caching results. this commit moves calls to rustc queries from `Tables` to `SmirCtxt`.
2025-07-04refactor: move `convert` module to `stable_mir`Makai-0/+3540
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-04refactor: split `rustc_smir::alloc` into two partsMakai-0/+87
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-04refactor: impl `SmirError` for `stable_mir::Error`Makai-4/+13
2025-07-04refactor: move `IndexedVal` from `stable_mir` to `rustc_smir`Makai-16/+14
2025-07-04refactor: make `SmirInterface` a trait and impl it for `SmirContainer`Makai-206/+912
- 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-03setup CI and tidy to use typos for spellchecking and fix few typosklensy-1/+1
2025-07-01Remove support for dyn*Michael Goulet-3/+0
2025-06-28Auto merge of #141759 - 1c3t3a:discriminants-query, r=saethlinbors-1/+10
Insert checks for enum discriminants when debug assertions are enabled Similar to the existing null-pointer and alignment checks, this checks for valid enum discriminants on creation of enums through unsafe transmutes. Essentially this sanitizes patterns like the following: ```rust let val: MyEnum = unsafe { std::mem::transmute<u32, MyEnum>(42) }; ``` An extension of this check will be done in a follow-up that explicitly sanitizes for extern enum values that come into Rust from e.g. C/C++. This check is similar to Miri's capabilities of checking for valid construction of enum values. This PR is inspired by saethlin@'s PR https://github.com/rust-lang/rust/pull/104862. Thank you so much for keeping this code up and the detailed comments! I also pair-programmed large parts of this together with vabr-g@. r? `@saethlin`
2025-06-27Insert checks for enum discriminants when debug assertions are enabledBastian Kersting-1/+10
Similar to the existing nullpointer and alignment checks, this checks for valid enum discriminants on creation of enums through unsafe transmutes. Essentially this sanitizes patterns like the following: ```rust let val: MyEnum = unsafe { std::mem::transmute<u32, MyEnum>(42) }; ``` An extension of this check will be done in a follow-up that explicitly sanitizes for extern enum values that come into Rust from e.g. C/C++. This check is similar to Miri's capabilities of checking for valid construction of enum values. This PR is inspired by saethlin@'s PR https://github.com/rust-lang/rust/pull/104862. Thank you so much for keeping this code up and the detailed comments! I also pair-programmed large parts of this together with vabr-g@.
2025-06-26Rollup merge of #142884 - makai410:coroutine-body, r=celinvalMatthias Krüger-0/+6
StableMIR: Add method to retrieve body of coroutine It would be handy if we can retrieve body of a coroutine in StableMIR.
2025-06-24Add rust-invalid ABIMichael Goulet-0/+1
2025-06-22add method to retrieve body of coroutineMakai-0/+6
2025-06-16Add discriminant_for_variant to CoroutineDefNotLebedev-4/+20
2025-06-16Add discriminant_for_variant to AdtDefNotLebedev-2/+16
2025-06-13Rollup merge of #140770 - folkertdev:custom-abi, r=tgross35Matthias Krüger-0/+3
add `extern "custom"` functions tracking issue: rust-lang/rust#140829 previous discussion: https://github.com/rust-lang/rust/issues/140566 In short, an `extern "custom"` function is a function with a custom ABI, that rust does not know about. Therefore, such functions can only be defined with `#[unsafe(naked)]` and `naked_asm!`, or via an `extern "C" { /* ... */ }` block. These functions cannot be called using normal rust syntax: calling them can only be done from inline assembly. The motivation is low-level scenarios where a custom calling convention is used. Currently, we often pick `extern "C"`, but that is a lie because the function does not actually respect the C calling convention. At the moment `"custom"` seems to be the name with the most support. That name is not final, but we need to pick something to actually implement this. r? `@traviscross` cc `@tgross35` try-job: x86_64-apple-2
2025-06-12add `extern "custom"` functionsFolkert de Vries-0/+3
2025-06-12Rollup merge of #141307 - b-naber:closure-body, r=celinvalMatthias Krüger-0/+8
Add method to retrieve body of closure in stable-mir fixes https://github.com/rust-lang/project-stable-mir/issues/85 r? `@celinval`
2025-06-10Implement representation options to smirShoyu Vanilla-1/+46
2025-06-02add doc comment and a test with a generic closureb-naber-0/+2
2025-06-02add `body` to `ClosureDef`b-naber-0/+6
2025-04-28Auto merge of #140388 - GuillaumeGomez:rollup-aj9o3ch, r=GuillaumeGomezbors-1/+1
Rollup of 7 pull requests Successful merges: - #140056 (Fix a wrong error message in 2024 edition) - #140220 (Fix detection of main function if there are expressions around it) - #140249 (Remove `weak` alias terminology) - #140316 (Introduce `BoxMarker` to improve pretty-printing correctness) - #140347 (ci: clean more disk space in codebuild) - #140349 (ci: use aws codebuild for the `dist-x86_64-linux` job) - #140379 (rustc-dev-guide subtree update) r? `@ghost` `@rustbot` modify labels: rollup
2025-04-28Rollup merge of #140249 - BoxyUwU:remove_weak_alias_terminology, r=oli-obkGuillaume Gomez-1/+1
Remove `weak` alias terminology I find the "weak" alias terminology to be quite confusing. It implies the existence of "strong" aliases (which do not exist) and I'm not really sure what about weak aliases is "weak". I much prefer "free alias" as the term. I think it's much more obvious what it means as "free function" is a well defined term that already exists in rust. It's also a little confusing given "weak alias" is already a term in linker/codegen spaces which are part of the compiler too. Though I'm not particularly worried about that as it's usually very obvious if you're talking about the type system or not lol. I'm also currently trying to write documentation about aliases and it's somewhat awkward/confusing to be talking about *weak* aliases, when I'm not really sure what the basis for that as the term actually *is*. I would also be happy to just find out there's a nice meaning behind calling them "weak" aliases :-) r? `@oli-obk` maybe we want a types MCP to decide on a specific naming here? or maybe we think its just too late to go back on this naming decision ^^'
2025-04-28AsyncDrop implementation using shim codegen of ↵Andrew Zhogin-11/+23
async_drop_in_place::{closure}, scoped async drop added.
2025-04-26convert some `GenericArg` to `Term`lcnr-1/+1
2025-04-24Remove `weak` alias terminologyBoxy-1/+1
2025-04-24Rollup merge of #139852 - makai410:smir-refactor, r=celinvalMatthias Krüger-107/+321
StableMIR: Implement `CompilerInterface` This PR implements part of [the document](https://hackmd.io/``@celinaval/H1lJBGse0).`` With `TablesWrapper` wrapped by `CompilerInterface`, the stable-mir's TLV stores a pointer to `CompilerInterface`, while the rustc-specific TLV stores a pointer to tables.
2025-04-23Make `SmirInterface` pub(crate) and rename `Context` to `SmirContext`Makai-91/+103
Co-authored-by: Celina G. Val <celinval@amazon.com>
2025-04-18Implement `SmirInterface`Makai-107/+309
- With `Context` wrapped by `SmirInterface`, the stable-mir's TLV stores a pointer to `SmirInterface`, while the rustc-specific TLV stores a pointer to tables. - This PR make the `rustc_smir` mod public.
2025-04-15Move `name` field from `AssocItem` to `AssocKind` variants.Nicholas Nethercote-15/+16
To accurately reflect that RPITIT assoc items don't have a name. This avoids the use of `kw::Empty` to mean "no name", which is error prone. Helps with #137978.
2025-04-15Move `opt_rpitit_info` field to `hir::AssocKind::Type`.Nicholas Nethercote-9/+11
From `hir::AssocItem`.
2025-04-14Move `has_self` field to `hir::AssocKind::Fn`.Nicholas Nethercote-6/+3
`hir::AssocItem` currently has a boolean `fn_has_self_parameter` field, which is misplaced, because it's only relevant for associated fns, not for associated consts or types. This commit moves it (and renames it) to the `AssocKind::Fn` variant, where it belongs. This requires introducing a new C-style enum, `AssocTag`, which is like `AssocKind` but without the fields. This is because `AssocKind` values are passed to various functions like `find_by_ident_and_kind` to indicate what kind of associated item should be searched for, and having to specify `has_self` isn't relevant there. New methods: - Predicates `AssocItem::is_fn` and `AssocItem::is_method`. - `AssocItem::as_tag` which converts `AssocItem::kind` to `AssocTag`. Removed `find_by_name_and_kinds`, which is unused. `AssocItem::descr` can now distinguish between methods and associated functions, which slightly improves some error messages.
2025-04-06remove compiler support for `extern "rust-intrinsic"` blocksSkgland-1/+0
2025-04-05let `rustc_smir` host `stable_mir` for refactoringMakai-0/+5718
2023-09-25Split out the stable part of smir into its own crate to prevent accidental ↵Oli Scherer-1626/+0
usage of forever unstable things
2023-09-25Move `Opaque` to `stable_mir`Oli Scherer-15/+34
2023-09-25Fix test by adding a stable way to get an opaque DefKindOli Scherer-0/+10
2023-09-25Eliminate escape hatchOli Scherer-8/+9
2023-09-24Remove span from BrAnon.Camille GILLOT-1/+1
2023-09-14Rollup merge of #115772 - ouz-a:smir_span2, r=oli-obkMatthias Krüger-2/+11
Improve Span in smir Addressing https://github.com/rust-lang/project-stable-mir/issues/31 r? ``@oli-obk``
2023-09-14span is indexouz-a-2/+11