]>
git.proxmox.com Git - rustc.git/blob - vendor/syn/tests/common/parse.rs
1 extern crate rustc_parse
as parse
;
3 extern crate syntax_expand
;
4 extern crate syntax_pos
;
8 use syntax
::sess
::ParseSess
;
9 use syntax
::source_map
::FilePathMapping
;
10 use syntax_pos
::FileName
;
14 pub fn libsyntax_expr(input
: &str) -> Option
<P
<ast
::Expr
>> {
15 match panic
::catch_unwind(|| {
16 let sess
= ParseSess
::new(FilePathMapping
::empty());
17 sess
.span_diagnostic
.set_continue_after_error(false);
18 let e
= parse
::new_parser_from_source_str(
20 FileName
::Custom("test_precedence".to_string()),
25 Ok(expr
) => Some(expr
),
26 Err(mut diagnostic
) => {
32 Ok(Some(e
)) => Some(e
),
35 errorf
!("libsyntax panicked\n");
41 pub fn syn_expr(input
: &str) -> Option
<syn
::Expr
> {
42 match syn
::parse_str(input
) {
45 errorf
!("syn failed to parse\n{:?}\n", msg
);