rust/compiler/rustc_codegen_cranelift/src
bors e2750baf53 Auto merge of #88499 - eddyb:layout-off, r=nagisa
Provide `layout_of` automatically (given tcx + param_env + error handling).

After #88337, there's no longer any uses of `LayoutOf` within `rustc_target` itself, so I realized I could move the trait to `rustc_middle::ty::layout` and redesign it a bit.

This is similar to #88338 (and supersedes it), but at no ergonomic loss, since there's no funky `C: LayoutOf<Ty = Ty>` -> `Ty: TyAbiInterface<C>` generic `impl` chain, and each `LayoutOf` still corresponds to one `impl` (of `LayoutOfHelpers`) for the specific context.

After this PR, this is what's needed to get `trait LayoutOf` (with the `layout_of` method) implemented on some context type:
* `TyCtxt`, via `HasTyCtxt`
* `ParamEnv`, via `HasParamEnv`
* a way to transform `LayoutError`s into the desired error type
  * an error type of `!` can be paired with having `cx.layout_of(...)` return `TyAndLayout` *without* `Result<...>` around it, such as used by codegen
  * this is done through a new `LayoutOfHelpers` trait (and so is specifying the type of `cx.layout_of(...)`)

When going through this path (and not bypassing it with a manual `impl` of `LayoutOf`), the end result is that only the error case can be customized, the query itself and the success paths are guaranteed to be uniform.

(**EDIT**: just noticed that because of the supertrait relationship, you cannot actually implement `LayoutOf` yourself, the blanket `impl` fully covers all possible context types that could ever implement it)

Part of the motivation for this shape of API is that I've been working on querifying `FnAbi::of_*`, and what I want/need to introduce for that looks a lot like the setup in this PR - in particular, it's harder to express the `FnAbi` methods in `rustc_target`, since they're much more tied to `rustc` concepts.

r? `@nagisa` cc `@oli-obk` `@bjorn3`
2021-09-05 16:14:41 +00:00
..
abi Merge commit '05677b6bd6' into sync_cg_clif-2021-08-06 2021-08-06 16:26:56 +02:00
bin Merge commit '3a31c6d827' into sync_cg_clif-2021-07-07 2021-07-07 11:14:20 +02:00
debuginfo Auto merge of #88363 - michaelwoerister:remapped-diagnostics, r=estebank 2021-09-03 00:23:10 +00:00
driver Use in_incr_comp_dir_sess in cg_clif 2021-09-02 12:29:12 +02:00
intrinsics rustc_target: TyAndLayout::field should never error. 2021-08-30 00:44:09 +03:00
optimize Merge commit '05677b6bd6' into sync_cg_clif-2021-08-06 2021-08-06 16:26:56 +02:00
allocator.rs Merge commit '05677b6bd6' into sync_cg_clif-2021-08-06 2021-08-06 16:26:56 +02:00
analyze.rs Merge commit '05677b6bd6' into sync_cg_clif-2021-08-06 2021-08-06 16:26:56 +02:00
archive.rs Move add_rlib and add_native_library to cg_ssa 2021-09-01 14:43:27 +02:00
backend.rs Sync rustc_codegen_cranelift 'ddd4ce2553' 2021-04-30 14:49:58 +02:00
base.rs Merge commit '05677b6bd6' into sync_cg_clif-2021-08-06 2021-08-06 16:26:56 +02:00
cast.rs Merge commit '05677b6bd6' into sync_cg_clif-2021-08-06 2021-08-06 16:26:56 +02:00
codegen_i128.rs Merge commit '05677b6bd6' into sync_cg_clif-2021-08-06 2021-08-06 16:26:56 +02:00
common.rs ty::layout: split LayoutOf into required and (blanket) provided halves. 2021-09-02 01:17:14 +03:00
compiler_builtins.rs Use the now available implementation of IntoIterator for arrays 2021-06-14 23:40:09 +02:00
config.rs Merge commit '40dd3e2b70' into sync_cg_clif-2021-05-27 2021-05-27 13:08:14 +02:00
constant.rs make unevaluated const substs optional 2021-08-26 11:00:30 +02:00
discriminant.rs Merge commit '9a0c32934e' into sync_cg_clif-2021-03-05 2021-03-05 19:12:59 +01:00
inline_asm.rs Merge commit '40dd3e2b70' into sync_cg_clif-2021-05-27 2021-05-27 13:08:14 +02:00
lib.rs Auto merge of #88499 - eddyb:layout-off, r=nagisa 2021-09-05 16:14:41 +00:00
linkage.rs Sync rustc_codegen_cranelift 'ddd4ce2553' 2021-04-30 14:49:58 +02:00
main_shim.rs Merge commit '40dd3e2b70' into sync_cg_clif-2021-05-27 2021-05-27 13:08:14 +02:00
metadata.rs Drop metadata_encoding_version. 2021-06-01 21:12:27 +02:00
num.rs Merge commit '05677b6bd6' into sync_cg_clif-2021-08-06 2021-08-06 16:26:56 +02:00
pointer.rs Merge commit '0969bc6dde' into sync_cg_clif-2021-03-29 2021-03-29 10:45:09 +02:00
pretty_clif.rs Merge commit '3a31c6d827' into sync_cg_clif-2021-07-07 2021-07-07 11:14:20 +02:00
toolchain.rs Unify duplicate linker_and_flavor methods in rustc_codegen_{cranelift,ssa}. 2021-06-05 21:59:41 -07:00
trap.rs Merge commit '05677b6bd6' into sync_cg_clif-2021-08-06 2021-08-06 16:26:56 +02:00
unsize.rs Fold vtable_trait_upcasting_coercion_new_vptr_slot logic into obligation processing. 2021-08-18 13:00:27 +08:00
value_and_place.rs Merge commit '05677b6bd6' into sync_cg_clif-2021-08-06 2021-08-06 16:26:56 +02:00
vtable.rs Merge commit '05677b6bd6' into sync_cg_clif-2021-08-06 2021-08-06 16:26:56 +02:00