Skip to content

librustc: Take in account mutability when casting array to raw ptr. #14856

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

Closed
wants to merge 1 commit into from

Conversation

luqmana
Copy link
Member

@luqmana luqmana commented Jun 12, 2014

Fixes #14845.

mt1.ty, mt2.ty) => {
(&ty::ty_rptr(_, ty::mt { ty: mt1, mutbl: ast::MutImmutable }),
&ty::ty_ptr(ty::mt { ty: mt2, mutbl: ast::MutImmutable }))
if types_compatible(fcx, e.span, mt1, mt2) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, do we not intend to support &mut T to *mut T? I kind of assumed we did, though I can see an argument for not doing so, since the semantics are not compatible.

Copy link
Member Author

Choose a reason for hiding this comment

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

Currently, we allow &mut T to *mut T but not &mut [T] to *mut T. This change just disallows something like &[T] to *mut T.

Copy link
Contributor

Choose a reason for hiding this comment

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

On Fri, Jun 13, 2014 at 12:15:04PM -0700, Luqman Aden wrote:

Currently, we allow &mut T to *mut T but not &mut [T] to *mut T. This change just disallows something like &[T] to *mut T.

ok, hmm, I must have misread the patch.

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.

Shared reference to a fixed length vector in a struct can be cast to a *mut directly
2 participants