Skip to content

Allow multiple inherent impls on primitive types #32631

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
alexcrichton opened this issue Mar 31, 2016 · 3 comments
Closed

Allow multiple inherent impls on primitive types #32631

alexcrichton opened this issue Mar 31, 2016 · 3 comments
Labels
C-feature-accepted Category: A feature request that has been accepted pending implementation. T-lang Relevant to the language team, which will review and decide on the PR/issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@alexcrichton
Copy link
Member

In the standard library it's pretty unfortunate that we have to redefine all methods on string, slice, characters, and floating point types in libraries outside of libcore with an inherent methods. It's also unfortunate to have all the extension traits in libcore.

Let's just bite the bullet and allow multiple inherent impls on this type. It will...

  • Reduce duplication (thereby preventing drift between API surface area)
  • Remove unstable traits
  • Perhaps be simpler in terms of resolve

We'll have to be sure to update rustdoc, however, to provide one unified view to the API surface area rather than multiple impl blocks.

cc @rust-lang/libs

@aturon
Copy link
Member

aturon commented Mar 31, 2016

cc @rust-lang/lang

@steveklabnik steveklabnik added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. T-lang Relevant to the language team, which will review and decide on the PR/issue. and removed A-libs labels Mar 24, 2017
@Mark-Simulacrum Mark-Simulacrum added the C-feature-request Category: A feature request, i.e: not implemented / a PR. label Jul 24, 2017
@dtolnay dtolnay added C-feature-accepted Category: A feature request that has been accepted pending implementation. and removed C-feature-request Category: A feature request, i.e: not implemented / a PR. labels Nov 18, 2017
@czipperz
Copy link
Contributor

It appears this has been put on the back burner. Does anyone plan to implement this?

@Mark-Simulacrum
Copy link
Member

We seem to mostly permit this today via some lang items (e.g.,

rust/src/libstd/f32.rs

Lines 28 to 29 in d0677b9

#[lang = "f32_runtime"]
impl f32 {
and

rust/src/libcore/num/f32.rs

Lines 147 to 149 in d0677b9

#[lang = "f32"]
#[cfg(not(test))]
impl f32 {
) -- closing as such. If I've misinterpreted then we can of course reopen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-accepted Category: A feature request that has been accepted pending implementation. T-lang Relevant to the language team, which will review and decide on the PR/issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

6 participants