Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 90803b1

Browse files
committed
Split out syntax-bridge into a separate crate
1 parent d646f7b commit 90803b1

File tree

30 files changed

+268
-140
lines changed

30 files changed

+268
-140
lines changed

src/tools/rust-analyzer/Cargo.lock

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,10 @@ dependencies = [
148148
"derive_arbitrary",
149149
"expect-test",
150150
"intern",
151-
"mbe",
152151
"oorandom",
153152
"rustc-hash",
154153
"syntax",
154+
"syntax-bridge",
155155
"tt",
156156
]
157157

@@ -554,6 +554,7 @@ dependencies = [
554554
"span",
555555
"stdx",
556556
"syntax",
557+
"syntax-bridge",
557558
"test-fixture",
558559
"test-utils",
559560
"tracing",
@@ -582,6 +583,7 @@ dependencies = [
582583
"span",
583584
"stdx",
584585
"syntax",
586+
"syntax-bridge",
585587
"tracing",
586588
"triomphe",
587589
"tt",
@@ -1056,6 +1058,7 @@ dependencies = [
10561058
"span",
10571059
"stdx",
10581060
"syntax",
1061+
"syntax-bridge",
10591062
"test-utils",
10601063
"tracing",
10611064
"tt",
@@ -1350,7 +1353,6 @@ dependencies = [
13501353
"expect-test",
13511354
"intern",
13521355
"libloading",
1353-
"mbe",
13541356
"memmap2",
13551357
"object 0.33.0",
13561358
"paths",
@@ -1360,6 +1362,7 @@ dependencies = [
13601362
"snap",
13611363
"span",
13621364
"stdx",
1365+
"syntax-bridge",
13631366
"tt",
13641367
]
13651368

@@ -1665,7 +1668,6 @@ dependencies = [
16651668
"load-cargo",
16661669
"lsp-server 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)",
16671670
"lsp-types",
1668-
"mbe",
16691671
"memchr",
16701672
"mimalloc",
16711673
"nohash-hasher",
@@ -1685,6 +1687,7 @@ dependencies = [
16851687
"serde_json",
16861688
"stdx",
16871689
"syntax",
1690+
"syntax-bridge",
16881691
"test-fixture",
16891692
"test-utils",
16901693
"tikv-jemallocator",
@@ -1967,6 +1970,21 @@ dependencies = [
19671970
"triomphe",
19681971
]
19691972

1973+
[[package]]
1974+
name = "syntax-bridge"
1975+
version = "0.0.0"
1976+
dependencies = [
1977+
"intern",
1978+
"parser",
1979+
"rustc-hash",
1980+
"span",
1981+
"stdx",
1982+
"syntax",
1983+
"test-utils",
1984+
"tracing",
1985+
"tt",
1986+
]
1987+
19701988
[[package]]
19711989
name = "test-fixture"
19721990
version = "0.0.0"

src/tools/rust-analyzer/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ salsa = { path = "./crates/salsa", version = "0.0.0" }
7777
span = { path = "./crates/span", version = "0.0.0" }
7878
stdx = { path = "./crates/stdx", version = "0.0.0" }
7979
syntax = { path = "./crates/syntax", version = "0.0.0" }
80+
syntax-bridge = { path = "./crates/syntax-bridge", version = "0.0.0" }
8081
text-edit = { path = "./crates/text-edit", version = "0.0.0" }
8182
toolchain = { path = "./crates/toolchain", version = "0.0.0" }
8283
tt = { path = "./crates/tt", version = "0.0.0" }

src/tools/rust-analyzer/crates/cfg/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ arbitrary = "1.3.2"
2828
derive_arbitrary = "1.3.2"
2929

3030
# local deps
31-
mbe.workspace = true
31+
syntax-bridge.workspace = true
3232
syntax.workspace = true
3333

3434
[lints]

src/tools/rust-analyzer/crates/cfg/src/tests.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
use arbitrary::{Arbitrary, Unstructured};
22
use expect_test::{expect, Expect};
33
use intern::Symbol;
4-
use mbe::{syntax_node_to_token_tree, DocCommentDesugarMode, DummyTestSpanMap, DUMMY};
54
use syntax::{ast, AstNode, Edition};
5+
use syntax_bridge::{
6+
dummy_test_span_utils::{DummyTestSpanMap, DUMMY},
7+
syntax_node_to_token_tree, DocCommentDesugarMode,
8+
};
69

710
use crate::{CfgAtom, CfgExpr, CfgOptions, DnfExpr};
811

src/tools/rust-analyzer/crates/hir-def/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ expect-test.workspace = true
5252
# local deps
5353
test-utils.workspace = true
5454
test-fixture.workspace = true
55-
55+
syntax-bridge.workspace = true
5656
[features]
5757
in-rust-tree = ["hir-expand/in-rust-tree"]
5858

src/tools/rust-analyzer/crates/hir-def/src/attr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,9 +657,9 @@ mod tests {
657657
use triomphe::Arc;
658658

659659
use hir_expand::span_map::{RealSpanMap, SpanMap};
660-
use mbe::{syntax_node_to_token_tree, DocCommentDesugarMode};
661660
use span::FileId;
662661
use syntax::{ast, AstNode, TextRange};
662+
use syntax_bridge::{syntax_node_to_token_tree, DocCommentDesugarMode};
663663

664664
use crate::attr::{DocAtom, DocExpr};
665665

src/tools/rust-analyzer/crates/hir-def/src/macro_expansion_tests/mbe.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1201,7 +1201,6 @@ macro_rules! m {
12011201

12021202
#[test]
12031203
fn test_meta_doc_comments() {
1204-
cov_mark::check!(test_meta_doc_comments);
12051204
check(
12061205
r#"
12071206
macro_rules! m {

src/tools/rust-analyzer/crates/hir-def/src/macro_expansion_tests/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,9 +317,9 @@ impl ProcMacroExpander for IdentityWhenValidProcMacroExpander {
317317
_: Span,
318318
_: Span,
319319
) -> Result<Subtree, ProcMacroExpansionError> {
320-
let (parse, _) = ::mbe::token_tree_to_syntax_node(
320+
let (parse, _) = syntax_bridge::token_tree_to_syntax_node(
321321
subtree,
322-
::mbe::TopEntryPoint::MacroItems,
322+
syntax_bridge::TopEntryPoint::MacroItems,
323323
span::Edition::CURRENT,
324324
);
325325
if parse.errors().is_empty() {

src/tools/rust-analyzer/crates/hir-expand/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ mbe.workspace = true
3333
limit.workspace = true
3434
span.workspace = true
3535
parser.workspace = true
36+
syntax-bridge.workspace = true
3637

3738
[dev-dependencies]
3839
expect-test = "1.4.0"

src/tools/rust-analyzer/crates/hir-expand/src/attrs.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,12 @@ use cfg::CfgExpr;
66
use either::Either;
77
use intern::{sym, Interned, Symbol};
88

9-
use mbe::{
10-
desugar_doc_comment_text, syntax_node_to_token_tree, DelimiterKind, DocCommentDesugarMode,
11-
Punct,
12-
};
9+
use mbe::{DelimiterKind, Punct};
1310
use smallvec::{smallvec, SmallVec};
1411
use span::{Span, SyntaxContextId};
1512
use syntax::unescape;
1613
use syntax::{ast, match_ast, AstNode, AstToken, SyntaxNode};
14+
use syntax_bridge::{desugar_doc_comment_text, syntax_node_to_token_tree, DocCommentDesugarMode};
1715
use triomphe::ThinArc;
1816

1917
use crate::name::Name;

0 commit comments

Comments
 (0)