about summary refs log tree commit diff
path: root/compiler/rustc_smir/src
AgeCommit message (Collapse)AuthorLines
2024-02-23compiler: clippy::complexity fixesMatthias Krüger-2/+1
2024-02-17Merge `CompilerError::CompilationFailed` and `CompilerError::ICE`.Nicholas Nethercote-2/+8
`CompilerError` has `CompilationFailed` and `ICE` variants, which seems reasonable at first. But the way it identifies them is flawed: - If compilation errors out, i.e. `RunCompiler::run` returns an `Err`, it uses `CompilationFailed`, which is reasonable. - If compilation panics with `FatalError`, it catches the panic and uses `ICE`. This is sometimes right, because ICEs do cause `FatalError` panics, but sometimes wrong, because certain compiler errors also cause `FatalError` panics. (The compiler/rustdoc/clippy/whatever just catches the `FatalError` with `catch_with_exit_code` in `main`.) In other words, certain non-ICE compilation failures get miscategorized as ICEs. It's not possible to reliably distinguish the two cases, so this commit merges them. It also renames the combined variant as just `Failed`, to better match the existing `Interrupted` and `Skipped` variants. Here is an example of a non-ICE failure that causes a `FatalError` panic, from `tests/ui/recursion_limit/issue-105700.rs`: ``` #![recursion_limit="4"] #![invalid_attribute] #![invalid_attribute] #![invalid_attribute] #![invalid_attribute] #![invalid_attribute] //~^ERROR recursion limit reached while expanding fn main() {{}} ```
2024-02-15Rollup merge of #120982 - momvart:smir-61-foreign_kind, r=oli-obkMatthias Krüger-33/+105
Add APIs for fetching foreign items Closes https://github.com/rust-lang/project-stable-mir/issues/61
2024-02-14Rewrite foreign item kind query using `DefKind`Mohammad Omidvar-21/+13
2024-02-12Add APIs for fetching foreign items including foreign modules, their ABIs, ↵Mohammad Omidvar-33/+113
and their items
2024-02-12Dejargnonize substShoyu Vanilla-1/+1
2024-02-08Add a new debug_assertions instrinsic (compiler)Ben Kimock-0/+1
And in clippy
2024-02-06Fix drop shim for AsyncFnOnce closure, AsyncFnMut shim for AsyncFn closureMichael Goulet-1/+1
2024-02-06Bless tests, add commentsMichael Goulet-2/+2
2024-02-06Construct body for by-move coroutine closure outputMichael Goulet-0/+1
2024-02-06Build a shim to call async closures with different AsyncFn trait kindsMichael Goulet-0/+1
2024-02-06Add CoroutineClosure to TyKind, AggregateKind, UpvarArgsMichael Goulet-0/+4
2024-01-30Remove the `abi_amdgpu_kernel` featureclubby789-3/+0
2024-01-22Do not normalize closure signature when building FnOnce shimMichael Goulet-1/+4
2024-01-19Use the new `with_tables` everywhereOli Scherer-145/+127
2024-01-19Ensure internal function is safeCelina G. Val-198/+294
The internal function was unsound, it could cause UB in rare cases where the user inadvertly stored the returned object in a location that could outlive the TyCtxt. In order to make it safe, we now take a type context as an argument to the internal fn, and we ensure that interned items are lifted using the provided context. Thus, this change ensures that the compiler can properly enforce that the object does not outlive the type context it was lifted to.
2024-01-19Fix `Stable` trait and its impls to work with the new `with_tables`Oli Scherer-129/+136
2024-01-19Fix a soundness bug in `with_tables`.Oli Scherer-2/+2
We were able to uplift any value from `Tables` to `'static`, which is unsound.
2024-01-18Rollup merge of #119833 - celinval:smir-accept-closures, r=oli-obkMatthias Krüger-16/+106
Make tcx optional from StableMIR run macro and extend it to accept closures Change `run` macro to avoid sometimes unnecessary dependency on `TyCtxt`, and introduce `run_with_tcx` to capture use cases where `tcx` is required. Additionally, extend both macros to accept closures that may capture variables. I've also modified the `internal()` method to make it safer, by accepting the type context to force the `'tcx` lifetime to match the context lifetime. These are non-backward compatible changes, but they only affect internal APIs which are provided today as helper functions until we have a stable API to start the compiler.
2024-01-17Revert changes to internal method for nowCelina G. Val-29/+4
- Move fix to a separate PR
2024-01-16Remove tcx function and make `internal` fn saferCelina G. Val-28/+55
I added `tcx` argument to `internal` to force 'tcx to be the same lifetime as TyCtxt. The only other solution I could think is to change this function to be `unsafe`.
2024-01-16Remove tcx from SMIR run macro and accept closuresCelina G. Val-17/+105
Simplify the `run` macro to avoid sometimes unnecessary dependency on `TyCtxt`. Instead, users can use the new internal method `tcx()`. Additionally, extend the macro to accept closures that may capture variables. These are non-backward compatible changes, but they only affect internal APIs which are provided today as helper functions until we have a stable API to start the compiler.
2024-01-15compiler: Lower fn call arg spans down to MIRMartin Nordholts-1/+1
To enable improved accuracy of diagnostics in upcoming commits.
2024-01-11Rollup merge of #119790 - celinval:smir-all-traits, r=oli-obkMatthias Krüger-4/+27
Fix all_trait* methods to return all traits available in StableMIR Also provide a mechanism to retrieve traits and implementations for a given crate. This fixes https://github.com/rust-lang/project-stable-mir/issues/37
2024-01-10Simplify some redundant namesMichael Goulet-8/+6
2024-01-09Fix all_trait* methods to return all trait availableCelina G. Val-4/+27
Also provide a mechanism to retrieve traits and implementations for a given crate.
2023-12-28Movability doesn't need to be a query anymoreMichael Goulet-2/+2
2023-12-28Restore movability to SMIRMichael Goulet-1/+3
2023-12-28Remove movability from TyKind::CoroutineMichael Goulet-9/+5
2023-12-25Only regular coroutines have movabilityMichael Goulet-2/+4
2023-12-22Split coroutine desugaring kind from sourceMichael Goulet-7/+16
2023-12-20Rollup merge of #119141 - celinval:smir-instance-args, r=compiler-errorsMatthias Krüger-0/+6
Add method to get instance instantiation arguments Add a method to get the instance instantiation arguments, and include that information in the instance debug.
2023-12-20Add method to get instance instantiation argumentsCelina G. Val-0/+6
2023-12-20Add `ItemKind::Ctor` to stable mirCelina G. Val-9/+7
2023-12-20Fix crash for `CrateItem::kind()` with constructorsCelina G. Val-5/+8
Change how we classify item kind for DefKind::Ctor
2023-12-20Rollup merge of #119094 - celinval:smir-layout, r=compiler-errorsMatthias Krüger-21/+344
Add function ABI and type layout to StableMIR 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. r? ```@compiler-errors```
2023-12-19Fix c_variadic flag and add opaque info to PassModeCelina G. Val-4/+17
We should expand the information in PassMode later.
2023-12-18Add the function body span to StableMIRCelina G. Val-0/+1
2023-12-18Add function ABI and type layout to StableMIRCelina G. Val-21/+331
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-17Auto merge of #119000 - celinval:smir-cstr, r=ouz-abors-0/+6
Add a method to StableMIR to check if a type is a CStr Also add a check that StableMIR works properly with C string literal.
2023-12-15NFC don't convert types to identical typesMatthias Krüger-1/+0
2023-12-15Add a method to check if type is a CStrCelina G. Val-0/+6
2023-12-14Address PR commentsCelina G. Val-12/+6
- 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-1/+4
2023-12-13Erase late bound regions from instance `fn_sig()`Celina G. Val-3/+12
Late bound regions were still part of the signature.
2023-12-12Rollup merge of #118889 - matthiaskrgr:compl_2023_2, r=WaffleLapkinJubilee-1/+1
more clippy::complexity fixes redundant_guards redundant_slicing filter_next needless_borrowed_reference useless_format
2023-12-12more clippy::complexity fixesMatthias Krüger-1/+1
redundant_guards redundant_slicing filter_next needless_borrowed_reference useless_format
2023-12-12clippy::complexity fixesMatthias Krüger-1/+1
filter_map_identity needless_bool search_is_some unit_arg map_identity needless_question_mark derivable_impls
2023-12-12Rollup merge of #118846 - celinval:smir-ty-methods, r=compiler-errorsMatthias Krüger-0/+12
Fix BinOp `ty()` assertion and `fn_sig()` for closures `BinOp::ty()` was asserting that the argument types were primitives. However, the primitive check doesn't include pointers, which can be used in a `BinaryOperation`. Thus extend the arguments to include them. Since I had to add methods to check for pointers in TyKind, I just went ahead and added a bunch more utility checks that can be handy for our users and fixed the `fn_sig()` method to also include closures. `@compiler-errors` just wanted to confirm that today no `BinaryOperation` accept SIMD types. Is that correct? r? `@compiler-errors`
2023-12-11Fix BinOp ty assertion and `fn_sig` for closuresCelina G. Val-0/+12
Also added a few more util methods to TyKind to check for specific types.