Skip to content

Commit db6d214

Browse files
bors[bot]matklad
andcommitted
Merge #793
793: remove hard-coded query-group macro r=matklad a=matklad Co-authored-by: Aleksey Kladov <[email protected]>
2 parents a78142c + 0d060b0 commit db6d214

File tree

5 files changed

+4
-67
lines changed

5 files changed

+4
-67
lines changed

crates/ra_hir/src/macros.rs

+2-24
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use std::sync::Arc;
1111

1212
use ra_syntax::{
1313
TextRange, TextUnit, SourceFile, AstNode, SyntaxNode, TreeArc, SyntaxNodePtr,
14-
ast::{self, NameOwner},
14+
ast,
1515
};
1616

1717
use crate::{MacroCallId, PersistentHirDatabase};
@@ -20,7 +20,6 @@ use crate::{MacroCallId, PersistentHirDatabase};
2020
#[derive(Debug, Clone, PartialEq, Eq)]
2121
pub enum MacroDef {
2222
Vec,
23-
QueryGroup,
2423
}
2524

2625
impl MacroDef {
@@ -39,8 +38,6 @@ impl MacroDef {
3938
let name_ref = path.segment()?.name_ref()?;
4039
if name_ref.text() == "vec" {
4140
MacroDef::Vec
42-
} else if name_ref.text() == "query_group" {
43-
MacroDef::QueryGroup
4441
} else {
4542
return None;
4643
}
@@ -56,7 +53,6 @@ impl MacroDef {
5653
fn expand(self, input: MacroInput) -> Option<MacroExpansion> {
5754
match self {
5855
MacroDef::Vec => self.expand_vec(input),
59-
MacroDef::QueryGroup => self.expand_query_group(input),
6056
}
6157
}
6258
fn expand_vec(self, input: MacroInput) -> Option<MacroExpansion> {
@@ -69,24 +65,6 @@ impl MacroDef {
6965
let res = MacroExpansion { text, ranges_map, ptr };
7066
Some(res)
7167
}
72-
fn expand_query_group(self, input: MacroInput) -> Option<MacroExpansion> {
73-
let anchor = "trait ";
74-
let pos = input.text.find(anchor)? + anchor.len();
75-
let trait_name =
76-
input.text[pos..].chars().take_while(|c| c.is_alphabetic()).collect::<String>();
77-
if trait_name.is_empty() {
78-
return None;
79-
}
80-
let src_range = TextRange::offset_len((pos as u32).into(), TextUnit::of_str(&trait_name));
81-
let text = format!(r"trait {} {{ }}", trait_name);
82-
let file = SourceFile::parse(&text);
83-
let trait_def = file.syntax().descendants().find_map(ast::TraitDef::cast)?;
84-
let name = trait_def.name()?;
85-
let ptr = SyntaxNodePtr::new(trait_def.syntax());
86-
let ranges_map = vec![(src_range, name.syntax().range())];
87-
let res = MacroExpansion { text, ranges_map, ptr };
88-
Some(res)
89-
}
9068
}
9169

9270
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -109,7 +87,7 @@ pub struct MacroExpansion {
10987
}
11088

11189
impl MacroExpansion {
112-
// FIXME: does not really make sense, macro expansion is not neccessary a
90+
// FIXME: does not really make sense, macro expansion is not necessary a
11391
// whole file. See `MacroExpansion::ptr` as well.
11492
pub(crate) fn file(&self) -> TreeArc<SourceFile> {
11593
SourceFile::parse(&self.text)

crates/ra_hir/src/nameres/tests.rs

+1
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ fn name_res_works_for_broken_modules() {
326326
}
327327

328328
#[test]
329+
#[ignore]
329330
fn item_map_contains_items_from_expansions() {
330331
let (item_map, module_id) = item_map(
331332
"

crates/ra_ide_api/src/snapshots/tests__highlight_query_group_macro.snap

-28
This file was deleted.

crates/ra_ide_api/src/syntax_highlighting.rs

-15
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,4 @@ mod tests {
4141
let highlights = analysis.highlight(file_id).unwrap();
4242
assert_debug_snapshot_matches!("highlights_code_inside_macros", &highlights);
4343
}
44-
45-
// FIXME: this test is not really necessary: artifact of the inital hacky
46-
// macros implementation.
47-
#[test]
48-
fn highlight_query_group_macro() {
49-
let (analysis, file_id) = single_file(
50-
"
51-
salsa::query_group! {
52-
pub trait HirDatabase: SyntaxDatabase {}
53-
}
54-
",
55-
);
56-
let highlights = analysis.highlight(file_id).unwrap();
57-
assert_debug_snapshot_matches!("highlight_query_group_macro", &highlights);
58-
}
5944
}

crates/ra_ide_api/tests/test/main.rs

+1
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ fn test_find_all_refs_for_fn_param() {
9191
}
9292

9393
#[test]
94+
#[ignore]
9495
fn world_symbols_include_stuff_from_macros() {
9596
let (analysis, _) = single_file(
9697
"

0 commit comments

Comments
 (0)