diff options
Diffstat (limited to 'crates/ra_cfg/src')
-rw-r--r-- | crates/ra_cfg/src/cfg_expr.rs | 10 | ||||
-rw-r--r-- | crates/ra_cfg/src/lib.rs | 7 |
2 files changed, 7 insertions, 10 deletions
diff --git a/crates/ra_cfg/src/cfg_expr.rs b/crates/ra_cfg/src/cfg_expr.rs index 39d71851c..85b100c6a 100644 --- a/crates/ra_cfg/src/cfg_expr.rs +++ b/crates/ra_cfg/src/cfg_expr.rs | |||
@@ -88,13 +88,17 @@ fn next_cfg_expr(it: &mut SliceIter<tt::TokenTree>) -> Option<CfgExpr> { | |||
88 | mod tests { | 88 | mod tests { |
89 | use super::*; | 89 | use super::*; |
90 | 90 | ||
91 | use mbe::ast_to_token_tree; | 91 | use mbe::{ast_to_token_tree, TokenMap}; |
92 | use ra_syntax::ast::{self, AstNode}; | 92 | use ra_syntax::ast::{self, AstNode}; |
93 | 93 | ||
94 | fn assert_parse_result(input: &str, expected: CfgExpr) { | 94 | fn get_token_tree_generated(input: &str) -> (tt::Subtree, TokenMap) { |
95 | let source_file = ast::SourceFile::parse(input).ok().unwrap(); | 95 | let source_file = ast::SourceFile::parse(input).ok().unwrap(); |
96 | let tt = source_file.syntax().descendants().find_map(ast::TokenTree::cast).unwrap(); | 96 | let tt = source_file.syntax().descendants().find_map(ast::TokenTree::cast).unwrap(); |
97 | let (tt, _) = ast_to_token_tree(&tt).unwrap(); | 97 | ast_to_token_tree(&tt).unwrap() |
98 | } | ||
99 | |||
100 | fn assert_parse_result(input: &str, expected: CfgExpr) { | ||
101 | let (tt, _) = get_token_tree_generated(input); | ||
98 | assert_eq!(parse_cfg(&tt), expected); | 102 | assert_eq!(parse_cfg(&tt), expected); |
99 | } | 103 | } |
100 | 104 | ||
diff --git a/crates/ra_cfg/src/lib.rs b/crates/ra_cfg/src/lib.rs index 51d953f6e..57feabcb2 100644 --- a/crates/ra_cfg/src/lib.rs +++ b/crates/ra_cfg/src/lib.rs | |||
@@ -2,8 +2,6 @@ | |||
2 | 2 | ||
3 | mod cfg_expr; | 3 | mod cfg_expr; |
4 | 4 | ||
5 | use std::iter::IntoIterator; | ||
6 | |||
7 | use ra_syntax::SmolStr; | 5 | use ra_syntax::SmolStr; |
8 | use rustc_hash::FxHashSet; | 6 | use rustc_hash::FxHashSet; |
9 | 7 | ||
@@ -48,9 +46,4 @@ impl CfgOptions { | |||
48 | pub fn insert_key_value(&mut self, key: SmolStr, value: SmolStr) { | 46 | pub fn insert_key_value(&mut self, key: SmolStr, value: SmolStr) { |
49 | self.key_values.insert((key, value)); | 47 | self.key_values.insert((key, value)); |
50 | } | 48 | } |
51 | |||
52 | /// Shortcut to set features | ||
53 | pub fn insert_features(&mut self, iter: impl IntoIterator<Item = SmolStr>) { | ||
54 | iter.into_iter().for_each(|feat| self.insert_key_value("feature".into(), feat)); | ||
55 | } | ||
56 | } | 49 | } |