Skip to content

Doc comments causing build errors #83492

Closed
@hquil

Description

@hquil

rustc 1.51.0 (2fd73fabe 2021-03-23)
rustc 1.53.0-nightly (07e0e2ec2 2021-03-24)

Docstrings placed at a few selected positions that cause either a warning (good), an unrelated error (bad) or both (ugly).

fn good(num: u8) -> bool {	
   match num {
      3 => true,
      /// warning: unused doc comment
      _ => false,
   }
}

fn bad(num: u8) -> bool {
   if num == 3 {
      true
   }
   /// error[E0308]: mismatched types
   /// error: expected expression, found keyword `else`
   else {
      false
   }
}

fn ugly(num: u8) -> bool {
   /// error[E0658]: attributes on expressions are experimental
   /// warning: unused doc comment
   num == 3
}

On the third example we at least get an additional warning to point us in the right direction.
The second example can become nightmare to catch :3

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-parserArea: The lexing & 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