Rust errors / Everything else
Rust compiler error · checked with rustc 1.99.0
Rust error E0641: cannot cast to a pointer of an unknown kind
What it meansAttempted to cast to/from a pointer with an unknown kind.
What rustc prints
error[E0641]: cannot cast to a pointer of an unknown kind --> main.rs:3:14 | 3 | let b = 0 as *const _; // error | ^^^^^^^^ needs more type information | = note: the type information given here is insufficient to check whether the pointer cast is valid
Real output of rustc 1.99.0 compiling the official example below (2021 edition). Your names and line numbers will differ; the first line is the part to match.
The compiler team's explanation
Attempted to cast to/from a pointer with an unknown kind.
Erroneous code example:
let b = 0 as *const _; // error
Type information must be provided if a pointer type being cast from/into another type which cannot be inferred:
// Creating a pointer from reference: type can be inferred
let a = &(String::from("Hello world!")) as *const _; // ok!
let b = 0 as *const i32; // ok!
let c: *const i32 = 0 as *const _; // ok!From rustc --explain E0641 (1.99.0), part of the Rust project, MIT or Apache-2.0. Official page.
Related errors
- E0061this function takes N arguments but M were supplied
- E0412cannot find type in this scope
- E0515cannot return reference to local variable
- E0728await is only allowed inside async functions and blocks
- E0627yield expression outside of coroutine literal
- E0628too many parameters for a coroutine (expected 0 or 1 parameters)
- E0646`main` function is not allowed to have a `where` clause
- E0659`foo` is ambiguous
Up next
Often hit nextE0061: this function takes N arguments but M were suppliedA related error from the same family.Read it next →Did this answer your question?