Skip to content

Commit c770e41

Browse files
authored
Rollup merge of #111571 - jhpratt:proc-macro-span, r=m-ou-se
Implement proposed API for `proc_macro_span` As proposed in [#54725 (comment)](rust-lang/rust#54725 (comment)). I have omitted the byte-level API as it's already available as [`Span::byte_range`](https://doc.rust-lang.org/nightly/proc_macro/struct.Span.html#method.byte_range). `@rustbot` label +A-proc-macros r? `@m-ou-se`
2 parents a229eeb + 36bbc38 commit c770e41

File tree

2 files changed

+15
-16
lines changed

2 files changed

+15
-16
lines changed

Cargo.lock

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

+13-14
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@
88
//!
99
//! FIXME: No span and source file information is implemented yet
1010
11-
use proc_macro::{
12-
bridge::{self, server},
13-
LineColumn,
14-
};
11+
use proc_macro::bridge::{self, server};
1512

1613
mod token_stream;
1714
pub use token_stream::TokenStream;
@@ -304,14 +301,6 @@ impl server::Span for RustAnalyzer {
304301
// FIXME handle span
305302
Range { start: 0, end: 0 }
306303
}
307-
fn start(&mut self, _span: Self::Span) -> LineColumn {
308-
// FIXME handle span
309-
LineColumn { line: 0, column: 0 }
310-
}
311-
fn end(&mut self, _span: Self::Span) -> LineColumn {
312-
// FIXME handle span
313-
LineColumn { line: 0, column: 0 }
314-
}
315304
fn join(&mut self, first: Self::Span, _second: Self::Span) -> Option<Self::Span> {
316305
// Just return the first span again, because some macros will unwrap the result.
317306
Some(first)
@@ -330,13 +319,23 @@ impl server::Span for RustAnalyzer {
330319
tt::TokenId::unspecified()
331320
}
332321

333-
fn after(&mut self, _self_: Self::Span) -> Self::Span {
322+
fn end(&mut self, _self_: Self::Span) -> Self::Span {
334323
tt::TokenId::unspecified()
335324
}
336325

337-
fn before(&mut self, _self_: Self::Span) -> Self::Span {
326+
fn start(&mut self, _self_: Self::Span) -> Self::Span {
338327
tt::TokenId::unspecified()
339328
}
329+
330+
fn line(&mut self, _span: Self::Span) -> usize {
331+
// FIXME handle line
332+
0
333+
}
334+
335+
fn column(&mut self, _span: Self::Span) -> usize {
336+
// FIXME handle column
337+
0
338+
}
340339
}
341340

342341
impl server::Symbol for RustAnalyzer {

0 commit comments

Comments
 (0)