rust-lang/rust · error
not implemented
Error message
not implemented
What it means
Thrown by `pointercast` in the `(true, false)` arm of its match on `(type_is_pointer(val_type), type_is_pointer(dest_ty))` — i.e. casting a pointer-typed value to a non-pointer destination type via `unimplemented!()`. The backend handles ptr→ptr, non-ptr→ptr (via `inttoptr`), and non-ptr→non-ptr (transmute via `bitcast`), but a direct pointer-to-integer reinterpretation routed through `pointercast` is not implemented and panics.
Source
Thrown at compiler/rustc_codegen_gcc/src/builder.rs:1339
fn pointercast(&mut self, value: RValue<'gcc>, dest_ty: Type<'gcc>) -> RValue<'gcc> {
let val_type = value.get_type();
match (type_is_pointer(val_type), type_is_pointer(dest_ty)) {
(false, true) => {
// NOTE: Projecting a field of a pointer type will attempt a cast from a signed char to
// a pointer, which is not supported by gccjit.
self.cx.context.new_cast(
self.location,
self.inttoptr(value, val_type.make_pointer()),
dest_ty,
)
}
(false, false) => {
// When they are not pointers, we want a transmute (or reinterpret_cast).
self.bitcast(value, dest_ty)
}
(true, true) => self.cx.context.new_cast(self.location, value, dest_ty),
(true, false) => unimplemented!(),
}
}
/* Comparisons */
fn icmp(&mut self, op: IntPredicate, lhs: RValue<'gcc>, rhs: RValue<'gcc>) -> RValue<'gcc> {
self.gcc_icmp(op, lhs, rhs)
}
fn fcmp(&mut self, op: RealPredicate, lhs: RValue<'gcc>, rhs: RValue<'gcc>) -> RValue<'gcc> {
// LLVM has a concept of "unordered compares", where eg ULT returns true if either the two
// arguments are unordered (i.e. either is NaN), or the lhs is less than the rhs. GCC does
// not natively have this concept, so in some cases we must manually handle NaNs
let must_handle_nan = match op {
RealPredicate::RealPredicateFalse => unreachable!(),
RealPredicate::RealOEQ => false,
RealPredicate::RealOGT => false,
RealPredicate::RealOGE => false,
RealPredicate::RealOLT => false,View on GitHub (pinned to 22057b88b0)
Solutions
- Update rustc_codegen_gcc to the commit matching your rustc toolchain
- If you control the codegen call site, route pointer→integer casts through `ptrtoint` + `intcast` instead of `pointercast`
- Implement the missing arm using the existing `inttoptr`/`ptrtoint` helpers
- Report with a minimal reproducer (transmute/union access) to rustc_codegen_gcc
Example fix
// before
(true, false) => unimplemented!(),
// after
(true, false) => {
// pointer -> non-pointer: reinterpret the address bits
let usize_value = self.cx.context.new_cast(None, value, self.cx.type_isize());
self.intcast(usize_value, dest_ty, false)
} Defensive patterns
Strategy: fallback
Validate before calling
// pointercast hits unimplemented!() in the (pointer, non-pointer) arm.
// Detect that case and route to ptrtoint instead of pointercast.
let from_ptr = type_is_pointer(value.get_type());
let to_ptr = type_is_pointer(dest_ty);
if from_ptr && !to_ptr {
return builder.ptrtoint(value, dest_ty);
}
// otherwise pointercast is safe (both ptr or both non-ptr) Try / catch
// These panics abort the compiler process; if you drive cg_gcc as a library,
// isolate the call and fall back to an explicit ptrtoint on panic.
match std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
builder.pointercast(value, dest_ty)
})) {
Ok(v) => v,
Err(_) => builder.ptrtoint(value, dest_ty),
} Prevention
- Never rely on pointercast for pointer-to-non-pointer conversions; call ptrtoint explicitly.
- When porting reinterpret_cast/transmute-style code, confirm both the operand and target are pointers, or both are non-pointers, before calling pointercast.
- Centralize cast dispatch in one helper so the (ptr, non-ptr) case always redirects to ptrtoint.
When it happens
Trigger: rustc emits a `pointercast` whose source is a pointer and whose destination type is an integer or aggregate (not itself a pointer), instead of routing it through `ptrtoint`. This arm fires for pointer-to-aggregate transmutes, union field projections of pointer type, or FFI casts that lower to a pointer→non-pointer `pointercast`.
Common situations: Nightly rustc changes to how `mem::transmute` of pointer-sized data, `#[repr(C)]` unions, or FFI structs holding pointers are lowered. Hits crates doing raw pointer reinterpretation or transmute between pointer and integer-sized types under `-Zcodegen-backend=gcc`.
Related errors
- first index in inbounds_gep
- `rustc_codegen_gcc` doesn't support scalable vectors yet
- not implemented
- internal error: entered unreachable code
- Called extract_element on a non-vector type
AI-assisted analysis of rust-lang/rust@22057b88b0 (2026-08-03).
Data as JSON: /data/errors/f0a595a1e0a0ce7c.json.
Report an issue: GitHub.