Logo
Explore Help
Register Sign In
rust-lang/rust
1
0
Fork 0
You've already forked rust
Code Issues Pull Requests Actions 1 Packages Projects Releases Wiki Activity
Files
c5c05c2528944e64bea76cb9e07e2aeb4be3cb15
rust/tests/ui/const-generics/transmute.rs

15 lines
284 B
Rust
Raw Normal View History

[AUTO-GENERATED] Migrate ui tests from `//` to `//@` directives
2024-02-16 20:02:50 +00:00
//@ run-pass
Add ability to transmute with generic consts Previously if the expression contained generic consts and did not have a directly equivalent type, transmuting the type in this way was forbidden, despite the two sizes being identical. Instead, we should be able to lazily tell if the two consts are identical, and if so allow them to be transmuted.
2022-12-29 09:45:19 +00:00
#![feature(generic_const_exprs)]
Add feature gate
2023-04-04 08:41:44 +00:00
#![feature(transmute_generic_consts)]
Add ability to transmute with generic consts Previously if the expression contained generic consts and did not have a directly equivalent type, transmuting the type in this way was forbidden, despite the two sizes being identical. Instead, we should be able to lazily tell if the two consts are identical, and if so allow them to be transmuted.
2022-12-29 09:45:19 +00:00
#![allow(incomplete_features)]
fn ident<const W: usize, const H: usize>(v: [[u32; H]; W]) -> [[u32; H]; W] {
unsafe {
std::mem::transmute(v)
}
}
fn main() {
let _ = ident([[0; 8]; 16]);
}
Reference in New Issue Copy Permalink
Powered by Gitea Version: 1.24.6 Page: 649ms Template: 4ms
English
Bahasa Indonesia Deutsch English Español Français Gaeilge Italiano Latviešu Magyar nyelv Nederlands Polski Português de Portugal Português do Brasil Suomi Svenska Türkçe Čeština Ελληνικά Български Русский Українська فارسی മലയാളം 日本語 简体中文 繁體中文(台灣) 繁體中文(香港) 한국어
Licenses API