-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
648a35e
commit b76dd8c
Showing
9 changed files
with
200 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
#![feature(transmute_generic_consts)] | ||
#![feature(generic_const_exprs)] | ||
#![allow(incomplete_features)] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
// gate-test-transmute_generic_consts | ||
#![feature(generic_const_exprs)] | ||
#![allow(incomplete_features)] | ||
|
||
fn transpose<const W: usize, const H: usize>(v: [[u32;H]; W]) -> [[u32; W]; H] { | ||
unsafe { | ||
std::mem::transmute(v) | ||
//~^ ERROR cannot transmute | ||
} | ||
} | ||
|
||
fn ident<const W: usize, const H: usize>(v: [[u32; H]; W]) -> [[u32; H]; W] { | ||
unsafe { | ||
std::mem::transmute(v) | ||
} | ||
} | ||
|
||
fn flatten<const W: usize, const H: usize>(v: [[u32; H]; W]) -> [u32; W * H] { | ||
unsafe { | ||
std::mem::transmute(v) | ||
//~^ ERROR cannot transmute | ||
} | ||
} | ||
|
||
fn coagulate<const W: usize, const H: usize>(v: [u32; H*W]) -> [[u32; W];H] { | ||
unsafe { | ||
std::mem::transmute(v) | ||
//~^ ERROR cannot transmute | ||
} | ||
} | ||
|
||
fn flatten_3d<const W: usize, const H: usize, const D: usize>( | ||
v: [[[u32; D]; H]; W] | ||
) -> [u32; D * W * H] { | ||
unsafe { | ||
std::mem::transmute(v) | ||
//~^ ERROR cannot transmute | ||
} | ||
} | ||
|
||
fn flatten_somewhat<const W: usize, const H: usize, const D: usize>( | ||
v: [[[u32; D]; H]; W] | ||
) -> [[u32; D * W]; H] { | ||
unsafe { | ||
std::mem::transmute(v) | ||
//~^ ERROR cannot transmute | ||
} | ||
} | ||
|
||
fn known_size<const L: usize>(v: [u16; L]) -> [u8; L * 2] { | ||
unsafe { | ||
std::mem::transmute(v) | ||
//~^ ERROR cannot transmute | ||
} | ||
} | ||
|
||
fn condense_bytes<const L: usize>(v: [u8; L * 2]) -> [u16; L] { | ||
unsafe { | ||
std::mem::transmute(v) | ||
//~^ ERROR cannot transmute | ||
} | ||
} | ||
|
||
fn singleton_each<const L: usize>(v: [u8; L]) -> [[u8;1]; L] { | ||
unsafe { | ||
std::mem::transmute(v) | ||
//~^ ERROR cannot transmute | ||
} | ||
} | ||
|
||
fn transpose_with_const<const W: usize, const H: usize>( | ||
v: [[u32; 2 * H]; W + W] | ||
) -> [[u32; W + W]; 2 * H] { | ||
unsafe { | ||
std::mem::transmute(v) | ||
//~^ ERROR cannot transmute | ||
} | ||
} | ||
|
||
fn main() { | ||
let _ = transpose([[0; 8]; 16]); | ||
let _ = transpose_with_const::<8,4>([[0; 8]; 16]); | ||
let _ = ident([[0; 8]; 16]); | ||
let _ = flatten([[0; 13]; 5]); | ||
let _: [[_; 5]; 13] = coagulate([0; 65]); | ||
let _ = flatten_3d([[[0; 3]; 13]; 5]); | ||
let _ = flatten_somewhat([[[0; 3]; 13]; 5]); | ||
let _ = known_size([16; 13]); | ||
let _: [u16; 5] = condense_bytes([16u8; 10]); | ||
let _ = singleton_each([16; 10]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types | ||
--> $DIR/transmute_no_gate.rs:7:5 | ||
| | ||
LL | std::mem::transmute(v) | ||
| ^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: source type: `[[u32; H]; W]` (this type does not have a fixed size) | ||
= note: target type: `[[u32; W]; H]` (this type does not have a fixed size) | ||
|
||
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types | ||
--> $DIR/transmute_no_gate.rs:20:5 | ||
| | ||
LL | std::mem::transmute(v) | ||
| ^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: source type: `[[u32; H]; W]` (this type does not have a fixed size) | ||
= note: target type: `[u32; W * H]` (this type does not have a fixed size) | ||
|
||
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types | ||
--> $DIR/transmute_no_gate.rs:27:5 | ||
| | ||
LL | std::mem::transmute(v) | ||
| ^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: source type: `[u32; H*W]` (this type does not have a fixed size) | ||
= note: target type: `[[u32; W]; H]` (this type does not have a fixed size) | ||
|
||
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types | ||
--> $DIR/transmute_no_gate.rs:36:5 | ||
| | ||
LL | std::mem::transmute(v) | ||
| ^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: source type: `[[[u32; D]; H]; W]` (this type does not have a fixed size) | ||
= note: target type: `[u32; D * W * H]` (this type does not have a fixed size) | ||
|
||
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types | ||
--> $DIR/transmute_no_gate.rs:45:5 | ||
| | ||
LL | std::mem::transmute(v) | ||
| ^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: source type: `[[[u32; D]; H]; W]` (this type does not have a fixed size) | ||
= note: target type: `[[u32; D * W]; H]` (this type does not have a fixed size) | ||
|
||
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types | ||
--> $DIR/transmute_no_gate.rs:52:5 | ||
| | ||
LL | std::mem::transmute(v) | ||
| ^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: source type: `[u16; L]` (this type does not have a fixed size) | ||
= note: target type: `[u8; L * 2]` (this type does not have a fixed size) | ||
|
||
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types | ||
--> $DIR/transmute_no_gate.rs:59:5 | ||
| | ||
LL | std::mem::transmute(v) | ||
| ^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: source type: `[u8; L * 2]` (this type does not have a fixed size) | ||
= note: target type: `[u16; L]` (this type does not have a fixed size) | ||
|
||
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types | ||
--> $DIR/transmute_no_gate.rs:66:5 | ||
| | ||
LL | std::mem::transmute(v) | ||
| ^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: source type: `[u8; L]` (this type does not have a fixed size) | ||
= note: target type: `[[u8; 1]; L]` (this type does not have a fixed size) | ||
|
||
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types | ||
--> $DIR/transmute_no_gate.rs:75:5 | ||
| | ||
LL | std::mem::transmute(v) | ||
| ^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: source type: `[[u32; 2 * H]; W + W]` (this type does not have a fixed size) | ||
= note: target type: `[[u32; W + W]; 2 * H]` (this type does not have a fixed size) | ||
|
||
error: aborting due to 9 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0512`. |