rust/tests/ui/rfcs
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
..
rfc-0107-bind-by-move-pattern-guards Better group RFC ui tests together 2023-06-05 16:09:46 +00:00
rfc-1014-stdout-existential-crisis Better group RFC ui tests together 2023-06-05 16:09:46 +00:00
rfc-1445-restrict-constants-in-patterns Better group RFC ui tests together 2023-06-05 16:09:46 +00:00
rfc-1623-static Better group RFC ui tests together 2023-06-05 16:09:46 +00:00
rfc-1717-dllimport Better group RFC ui tests together 2023-06-05 16:09:46 +00:00
rfc-1789-as-cell Move /src/test to /tests 2023-01-11 09:32:08 +00:00
rfc-1857-stabilize-drop-order Better group RFC ui tests together 2023-06-05 16:09:46 +00:00
rfc-1937-termination-trait Better group RFC ui tests together 2023-06-05 16:09:46 +00:00
rfc-2005-default-binding-mode Better group RFC ui tests together 2023-06-05 16:09:46 +00:00
rfc-2008-non-exhaustive Better group RFC ui tests together 2023-06-05 16:09:46 +00:00
rfc-2027-object-safe-for-dispatch Better group RFC ui tests together 2023-06-05 16:09:46 +00:00
rfc-2091-track-caller Better group RFC ui tests together 2023-06-05 16:09:46 +00:00
rfc-2093-infer-outlives Better group RFC ui tests together 2023-06-05 16:09:46 +00:00
rfc-2126-crate-paths Better group RFC ui tests together 2023-06-05 16:09:46 +00:00
rfc-2126-extern-absolute-paths Better group RFC ui tests together 2023-06-05 16:09:46 +00:00
rfc-2151-raw-identifiers Move /src/test to /tests 2023-01-11 09:32:08 +00:00
rfc-2175-or-if-while-let Move /src/test to /tests 2023-01-11 09:32:08 +00:00
rfc-2294-if-let-guard Better group RFC ui tests together 2023-06-05 16:09:46 +00:00
rfc-2302-self-struct-ctor Better group RFC ui tests together 2023-06-05 16:09:46 +00:00
rfc-2306-convert-id Better group RFC ui tests together 2023-06-05 16:09:46 +00:00
rfc-2361-dbg-macro Better group RFC ui tests together 2023-06-05 16:09:46 +00:00
rfc-2396-target_feature-11 Forbid the use of #[target_feature] on start 2023-03-12 14:57:38 +01:00
rfc-2397-do-not-recommend Better group RFC ui tests together 2023-06-05 16:09:46 +00:00
rfc-2421-unreserve-pure-offsetof-sizeof-alignof Better group RFC ui tests together 2023-06-05 16:09:46 +00:00
rfc-2457-non-ascii-idents Better group RFC ui tests together 2023-06-05 16:09:46 +00:00
rfc-2497-if-let-chains Better group RFC ui tests together 2023-06-05 16:09:46 +00:00
rfc-2528-type-changing-struct-update Modify primary span label for E0308 2023-01-30 20:12:19 +00:00
rfc-2565-param-attrs Adjust UI tests for unit_bindings 2023-06-12 20:24:48 +08:00
rfc-2627-raw-dylib Better group RFC ui tests together 2023-06-05 16:09:46 +00:00
rfc-2632-const-trait-impl Auto merge of #112320 - compiler-errors:do-not-impl-via-obj, r=lcnr 2023-06-20 08:42:37 +00:00
rfc-3348-c-string-literals fix tidy 2023-05-02 10:32:08 +00:00