rust-lang / rust-lang/rust

`-Znext-solver=globally` breaks `TransmuteFrom<&T>`

Open
#161,251 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug F-transmutability needs-triage T-compiler WG-trait-system-refactor
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

I tried this code:

#![feature(transmutability)]

use std::mem::TransmuteFrom;

fn main() {
    let bytes: &[u8; 4] = unsafe { TransmuteFrom::<&i32>::transmute(&1i32) };
}

I expected to see this happen: code compiles (it does with -Znext-solver=coherence)

Instead, this happened: code doesn't compile

Meta

rustc --version --verbose:

rustc 1.100.0-nightly (67854e511 2026-08-15)
binary: rustc
commit-hash: 67854e511de21d881bb16426996cd4259d44aa2e
commit-date: 2026-08-15
host: x86_64-unknown-linux-gnu
release: 1.100.0-nightly
LLVM version: 23.1.0
Backtrace

error[E0277]: `&i32` cannot be safely transmuted into `&[u8; 4]`
  |
6 |     let bytes: &[u8; 4] = unsafe { TransmuteFrom::<&i32>::transmute(&1i32) };
  |                                    -------------------------------- ^^^^^ the nightly-only, unstable trait `TransmuteFrom<&i32, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `&[u8; 4]`
  |                                    |
  |                                    required by a bound introduced by this call

For more information about this error, try `rustc --explain E0277`.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the supplied minimal Rust program and run it on the stated nightly compiler with -Znext-solver=globally, comparing the result with -Znext-solver=coherence. Investigate the TransmuteFrom<&i32> trait-solving path; done means the example compiles with the global solver as it does with the coherence solver.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.