@@ -73,13 +73,15 @@ impl ASTWithValidityInfo {
7373}
7474
7575impl FromStr for ASTWithValidityInfo {
76- type Err = Vec < HeaderError < Span > > ;
76+ type Err = Vec < YaccGrammarError > ;
7777 /// Parses the `%grmtools section` expecting it to contain a `yacckind` entry.
78- fn from_str ( src : & str ) -> Result < Self , Vec < HeaderError < Span > > > {
78+ fn from_str ( src : & str ) -> Result < Self , Vec < YaccGrammarError > > {
7979 let mut errs = Vec :: new ( ) ;
80- let ( header, _) = GrmtoolsSectionParser :: new ( src, true ) . parse ( ) ?;
80+ let ( header, _) = GrmtoolsSectionParser :: new ( src, true )
81+ . parse ( )
82+ . map_err ( |mut errs| errs. drain ( ..) . map ( |e| e. into ( ) ) . collect :: < Vec < _ > > ( ) ) ?;
8183 if let Some ( HeaderValue ( _, yk_val) ) = header. get ( "yacckind" ) {
82- let yacc_kind = YaccKind :: try_from ( yk_val) . map_err ( |e| vec ! [ e] ) ?;
84+ let yacc_kind = YaccKind :: try_from ( yk_val) . map_err ( |e| vec ! [ e. into ( ) ] ) ?;
8385 let ast = {
8486 // We don't want to strip off the header so that span's will be correct.
8587 let mut yp = YaccParser :: new ( yacc_kind, src) ;
@@ -96,8 +98,9 @@ impl FromStr for ASTWithValidityInfo {
9698 } else {
9799 Err ( vec ! [ HeaderError {
98100 kind: HeaderErrorKind :: InvalidEntry ( "yacckind" ) ,
99- locations: vec![ ] ,
100- } ] )
101+ locations: vec![ Span :: new( 0 , 0 ) ] ,
102+ }
103+ . into( ) ] )
101104 }
102105 }
103106}
0 commit comments