allow arbitrary inherent impls in the standard library · Issue #487 · rust-lang/compiler-team (original) (raw)

Proposal

We currently use a lot of different lang items to support inherent impls in the standard library, e.g.
https://github.com/rust-lang/rust/blob/6e5a6ffb14fc47051b0a23410c681ad6e4af045f/library/alloc/src/slice.rs#L659-L661

I intend to change both probe and coherence to deal with arbitrary inherent impls from all crates in the dependency crate with some special crate attribute, e.g. #[rustc_arbitrary_inherent_impls]. This change removes a lot of lang items and greatly improves the experience of library developers looking to move types into core. Alternatively, add 3 lang items for the crates core, alloc and std to only search these.

Having inherent impls for foreign types is sound and to my knowledge only forbidden because:

All of these things do not get worse if we stop requiring lang items in the standard library for this.

Mentors or Reviewers

If you have a reviewer or mentor in mind for this work, mention then here. You can put your own name here if you are planning to mentor the work.

Process

The main points of the Major Change Process are as follows:

You can read more about Major Change Proposals on forge.

Comments

This issue is not meant to be used for technical discussion. There is a Zulip stream for that. Use this issue to leave procedural comments, such as volunteering to review, indicating that you second the proposal (or third, etc), or raising a concern that you would like to be addressed.