rust/tests/ui/unsized
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
..
box-instead-of-dyn-fn.rs Remove return type sized check hack from hir typeck 2023-05-18 01:53:01 +00:00
box-instead-of-dyn-fn.stderr Remove return type sized check hack from hir typeck 2023-05-18 01:53:01 +00:00
issue-30355.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-30355.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-40231-1.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-40231-2.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-71659.current.stderr Add rustc_do_not_implement_via_object 2023-06-20 04:38:46 +00:00
issue-71659.next.stderr Add rustc_do_not_implement_via_object 2023-06-20 04:38:46 +00:00
issue-71659.rs Add rustc_do_not_implement_via_object 2023-06-20 04:38:46 +00:00
issue-75707.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-75707.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-75899-but-gats.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-75899.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-91801.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-91801.stderr Simplify suggestion when returning bare dyn trait 2023-05-18 01:47:55 +00:00
issue-91803.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue-91803.stderr Simplify suggestion when returning bare dyn trait 2023-05-18 01:47:55 +00:00
issue-97732.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
maybe-bounds-where-cpass.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
maybe-bounds-where.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
maybe-bounds-where.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
param-mentioned-by-different-field.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
param-mentioned-by-different-field.stderr Modify primary span label for E0308 2023-01-30 20:12:19 +00:00
return-unsized-from-trait-method.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
return-unsized-from-trait-method.stderr Move /src/test to /tests 2023-01-11 09:32:08 +00:00
unchanged-param.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
unsized2.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
unsized3-rpass.rs Fix unintentional UB in ui tests 2023-02-15 09:05:05 -05:00
unsized3.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
unsized3.stderr change std::marker::Sized to just Sized 2023-06-15 12:01:38 +02:00
unsized5.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
unsized5.stderr change std::marker::Sized to just Sized 2023-06-15 12:01:38 +02:00
unsized6.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
unsized6.stderr change std::marker::Sized to just Sized 2023-06-15 12:01:38 +02:00
unsized7.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
unsized7.stderr change std::marker::Sized to just Sized 2023-06-15 12:01:38 +02:00
unsized-bare-typaram.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
unsized-bare-typaram.stderr change std::marker::Sized to just Sized 2023-06-15 12:01:38 +02:00
unsized-enum2.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
unsized-enum2.stderr change std::marker::Sized to just Sized 2023-06-15 12:01:38 +02:00
unsized-enum.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
unsized-enum.stderr change std::marker::Sized to just Sized 2023-06-15 12:01:38 +02:00
unsized-fn-arg.fixed Move /src/test to /tests 2023-01-11 09:32:08 +00:00
unsized-fn-arg.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
unsized-fn-arg.stderr change std::marker::Sized to just Sized 2023-06-15 12:01:38 +02:00
unsized-fn-param.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
unsized-fn-param.stderr Note base types of coercion 2023-05-12 00:10:52 +00:00
unsized-inherent-impl-self-type.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
unsized-inherent-impl-self-type.stderr change std::marker::Sized to just Sized 2023-06-15 12:01:38 +02:00
unsized-struct.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
unsized-struct.stderr change std::marker::Sized to just Sized 2023-06-15 12:01:38 +02:00
unsized-trait-impl-self-type.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
unsized-trait-impl-self-type.stderr change std::marker::Sized to just Sized 2023-06-15 12:01:38 +02:00
unsized-trait-impl-trait-arg.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
unsized-trait-impl-trait-arg.stderr change std::marker::Sized to just Sized 2023-06-15 12:01:38 +02:00
unsized-tuple-impls.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
unsized.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00