about summary refs log tree commit diff
path: root/compiler/stable_mir/src/mir
AgeCommit message (Collapse)AuthorLines
2023-12-05Change ty_with_args to return Ty instead of ResultCelina G. Val-1/+1
Although, we would like to avoid crashes whenever possible, and that's why I wanted to make this API fallible. It's looking pretty hard to do proper validation. I think many of our APIs will unfortunately depend on the user doing the correct thing since at the MIR level we are working on, we expect types to have been checked already.
2023-12-04Add FieldDef to StableMIR and methods to get typeCelina G. Val-1/+1
2023-12-04Finish implementing `RustcInternal` for `TyKind`Celina G. Val-1/+1
This will allow us to provide methods to create `Ty` inside the stable MIR, which can be helpful while handling pointers and other stuff.
2023-12-04Add Variant and a few more APIs to stable_mirCelina G. Val-22/+33
2023-12-01Add more information to stable InstanceCelina G. Val-9/+34
- Retrieve `FnSig`. - Implement CrateDef for InstanceDef. - Add VTable index for Virtual instances.
2023-11-30Fix SwitchTarget pretty printCelina G. Val-4/+1
We currently rely on the order of successors to be conditional branches first, followed by the otherwise target.
2023-11-30Change SwitchTarget representationCelina G. Val-38/+67
The new structure encodes its invariant, which reduces the likelihood of having an inconsistent representation. It is also more intuitive and user friendly. I encapsulated the structure for now in case we decide to change it back.
2023-11-27Rollup merge of #118172 - ouz-a:improve_emit_stable1, r=celinvalMichael Goulet-9/+277
Add `pretty_terminator` to pretty stable-mir ~Because we don't have successors in `stable_mir` this is somewhat lacking but it's better than nothing~, also fixed bug(?) with `Opaque` which printed extra `"` when we try to print opaqued `String`. **Edit**: Added successors so this covers Terminators as a whole. r? `@celinval`
2023-11-27add otherwise into targetsouz-a-2/+2
2023-11-26add successors and their formatterouz-a-23/+159
2023-11-25add pretty_terminatorouz-a-1/+133
2023-11-25is_{some,ok}_andMichael Goulet-1/+1
2023-11-24Fix smir's `Ty::Ref` pretty printingCelina G. Val-2/+4
2023-11-23Improve documentation and fix the fixme commentCelina G. Val-2/+8
2023-11-22Add CrateDef trait and methods to get def namesCelina G. Val-4/+23
2023-11-21Add allocation test and a bit more documentationCelina G. Val-0/+7
2023-11-21Add support to get virtual table allocationCelina G. Val-0/+7
2023-11-21Add support to global allocation to stable-mirCelina G. Val-1/+61
2023-11-22Auto merge of #118152 - matthiaskrgr:rollup-bqcck4w, r=matthiaskrgrbors-4/+74
Rollup of 5 pull requests Successful merges: - #117972 (Add VarDebugInfo to Stable MIR) - #118109 (rustdoc-search: simplify `checkPath` and `sortResults`) - #118110 (Document `DefiningAnchor` a bit more) - #118112 (Don't ICE when ambiguity is found when selecting `Index` implementation in typeck) - #118135 (Remove quotation from filename in stable_mir) Failed merges: - #118012 (Add support for global allocation in smir) r? `@ghost` `@rustbot` modify labels: rollup
2023-11-21Fix `clippy::needless_borrow` in the compilerNilstrieb-3/+3
`x clippy compiler -Aclippy::all -Wclippy::needless_borrow --fix`. Then I had to remove a few unnecessary parens and muts that were exposed now.
2023-11-21de-structure variable and add stablesouz-a-4/+6
2023-11-21Add VarDebugInfo to Stable MIRouz-a-4/+72
2023-11-20Improve code per PR commentsCelina G. Val-29/+35
- Simplified DefTy::internal - Break down place::ty() method
2023-11-20Add place.ty() and Ty build from a kind to smirCelina G. Val-17/+73
2023-11-17use new apis and add new functionouz-a-12/+8
2023-11-17move pretty into stable_mirOğuz Ağcayazı-2/+286
2023-11-17better formatting for statementsOğuz Ağcayazı-1/+1
2023-11-17emit basic smirOğuz Ağcayazı-0/+2
2023-11-16Fix has_body() and change resolve_drop_in_place() sigCelina G. Val-2/+1
Fixed the `has_body()` function operator. Before that, this function was returning false for all shims. Change resolve_drop_in_place() to also return an instance for empty shims, since they may still be required for vtable construction.
2023-11-16Address PR commentsCelina G. Val-2/+2
2023-11-16Add more APIs and fix `Instance::body`Celina G. Val-8/+60
Add more APIs to retrieve information about types, and add more instance resolution options. Make `Instance::body()` return an Option<Body>, since not every instance might have an available body. For example, foreign instances, virtual instances, dependencies.
2023-11-16Fix bug on MIRVisitorCelina G. Val-2/+2
We were not iterating over all local variables due to a typo.
2023-11-14Make UserTypeProjection projections OpaqueKirby Linvill-5/+1
Also shifts comments explaining why Stable MIR drops an optional variant name field, for `Downcast` projection elements, to the `Place::stable` function.
2023-11-10Ignore FieldIdx and VariantIdx examples in docsKirby Linvill-2/+2
2023-11-10Add SMIR visitor for Places and projectionsKirby Linvill-2/+33
2023-11-09Defer Place ty implementation in Stable Mir to later PRKirby Linvill-2/+4
2023-11-09Remove rich UserTypeProjection projections in SMIRKirby Linvill-13/+12
It's not clear to me (klinvill) that UserTypeProjections are produced anymore with the removal of type ascriptions as per https://github.com/rust-lang/rfcs/pull/3307. Furthermore, it's not clear to me which variants of ProjectionElem could appear in such projections. For these reasons, I'm reverting projections in UserTypeProjections to simple strings until I can get more clarity on UserTypeProjections.
2023-11-09Add stable MIR Projections support based on MIR structureKirby Linvill-2/+115
This commit includes richer projections for both Places and UserTypeProjections. However, the tests only touch on Places. There are also outstanding TODOs regarding how projections should be resolved to produce Place types, and regarding if UserTypeProjections should just contain ProjectionElem<(),()> objects as in MIR.
2023-11-08rename `BorrowKind::Shallow` to `Fake`lcnr-2/+3
also adds some comments
2023-11-01Auto merge of #114208 - GKFX:offset_of_enum, r=wesleywiserbors-1/+1
Support enum variants in offset_of! This MR implements support for navigating through enum variants in `offset_of!`, placing the enum variant name in the second argument to `offset_of!`. The RFC placed it in the first argument, but I think it interacts better with nested field access in the second, as you can then write things like ```rust offset_of!(Type, field.Variant.field) ``` Alternatively, a syntactic distinction could be made between variants and fields (e.g. `field::Variant.field`) but I'm not convinced this would be helpful. [RFC 3308 # Enum Support](https://rust-lang.github.io/rfcs/3308-offset_of.html#enum-support-offset_ofsomeenumstructvariant-field_on_variant) Tracking Issue #106655.
2023-10-31Enums in offset_of: update based on est31, scottmcm & llogiq reviewGeorge Bateman-1/+1
2023-10-30Add a stable MIR visitorCelina G. Val-36/+456
Add a few utility functions as well and extend most `mir` and `ty` ADTs to implement `PartialEq` and `Eq`.
2023-10-29Auto merge of #116447 - oli-obk:gen_fn, r=compiler-errorsbors-0/+1
Implement `gen` blocks in the 2024 edition Coroutines tracking issue https://github.com/rust-lang/rust/issues/43122 `gen` block tracking issue https://github.com/rust-lang/rust/issues/117078 This PR implements `gen` blocks that implement `Iterator`. Most of the logic with `async` blocks is shared, and thus I renamed various types that were referring to `async` specifically. An example usage of `gen` blocks is ```rust fn foo() -> impl Iterator<Item = i32> { gen { yield 42; for i in 5..18 { if i.is_even() { continue } yield i * 2; } } } ``` The limitations (to be resolved) of the implementation are listed in the tracking issue
2023-10-26Rollup merge of #117095 - klinvill:smir-fn-arg-count, r=oli-obkMatthias Krüger-3/+53
Add way to differentiate argument locals from other locals in Stable MIR This PR resolves rust-lang/project-stable-mir#47 which request a way to differentiate argument locals in a SMIR `Body` from other locals. Specifically, this PR exposes the `arg_count` field from the MIR `Body`. However, I'm opening this as a draft PR because I think there are a few outstanding questions on how this information should be exposed and described. Namely: - Is exposing `arg_count` the best way to surface this information to SMIR users? Would it be better to leave `arg_count` as a private field and add public methods (e.g. `fn arguments(&self) -> Iter<'_, LocalDecls>`) that may use the underlying `arg_count` info from the MIR body, but expose this information to users in a more convenient form? Or is it best to stick close to the current MIR convention? - If the answer to the above point is to stick with the current MIR convention (`arg_count`), is it reasonable to also commit to sticking to the current MIR convention that the first local is always the return local, while the next `arg_count` locals are always the (in-order) argument locals? - Should `Body` in SMIR only represent function bodies (as implied by the comment I added)? That seems to be the current case in MIR, but should this restriction always be the case for SMIR? r? `@celinval` r? `@oli-obk`
2023-10-26Use two slice expressions to save on an offset repetitionOli Scherer-1/+1
2023-10-26Add hir::GeneratorKind::GenOli Scherer-0/+1
2023-10-26Update Place and Operand to take slicesKirby Linvill-2/+2
The latest locals() method in stable MIR returns slices instead of vecs. This commit also includes fixes to the existing tests that previously referenced the private locals field.
2023-10-26Rename internal_locals to inner_localsKirby Linvill-4/+4
The word internal has connotations about information that's not exposed. It's more accurate to say that the remaining locals apply only to the inner part of the function, so I'm renaming them to inner locals.
2023-10-25Rollup merge of #117175 - oli-obk:gen_fn_split, r=compiler-errorsMatthias Krüger-2/+2
Rename AsyncCoroutineKind to CoroutineSource pulled out of https://github.com/rust-lang/rust/pull/116447 Also refactors the printing infra of `CoroutineSource` to be ready for easily extending it with a `Gen` variant for `gen` blocks
2023-10-25Add a public API to get all body localsKirby Linvill-0/+8
This is particularly helpful for the ui tests, but also could be helpful for Stable MIR users who just want all the locals without needing to concatenate responses