Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please investigate original issue, it seems like this is not transmute problem

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please give a hint as to which directory it should belong to? (Or maybe just the part of the test file that indicates that the test might not be related to transmute).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like if you do your own investigation and found root cause of problem in that code, and decide whether it's fine to stay here, should be moved somewhere else or be deleted, one of requirement for the project is independence

Copy link
Copy Markdown
Contributor Author

@ujjwalvishwakarma2006 ujjwalvishwakarma2006 Mar 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From my perspective, the following could be potentially appropriate directories (not in priority order):

  • tests/ui/instrinsics: reason; because earlier instrinsicck was used to replace types with isize to compare sizes of two dynamically sized types.
  • tests/ui/associated-types: reason; the description mentions that

Tests focused on associated types. If the associated type is not in a trait definition, it belongs in the tests/ui/associated-inherent-types/ directory. Aspects exercised include, e.g., default associated types, overriding defaults, and type inference.

  • tests/ui/impl-traits: reason; some similar tests exist, but no transmutes are used.
  • tests/ui/layout: reason; as the memory layout of the [u8; 2] and struct Bar is different.
  • tests/ui/dst: reason; maybe because [u8; N] is dynamically sized

I am trying to figure out other potential candidates.

But as of now, transmute suits the most in my opinion, as most of the tests giving cannot transmute between different-sized types error are in the transmute directory only.

I take the just-above sentence back. Now, tests/ui/intrinsics is the most appropriate one here, imo.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But as of now, transmute suits the most in my opinion, as most of the tests giving cannot transmute between different-sized types error are in the transmute directory only.

it's not about error message, it's about why this code originally was failing

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it means, if you see word transmute in test, it's not always have to go to transmute directory

Copy link
Copy Markdown
Contributor Author

@ujjwalvishwakarma2006 ujjwalvishwakarma2006 Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is my understanding of the test:

  • This test checks if we can transmute from one data type to another data type when they have different types and memory layouts.
  • It results in ICE, because earlier the compiler used to replace generic types with isize to deduce the size of the types whose size can't be deduced at compile time.

Oh, wait, it may belong to tests/ui/intrinsics. See here. This particular comment mentions the second point that I wrote above. And it's the duty of intrinsic, so it may also be a potential candidate. I have updated this in the upper comment as well.
This is the most appropriate now. (even better than transmute, imo)

Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//! regression test for <https://github.com/rust-lang/rust/issues/32377>
//@ normalize-stderr: "\d+ bits" -> "N bits"

use std::mem;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
--> $DIR/issue-32377.rs:15:14
--> $DIR/transmute-phantomdata-generic-unequal-size.rs:16:14
|
LL | unsafe { mem::transmute(x) }
| ^^^^^^^^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//@ run-pass
//! regression test for <https://github.com/rust-lang/rust/issues/25746>
//@ build-pass
#![allow(unnecessary_transmutes)]
use std::mem::transmute;

Expand Down
Loading