| ab0a321b | 02-Jun-2026 |
Gary Guo <gary@garyguo.net> |
rust: ptr: remove implicit index projection syntax
All users have been converted to use keyworded index projection syntax to explicitly state their intention when doing index projection.
Reviewed-b
rust: ptr: remove implicit index projection syntax
All users have been converted to use keyworded index projection syntax to explicitly state their intention when doing index projection.
Reviewed-by: Alexandre Courbot <acourbot@nvidia.com> Reviewed-by: Andreas Hindborg <a.hindborg@kernel.org> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Signed-off-by: Gary Guo <gary@garyguo.net> Acked-by: Danilo Krummrich <dakr@kernel.org> Link: https://patch.msgid.link/20260602-projection-syntax-rework-v2-6-6989470f5440@garyguo.net Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
show more ...
|
| 38c3cbf5 | 02-Jun-2026 |
Gary Guo <gary@garyguo.net> |
rust: ptr: add panicking index projection variant
There have been a few cases where the programmer knows that the indices are in bounds but the compiler cannot deduce that. This is also compiler-ver
rust: ptr: add panicking index projection variant
There have been a few cases where the programmer knows that the indices are in bounds but the compiler cannot deduce that. This is also compiler-version-dependent, so using build indexing here can be problematic. On the other hand, it is also not ideal to use the fallible variant, as it adds an error handling path that is never hit.
Add a new panicking index projection for this scenario. Like all panicking operations, this should be used carefully only in cases where the user knows the index is going to be in bounds, and panicking would indicate something is catastrophically wrong.
To signify this, require users to explicitly denote the type of index being used. The existing two types of index projections also gain the keyworded version, which will be the recommended way going forward.
The keyworded syntax also paves the way of perhaps adding more flavors in the future, e.g. `unsafe` index projection. However, unless the code is extremely performance sensitive and bounds checking cannot be tolerated, the panicking variant is safer and should be preferred, so it will be left to the future when demand arises.
Signed-off-by: Gary Guo <gary@garyguo.net> Reviewed-by: Alexandre Courbot <acourbot@nvidia.com> Reviewed-by: Andreas Hindborg <a.hindborg@kernel.org> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Acked-by: Danilo Krummrich <dakr@kernel.org> Link: https://patch.msgid.link/20260602-projection-syntax-rework-v2-3-6989470f5440@garyguo.net [ Fixed broken intra-doc link. Added a few extra intra-doc links. Reworded some docs slightly. - Miguel ] Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
show more ...
|
| 4dda1912 | 02-Jun-2026 |
Gary Guo <gary@garyguo.net> |
rust: ptr: use `match` instead of `unwrap_or_else` for `build_index`
Use `match` to avoid potential inlining issues of the `unwrap_or_else` function.
Suggested-by: Alice Ryhl <aliceryhl@google.com>
rust: ptr: use `match` instead of `unwrap_or_else` for `build_index`
Use `match` to avoid potential inlining issues of the `unwrap_or_else` function.
Suggested-by: Alice Ryhl <aliceryhl@google.com> Link: https://lore.kernel.org/rust-for-linux/aeCKlut-88SbNsyW@google.com/ Signed-off-by: Gary Guo <gary@garyguo.net> Reviewed-by: Alexandre Courbot <acourbot@nvidia.com> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Acked-by: Danilo Krummrich <dakr@kernel.org> Link: https://patch.msgid.link/20260602-projection-syntax-rework-v2-2-6989470f5440@garyguo.net Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
show more ...
|