@@ -709,6 +709,7 @@ impl<'i> RecipeCollector<'i, '_> {
709709 note. span ( ) ,
710710 implicit,
711711 definition_location. span ( ) ,
712+ definition_location. note . as_ref ( ) . map ( |n| n. span ( ) ) ,
712713 ) ) ;
713714 }
714715
@@ -933,6 +934,7 @@ impl<'i> RecipeCollector<'i, '_> {
933934 note. span ( ) ,
934935 implicit,
935936 definition_location. span ( ) ,
937+ definition_location. note . as_ref ( ) . map ( |n| n. span ( ) ) ,
936938 ) ) ;
937939 }
938940
@@ -1399,12 +1401,23 @@ fn find_temperature<'a>(text: &'a str, re: &Regex) -> Option<(&'a str, Quantity<
13991401 Some ( ( before, temperature, after) )
14001402}
14011403
1402- fn note_reference_error ( span : Span , implicit : bool , def_span : Span ) -> SourceDiag {
1404+ fn note_reference_error (
1405+ span : Span ,
1406+ implicit : bool ,
1407+ def_span : Span ,
1408+ def_note_span : Option < Span > ,
1409+ ) -> SourceDiag {
14031410 let span = Span :: new ( span. start ( ) . saturating_sub ( 1 ) , span. end ( ) + 1 ) ;
14041411
1405- let mut e = error ! ( "Note not allowed in reference" , label!( span, "remove this" ) )
1406- . hint ( "Add the note in the definition of the ingredient" )
1407- . label ( label ! ( Span :: pos( def_span. end( ) ) , "add the note here" ) ) ;
1412+ let mut e = error ! ( "Note not allowed in reference" , label!( span, "remove this" ) ) ;
1413+
1414+ if let Some ( sp) = def_note_span {
1415+ e. add_label ( label ! ( sp, "the definition already has a note" ) ) ;
1416+ } else {
1417+ e. add_hint ( "Add the note in the definition of the ingredient" ) ;
1418+ e. add_label ( label ! ( Span :: pos( def_span. end( ) ) , "add the note here" ) ) ;
1419+ }
1420+
14081421 if implicit {
14091422 e. add_hint ( IMPLICIT_REF_WARN ) ;
14101423 }
0 commit comments