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

Allow using Slice Iterators in const Contexts #104491

Closed

Conversation

onestacked
Copy link
Contributor

@onestacked onestacked commented Nov 16, 2022

based on #102225 by @fee1-dead

@rustbot
Copy link
Collaborator

rustbot commented Nov 16, 2022

r? @joshtriplett

(rustbot has picked a reviewer for you, use r? to override)

@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 Nov 16, 2022
@rustbot
Copy link
Collaborator

rustbot commented Nov 16, 2022

Hey! It looks like you've submitted a new PR for the library teams!

If this PR contains changes to any rust-lang/rust public library APIs then please comment with @rustbot label +T-libs-api -T-libs to tag it appropriately. If this PR contains changes to any unstable APIs please edit the PR description to add a link to the relevant API Change Proposal or create one if you haven't already. If you're unsure where your change falls no worries, just leave it as is and the reviewer will take a look and make a decision to forward on if necessary.

Examples of T-libs-api changes:

  • Stabilizing library features
  • Introducing insta-stable changes such as new implementations of existing stable traits on existing stable types
  • Introducing new or changing existing unstable library APIs (excluding permanently unstable features / features without a tracking issue)
  • Changing public documentation in ways that create new stability guarantees
  • Changing observable runtime behavior of library APIs

@onestacked onestacked marked this pull request as draft November 16, 2022 14:37
@onestacked
Copy link
Contributor Author

@rustbot label +T-libs-api -T-libs

@rustbot rustbot added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. and removed T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Nov 16, 2022
@onestacked
Copy link
Contributor Author

@rustbot label +S-experimental

@rustbot rustbot added the S-experimental Status: Ongoing experiment that does not require reviewing and won't be merged in its current state. label Nov 16, 2022
@the8472
Copy link
Member

the8472 commented Nov 16, 2022

This is the 2nd PR blocked on that PR which in turn is blocked on a bunch of concerns one of which is blocked on another WIP PR. It could take many months for these things to percolate.

@onestacked
Copy link
Contributor Author

I know, but I made those changes mainly because I wanted to know how much would be required for them.
And since I already had working local version I thought I should do a (Draft) PR so that no one will do unnecessary work re-implementing this in the future.

@fee1-dead
Copy link
Member

@chriss0612, you could r? @ghost when opening a PR so that the PR will not be automatically assigned a reviewer.

@rustbot
Copy link
Collaborator

rustbot commented Nov 17, 2022

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.

@bors
Copy link
Contributor

bors commented Nov 19, 2022

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

@jackh726 jackh726 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 10, 2023
@onestacked
Copy link
Contributor Author

Currently includes #104100, but DoubleEndedIterator could be made #[const_trait] here and the one for loop that uses a range could be manually converted to a while.

For Slices of zero sized types this is currently blocked on #92512, since there is currently not way to find the calculate the length of a zero sized slice without UB.

Theoretically const_eval_selectcould be used to panic for slices of ZST's at CTFE, but I don't think that is a good approach.

So I think that #92512 should be figured out before this is considerd for merging.

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Feb 27, 2023

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

@rust-log-analyzer

This comment has been minimized.

@onestacked
Copy link
Contributor Author

@rustbot label -T-compiler

@rustbot rustbot removed the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Mar 9, 2023
@bors
Copy link
Contributor

bors commented Mar 19, 2023

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

@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-tools failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
Prepare all required actions
Getting action download info
Download action repository 'actions/checkout@v3' (SHA:24cb9080177205b6e8c946b17badbe402adc938f)
Download action repository 'rust-lang/simpleinfra@master' (SHA:3fb2b44a4eaebb9ed8086446bde46c27199ef5ed)
Complete job name: PR (x86_64-gnu-tools, false, ubuntu-20.04-xl)
git config --global core.autocrlf false
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
env:
  CI_JOB_NAME: x86_64-gnu-tools
---
   Compiling memchr v2.5.0
   Compiling std v0.0.0 (/checkout/library/std)
   Compiling compiler_builtins v0.1.87
   Compiling unwind v0.0.0 (/checkout/library/unwind)
error[E0636]: the feature `const_pointer_byte_offsets` has already been declared
    |
147 | #![feature(const_pointer_byte_offsets)]
    |            ^^^^^^^^^^^^^^^^^^^^^^^^^^


error: unreachable block in `if` or `while` expression
    |
29  | /   macro_rules! iterator {
30  | |       (
30  | |       (
31  | |           struct $name:ident -> $ptr:ty,
32  | |           $elem:ty,
404 | |                       if is_empty!(self) {
    | |  ________________________________________^
405 | | |                         None
406 | | |                     } else {
406 | | |                     } else {
    | | |_____________________^ unreachable block in `if` or `while` expression
665 | |       }
666 | |   }
    | |___- in this expansion of `iterator!`
    |
    |
   ::: library/core/src/panic.rs:57:9
    |
57  |             $crate::panicking::panic_fmt($crate::const_format_args!($($t)+))
    |             ---------------------------------------------------------------- any code following this expression is unreachable
    |
   ::: library/core/src/slice/iter.rs:133:1
    |
133 |   / iterator! {struct Iter -> *const T, &'a T, const, {/* no mut */}, {
134 |   |     // FIXME(const_trait_impl)
135 |   |     // fn is_sorted_by<F>(self, mut compare: F) -> bool
136 |   |     // where
143 |   |     // }
144 |   | }}
    |   |__- in this macro invocation
    |
    |
    = note: `-D unreachable-code` implied by `-D warnings`

error: unreachable block in `if` or `while` expression
    |
29  | /   macro_rules! iterator {
30  | |       (
30  | |       (
31  | |           struct $name:ident -> $ptr:ty,
32  | |           $elem:ty,
620 | |                       if is_empty!(self) {
    | |  ________________________________________^
621 | | |                         None
622 | | |                     } else {
622 | | |                     } else {
    | | |_____________________^ unreachable block in `if` or `while` expression
665 | |       }
666 | |   }
    | |___- in this expansion of `iterator!`
    |
    |
   ::: library/core/src/panic.rs:57:9
    |
57  |             $crate::panicking::panic_fmt($crate::const_format_args!($($t)+))
    |             ---------------------------------------------------------------- any code following this expression is unreachable
    |
   ::: library/core/src/slice/iter.rs:133:1
    |
133 |   / iterator! {struct Iter -> *const T, &'a T, const, {/* no mut */}, {
134 |   |     // FIXME(const_trait_impl)
135 |   |     // fn is_sorted_by<F>(self, mut compare: F) -> bool
136 |   |     // where
143 |   |     // }
144 |   | }}
    |   |__- in this macro invocation


error: unreachable block in `if` or `while` expression
   ::: library/core/src/panic.rs:57:9
    |
57  |            $crate::panicking::panic_fmt($crate::const_format_args!($($t)+))
    |            ---------------------------------------------------------------- any code following this expression is unreachable
    |            ---------------------------------------------------------------- any code following this expression is unreachable
    |
   ::: library/core/src/slice/iter.rs:366:1
    |
366 |    iterator! {struct IterMut -> *mut T, &'a mut T, mut, {mut}, {}}
   --> library/core/src/slice/iter/macros.rs:404:40
    |
29  | /  macro_rules! iterator {
30  | |      (
30  | |      (
31  | |          struct $name:ident -> $ptr:ty,
32  | |          $elem:ty,
404 | |                      if is_empty!(self) {
    | | ________________________________________^
405 | ||                         None
406 | ||                     } else {
406 | ||                     } else {
    | ||_____________________^ unreachable block in `if` or `while` expression
665 | |      }
666 | |  }
    | |__- in this expansion of `iterator!`


error: unreachable block in `if` or `while` expression
   ::: library/core/src/panic.rs:57:9
    |
57  |            $crate::panicking::panic_fmt($crate::const_format_args!($($t)+))
    |            ---------------------------------------------------------------- any code following this expression is unreachable
    |            ---------------------------------------------------------------- any code following this expression is unreachable
    |
   ::: library/core/src/slice/iter.rs:366:1
    |
366 |    iterator! {struct IterMut -> *mut T, &'a mut T, mut, {mut}, {}}
   --> library/core/src/slice/iter/macros.rs:620:40
    |
29  | /  macro_rules! iterator {
30  | |      (
30  | |      (
31  | |          struct $name:ident -> $ptr:ty,
32  | |          $elem:ty,
620 | |                      if is_empty!(self) {
    | | ________________________________________^
621 | ||                         None
622 | ||                     } else {
622 | ||                     } else {
    | ||_____________________^ unreachable block in `if` or `while` expression
665 | |      }
666 | |  }
    | |__- in this expansion of `iterator!`

@bors
Copy link
Contributor

bors commented Mar 20, 2023

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

@Dylan-DPC
Copy link
Member

Closing this as it is an experiment and blocked on multiple things

@Dylan-DPC Dylan-DPC closed this May 17, 2023
@Dylan-DPC Dylan-DPC removed the S-blocked Status: Marked as blocked ❌ on something else such as an RFC or other implementation work. label May 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-experimental Status: Ongoing experiment that does not require reviewing and won't be merged in its current state. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants