File tree Expand file tree Collapse file tree 3 files changed +11
-8
lines changed
proc-macro-srv/src/server Expand file tree Collapse file tree 3 files changed +11
-8
lines changed Original file line number Diff line number Diff line change @@ -71,7 +71,7 @@ impl server::FreeFunctions for RaSpanServer {
7171 & mut self ,
7272 s : & str ,
7373 ) -> Result < bridge:: Literal < Self :: Span , Self :: Symbol > , ( ) > {
74- let literal = ast:: Literal :: parse ( s) ;
74+ let literal = ast:: Literal :: parse ( s) . ok_or ( ( ) ) ? ;
7575 let literal = literal. tree ( ) ;
7676
7777 let kind = literal_to_external ( literal. kind ( ) ) . ok_or ( ( ) ) ?;
Original file line number Diff line number Diff line change @@ -63,7 +63,7 @@ impl server::FreeFunctions for TokenIdServer {
6363 & mut self ,
6464 s : & str ,
6565 ) -> Result < bridge:: Literal < Self :: Span , Self :: Symbol > , ( ) > {
66- let literal = ast:: Literal :: parse ( s) ;
66+ let literal = ast:: Literal :: parse ( s) . ok_or ( ( ) ) ? ;
6767 let literal = literal. tree ( ) ;
6868
6969 let kind = literal_to_external ( literal. kind ( ) ) . ok_or ( ( ) ) ?;
Original file line number Diff line number Diff line change @@ -188,7 +188,7 @@ impl SourceFile {
188188}
189189
190190impl ast:: Literal {
191- pub fn parse ( text : & str ) -> Parse < ast:: Literal > {
191+ pub fn parse ( text : & str ) -> Option < Parse < ast:: Literal > > {
192192 let lexed = parser:: LexedStr :: new ( text) ;
193193 let parser_input = lexed. to_input ( ) ;
194194 let parser_output = parser:: TopEntryPoint :: Expr . parse ( & parser_input) ;
@@ -197,11 +197,14 @@ impl ast::Literal {
197197
198198 errors. extend ( validation:: validate ( & root) ) ;
199199
200- assert_eq ! ( root. kind( ) , SyntaxKind :: LITERAL ) ;
201- Parse {
202- green,
203- errors : if errors. is_empty ( ) { None } else { Some ( errors. into ( ) ) } ,
204- _ty : PhantomData ,
200+ if root. kind ( ) == SyntaxKind :: LITERAL {
201+ Some ( Parse {
202+ green,
203+ errors : if errors. is_empty ( ) { None } else { Some ( errors. into ( ) ) } ,
204+ _ty : PhantomData ,
205+ } )
206+ } else {
207+ None
205208 }
206209 }
207210}
You can’t perform that action at this time.
0 commit comments