diff options
Diffstat (limited to 'crates/ra_cfg')
-rw-r--r-- | crates/ra_cfg/src/cfg_expr.rs | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/crates/ra_cfg/src/cfg_expr.rs b/crates/ra_cfg/src/cfg_expr.rs index fc93730d9..336fe25bc 100644 --- a/crates/ra_cfg/src/cfg_expr.rs +++ b/crates/ra_cfg/src/cfg_expr.rs | |||
@@ -86,17 +86,15 @@ fn next_cfg_expr(it: &mut SliceIter<tt::TokenTree>) -> Option<CfgExpr> { | |||
86 | mod tests { | 86 | mod tests { |
87 | use super::*; | 87 | use super::*; |
88 | 88 | ||
89 | use mbe::{ast_to_token_tree, TokenMap}; | 89 | use mbe::ast_to_token_tree; |
90 | use syntax::ast::{self, AstNode}; | 90 | use syntax::ast::{self, AstNode}; |
91 | 91 | ||
92 | fn get_token_tree_generated(input: &str) -> (tt::Subtree, TokenMap) { | ||
93 | let source_file = ast::SourceFile::parse(input).ok().unwrap(); | ||
94 | let tt = source_file.syntax().descendants().find_map(ast::TokenTree::cast).unwrap(); | ||
95 | ast_to_token_tree(&tt).unwrap() | ||
96 | } | ||
97 | |||
98 | fn assert_parse_result(input: &str, expected: CfgExpr) { | 92 | fn assert_parse_result(input: &str, expected: CfgExpr) { |
99 | let (tt, _) = get_token_tree_generated(input); | 93 | let (tt, _) = { |
94 | let source_file = ast::SourceFile::parse(input).ok().unwrap(); | ||
95 | let tt = source_file.syntax().descendants().find_map(ast::TokenTree::cast).unwrap(); | ||
96 | ast_to_token_tree(&tt).unwrap() | ||
97 | }; | ||
100 | let cfg = CfgExpr::parse(&tt); | 98 | let cfg = CfgExpr::parse(&tt); |
101 | assert_eq!(cfg, expected); | 99 | assert_eq!(cfg, expected); |
102 | } | 100 | } |