rust/compiler
bors 6fc0273b5a Auto merge of #112320 - compiler-errors:do-not-impl-via-obj, r=lcnr
Add `implement_via_object` to `rustc_deny_explicit_impl` to control object candidate assembly

Some built-in traits are special, since they are used to prove facts about the program that are important for later phases of compilation such as codegen and CTFE. For example, the `Unsize` trait is used to assert to the compiler that we are able to unsize a type into another type. It doesn't have any methods because it doesn't actually *instruct* the compiler how to do this unsizing, but this is later used (alongside an exhaustive match of combinations of unsizeable types) during codegen to generate unsize coercion code.

Due to this, these built-in traits are incompatible with the type erasure provided by object types. For example, the existence of `dyn Unsize<T>` does not mean that the compiler is able to unsize `Box<dyn Unsize<T>>` into `Box<T>`, since `Unsize` is a *witness* to the fact that a type can be unsized, and it doesn't actually encode that unsizing operation in its vtable as mentioned above.

The old trait solver gets around this fact by having complex control flow that never considers object bounds for certain built-in traits:
2f896da247/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs (L61-L132)

However, candidate assembly in the new solver is much more lovely, and I'd hate to add this list of opt-out cases into the new solver. Instead of maintaining this complex and hard-coded control flow, instead we can make this a property of the trait via a built-in attribute. We already have such a build attribute that's applied to every single trait that we care about: `rustc_deny_explicit_impl`. This PR adds `implement_via_object` as a meta-item to that attribute that allows us to opt a trait out of object-bound candidate assembly as well.

r? `@lcnr`
2023-06-20 08:42:37 +00:00
..
rustc fix link 2023-03-11 10:53:47 -06:00
rustc_abi Auto merge of #112062 - lukas-code:unsized-layout, r=wesleywiser 2023-06-13 22:34:59 +00:00
rustc_apfloat
rustc_arena Extend unused_must_use to cover block exprs 2023-06-15 17:59:13 +08:00
rustc_ast Remember names of cfg-ed out items to mention them in diagnostics 2023-06-01 19:17:19 +02:00
rustc_ast_lowering Separate AnonConst from ConstBlock in HIR. 2023-06-02 21:25:18 +00:00
rustc_ast_passes Fix debug ICE for extern type with where clauses 2023-06-12 15:15:45 +08:00
rustc_ast_pretty Fix suggestion for E0404 not dealing with multiple generics 2023-06-15 18:19:09 +08:00
rustc_attr Ensure Fluent messages are in alphabetical order 2023-05-25 23:49:35 +00:00
rustc_baked_icu_data Regen baked data 2023-05-02 10:45:16 -07:00
rustc_borrowck Rollup merge of #112781 - compiler-errors:new-solver-tait-overlaps-hidden, r=lcnr 2023-06-19 17:53:35 -07:00
rustc_builtin_macros Auto merge of #112366 - lukas-code:test, r=Nilstrieb 2023-06-19 13:39:46 +00:00
rustc_codegen_cranelift Rollup merge of #112232 - fee1-dead-contrib:match-eq-const-msg, r=b-naber 2023-06-19 17:53:33 -07:00
rustc_codegen_gcc Rollup merge of #112499 - tgross35:py-ruff-fixes, r=Mark-Simulacrum 2023-06-19 17:53:34 -07:00
rustc_codegen_llvm Rollup merge of #112474 - ldm0:ldm_enum_debuginfo_128_support, r=compiler-errors 2023-06-16 12:53:22 -07:00
rustc_codegen_ssa Rollup merge of #112232 - fee1-dead-contrib:match-eq-const-msg, r=b-naber 2023-06-19 17:53:33 -07:00
rustc_const_eval Rollup merge of #112232 - fee1-dead-contrib:match-eq-const-msg, r=b-naber 2023-06-19 17:53:33 -07:00
rustc_data_structures Don't print Interned or PrivateZst 2023-06-09 00:20:37 +00:00
rustc_driver fix spelling error 2023-06-05 16:01:09 +02:00
rustc_driver_impl Rollup merge of #112109 - Alexendoo:unsupported-split-debuginfo, r=b-naber 2023-06-14 18:10:29 +02:00
rustc_error_codes Implement custom diagnostic for ConstParamTy 2023-06-01 18:21:42 +00:00
rustc_error_messages Use translatable diagnostics in rustc_const_eval 2023-06-01 14:45:18 +00:00
rustc_errors s/drain_filter/extract_if/ for Vec, Btree{Map,Set} and LinkedList 2023-06-14 09:28:54 +02:00
rustc_expand Add SyntaxContext::is_root 2023-06-16 13:47:42 +00:00
rustc_feature Merge attrs, better validation 2023-06-20 04:38:55 +00:00
rustc_fluent_macro Remove unused synstructure dep 2023-04-22 22:03:33 +01:00
rustc_fs_util Add try_canonicalize to rustc_fs_util and use it over fs::canonicalize 2023-03-16 21:50:23 +01:00
rustc_graphviz enable rust_2018_idioms for doctests 2023-05-07 00:12:29 +03:00
rustc_hir Auto merge of #100036 - DrMeepster:box_free_free_box, r=oli-obk 2023-06-17 16:10:57 +00:00
rustc_hir_analysis Auto merge of #112320 - compiler-errors:do-not-impl-via-obj, r=lcnr 2023-06-20 08:42:37 +00:00
rustc_hir_pretty Separate AnonConst from ConstBlock in HIR. 2023-06-02 21:25:18 +00:00
rustc_hir_typeck Rollup merge of #112537 - compiler-errors:dont-record-adjustments-twice, r=cjgillot 2023-06-18 13:17:05 -07:00
rustc_incremental Removed stable/unstable sort arg from into_sorted_stable_ord, fixed a few misc issues, added collect to UnordItems 2023-06-08 00:38:50 -04:00
rustc_index Auto merge of #111925 - Manishearth:rollup-z6z6l2v, r=Manishearth 2023-05-25 00:33:43 +00:00
rustc_infer Rollup merge of #112781 - compiler-errors:new-solver-tait-overlaps-hidden, r=lcnr 2023-06-19 17:53:35 -07:00
rustc_interface Remove comments from mir-opt MIR dumps 2023-06-15 15:19:11 -04:00
rustc_lexer Don't try to eat non-existent decimal digits. 2023-05-15 18:33:12 +10:00
rustc_lint Move ConstEvaluatable to Clause 2023-06-17 21:27:13 +00:00
rustc_lint_defs Private-in-public lints implementation 2023-06-12 01:02:19 +03:00
rustc_llvm Add SafeStack support to rustc 2023-05-26 15:18:54 -04:00
rustc_log Stabilize IsTerminal 2023-04-10 17:24:23 +09:00
rustc_macros Use translatable diagnostics in rustc_const_eval 2023-06-01 14:45:18 +00:00
rustc_metadata s/drain_filter/extract_if/ for Vec, Btree{Map,Set} and LinkedList 2023-06-14 09:28:54 +02:00
rustc_middle Auto merge of #112320 - compiler-errors:do-not-impl-via-obj, r=lcnr 2023-06-20 08:42:37 +00:00
rustc_mir_build Rollup merge of #112232 - fee1-dead-contrib:match-eq-const-msg, r=b-naber 2023-06-19 17:53:33 -07:00
rustc_mir_dataflow Rollup merge of #112232 - fee1-dead-contrib:match-eq-const-msg, r=b-naber 2023-06-19 17:53:33 -07:00
rustc_mir_transform Rollup merge of #112232 - fee1-dead-contrib:match-eq-const-msg, r=b-naber 2023-06-19 17:53:33 -07:00
rustc_monomorphize Auto merge of #100036 - DrMeepster:box_free_free_box, r=oli-obk 2023-06-17 16:10:57 +00:00
rustc_parse Handle interpolated literal errors 2023-06-15 01:55:37 +00:00
rustc_parse_format Fix typos in compiler 2023-04-10 22:02:52 +02:00
rustc_passes Merge attrs, better validation 2023-06-20 04:38:55 +00:00
rustc_plugin_impl Add rustc_fluent_macro to decouple fluent from rustc_macros 2023-04-18 18:56:22 +00:00
rustc_privacy Rollup merge of #112734 - dswij:bounds-predicates-clause, r=compiler-errors 2023-06-18 08:06:43 +02:00
rustc_query_impl Update field-offset and enable unstable_offset_of 2023-06-05 15:57:13 +02:00
rustc_query_system Rollup merge of #112333 - Zoxc:try_collect_active_jobs-deadlock, r=cjgillot 2023-06-08 12:36:18 +02:00
rustc_resolve Rollup merge of #112768 - NotStirred:translatable_diag/resolve1, r=WaffleLapkin 2023-06-19 19:26:27 +02:00
rustc_serialize Fix the FileEncoder buffer size. 2023-05-15 08:59:11 +10:00
rustc_session add -Z flag 2023-06-19 09:01:37 +01:00
rustc_smir Rollup merge of #112232 - fee1-dead-contrib:match-eq-const-msg, r=b-naber 2023-06-19 17:53:33 -07:00
rustc_span Auto merge of #112320 - compiler-errors:do-not-impl-via-obj, r=lcnr 2023-06-20 08:42:37 +00:00
rustc_symbol_mangling Add AliasKind::Weak for type aliases. 2023-06-16 19:39:48 +00:00
rustc_target loongarch64-none*: Remove environment component from llvm target 2023-06-13 20:24:22 +08:00
rustc_trait_selection Auto merge of #112320 - compiler-errors:do-not-impl-via-obj, r=lcnr 2023-06-20 08:42:37 +00:00
rustc_traits Move ConstEvaluatable to Clause 2023-06-17 21:27:13 +00:00
rustc_transmute Safe Transmute: Refactor error handling and Answer type 2023-06-12 16:56:21 -07:00
rustc_ty_utils Promote unchecked_add/sub/mul/shl/shr to mir::BinOp 2023-06-19 01:47:03 -07:00
rustc_type_ir Add AliasKind::Weak for type aliases. 2023-06-16 19:39:48 +00:00