]> git.lizzy.rs Git - rust.git/commit - src/tools/rustfmt
Rollup merge of #81479 - osa1:issue24151, r=lcnr
authorDylan DPC <dylan.dpc@gmail.com>
Fri, 12 Feb 2021 21:53:29 +0000 (22:53 +0100)
committerGitHub <noreply@github.com>
Fri, 12 Feb 2021 21:53:29 +0000 (22:53 +0100)
commitfc93e260e914aefb6896a65de025fb34127cccaf
treeea75ad358d946906d138142c1bdc7b566f90afcb
parent8280abc57b50a08b42cbfec39e6a6840f466c33c
parentd64b749f2cebcfec942ecbbb87e24a9f8cc28469
Rollup merge of #81479 - osa1:issue24151, r=lcnr

Allow casting mut array ref to mut ptr

Allow casting mut array ref to mut ptr

We now allow two new casts:

- mut array reference to mut ptr. Example:

      let mut x: [usize; 2] = [0, 0];
      let p = &mut x as *mut usize;

  We allow casting const array references to const pointers so not
  allowing mut references to mut pointers was inconsistent.

- mut array reference to const ptr. Example:

      let mut x: [usize; 2] = [0, 0];
      let p = &mut x as *const usize;

  This was similarly inconsistent as we allow casting mut references to
  const pointers.

Existing test 'vector-cast-weirdness' updated to test both cases.

Fixes #24151