Skip to content

size can vary because of [type error] in E0512 #106695

Closed
@matthiaskrgr

Description

@matthiaskrgr

Given the following code:

#![feature(type_alias_impl_trait)]
#![allow(dead_code)]

type Bug<T, U> = impl Fn(T) -> U + Copy; //~ ERROR cycle detected

const CONST_BUG: Bug<u8, ()> = unsafe { std::mem::transmute(|_: u8| ()) };
//~^ ERROR: cannot transmute

fn main() {}

The current output is:

....
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
 --> ./src/test/ui/type-alias-impl-trait/issue-53092-2.rs:6:41
  |
6 | const CONST_BUG: Bug<u8, ()> = unsafe { std::mem::transmute(|_: u8| ()) };
  |                                         ^^^^^^^^^^^^^^^^^^^
  |
  = note: source type: `[closure@./src/test/ui/type-alias-impl-trait/issue-53092-2.rs:6:61: 6:68]` (0 bits)
  = note: target type: `Bug<u8, ()>` (size can vary because of [type error])

error: aborting due to 2 previous errors

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions