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

Revert "Allow ~const bounds on non-const functions" #102409

Closed
wants to merge 1 commit into from

Conversation

fee1-dead
Copy link
Member

Reverts #102273.

It is not sound to use ~const bounded trait types in const_generics because const_generics requires the type to be const at all times, while ~const does not guarantee that.

r? @oli-obk

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Sep 28, 2022
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 28, 2022
Comment on lines +20 to +24
fn generic<P: ~const T>() {}
//~^ ERROR `~const` is not allowed

fn where_clause<P>() where P: ~const T {}
//~^ ERROR `~const` is not allowed
Copy link
Contributor

Choose a reason for hiding this comment

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

Afaict from the impl, these functions would be accepted if they were in an impl block. They should only be allowed if the impl block is for a const Trait impl.

|| matches!(fk.ctxt(), Some(FnCtxt::Assoc(_)));
let tilde_const_allowed =
matches!(fk.header(), Some(FnHeader { constness: Const::Yes(_), .. }))
|| matches!(fk.ctxt(), Some(FnCtxt::Assoc(_)));

This comment was marked as duplicate.

@bors
Copy link
Contributor

bors commented Oct 4, 2022

☔ The latest upstream changes (presumably #102666) made this pull request unmergeable. Please resolve the merge conflicts.

@fee1-dead fee1-dead closed this Oct 21, 2022
@pietroalbini pietroalbini deleted the revert-102273-relax_const_bound branch November 13, 2022 21:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants