Skip to content

Commit

Permalink
Annotate Report and ReportBuilder with #[must_use]
Browse files Browse the repository at this point in the history
This ensures that one doesn't forget to call `.finish()` or `.eprint()`
  • Loading branch information
ISSOtm committed May 23, 2024
1 parent 876a093 commit 6b4c82b
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ impl<S: Span> Label<S> {
}

/// A type representing a diagnostic that is ready to be written to output.
#[must_use = "call `.print()` or `.eprint()` to print the report"]
pub struct Report<'a, S: Span = Range<usize>> {
kind: ReportKind<'a>,
code: Option<String>,
Expand Down Expand Up @@ -252,6 +253,7 @@ impl fmt::Display for ReportKind<'_> {
}

/// A type used to build a [`Report`].
#[must_use = "call `.finish()` to obtain a `Report`"]
pub struct ReportBuilder<'a, S: Span> {
kind: ReportKind<'a>,
code: Option<String>,
Expand Down

0 comments on commit 6b4c82b

Please sign in to comment.