Skip to content

Error message E0568 doesn't match actual restrictions on auto traits #117838

Open
@jruderman

Description

@jruderman

I noticed this while looking at #117829.

Code

#![feature(auto_traits)]

struct A {}

auto trait B where
    A: B,
{
}

fn main() {}

Error output

error[E0568]: auto traits cannot have super traits or lifetime bounds
 --> np.rs:5:14
  |
5 |   auto trait B where
  |  ____________-_^
  | |            |
  | |            auto traits cannot have super traits or lifetime bounds
6 | |     A: B,
  | |_________^ help: remove the super traits or lifetime bounds

error: aborting due to previous error

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

The problem

The error message E0568 refers to "super traits or lifetime bounds", but this code isn't trying to use either of those features.

I guess the error message should be updated to reflect the actual rule, or split into two error messages. But I'm not sure what the actual rule is for auto traits. No bounds at all, whether directly on the trait or in where clauses?

CC @FabianWolff who updated the rule and error message in #89494

Version

rustc 1.75.0-nightly (fdaaaf9f9 2023-11-08)
binary: rustc
commit-hash: fdaaaf9f923281ab98b865259aa40fbf93d72c7a
commit-date: 2023-11-08
host: x86_64-apple-darwin
release: 1.75.0-nightly
LLVM version: 17.0.4

@rustbot label +A-diagnostics +f-auto_traits

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsF-auto_traits`#![feature(auto_traits)]`

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions