Skip to content

const_trait_impl does not keep track of closures #119687

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
fmease opened this issue Jan 7, 2024 · 4 comments
Closed

const_trait_impl does not keep track of closures #119687

fmease opened this issue Jan 7, 2024 · 4 comments
Labels
A-closures Area: Closures (`|…| { … }`) C-bug Category: This is a bug. F-const_trait_impl `#![feature(const_trait_impl)]` F-effects `#![feature(effects)]` PG-const-traits Project group: Const traits T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@fmease
Copy link
Member

fmease commented Jan 7, 2024

The feature effects doesn't track the constness of closures.
This currently type-checks but it shouldn't:
Update: We (project-const-traits) have decided that we do want the code below to compile. It still holds true that effects doesn't track the constness of closures yet but we now plan on removing the need for const || {} (and remove the whole feature const_closures at some point) and want to rely on effect inference to make it work. Please see this Zulip discussion.

#![feature(effects)]
const fn f() { (|| {})() }

However, the following definitely shouldn't compile:

#![feature(effects)]
const fn f() { (|| println!())() }

Without effects, they get rejected early with error[E0015]: cannot call non-const closure in constant functions.

See also this Zulip discussion.

@fmease fmease added A-closures Area: Closures (`|…| { … }`) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. F-effects `#![feature(effects)]` labels Jan 7, 2024
@fmease fmease self-assigned this Jan 7, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jan 7, 2024
@fmease fmease removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jan 7, 2024
@fmease fmease removed their assignment Jan 7, 2024
@fmease
Copy link
Member Author

fmease commented Jan 8, 2024

cc this other Zulip discussion.

@fmease
Copy link
Member Author

fmease commented Jan 12, 2024

@obeis Have you read this Zulip discussion already? The plan has slightly changed. See also the updated issue description.

@obeis obeis removed their assignment Jan 14, 2024
@fee1-dead
Copy link
Member

cc @rust-lang/project-const-traits

@fmease fmease added the PG-const-traits Project group: Const traits label Mar 20, 2024
@fmease fmease added the F-const_trait_impl `#![feature(const_trait_impl)]` label Nov 15, 2024
@fmease fmease changed the title effects does not keep track of closures const_trait_impl does not keep track of closures Nov 16, 2024
@fmease
Copy link
Member Author

fmease commented Nov 16, 2024

#![feature(const_trait_impl)]
const fn f() { (|| println!())() }

Gets correctly rejected.

Closing in favor of rust-lang/project-const-traits#10

@fmease fmease closed this as not planned Won't fix, can't repro, duplicate, stale Nov 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-closures Area: Closures (`|…| { … }`) C-bug Category: This is a bug. F-const_trait_impl `#![feature(const_trait_impl)]` F-effects `#![feature(effects)]` PG-const-traits Project group: Const traits T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants