diff options
author | Aleksey Kladov <[email protected]> | 2020-08-13 09:17:59 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-08-13 09:36:04 +0100 |
commit | 5734cc85868bf5fe2e4e023b40913b2063a78e31 (patch) | |
tree | faab3b05956536abaab4ab87ec7f71684ba7c0d1 /crates/ra_cfg/src | |
parent | 3615758f8ebf5d2cdd5d82f10daa596acfc1a64f (diff) |
Simplify
Diffstat (limited to 'crates/ra_cfg/src')
-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 | } |