rust/library
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
..
alloc Introduce alloc::::UniqueRc 2023-06-19 12:24:06 -07:00
backtrace@4245978ca8 PS Vita std support 2023-05-07 18:57:43 +03:00
core Auto merge of #112320 - compiler-errors:do-not-impl-via-obj, r=lcnr 2023-06-20 08:42:37 +00:00
panic_abort
panic_unwind Partial stabilisation of c_unwind 2023-04-29 13:01:44 +01:00
portable-simd Explicit set workspace.resolver = "1" 2023-05-31 00:08:11 +01:00
proc_macro fix TODO comments 2023-05-02 10:32:07 +00:00
profiler_builtins
rtstartup
rustc-std-workspace-alloc
rustc-std-workspace-core
rustc-std-workspace-std
std Rollup merge of #112606 - clarfonthey:ip-display, r=thomcc 2023-06-19 17:53:35 -07:00
stdarch@d77878b729 Bump stdarch 2023-06-13 21:45:04 -07:00
sysroot Add a sysroot crate to represent the standard library crates 2023-04-25 13:40:36 +02:00
test ignore core, alloc and test tests that require unwinding on panic=abort 2023-06-13 15:53:24 +02:00
unwind