@@ -51,6 +51,7 @@ diagnostic error code: ruget::api::bad_json
51
51
- [ ... handler options] ( #-handler-options )
52
52
- [ ... dynamic diagnostics] ( #-dynamic-diagnostics )
53
53
- [ ... syntax highlighting] ( #-syntax-highlighting )
54
+ - [ ... primary label] ( #-primary-label )
54
55
- [ ... collection of labels] ( #-collection-of-labels )
55
56
- [ Acknowledgements] ( #acknowledgements )
56
57
- [ License] ( #license )
@@ -689,6 +690,37 @@ trait to [`MietteHandlerOpts`] by calling the
689
690
[ ` with_syntax_highlighting ` ] ( MietteHandlerOpts::with_syntax_highlighting )
690
691
method. See the [ ` highlighters ` ] module docs for more details.
691
692
693
+ #### ... primary label
694
+
695
+ You can use the ` primary ` parameter to ` label ` to indicate that the label
696
+ is the primary label.
697
+
698
+ ``` rust
699
+ #[derive(Debug , Diagnostic , Error )]
700
+ #[error(" oops!" )]
701
+ struct MyError {
702
+ #[label(primary, " main issue" )]
703
+ primary_span : SourceSpan ,
704
+
705
+ #[label(" other label" )]
706
+ other_span : SourceSpan ,
707
+ }
708
+ ```
709
+
710
+ The ` primary ` parameter can be used at most once:
711
+
712
+ ``` rust
713
+ #[derive(Debug , Diagnostic , Error )]
714
+ #[error(" oops!" )]
715
+ struct MyError {
716
+ #[label(primary, " main issue" )]
717
+ primary_span : SourceSpan ,
718
+
719
+ #[label(primary, " other label" )] // Error: Cannot have more than one primary label.
720
+ other_span : SourceSpan ,
721
+ }
722
+ ```
723
+
692
724
#### ... collection of labels
693
725
694
726
When the number of labels is unknown, you can use a collection of ` SourceSpan `
0 commit comments