pub fn parse_source<R: Send>(
file: &RelPath,
text: &str,
visit: impl FnOnce(&File) -> R + Send,
) -> Result<R, LoadError>Expand description
Parse text as a Rust file and run visit on the syntax tree.
The recursion budgets and the token budget, at its default limit
(Budget::FileTokens), are checked on the
caller’s thread first. The parse
and visit then run on a scoped thread named after file, with a stack of
PARSE_STACK_BYTES; a stack overflow in the runtime names that thread.
A panic in visit or in the parser is raised again on the caller’s thread.
The tree is dropped when visit returns, so visit copies out what the
caller keeps.
§Errors
Returns a LoadError naming file when the text exceeds a budget
(LoadErrorKind::Budget), is not valid Rust (LoadErrorKind::Syntax)
or the thread cannot start (LoadErrorKind::Spawn).
§Panics
Panics only when visit or the parser panics, with the original payload.