Changing libsyntax to use result instead of panic?


Racer[1] uses libsyntax to parse small snippets of code when trying to complete or find definitions.

Unfortunately libsyntax panics on parse errors, which means racer must wrap calls to libsyntax in a thread. Spawning threads in this way is expensive for racer, doubling the time taken for a search in a lot of cases because of the number of times it calls into libsyntax.

I’m considering changing libsyntax to use Result<>s rather than panicing on a fatal error. In principle is this a change that the devs would be happy to accept?





Maybe we should just renamed panic!() to my_bad!(). :imp:

1 Like

I can’t speak for everyone, but I would be very happy to see that change. I think it is also something that has come up in the past as something we’d like to fix.

Awesome, I’ll get started on a patch. Thanks!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.