rust/compiler
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
..
rustc
rustc_apfloat
rustc_arena Remove unused arena macro args 2021-08-30 13:09:38 +02:00
rustc_ast Auto merge of #88598 - estebank:type-ascription-can-die-in-a-fire, r=wesleywiser 2021-09-04 01:40:36 +00:00
rustc_ast_lowering Replace Vec by Option. 2021-09-03 23:36:22 +02:00
rustc_ast_passes Auto merge of #87114 - cjgillot:abilint, r=estebank 2021-09-02 06:06:24 +00:00
rustc_ast_pretty Add let-else to AST 2021-08-30 20:17:45 -05:00
rustc_attr
rustc_builtin_macros Auto merge of #88598 - estebank:type-ascription-can-die-in-a-fire, r=wesleywiser 2021-09-04 01:40:36 +00:00
rustc_codegen_cranelift Auto merge of #88499 - eddyb:layout-off, r=nagisa 2021-09-05 16:14:41 +00:00
rustc_codegen_llvm Auto merge of #88499 - eddyb:layout-off, r=nagisa 2021-09-05 16:14:41 +00:00
rustc_codegen_ssa Auto merge of #88499 - eddyb:layout-off, r=nagisa 2021-09-05 16:14:41 +00:00
rustc_data_structures Rollup merge of #88053 - bjorn3:fix_flock_fallback_impl, r=cjgillot 2021-09-01 09:23:25 +02:00
rustc_driver Remove print_fuel_crate field of Session 2021-09-02 12:29:11 +02:00
rustc_error_codes Update E0785.md 2021-08-30 22:18:55 -07:00
rustc_errors Path remapping: Make behavior of diagnostics output dependent on presence of --remap-path-prefix. 2021-08-27 11:50:44 +02:00
rustc_expand Auto merge of #88598 - estebank:type-ascription-can-die-in-a-fire, r=wesleywiser 2021-09-04 01:40:36 +00:00
rustc_feature Add let_else feature gate 2021-08-30 20:18:39 -05:00
rustc_fs_util
rustc_graphviz
rustc_hir Auto merge of #88572 - matthewjasper:if-let-scoping-fix, r=oli-obk 2021-09-03 20:31:43 +00:00
rustc_hir_pretty Remove obsolete MacroDef variant of OwnerNode 2021-08-28 00:24:30 -07:00
rustc_incremental
rustc_index Suggested changes 2021-08-27 16:21:25 -07:00
rustc_infer Auto merge of #88363 - michaelwoerister:remapped-diagnostics, r=estebank 2021-09-03 00:23:10 +00:00
rustc_interface Auto merge of #88598 - estebank:type-ascription-can-die-in-a-fire, r=wesleywiser 2021-09-04 01:40:36 +00:00
rustc_lexer
rustc_lint Auto merge of #88499 - eddyb:layout-off, r=nagisa 2021-09-05 16:14:41 +00:00
rustc_lint_defs Tracking issue for UNSUPPORTED_CALLING_CONVENTIONS 2021-08-27 20:47:00 +03:00
rustc_llvm RustWrapper: adapt to LLVM change 0f45c16f2caa 2021-08-26 10:40:27 -04:00
rustc_macros
rustc_metadata Auto merge of #88538 - bjorn3:no_session_in_crate_loader, r=petrochenkov 2021-09-04 07:17:12 +00:00
rustc_middle Auto merge of #88499 - eddyb:layout-off, r=nagisa 2021-09-05 16:14:41 +00:00
rustc_mir Auto merge of #88499 - eddyb:layout-off, r=nagisa 2021-09-05 16:14:41 +00:00
rustc_mir_build Bless 32bit MIR opt tests 2021-09-02 10:18:08 +01:00
rustc_parse Rollup merge of #88257 - estebank:invalid-attr-error, r=oli-obk 2021-09-05 10:32:20 +02:00
rustc_parse_format
rustc_passes Auto merge of #88499 - eddyb:layout-off, r=nagisa 2021-09-05 16:14:41 +00:00
rustc_plugin_impl
rustc_privacy rename const_evaluatable_checked to generic_const_exprs 2021-08-30 11:00:21 +02:00
rustc_query_impl Auto merge of #88121 - camelid:better-recursive-alias-error, r=estebank 2021-09-01 03:43:37 +00:00
rustc_query_system Remove redundant Span in QueryJobInfo 2021-09-01 11:10:58 -07:00
rustc_resolve Auto merge of #88598 - estebank:type-ascription-can-die-in-a-fire, r=wesleywiser 2021-09-04 01:40:36 +00:00
rustc_save_analysis Treat macros as HIR items 2021-08-28 00:16:34 -07:00
rustc_serialize
rustc_session Add explanation for ctfe_backtrace lock 2021-09-02 12:29:12 +02:00
rustc_span Auto merge of #88363 - michaelwoerister:remapped-diagnostics, r=estebank 2021-09-03 00:23:10 +00:00
rustc_symbol_mangling Rollup merge of #85534 - csmoe:demagnle-assert, r=michaelwoerister 2021-08-29 16:25:28 +02:00
rustc_target Auto merge of #88499 - eddyb:layout-off, r=nagisa 2021-09-05 16:14:41 +00:00
rustc_trait_selection Auto merge of #88618 - m-ou-se:rollup-6tss5z6, r=m-ou-se 2021-09-03 11:37:52 +00:00
rustc_traits Auto merge of #88371 - Manishearth:rollup-pkkjsme, r=Manishearth 2021-08-27 01:07:17 +00:00
rustc_ty_utils Auto merge of #88371 - Manishearth:rollup-pkkjsme, r=Manishearth 2021-08-27 01:07:17 +00:00
rustc_type_ir update TypeFlags to deal with missing ct substs 2021-08-26 11:00:30 +02:00
rustc_typeck Fix 2021 dyn suggestion that used code as label 2021-09-04 18:31:00 -07:00