Skip to content

Conversation

@jagourq
Copy link
Contributor

@jagourq jagourq commented Feb 4, 2016

Adds &mut [T; n] to *mut T and &mut [T; n] to *const T casts. Closes #24151.

@rust-highfive
Copy link
Contributor

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @nrc (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

// array-ptr-cast.

if m_expr.mutbl == hir::MutImmutable && m_cast.mutbl == hir::MutImmutable {
if !(m_expr.mutbl == hir::MutImmutable && m_cast.mutbl == hir::MutMutable) {
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this is correct - this would only allow casts from &[T; n] to *mut T, whereas you want casts from immutable to const and mut to mut.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It should do the opposite of that due to the ! at the front and only accept casts that are not
&[T; n] to *mut T. The other 3 casts work with a version of rustc that contains this change.

@nrc
Copy link
Member

nrc commented Feb 5, 2016

This will need some tests too.

@jagourq
Copy link
Contributor Author

jagourq commented Feb 5, 2016

@nrc Should I add a file to test/run-pass and to test/compile-fail then?

@nrc
Copy link
Member

nrc commented Feb 8, 2016

@Jexell yes, or you could find tests that already test similar casts and add tests to those files.

BTW, the CI tests are failing because you used a tab rather than spaces

@alexcrichton
Copy link
Member

Closing due to inactivity, but feel free to resubmit with the tests fixed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants