about summary refs log tree commit diff
path: root/compiler/stable_mir/src/ty.rs
AgeCommit message (Collapse)AuthorLines
2023-12-18Add function ABI and type layout to StableMIRCelina G. Val-0/+6
This change introduces a new module to StableMIR named `abi` with information from `rustc_target::abi` and `rustc_abi`, that allow users to retrieve more low level information required to perform bit-precise analysis. The layout of a type can be retrieved via `Ty::layout`, and the instance ABI can be retrieved via `Instance::fn_abi()`. To properly handle errors while retrieve layout information, we had to implement a few layout related traits.
2023-12-15Add a method to check if type is a CStrCelina G. Val-0/+6
2023-12-14Address PR commentsCelina G. Val-4/+8
- Remove `fn_sig()` from Instance. - Change return value of `AssertMessage::description` to `Cow<>`. - Add assert to instance `ty()`. - Generalize uint / int type creation.
2023-12-13Add spread arg and missing CoroutineKindCelina G. Val-3/+7
2023-12-11Remove scalar fn and tighten the BiOp Ty assertionsCelina G. Val-19/+1
2023-12-11Fix doc commentCelina G. Val-1/+1
2023-12-11Fix BinOp ty assertion and `fn_sig` for closuresCelina G. Val-2/+137
Also added a few more util methods to TyKind to check for specific types.
2023-12-07Add tests to allocation methods and fix is_null()Celina G. Val-1/+5
2023-12-07Add instance evaluation and methods to read allocCelina G. Val-4/+96
The instance evaluation is needed to handle intrinsics such as `type_id` and `type_name`. Since we now use Allocation to represent all evaluated constants, provide a few methods to help process the data inside an allocation.
2023-12-06Add sanity check to `BinOp::ty()`Celina G. Val-0/+13
2023-12-06Add method to get type of an Rvalue in StableMIRCelina G. Val-0/+48
2023-12-05Change ty_with_args to return Ty instead of ResultCelina G. Val-2/+7
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/+41
2023-12-04Add Variant and a few more APIs to stable_mirCelina G. Val-0/+71
2023-12-01Add more information to stable InstanceCelina G. Val-3/+35
- Retrieve `FnSig`. - Implement CrateDef for InstanceDef. - Add VTable index for Virtual instances.
2023-11-24Rollup merge of #118215 - celinval:smir-def-paths, r=ouz-aMichael Goulet-28/+45
Add common trait for crate definitions In stable mir, we specialize DefId, however some functionality is the same for every definition, such as def paths, and getting their crate. Use a trait to implement those.
2023-11-22Auto merge of #118120 - compiler-errors:closure-kind, r=lcnrbors-1/+0
Remove `PredicateKind::ClosureKind` We don't need the `ClosureKind` predicate kind -- instead, `Fn`-family trait goals are left as ambiguous, and we only need to make progress on `FnOnce` projection goals for inference purposes. This is similar to how we do confirmation of `Fn`-family trait and projection goals in the new trait solver, which also doesn't use the `ClosureKind` predicate. Some hacky logic is added in the second commit so that we can keep the error messages the same.
2023-11-22Add CrateDef trait and methods to get def namesCelina G. Val-28/+45
2023-11-21Add support to global allocation to stable-mirCelina G. Val-1/+2
2023-11-21Fix `clippy::needless_borrow` in the compilerNilstrieb-1/+1
`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-21Remove ClosureKind predicate kindMichael Goulet-1/+0
2023-11-20Add place.ty() and Ty build from a kind to smirCelina G. Val-1/+76
2023-11-16Add more APIs and fix `Instance::body`Celina G. Val-2/+147
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-15Auto merge of #117908 - lcnr:region-kind-rename, r=BoxyUwUbors-2/+2
finish `RegionKind` renaming second step of https://github.com/rust-lang/types-team/issues/95 continues the work from #117876. While working on this and I encountered a bunch of further cleanup which I'll either open a tracking issue for or will do in a separate PR: - rewrite the `RegionKind` docs, they still talk about `ReEmpty` and are generally out of date - rename `DescriptionCtx` to `DescriptionCtxt` - what is `CheckRegions::Bound`? - `collect_late_bound_regions` et al - `erase_late_bound_regions` -> `instantiate_bound_regions_with_erased`? - `EraseEarlyRegions` visitor should be removed, feels duplicate r? `@BoxyUwU`
2023-11-14finish `RegionKind` renamelcnr-2/+2
- `ReFree` -> `ReLateParam` - `ReEarlyBound` -> `ReEarlyParam`
2023-11-14Auto merge of #117787 - ouz-a:smir_coroutinewitness, r=celinvalbors-0/+4
Add CoroutineWitness to covered types in smir Previously we accepted `CouroutineWitness` as `unreachable!` but https://github.com/rust-lang/project-stable-mir/issues/50 shows it is indeed reachable, this pr fixes that and covers `CouroutineWitness`
2023-11-13rename `ReLateBound` to `ReBound`lcnr-1/+1
other changes: - `Region::new_late_bound` -> `Region::new_bound` - `Region::is_late_bound` -> `Region::is_bound`
2023-11-10add CoroutineWitness to covered typesOğuz Ağcayazı-0/+4
2023-10-30Add a stable MIR visitorCelina G. Val-46/+46
Add a few utility functions as well and extend most `mir` and `ty` ADTs to implement `PartialEq` and `Eq`.
2023-10-26Specialize ZeroSized constantsCelina G. Val-0/+3
ZeroSized constants can be represented as `mir::Const::Val` even if their layout is not yet known. In those cases, CrateItem::body() was crashing when trying to convert a `ConstValue::ZeroSized` into its stable counterpart `ConstantKind::Allocated`. Instead, we now map `ConstValue::ZeroSized` into a new variant: `ConstantKind::ZeroSized`.
2023-10-24Use IndexMap for handling stable TyCelina G. Val-19/+18
2023-10-24Remove fold code and add Const::internal()Celina G. Val-7/+35
We are not planning to support user generated constant in the foreseeable future, so we are removing the Fold logic for now in favor of the Instance::resolve logic. The Instance::resolve was however incomplete, since we weren't handling internalizing constants yet. Thus, I added that. I decided to keep the Const fields private in case we decide to translate them lazily.
2023-10-21Rollup merge of #116964 - celinval:smir-mono-body, r=oli-obkMatthias Krüger-0/+1
Add stable Instance::body() and RustcInternal trait The `Instance::body()` returns a monomorphized body. For that, we had to implement visitor that monomorphize types and constants. We are also introducing the RustcInternal trait that will allow us to convert back from Stable to Internal. Note that this trait is not yet visible for our users as it depends on Tables. We should probably add a new trait that can be exposed. The tests here are very simple, and I'm planning on creating more exhaustive tests in the project-mir repo. But I was hoping to get some feedback here first. r? ```@oli-obk```
2023-10-20s/Generator/Coroutine/Oli Scherer-2/+2
2023-10-20Remove obsolete commentCelina G. Val-1/+0
2023-10-19Add stable Instance::body() and RustcInternal traitCelina G. Val-0/+2
The `Instance::body()` returns a monomorphized body. For that, we had to implement visitor that monomorphize types and constants. We are also introducing the RustcInternal trait that will allow us to convert back from Stable to Internal. Note that this trait is not yet visible for our users as it depends on Tables. We should probably add a new trait that can be exposed.
2023-10-13change fn name, return loc info, local nameOğuz Ağcayazı-3/+4
2023-10-11implement get_filename/lines for spanOğuz Ağcayazı-1/+22
2023-10-10add new wrapper for FxIndexMapOğuz Ağcayazı-1/+16
2023-09-28remove un-needed variantsouz-a-13/+0
2023-09-28fix importsouz-a-1/+1
2023-09-28make reg public and add visit, foldouz-a-1/+8
2023-09-28add stable for RegionKindouz-a-1/+1
2023-09-28add RegionDefouz-a-3/+6
2023-09-28make region struct and add neccesasry typesouz-a-2/+47
2023-09-25Split out the stable part of smir into its own crate to prevent accidental ↵Oli Scherer-0/+525
usage of forever unstable things