Skip to content
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

Making impls const across bootstrap versions #7

Open
compiler-errors opened this issue Oct 24, 2024 · 2 comments
Open

Making impls const across bootstrap versions #7

compiler-errors opened this issue Oct 24, 2024 · 2 comments

Comments

@compiler-errors
Copy link
Member

As we re-constify traits, we're gonna have issues when constifying impls across bootstrap versions, since we have to basically duplicate the whole impl since we can't currently cfg out constness of an impl:

#[cfg(bootstrap)]
impl Foo for Bar {}

#[cfg(not(bootstrap))]
impl const Foo for Bar {}

SOLUTION

So we probably should make it possible to do this, i.e. allow an new attribute like rustc_const_impl so we can just do:

#[cfg_attr(not(bootstrap), rustc_const_impl)]
impl const Foo for Bar {}

Then after a bootstrap bump, we will just have:

#[rustc_const_impl]
imp Foo for Bar {}

Which can then just trivially be converted to:

impl const Foo for Bar {}
@RalfJung
Copy link
Member

I assume this

#[cfg_attr(not(bootstrap), rustc_const_impl)]
impl const Foo for Bar {}

should be

#[cfg_attr(not(bootstrap), rustc_const_impl)]
impl Foo for Bar {}

Also this will only be a problem once, right, when impl const re-lands? So we can also "just" wait a cycle before we start mass-adding this again. But we're not patient enough for that. ;)

@compiler-errors
Copy link
Member Author

I assume this

Yeah, typo.

But we're not patient enough for that. ;)

Yeah, I guess we could wait one beta bump after we land the effects implementation of the old trait solver (rust-lang/rust#132119) before we start constifying traits in the standard library. I am impatient, but it may end up being fine if we can just land that PR soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants