mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 06:11:35 +00:00
Deduplicate dummy test span maps
This commit is contained in:
parent
c43078f99d
commit
6208960c48
12 changed files with 99 additions and 139 deletions
|
@ -209,26 +209,17 @@ mod tests {
|
|||
use super::*;
|
||||
|
||||
use cfg::CfgExpr;
|
||||
use hir_def::tt::{self, Span};
|
||||
use mbe::{syntax_node_to_token_tree, SpanMapper};
|
||||
use mbe::{syntax_node_to_token_tree, DummyTestSpanMap};
|
||||
use syntax::{
|
||||
ast::{self, AstNode},
|
||||
SmolStr,
|
||||
};
|
||||
|
||||
struct NoOpMap;
|
||||
|
||||
impl SpanMapper<tt::SpanData> for NoOpMap {
|
||||
fn span_for(&self, _: syntax::TextRange) -> tt::SpanData {
|
||||
tt::SpanData::DUMMY
|
||||
}
|
||||
}
|
||||
|
||||
fn check(cfg: &str, expected_features: &[&str]) {
|
||||
let cfg_expr = {
|
||||
let source_file = ast::SourceFile::parse(cfg).ok().unwrap();
|
||||
let tt = source_file.syntax().descendants().find_map(ast::TokenTree::cast).unwrap();
|
||||
let tt = syntax_node_to_token_tree(tt.syntax(), &NoOpMap);
|
||||
let tt = syntax_node_to_token_tree(tt.syntax(), &DummyTestSpanMap);
|
||||
CfgExpr::parse(&tt)
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue