Skip to content

Commit c26d5f5

Browse files
committed
Simplify
1 parent 26f7400 commit c26d5f5

File tree

15 files changed

+274
-352
lines changed

15 files changed

+274
-352
lines changed

crates/hir-def/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ tracing.workspace = true
2727
smallvec.workspace = true
2828
triomphe.workspace = true
2929
rustc_apfloat = "0.2.3"
30-
text-size.workspace = true
3130
salsa.workspace = true
3231
salsa-macros.workspace = true
3332
query-group.workspace = true

crates/hir-ty/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,12 @@ doctest = false
1616
cov-mark = "2.0.0"
1717
itertools.workspace = true
1818
arrayvec.workspace = true
19-
bitflags.workspace = true
2019
smallvec.workspace = true
2120
ena = "0.14.3"
2221
either.workspace = true
2322
oorandom = "11.1.5"
2423
tracing.workspace = true
2524
rustc-hash.workspace = true
26-
scoped-tls = "1.0.1"
2725
la-arena.workspace = true
2826
triomphe.workspace = true
2927
typed-arena = "2.0.2"

crates/hir/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ itertools.workspace = true
2020
smallvec.workspace = true
2121
tracing.workspace = true
2222
triomphe.workspace = true
23-
indexmap.workspace = true
2423

2524
ra-ap-rustc_type_ir.workspace = true
2625

crates/ide-db/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ rustc-hash.workspace = true
2222
either.workspace = true
2323
itertools.workspace = true
2424
arrayvec.workspace = true
25-
indexmap.workspace = true
2625
memchr = "2.7.5"
2726
salsa.workspace = true
2827
salsa-macros.workspace = true
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
use proc_macro::bridge as pm_bridge;
2+
3+
pub(crate) use pm_bridge::{DelimSpan, Diagnostic, ExpnGlobals, LitKind};
4+
5+
pub(crate) type TokenTree<S> =
6+
pm_bridge::TokenTree<crate::token_stream::TokenStream<S>, S, intern::Symbol>;
7+
pub(crate) type Literal<S> = pm_bridge::Literal<S, intern::Symbol>;
8+
pub(crate) type Group<S> = pm_bridge::Group<crate::token_stream::TokenStream<S>, S>;
9+
pub(crate) type Punct<S> = pm_bridge::Punct<S>;
10+
pub(crate) type Ident<S> = pm_bridge::Ident<S, intern::Symbol>;

crates/proc-macro-srv/src/dylib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ use object::Object;
1212
use paths::{Utf8Path, Utf8PathBuf};
1313

1414
use crate::{
15-
PanicMessage, ProcMacroKind, ProcMacroSrvSpan, dylib::proc_macros::ProcMacros, tt::TokenStream,
15+
PanicMessage, ProcMacroKind, ProcMacroSrvSpan, dylib::proc_macros::ProcMacros,
16+
token_stream::TokenStream,
1617
};
1718

1819
pub(crate) struct Expander {

crates/proc-macro-srv/src/dylib/proc_macros.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use proc_macro::bridge;
44

5-
use crate::{ProcMacroKind, ProcMacroSrvSpan, tt::TokenStream};
5+
use crate::{ProcMacroKind, ProcMacroSrvSpan, token_stream::TokenStream};
66

77
#[repr(transparent)]
88
pub(crate) struct ProcMacros([bridge::client::ProcMacro]);

crates/proc-macro-srv/src/dylib/version.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@ use std::io::{self, Read};
55
use object::read::{Object, ObjectSection};
66

77
#[derive(Debug)]
8-
#[allow(dead_code)]
98
pub struct RustCInfo {
9+
#[allow(dead_code)]
1010
pub version: (usize, usize, usize),
11+
#[allow(dead_code)]
1112
pub channel: String,
13+
#[allow(dead_code)]
1214
pub commit: Option<String>,
15+
#[allow(dead_code)]
1316
pub date: Option<String>,
1417
// something like "rustc 1.58.1 (db9d1b20b 2022-01-20)"
1518
pub version_string: String,

crates/proc-macro-srv/src/lib.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ extern crate ra_ap_rustc_lexer as rustc_lexer;
2626
#[cfg(feature = "in-rust-tree")]
2727
extern crate rustc_lexer;
2828

29+
mod bridge;
2930
mod dylib;
3031
mod server_impl;
31-
mod tt;
32+
mod token_stream;
3233

3334
use std::{
3435
collections::{HashMap, hash_map::Entry},
@@ -80,12 +81,12 @@ impl ProcMacroSrv<'_> {
8081
env: &[(String, String)],
8182
current_dir: Option<impl AsRef<Path>>,
8283
macro_name: &str,
83-
macro_body: tt::TokenStream<S>,
84-
attribute: Option<tt::TokenStream<S>>,
84+
macro_body: token_stream::TokenStream<S>,
85+
attribute: Option<token_stream::TokenStream<S>>,
8586
def_site: S,
8687
call_site: S,
8788
mixed_site: S,
88-
) -> Result<tt::TokenStream<S>, PanicMessage> {
89+
) -> Result<token_stream::TokenStream<S>, PanicMessage> {
8990
let snapped_env = self.env;
9091
let expander = self.expander(lib.as_ref()).map_err(|err| PanicMessage {
9192
message: Some(format!("failed to load macro: {err}")),
@@ -149,7 +150,7 @@ impl ProcMacroSrv<'_> {
149150
}
150151

151152
pub trait ProcMacroSrvSpan: Copy + Send + Sync {
152-
type Server: proc_macro::bridge::server::Server<TokenStream = crate::tt::TokenStream<Self>>;
153+
type Server: proc_macro::bridge::server::Server<TokenStream = crate::token_stream::TokenStream<Self>>;
153154
fn make_server(call_site: Self, def_site: Self, mixed_site: Self) -> Self::Server;
154155
}
155156

crates/proc-macro-srv/src/server_impl.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
//! The original idea from fedochet is using proc-macro2 as backend,
77
//! we use tt instead for better integration with RA.
88
9-
pub mod rust_analyzer_span;
10-
pub mod token_id;
9+
pub(crate) mod rust_analyzer_span;
10+
pub(crate) mod token_id;
1111

1212
pub(super) fn literal_from_str<Span: Copy>(
1313
s: &str,
1414
span: Span,
15-
) -> Result<proc_macro::bridge::Literal<Span, intern::Symbol>, ()> {
15+
) -> Result<crate::bridge::Literal<Span>, ()> {
1616
use rustc_lexer::{LiteralKind, Token, TokenKind};
1717
let mut tokens = rustc_lexer::tokenize(s, rustc_lexer::FrontmatterAllowed::No);
1818
let minus_or_lit = tokens.next().unwrap_or(Token { kind: TokenKind::Eof, len: 0 });
@@ -35,5 +35,5 @@ pub(super) fn literal_from_str<Span: Copy>(
3535
}
3636

3737
let TokenKind::Literal { kind, suffix_start } = lit.kind else { return Err(()) };
38-
Ok(crate::tt::literal_from_lexer(s, span, kind, suffix_start))
38+
Ok(crate::token_stream::literal_from_lexer(s, span, kind, suffix_start))
3939
}

0 commit comments

Comments
 (0)