Skip to content

Bad diagnostic for misplaced where clause #126311

Closed
@bugaevc

Description

@bugaevc

Code

trait Service {
    type Output;
    type Error;
}

fn takes_service<S: Service>(s: S) where S::Error: Debug -> S::Output { loop {} }

Current output

Compiling playground v0.0.1 (/playground)
error: expected one of `(`, `+`, `,`, `::`, `<`, or `{`, found `->`
  --> src/main.rs:31:58
   |
31 | fn takes_service<S: Service>(s: S) where S::Error: Debug -> S::Output {
   |                                                    ------^^ expected one of `(`, `+`, `,`, `::`, `<`, or `{`
   |                                                    |    |
   |                                                    |    help: try adding parentheses
   |                                                    `Fn` bounds require arguments in parentheses

error: could not compile `playground` (bin "playground") due to 1 previous error

Desired output

Something about misplaced where clause, directing me to place it _after_ the return type

Rationale and extra context

No response

Other cases

No response

Rust Version

Build using the Nightly version: 1.81.0-nightly

(2024-06-11 d0227c6a19c2d6e8dceb)

Anything else?

No response

Metadata

Metadata

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions