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

Fix unsafe blocks in s![] macro #1196

Merged
merged 1 commit into from
Mar 9, 2024
Merged

Conversation

jturner314
Copy link
Member

Before, the user could silently violate safety requirements of SliceInfo::new_unchecked by directly calling s![@parse inconsistent_values], where inconsistent_values represents inconsistent values for the dimensions, etc. Now, the macro calls SliceInfo::new_unchecked only in the ($($t:tt)*) arm, which always constructs the correct values for the call.

@jturner314 jturner314 added the bug label Aug 13, 2022
@jturner314 jturner314 mentioned this pull request Aug 13, 2022
@jturner314
Copy link
Member Author

CI results:

  • The clippy warning is a bug (bad diagnostic) in clippy on the current Rust beta; it's fixed in the latest nightly.
  • The cross_test error is something wrong with the GitHub action -- it's not an issue with ndarray.

Before, the user could silently violate safety requirements of
`SliceInfo::new_unchecked` by directly calling `s![@parse
inconsistent_values]`, where `inconsistent_values` represents
inconsistent values for the dimensions, etc. Now, the macro calls
`SliceInfo::new_unchecked` only in the `($($t:tt)*)` arm, which always
constructs the correct values for the call.
@bluss bluss added this pull request to the merge queue Mar 9, 2024
@bluss bluss removed this pull request from the merge queue due to a manual request Mar 9, 2024
@bluss bluss added this pull request to the merge queue Mar 9, 2024
Merged via the queue into rust-ndarray:master with commit f124a16 Mar 9, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants