@@ -65,9 +65,10 @@ pub struct Error {
6565 /// What kind of message we expect (e.g., warning, error, suggestion).
6666 pub kind : ErrorKind ,
6767 pub msg : String ,
68- /// For some `Error`s, like secondary lines of multi-line diagnostics, line annotations
69- /// are not mandatory, even if they would otherwise be mandatory for primary errors.
70- /// Only makes sense for "actual" errors, not for "expected" errors.
68+ /// For `Error`s from the compiler, like secondary lines of multi-line diagnostics, line
69+ /// annotations are not mandatory, even if they would otherwise be mandatory for primary errors.
70+ /// For `Error`s from annotations this can be false if the annotation doesn't require to
71+ /// annotate an actual error (useful for target-dependent errors).
7172 pub require_annotation : bool ,
7273}
7374
@@ -167,7 +168,9 @@ fn parse_expected(
167168 rest. split_once ( |c : char | c != '_' && !c. is_ascii_alphabetic ( ) ) . unwrap_or ( ( rest, "" ) ) ;
168169 let kind = ErrorKind :: from_user_str ( kind_str) ;
169170 let untrimmed_msg = & rest[ kind_str. len ( ) ..] ;
170- let msg = untrimmed_msg. strip_prefix ( ':' ) . unwrap_or ( untrimmed_msg) . trim ( ) . to_owned ( ) ;
171+ let require_annotation = !untrimmed_msg. starts_with ( '?' ) ;
172+ let msg = untrimmed_msg. strip_prefix ( '?' ) . unwrap_or ( untrimmed_msg) ;
173+ let msg = msg. strip_prefix ( ':' ) . unwrap_or ( msg) . trim ( ) . to_owned ( ) ;
171174
172175 let line_num_adjust = & captures[ "adjust" ] ;
173176 let ( follow_prev, line_num) = if line_num_adjust == "|" {
@@ -188,7 +191,7 @@ fn parse_expected(
188191 kind,
189192 msg
190193 ) ;
191- Some ( ( follow_prev, Error { line_num, kind, msg, require_annotation : true } ) )
194+ Some ( ( follow_prev, Error { line_num, kind, msg, require_annotation } ) )
192195}
193196
194197#[ cfg( test) ]
0 commit comments