File tree 3 files changed +11
-8
lines changed
proc-macro-srv/src/server
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 {
71
71
& mut self ,
72
72
s : & str ,
73
73
) -> Result < bridge:: Literal < Self :: Span , Self :: Symbol > , ( ) > {
74
- let literal = ast:: Literal :: parse ( s) ;
74
+ let literal = ast:: Literal :: parse ( s) . ok_or ( ( ) ) ? ;
75
75
let literal = literal. tree ( ) ;
76
76
77
77
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 {
63
63
& mut self ,
64
64
s : & str ,
65
65
) -> Result < bridge:: Literal < Self :: Span , Self :: Symbol > , ( ) > {
66
- let literal = ast:: Literal :: parse ( s) ;
66
+ let literal = ast:: Literal :: parse ( s) . ok_or ( ( ) ) ? ;
67
67
let literal = literal. tree ( ) ;
68
68
69
69
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 {
188
188
}
189
189
190
190
impl ast:: Literal {
191
- pub fn parse ( text : & str ) -> Parse < ast:: Literal > {
191
+ pub fn parse ( text : & str ) -> Option < Parse < ast:: Literal > > {
192
192
let lexed = parser:: LexedStr :: new ( text) ;
193
193
let parser_input = lexed. to_input ( ) ;
194
194
let parser_output = parser:: TopEntryPoint :: Expr . parse ( & parser_input) ;
@@ -197,11 +197,14 @@ impl ast::Literal {
197
197
198
198
errors. extend ( validation:: validate ( & root) ) ;
199
199
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
205
208
}
206
209
}
207
210
}
You can’t perform that action at this time.
0 commit comments