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

Experiment: Const iterrator range with #[rustc_do_not_const_check] #107647

Closed

Conversation

onestacked
Copy link
Contributor

@onestacked onestacked commented Feb 3, 2023

TODO / this code will probably be used later in #104100:

r? @ghost

@rustbot
Copy link
Collaborator

rustbot commented Feb 3, 2023

Failed to set assignee to Ghost: invalid assignee

Note: Only org members, users with write permissions, or people who have commented on the PR may be assigned.

@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. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Feb 3, 2023
@onestacked onestacked changed the title Const iterrator range with #[rustc_do_not_const_check] Experiment: Const iterrator range with #[rustc_do_not_const_check] Feb 3, 2023
@onestacked
Copy link
Contributor Author

error[E0744]: `?` is not allowed in a `const fn`
   --> library/core/src/iter/range.rs:438:19
    |
438 |             res = Step::forward_checked(res, 0x800)?;
    |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

@fee1-dead Do you know why this doesn't work?

@fee1-dead
Copy link
Member

Enable #![feature(const_try)]?

@onestacked
Copy link
Contributor Author

It is enabled in library/core/src/lib.rs

@fee1-dead
Copy link
Member

fee1-dead commented Feb 4, 2023

Oh, then the function needs to be const-unstable so it can use unstable const features

EDIT: hmm it is unstable though..

@fee1-dead
Copy link
Member

This is probably a bug that needs fixing. The checking for ? is in rustc_passes that operates on the hir, unlike the const checking code we do on MIR. So there might be some complexity in that that doesn't work with rustc_do_not_const_check.

@onestacked
Copy link
Contributor Author

rustc_do_not_const_check does nothing here since it isn't yet in bootstrap, but i would think that ? should work here anyways.

@onestacked
Copy link
Contributor Author

And really the body of the Step impl functions should work without #[rustc_do_not_const_check] anyways, I just added it because i thought i might try it.

@onestacked
Copy link
Contributor Author

This commit now only implements const Step (and the internal RangeIteratorImpl) and that should work without #[rustc_do_not_const_check]

@onestacked
Copy link
Contributor Author

@fee1-dead Adding #[rustc_allow_const_fn_unstable(const_try)] lets it build, but I think that it should work without that since the Step implementation is rustc_const_unstable (this first commit does not use rustc_do_not_const_check).

Since this is still waiting for rustc_do_not_const_check and I don't think adding more #[cfg(bootstrap)]'s is a good idea I'm marking this as blocked.
@rustbot blocked

@rustbot rustbot added S-blocked Status: Marked as blocked ❌ on something else such as an RFC or other implementation work. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 4, 2023
@onestacked onestacked force-pushed the const_iterrator_range branch 2 times, most recently from e79c8cd to a805f13 Compare February 4, 2023 16:48
@bors
Copy link
Contributor

bors commented Feb 25, 2023

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

@onestacked onestacked closed this Feb 25, 2023
@onestacked onestacked deleted the const_iterrator_range branch February 25, 2023 01:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-blocked Status: Marked as blocked ❌ on something else such as an RFC or other implementation work. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants