Closed
Description
#![feature(type_alias_impl_trait)]
type Tait = impl Sized;
fn main() {
let foo1: Tait = 0u32;
let foo2: Tait = unsafe { core::mem::transmute(foo1) };
}
gives
error[[E0391]](https://doc.rust-lang.org/nightly/error-index.html#E0391): cycle detected when computing type of `Tait::{opaque#0}`
--> src/main.rs:3:13
|
3 | type Tait = impl Sized;
| ^^^^^^^^^^
|
note: ...which requires type-checking `main`...
--> src/main.rs:5:1
|
5 | fn main() {
| ^^^^^^^^^
= note: ...which requires computing layout of `Tait`...
= note: ...which requires normalizing `Tait`...
= note: ...which again requires computing type of `Tait::{opaque#0}`, completing the cycle
note: cycle used when checking item types in top-level module
--> src/main.rs:1:1
|
1 | / #![feature(type_alias_impl_trait)]
2 | |
3 | | type Tait = impl Sized;
4 | |
... |
7 | | let foo2: Tait = unsafe { core::mem::transmute(foo1) };
8 | | }
| |_^
error[[E0512]](https://doc.rust-lang.org/nightly/error-index.html#E0512): cannot transmute between types of different sizes, or dependently-sized types
--> src/main.rs:7:31
|
7 | let foo2: Tait = unsafe { core::mem::transmute(foo1) };
| ^^^^^^^^^^^^^^^^^^^^
|
= note: `Tait` does not have a fixed size
I find it quite confusing that the transmute is not allowed. They're the same type after all.
@rustbot label A-impl-trait F-type_alias_impl_trait
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Done