Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
matthiaskrgr opened this issue Jan 10, 2023 · 2 comments · Fixed by #106784
Closed

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

matthiaskrgr opened this issue Jan 10, 2023 · 2 comments · Fixed by #106784
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

matthiaskrgr commented Jan 10, 2023

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
@matthiaskrgr matthiaskrgr added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 10, 2023
@lyming2007
Copy link

it's pretty similar with #105946. I'll take a look

@lyming2007
Copy link

@rustbot claim

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jan 17, 2023
…fleLapkin

prevent E0512 from emitting [type error] by checking the references_error

but still emit E0512
this will fix rust-lang#106695
@bors bors closed this as completed in d1478a5 Jan 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants