lotsoftools

Rust Error E0568: Super Trait in Auto Trait

Understanding Rust Error E0568

Rust Error E0568 occurs when a super trait is added to an auto trait. An auto trait is a blanket implementation for all existing types. However, having a super trait in an auto trait can filter out many of those types.

Erroneous code:

#![feature(auto_traits)]

auto trait Bound : Copy {} // error!

fn main() {}

In the code above, the auto trait Bound has a super trait, Copy. The problem with this is that very few types implement Copy, and thus, most of the existing types get filtered out when trying to implement the Bound trait.

Correcting Rust Error E0568

To fix Rust Error E0568, you can simply remove the super trait from the auto trait definition. By doing this, the auto trait can again apply to all existing types without any filtering.

Fixed code:

#![feature(auto_traits)]

auto trait Bound {} // ok!

fn main() {}

Now that the super trait has been removed, the auto trait Bound can apply to all existing types without restriction.

In summary, Rust Error E0568 occurs when a super trait is added to an auto trait. To fix this error, remove the super trait from the auto trait definition. This allows the auto trait to apply to all existing types without any restrictions.