Skip to content

Unhelpful error message because of inner line doc #65329

Closed

Description

The code

fn main() {
    let x = 0;
    let y = x.max(1) //!foo
        .min(2);
}

I get this error:

error: expected one of `.`, `;`, `?`, or an operator, found `//!foo`
 --> src/main.rs:3:22
  |
3 |     let y = x.max(1) //!foo
  |                      ^^^^^^ expected one of `.`, `;`, `?`, or an operator here

Probably something like:

error: expected outer doc comment
 --> src/main.rs:3:16
  |
3 |     let y = x; //!foo
  |                ^^^^^^
  |
  = note: inner doc comments like this (starting with `//!` or `/*!`) can only appear before items

is more helpful because at least you can understand what's wrong (especially when you don't know inner doc comments).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-parserArea: The parsing of Rust source code to an ASTC-enhancementCategory: An issue proposing an enhancement or a PR with one.T-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