rust/library/core/src
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 Rollup merge of #107916 - reez12g:issue-107040, r=Amanieu 2023-05-30 12:57:38 +02:00
array Remove array_zip 2023-05-30 00:40:39 -07:00
ascii Add the basic ascii::Char type 2023-05-03 22:09:33 -07:00
async_iter use consistent terminology 2022-10-29 09:23:12 +02:00
cell replace version placeholders 2023-04-28 08:47:55 -07:00
char ascii::Char-ify the escaping code 2023-05-12 19:37:02 -07:00
cmp Merge two different equality specialization traits in core 2023-03-01 14:42:06 -08:00
convert remove reference to Into in ? operator core/std docs, fix 111655 2023-05-31 15:51:28 +01:00
ffi Bump to latest beta compiler 2023-05-30 08:00:10 -04:00
fmt Mark internal functions and traits unsafe 2023-05-15 14:31:00 -04:00
future Rollup merge of #109970 - danielhenrymantilla:add-poll-fn-pin-clarifications, r=thomcc 2023-06-19 19:26:25 +02:00
hash Swap out CURRENT_RUSTC_VERSION to 1.71.0 2023-05-30 07:54:29 -04:00
intrinsics Documentation 2023-05-15 12:08:16 +02:00
iter Fix typo 2023-06-14 16:52:29 +02:00
macros Mention env! in option_env!'s docs 2023-06-14 18:29:08 +03:00
mem Merge attrs, better validation 2023-06-20 04:38:55 +00:00
net Alter Display for Ipv6Addr for IPv4-compatible addresses 2023-06-13 22:30:38 -04:00
num Auto merge of #112724 - scottmcm:simpler-unchecked-shifts, r=Mark-Simulacrum 2023-06-19 04:48:35 +00:00
ops Auto merge of #103413 - RalfJung:phantom-dropck, r=lcnr 2023-05-13 00:23:51 +00:00
panic Rollup merge of #108356 - gftea:master, r=workingjubilee 2023-05-15 17:12:44 +02:00
prelude Revert "Remove #[alloc_error_handler] from the compiler and library" 2023-04-25 00:08:35 +02:00
ptr Auto merge of #112320 - compiler-errors:do-not-impl-via-obj, r=lcnr 2023-06-20 08:42:37 +00:00
slice Auto merge of #106343 - the8472:slice-iter-fold, r=scottmcm 2023-06-15 09:38:53 +00:00
str Add invalid_from_utf8 analogous to invalid_from_utf8_unchecked 2023-05-27 00:18:28 +02:00
sync replace version placeholders 2023-04-28 08:47:55 -07:00
task Auto merge of #96875 - SabrinaJewson:noop-waker, r=m-ou-se 2023-06-07 06:04:32 +00:00
unicode Apply changes to fix python linting errors 2023-06-16 20:56:01 -04:00
any.rs Fix typo 2023-06-07 21:27:51 -07:00
arch.rs move core::arch into separate file 2022-11-20 10:28:14 +01:00
ascii.rs ascii::Char-ify the escaping code 2023-05-12 19:37:02 -07:00
asserting.rs [RFC 2011] Library code 2022-05-22 07:18:32 -03:00
bool.rs core is now compilable 2023-04-16 07:20:26 +00:00
borrow.rs rm const traits in libcore 2023-04-16 06:49:27 +00:00
cell.rs Same for BorrowRef 2023-06-18 01:14:45 -07:00
clone.rs core is now compilable 2023-04-16 07:20:26 +00:00
cmp.rs Add #[inline] to functions that are never called 2023-05-07 12:41:37 +01:00
default.rs rm const traits in libcore 2023-04-16 06:49:27 +00:00
error.md Small round of typo fixes 2022-11-04 20:06:18 -07:00
error.rs Bump to latest beta 2023-03-15 08:55:22 -04:00
escape.rs ascii::Char-ify the escaping code 2023-05-12 19:37:02 -07:00
hint.rs Rollup merge of #108416 - pat-nel87:Issue-107957-black_box_docs, r=jyn514 2023-04-26 01:55:49 -05:00
internal_macros.rs rm const traits in libcore 2023-04-16 06:49:27 +00:00
intrinsics.rs Use 128 bits for TypeId hash 2023-06-04 08:34:48 -07:00
lib.rs Auto merge of #111524 - scottmcm:escape-using-ascii, r=cuviper 2023-05-20 04:43:17 +00:00
marker.rs Merge attrs, better validation 2023-06-20 04:38:55 +00:00
option.rs Rollup merge of #109093 - Dante-Broggi:patch-2, r=joshtriplett 2023-06-04 13:21:25 +02:00
panic.rs Shorten lifetime of even more panic temporaries 2023-05-15 03:47:37 -07:00
panicking.rs Launch a non-unwinding panic for misaligned pointer deref 2023-06-16 09:20:33 -04:00
pin.rs Document Pin memory layout 2023-05-18 01:30:12 -04:00
primitive.rs
primitive_docs.rs Extend unused_must_use to cover block exprs 2023-06-15 17:59:13 +08:00
result.rs replace version placeholders 2023-04-28 08:47:55 -07:00
time.rs Use fmt::Alignment instead of fmt::rt::v1::Alignment. 2023-04-20 18:03:47 +02:00
tuple.rs Impl ConstParamTy for tuples, make PartialStructuralEq a supertrait too 2023-06-01 18:21:42 +00:00
unit.rs Use implicit capture syntax in format_args 2022-03-10 10:23:40 -05:00