lotsoftools

Rust Error E0647: The start function with a where clause

Understanding Rust Error E0647

Rust Error E0647 occurs when the start function is defined with a where clause, which is not allowed. The error message informs you of the incorrect use of the where clause with the start function.

Erroneous Code Example

#![allow(unused)]
#![feature(start)]

fn main() {
#[start]
fn start(_: isize, _: *const *const u8) -> isize where (): Copy {
    //^ error: start function is not allowed to have a where clause
    0
}
}

The error occurs due to the where clause being present in the start function definition:

fn start(_: isize, _: *const *const u8) -> isize where (): Copy

How to Fix Rust Error E0647

To fix Rust Error E0647, simply remove the where clause from the start function definition. Let's modify the erroneous code example above to correct the issue:

Corrected Code Example

#![allow(unused)]
#![feature(start)]

fn main() {
#[start]
fn start(_: isize, _: *const *const u8) -> isize {
    0
}
}

In the corrected code example, the where clause has been removed from the start function definition. By doing so, the compiler will no longer generate the E0647 error.

Conclusion

Rust Error E0647 occurs when a where clause is included in the definition of a start function, which is not allowed. By removing the where clause and updating the function definition accordingly, the error can be easily resolved.