internal: remove useless helpers

We generally avoid "syntax only" helper wrappers, which don't do much:
they make code easier to write, but harder to read. They also make
investigations harder, as "find_usages" needs to be invoked both for the
wrapped and unwrapped APIs
This commit is contained in:
Aleksey Kladov 2021-08-09 15:41:19 +03:00
parent 977fef713e
commit 9aa6be71a5
12 changed files with 32 additions and 36 deletions

View file

@ -1,5 +1,5 @@
use expect_test::{expect, Expect};
use mbe::ast_to_token_tree;
use mbe::syntax_node_to_token_tree;
use syntax::{ast, AstNode};
use crate::{CfgAtom, CfgExpr, CfgOptions, DnfExpr};
@ -8,7 +8,7 @@ fn assert_parse_result(input: &str, expected: CfgExpr) {
let (tt, _) = {
let source_file = ast::SourceFile::parse(input).ok().unwrap();
let tt = source_file.syntax().descendants().find_map(ast::TokenTree::cast).unwrap();
ast_to_token_tree(&tt)
syntax_node_to_token_tree(tt.syntax())
};
let cfg = CfgExpr::parse(&tt);
assert_eq!(cfg, expected);
@ -18,7 +18,7 @@ fn check_dnf(input: &str, expect: Expect) {
let (tt, _) = {
let source_file = ast::SourceFile::parse(input).ok().unwrap();
let tt = source_file.syntax().descendants().find_map(ast::TokenTree::cast).unwrap();
ast_to_token_tree(&tt)
syntax_node_to_token_tree(tt.syntax())
};
let cfg = CfgExpr::parse(&tt);
let actual = format!("#![cfg({})]", DnfExpr::new(cfg));
@ -29,7 +29,7 @@ fn check_why_inactive(input: &str, opts: &CfgOptions, expect: Expect) {
let (tt, _) = {
let source_file = ast::SourceFile::parse(input).ok().unwrap();
let tt = source_file.syntax().descendants().find_map(ast::TokenTree::cast).unwrap();
ast_to_token_tree(&tt)
syntax_node_to_token_tree(tt.syntax())
};
let cfg = CfgExpr::parse(&tt);
let dnf = DnfExpr::new(cfg);
@ -42,7 +42,7 @@ fn check_enable_hints(input: &str, opts: &CfgOptions, expected_hints: &[&str]) {
let (tt, _) = {
let source_file = ast::SourceFile::parse(input).ok().unwrap();
let tt = source_file.syntax().descendants().find_map(ast::TokenTree::cast).unwrap();
ast_to_token_tree(&tt)
syntax_node_to_token_tree(tt.syntax())
};
let cfg = CfgExpr::parse(&tt);
let dnf = DnfExpr::new(cfg);