Skip to content

Commit 5113f5e

Browse files
committed
Update rust-analyzer for new proc_macro span api.
1 parent 3962069 commit 5113f5e

File tree

2 files changed

+13
-38
lines changed

2 files changed

+13
-38
lines changed

Diff for: src/tools/rust-analyzer/crates/proc-macro-srv/src/server_impl/rust_analyzer_span.rs

+8-21
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use std::{
1111

1212
use intern::Symbol;
1313
use proc_macro::bridge::{self, server};
14-
use span::{FileId, Span, FIXUP_ERASED_FILE_AST_ID_MARKER};
14+
use span::{Span, FIXUP_ERASED_FILE_AST_ID_MARKER};
1515
use tt::{TextRange, TextSize};
1616

1717
use crate::server_impl::{literal_kind_to_internal, token_stream::TokenStreamBuilder, TopSubtree};
@@ -27,10 +27,6 @@ mod tt {
2727

2828
type TokenStream = crate::server_impl::TokenStream<Span>;
2929

30-
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
31-
pub struct SourceFile {
32-
file_id: FileId,
33-
}
3430
pub struct FreeFunctions;
3531

3632
pub struct RaSpanServer {
@@ -46,7 +42,6 @@ pub struct RaSpanServer {
4642
impl server::Types for RaSpanServer {
4743
type FreeFunctions = FreeFunctions;
4844
type TokenStream = TokenStream;
49-
type SourceFile = SourceFile;
5045
type Span = Span;
5146
type Symbol = Symbol;
5247
}
@@ -245,25 +240,17 @@ impl server::TokenStream for RaSpanServer {
245240
}
246241
}
247242

248-
impl server::SourceFile for RaSpanServer {
249-
fn eq(&mut self, file1: &Self::SourceFile, file2: &Self::SourceFile) -> bool {
250-
file1 == file2
251-
}
252-
fn path(&mut self, _file: &Self::SourceFile) -> String {
253-
// FIXME
254-
String::new()
255-
}
256-
fn is_real(&mut self, _file: &Self::SourceFile) -> bool {
257-
true
258-
}
259-
}
260-
261243
impl server::Span for RaSpanServer {
262244
fn debug(&mut self, span: Self::Span) -> String {
263245
format!("{:?}", span)
264246
}
265-
fn source_file(&mut self, span: Self::Span) -> Self::SourceFile {
266-
SourceFile { file_id: span.anchor.file_id.file_id() }
247+
fn file(&mut self, _: Self::Span) -> String {
248+
// FIXME
249+
String::new()
250+
}
251+
fn local_file(&mut self, _: Self::Span) -> Option<String> {
252+
// FIXME
253+
None
267254
}
268255
fn save_span(&mut self, _span: Self::Span) -> usize {
269256
// FIXME, quote is incompatible with third-party tools

Diff for: src/tools/rust-analyzer/crates/proc-macro-srv/src/server_impl/token_id.rs

+5-17
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ type Literal = tt::Literal;
2424
type Span = tt::TokenId;
2525
type TokenStream = crate::server_impl::TokenStream<Span>;
2626

27-
#[derive(Clone)]
28-
pub struct SourceFile;
2927
pub struct FreeFunctions;
3028

3129
pub struct TokenIdServer {
@@ -37,7 +35,6 @@ pub struct TokenIdServer {
3735
impl server::Types for TokenIdServer {
3836
type FreeFunctions = FreeFunctions;
3937
type TokenStream = TokenStream;
40-
type SourceFile = SourceFile;
4138
type Span = Span;
4239
type Symbol = Symbol;
4340
}
@@ -223,24 +220,15 @@ impl server::TokenStream for TokenIdServer {
223220
}
224221
}
225222

226-
impl server::SourceFile for TokenIdServer {
227-
fn eq(&mut self, _file1: &Self::SourceFile, _file2: &Self::SourceFile) -> bool {
228-
true
229-
}
230-
fn path(&mut self, _file: &Self::SourceFile) -> String {
231-
String::new()
232-
}
233-
fn is_real(&mut self, _file: &Self::SourceFile) -> bool {
234-
true
235-
}
236-
}
237-
238223
impl server::Span for TokenIdServer {
239224
fn debug(&mut self, span: Self::Span) -> String {
240225
format!("{:?}", span.0)
241226
}
242-
fn source_file(&mut self, _span: Self::Span) -> Self::SourceFile {
243-
SourceFile {}
227+
fn file(&mut self, _span: Self::Span) -> String {
228+
String::new()
229+
}
230+
fn local_file(&mut self, _span: Self::Span) -> Option<String> {
231+
None
244232
}
245233
fn save_span(&mut self, _span: Self::Span) -> usize {
246234
0

0 commit comments

Comments
 (0)