Skip to content

Constify Index traits #143921

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

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

Constify Index traits #143921

wants to merge 3 commits into from

Conversation

oli-obk
Copy link
Contributor

@oli-obk oli-obk commented Jul 14, 2025

tracking issue: #143775

the SliceIndex trait cannot be implemented by users as it is sealed. While it would be useful for the get method on slices, it seems weird to have a feature gate for that that isn't also gating index syntax at the same time, so I put them under the same feature gate.

r? @fee1-dead

@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 Jul 14, 2025
Copy link
Member

@fee1-dead fee1-dead left a comment

Choose a reason for hiding this comment

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

really nice. I'm happy that this was done without any change to the actual logic :D

@fee1-dead
Copy link
Member

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Jul 14, 2025

📌 Commit 8b350d5 has been approved by fee1-dead

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 14, 2025
Kobzol added a commit to Kobzol/rust that referenced this pull request Jul 14, 2025
Constify `Index` traits

tracking issue: rust-lang#143775

the `SliceIndex` trait cannot be implemented by users as it is sealed. While it would be useful for the `get` method on slices, it seems weird to have a feature gate for that that isn't also gating index syntax at the same time, so I put them under the same feature gate.

r? `@fee1-dead`
Kobzol added a commit to Kobzol/rust that referenced this pull request Jul 14, 2025
Constify `Index` traits

tracking issue: rust-lang#143775

the `SliceIndex` trait cannot be implemented by users as it is sealed. While it would be useful for the `get` method on slices, it seems weird to have a feature gate for that that isn't also gating index syntax at the same time, so I put them under the same feature gate.

r? ``@fee1-dead``
@jieyouxu
Copy link
Member

Failed in rollup: #143947 (comment)

error[E0658]: cannot call conditionally-const method `core::slice::<impl [()]>::get_unchecked::<std::ops::Range<usize>>` in constants
##[error]  --> /checkout/tests/ui/consts/const-eval/ub-slice-get-unchecked.rs:7:29
   |
LL | const B: &[()] = unsafe { A.get_unchecked(3..1) };

@bors r-

@bors bors 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jul 15, 2025
@oli-obk
Copy link
Contributor Author

oli-obk commented Jul 15, 2025

@bors r=fee1-dead

@bors
Copy link
Collaborator

bors commented Jul 15, 2025

📌 Commit 2b4ede7 has been approved by fee1-dead

It is now in the queue for this repository.

@bors
Copy link
Collaborator

bors commented Jul 15, 2025

🌲 The tree is currently closed for pull requests below priority 100. This pull request will be tested once the tree is reopened.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 15, 2025
samueltardieu added a commit to samueltardieu/rust that referenced this pull request Jul 15, 2025
Constify `Index` traits

tracking issue: rust-lang#143775

the `SliceIndex` trait cannot be implemented by users as it is sealed. While it would be useful for the `get` method on slices, it seems weird to have a feature gate for that that isn't also gating index syntax at the same time, so I put them under the same feature gate.

r? `@fee1-dead`
samueltardieu added a commit to samueltardieu/rust that referenced this pull request Jul 15, 2025
Constify `Index` traits

tracking issue: rust-lang#143775

the `SliceIndex` trait cannot be implemented by users as it is sealed. While it would be useful for the `get` method on slices, it seems weird to have a feature gate for that that isn't also gating index syntax at the same time, so I put them under the same feature gate.

r? ``@fee1-dead``
samueltardieu added a commit to samueltardieu/rust that referenced this pull request Jul 15, 2025
Constify `Index` traits

tracking issue: rust-lang#143775

the `SliceIndex` trait cannot be implemented by users as it is sealed. While it would be useful for the `get` method on slices, it seems weird to have a feature gate for that that isn't also gating index syntax at the same time, so I put them under the same feature gate.

r? ```@fee1-dead```
samueltardieu added a commit to samueltardieu/rust that referenced this pull request Jul 15, 2025
Constify `Index` traits

tracking issue: rust-lang#143775

the `SliceIndex` trait cannot be implemented by users as it is sealed. While it would be useful for the `get` method on slices, it seems weird to have a feature gate for that that isn't also gating index syntax at the same time, so I put them under the same feature gate.

r? ````@fee1-dead````
samueltardieu added a commit to samueltardieu/rust that referenced this pull request Jul 15, 2025
Constify `Index` traits

tracking issue: rust-lang#143775

the `SliceIndex` trait cannot be implemented by users as it is sealed. While it would be useful for the `get` method on slices, it seems weird to have a feature gate for that that isn't also gating index syntax at the same time, so I put them under the same feature gate.

r? `````@fee1-dead`````
bors added a commit that referenced this pull request Jul 15, 2025
Rollup of 12 pull requests

Successful merges:

 - #142936 (rustdoc-json: Structured attributes)
 - #143355 (wrapping shift: remove first bitmask and table)
 - #143448 (remote-test-client: Exit code `128 + <signal-number>` instead of `3`)
 - #143692 (miri: fix out-of-bounds error for ptrs with negative offsets)
 - #143719 (Emit warning when there is no space between `-o` and arg)
 - #143738 (Move several float tests to floats/mod.rs)
 - #143891 (Port `#[coverage]` to the new attribute system)
 - #143920 (Make more of codegen_llvm safe)
 - #143921 (Constify `Index` traits)
 - #143939 (Add 0323pin as maintainer of NetBSD targets, fix link to pkgsrc-wip and explain.)
 - #143948 (Update mdbook to 0.4.52)
 - #143968 (Add tracing to `InterpCx::fn_abi_of_instance/fn_abi_of_fn_ptr`)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit that referenced this pull request Jul 15, 2025
Rollup of 12 pull requests

Successful merges:

 - #142936 (rustdoc-json: Structured attributes)
 - #143355 (wrapping shift: remove first bitmask and table)
 - #143448 (remote-test-client: Exit code `128 + <signal-number>` instead of `3`)
 - #143692 (miri: fix out-of-bounds error for ptrs with negative offsets)
 - #143719 (Emit warning when there is no space between `-o` and arg)
 - #143738 (Move several float tests to floats/mod.rs)
 - #143891 (Port `#[coverage]` to the new attribute system)
 - #143920 (Make more of codegen_llvm safe)
 - #143921 (Constify `Index` traits)
 - #143939 (Add 0323pin as maintainer of NetBSD targets, fix link to pkgsrc-wip and explain.)
 - #143948 (Update mdbook to 0.4.52)
 - #143968 (Add tracing to `InterpCx::fn_abi_of_instance/fn_abi_of_fn_ptr`)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit that referenced this pull request Jul 15, 2025
Rollup of 12 pull requests

Successful merges:

 - #142936 (rustdoc-json: Structured attributes)
 - #143355 (wrapping shift: remove first bitmask and table)
 - #143448 (remote-test-client: Exit code `128 + <signal-number>` instead of `3`)
 - #143692 (miri: fix out-of-bounds error for ptrs with negative offsets)
 - #143719 (Emit warning when there is no space between `-o` and arg)
 - #143738 (Move several float tests to floats/mod.rs)
 - #143891 (Port `#[coverage]` to the new attribute system)
 - #143920 (Make more of codegen_llvm safe)
 - #143921 (Constify `Index` traits)
 - #143939 (Add 0323pin as maintainer of NetBSD targets, fix link to pkgsrc-wip and explain.)
 - #143948 (Update mdbook to 0.4.52)
 - #143968 (Add tracing to `InterpCx::fn_abi_of_instance/fn_abi_of_fn_ptr`)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit that referenced this pull request Jul 15, 2025
Rollup of 12 pull requests

Successful merges:

 - #142936 (rustdoc-json: Structured attributes)
 - #143355 (wrapping shift: remove first bitmask and table)
 - #143448 (remote-test-client: Exit code `128 + <signal-number>` instead of `3`)
 - #143692 (miri: fix out-of-bounds error for ptrs with negative offsets)
 - #143719 (Emit warning when there is no space between `-o` and arg)
 - #143738 (Move several float tests to floats/mod.rs)
 - #143891 (Port `#[coverage]` to the new attribute system)
 - #143920 (Make more of codegen_llvm safe)
 - #143921 (Constify `Index` traits)
 - #143939 (Add 0323pin as maintainer of NetBSD targets, fix link to pkgsrc-wip and explain.)
 - #143948 (Update mdbook to 0.4.52)
 - #143968 (Add tracing to `InterpCx::fn_abi_of_instance/fn_abi_of_fn_ptr`)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit that referenced this pull request Jul 15, 2025
Rollup of 12 pull requests

Successful merges:

 - #142936 (rustdoc-json: Structured attributes)
 - #143355 (wrapping shift: remove first bitmask and table)
 - #143448 (remote-test-client: Exit code `128 + <signal-number>` instead of `3`)
 - #143692 (miri: fix out-of-bounds error for ptrs with negative offsets)
 - #143719 (Emit warning when there is no space between `-o` and arg)
 - #143738 (Move several float tests to floats/mod.rs)
 - #143891 (Port `#[coverage]` to the new attribute system)
 - #143920 (Make more of codegen_llvm safe)
 - #143921 (Constify `Index` traits)
 - #143939 (Add 0323pin as maintainer of NetBSD targets, fix link to pkgsrc-wip and explain.)
 - #143948 (Update mdbook to 0.4.52)
 - #143968 (Add tracing to `InterpCx::fn_abi_of_instance/fn_abi_of_fn_ptr`)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit that referenced this pull request Jul 15, 2025
Rollup of 12 pull requests

Successful merges:

 - #142936 (rustdoc-json: Structured attributes)
 - #143355 (wrapping shift: remove first bitmask and table)
 - #143448 (remote-test-client: Exit code `128 + <signal-number>` instead of `3`)
 - #143692 (miri: fix out-of-bounds error for ptrs with negative offsets)
 - #143719 (Emit warning when there is no space between `-o` and arg)
 - #143738 (Move several float tests to floats/mod.rs)
 - #143891 (Port `#[coverage]` to the new attribute system)
 - #143920 (Make more of codegen_llvm safe)
 - #143921 (Constify `Index` traits)
 - #143939 (Add 0323pin as maintainer of NetBSD targets, fix link to pkgsrc-wip and explain.)
 - #143948 (Update mdbook to 0.4.52)
 - #143968 (Add tracing to `InterpCx::fn_abi_of_instance/fn_abi_of_fn_ptr`)

r? `@ghost`
`@rustbot` modify labels: rollup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

5 participants