From 6118228cb4c9494990774f18ecd270740b6c16c0 Mon Sep 17 00:00:00 2001 From: ISSOtm Date: Thu, 23 May 2024 14:03:57 +0200 Subject: [PATCH] Annotate `Report` and `ReportBuilder` with `#[must_use]` This ensures that one doesn't forget to call `.finish()` or `.eprint()` --- src/lib.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 91e3018..1a41bf0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -169,6 +169,7 @@ impl Label { } /// 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> { kind: ReportKind<'a>, code: Option, @@ -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,