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

Reimplement ~const trait specialization #133325

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

compiler-errors
Copy link
Member

@compiler-errors compiler-errors commented Nov 22, 2024

Reimplement const specialization. We need this for PartialEq constification :)

r? lcnr

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 22, 2024
@compiler-errors compiler-errors changed the title Const spec Reimplement ~const trait specialization Nov 22, 2024
}

debug!("fulfill_implication: an impl for {:?} specializes {:?}", source_trait, target_trait);
// If the parent impl is const, then the specializing impl must be const.
Copy link
Member Author

@compiler-errors compiler-errors Nov 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to self: Actually I don't know if this is correct -- well, it's not sufficient.

const trait Bar {}
impl const Bar for T {}

const trait Foo {}
impl const Foo for T where T: ~const Bar {}
// specializing impl:
impl Foo for (T,) {}

The specializing impl satisfies (T,): ~const Bar because of the blanket impl, but it's still less const than the parent impl. I think we need to check that the specializing impl is also conditionally const, and then bail.

@compiler-errors
Copy link
Member Author

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants