rust-lang / rust-lang/rust

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

Open
#117,838 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-diagnostics D-papercut F-auto_traits T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the E0568 error-code documentation and the auto-trait diagnostic reproduced in the issue. Confirm which bounds auto traits actually reject, then align the diagnostic wording with that rule and verify the shown example's output.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.