about summary refs log tree commit diff
path: root/compiler/rustc_middle/src/ty/instance.rs
AgeCommit message (Collapse)AuthorLines
2024-06-18Apply suggestions from oli-obk's reviewDaria Sukhonina-24/+11
Co-authored-by: Oli Scherer <github35764891676564198441@oli-obk.de>
2024-06-18Make async drop code more consistent with regular drop codeDaria Sukhonina-3/+25
Fixes #126573
2024-06-16Rename InstanceDef -> InstanceKindMichael Goulet-102/+102
2024-06-14Use is_lang_item more aggressivelyMichael Goulet-5/+4
2024-05-26Give EarlyBinder a tcx parameterMichael Goulet-3/+3
We are gonna need it to uplift EarlyBinder
2024-05-23Remove `#[macro_use] extern crate tracing` from `rustc_middle`.Nicholas Nethercote-0/+1
2024-04-29Remove `extern crate rustc_macros` from `rustc_middle`.Nicholas Nethercote-1/+3
2024-04-18Fix disabling the export of noop async_drop_in_place_rawDaria Sukhonina-1/+3
2024-04-17Use non-exhaustive matches for TyKindDaria Sukhonina-2/+3
Also no longer export noop async_drop_in_place_raw
2024-04-16Add simple async drop glue generationzetanumbers-6/+23
Explainer: https://zetanumbers.github.io/book/async-drop-design.html https://github.com/rust-lang/rust/pull/121801
2024-04-08CFI: Fix ICE in KCFI non-associated function pointersMatthew Maurer-1/+4
We oddly weren't testing the more usual case of casting non-methods to function pointers. The KCFI shim insertion logic would ICE on these due to asking for an irrefutable associated item if we cast a function to a function pointer without needing a traditional shim.
2024-04-02CFI: Support function pointers for trait methodsMatthew Maurer-0/+18
Adds support for both CFI and KCFI for attaching concrete and abstract types to functions. KCFI does this through generation of `ReifyShim` on any function pointer that could go in a vtable, and checking the `ReifyReason` when emitting the instance. CFI does this by attaching both the concrete and abstract type to every instance. TypeID codegen tests are switched to be anchored on the left rather than the right in order to allow emission of additional type attachments. Fixes #115953
2024-04-02Track reason for creating a `ReifyShim`Matthew Maurer-8/+40
KCFI needs to be able to tell which kind of `ReifyShim` it is examining in order to decide whether to use a concrete type (`FnPtr` case) or an abstract case (`Vtable` case). You can *almost* tell this from context, but there is one case where you can't - if a trait has a method which is *not* `#[track_caller]`, with an impl that *is* `#[track_caller]`, both the vtable and a function pointer created from that method will be `ReifyShim(def_id)`. Currently, the reason is optional to ensure no additional unique `ReifyShim`s are added without KCFI on. However, the case in which an extra `ReifyShim` is created is sufficiently rare that this may be worth revisiting to reduce complexity.
2024-03-25Instance is CopyMichael Goulet-4/+4
2024-03-22Auto merge of #122580 - saethlin:compiler-builtins-can-panic, r=pnkfelixbors-0/+6
"Handle" calls to upstream monomorphizations in compiler_builtins This is pretty cooked, but I think it works. compiler-builtins has a long-standing problem that at link time, its rlib cannot contain any calls to `core`. And yet, in codegen we _love_ inserting calls to symbols in `core`, generally from various panic entrypoints. I intend this PR to attack that problem as completely as possible. When we generate a function call, we now check if we are generating a function call from `compiler_builtins` and whether the callee is a function which was not lowered in the current crate, meaning we will have to link to it. If those conditions are met, actually generating the call is asking for a linker error. So we don't. If the callee diverges, we lower to an abort with the same behavior as `core::intrinsics::abort`. If the callee does not diverge, we produce an error. This means that compiler-builtins can contain panics, but they'll SIGILL instead of panicking. I made non-diverging calls a compile error because I'm guessing that they'd mostly get into compiler-builtins by someone making a mistake while working on the crate, and compile errors are better than linker errors. We could turn such calls into aborts as well if that's preferred.
2024-03-20Add a testBen Kimock-0/+6
2024-03-19Add a few more commentsMichael Goulet-1/+1
2024-03-19Fix ABI for FnMut/Fn impls for async closuresMichael Goulet-1/+10
2024-03-19Only split by-ref/by-move futures for async closuresMichael Goulet-13/+5
2024-03-09Rollup merge of #122237 - fee1-dead-contrib:rmord, r=compiler-errorsMatthias Krüger-1/+1
Remove `Ord` from `ClosureKind` Using `Ord` to accomplish a meaning of subset relationship can be hard to read. The existing uses for that are easily replaced with a `match`, and in my opinion, more readable without needing to resorting to comments to explain the intention. cc `@compiler-errors`
2024-03-09Remove `Ord` from `ClosureKind`Deadbeef-1/+1
Using `Ord` to accomplish a meaning of subset relationship can be hard to read. The existing uses for that are easily replaced with a `match`, and in my opinion, more readable without needing to resorting to comments to explain the intention.
2024-03-07sync (try_)instantiate_mir_and_normalize_erasing_regions implementationklensy-2/+4
try_instantiate_mir_and_normalize_erasing_regions was changed in https://github.com/rust-lang/rust/commit/dbc2cc8717dd8c8006595d9e9c91ad472109165a, but not instantiate_mir_and_normalize_erasing_regions
2024-02-12Rollup merge of #120958 - ShoyuVanilla:remove-subst, r=oli-obkMatthias Krüger-8/+8
Dejargonize `subst` In favor of #110793, replace almost every occurence of `subst` and `substitution` from rustc codes, but they still remains in subtrees under `src/tools/` like clippy and test codes (I'd like to replace them after this)
2024-02-12Dejargnonize substShoyu Vanilla-8/+8
2024-02-11is_closure_likeMichael Goulet-5/+2
2024-02-07Record coroutine kind in genericsMichael Goulet-1/+8
2024-02-06Fix drop shim for AsyncFnOnce closure, AsyncFnMut shim for AsyncFn closureMichael Goulet-13/+13
2024-02-06More comments, final tweaksMichael Goulet-0/+7
2024-02-06Bless tests, add commentsMichael Goulet-1/+4
2024-02-06Construct body for by-move coroutine closure outputMichael Goulet-1/+20
2024-02-06Build a shim to call async closures with different AsyncFn trait kindsMichael Goulet-1/+22
2024-01-23Rollup merge of #120139 - compiler-errors:fnonce-shim, r=BoxyUwULeón Orell Valerian Liehr-10/+8
Do not normalize closure signature when building `FnOnce` shim It is not necessary to normalize the closure signature when building an `FnOnce` shim for an `Fn`/`FnMut` closure. That closure shim is just calling `FnMut::call_mut(&mut self)` anyways. It's also somewhat sketchy that we were ever doing this to begin with, since we're normalizing with a `ParamEnv::reveal_all()` param-env, which is definitely not right with possibly polymorphic substs. This cuts out a tiny bit of unnecessary work in `Instance::resolve` and simplifies the signature because now we can unconditionally return an `Instance`.
2024-01-22Do not normalize closure signature when building FnOnce shimMichael Goulet-10/+8
2024-01-19Consolidate logic around resolving built-in coroutine trait implsMichael Goulet-0/+50
2024-01-05fix OOM when `ty::Instance` is used in query descriptionLukas Markeffsky-4/+8
2023-12-30Use the right type for upvarsMichael Goulet-6/+4
2023-12-30is_coroutine -> is_coroutine_or_closureMichael Goulet-3/+6
2023-12-28Remove movability from TyKind::CoroutineMichael Goulet-2/+2
2023-12-03rustc: Harmonize `DefKind` and `DefPathData`Vadim Petrochenkov-1/+1
`DefPathData::(ClosureExpr,ImplTrait)` are renamed to match `DefKind::(Closure,OpaqueTy)`. `DefPathData::ImplTraitAssocTy` is replaced with `DefPathData::TypeNS(kw::Empty)` because both correspond to `DefKind::AssocTy`. It's possible that introducing `(DefKind,DefPathData)::AssocOpaqueTy` could be a better solution, but that would be a much more invasive change. Const generic parameters introduced for effects are moved from `DefPathData::TypeNS` to `DefPathData::ValueNS`, because constants are values. `DefPathData` is no longer passed to `create_def` functions to avoid redundancy.
2023-10-21Make `ty::print::Printer` take `&mut self` instead of `self`Nilstrieb-3/+3
This simplifies the code by removing all the `self` assignments and makes the flow of data clearer - always into the printer. Especially in v0 mangling, which already used `&mut self` in some places, it gets a lot more uniform.
2023-10-20s/generator/coroutine/Oli Scherer-6/+6
2023-10-20s/Generator/Coroutine/Oli Scherer-1/+1
2023-10-17Automatically enable cross-crate inlining for small functionsBen Kimock-5/+4
2023-10-02`skip_binder` to `instantiate_identity`lcnr-2/+7
2023-09-26subst -> instantiatelcnr-6/+6
2023-09-18Remove unused `Lift` derives.Nicholas Nethercote-0/+3
I found these by commenting out all `Lift` derives and then adding back the ones that were necessary to successfully compile.
2023-09-14treat host effect params as erased generics in codegenDeadbeef-1/+2
This fixes the changes brought to codegen tests when effect params are added to libcore, by not attempting to monomorphize functions that get the host param by being `const fn`.
2023-07-30inline format!() args up to and including rustc_middleMatthias Krüger-9/+7
2023-07-14refactor(rustc_middle): Substs -> GenericArgMahdi Dibaiee-81/+81
2023-07-05Move `TyCtxt::mk_x` to `Ty::new_x` where applicableBoxy-3/+3