Skip to content

Commit 9e29fed

Browse files
committed
Auto merge of #14960 - jneem:group-delim-span, r=<try>
Add span to group. This appears to fix #14959, but I've never contributed to rust-analyzer before and there were some things that confused me: - I had to add the `fn byte_range` method to get it to build. This was added to rust in [April](rust-lang/rust#109002), so I don't understand why it wasn't needed until now - When testing, I ran into the fact that rust recently updated its `METADATA_VERSION`, so I had to test this with nightly-2023-05-20. But then I noticed that rust has its own copy of `rust-analyzer`, and the metadata version bump has already been [handled there](rust-lang/rust@60e95e7). So I guess I don't really understand the relationship between the code there and the code here.
2 parents f3145dc + d013153 commit 9e29fed

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ impl server::TokenStream for RustAnalyzer {
9797
match tree {
9898
bridge::TokenTree::Group(group) => {
9999
let group = Group {
100-
delimiter: delim_to_internal(group.delimiter),
100+
delimiter: delim_to_internal(group.delimiter, group.span),
101101
token_trees: match group.stream {
102102
Some(stream) => stream.into_iter().collect(),
103103
None => Vec::new(),
@@ -221,14 +221,14 @@ impl server::TokenStream for RustAnalyzer {
221221
}
222222
}
223223

224-
fn delim_to_internal(d: proc_macro::Delimiter) -> tt::Delimiter {
224+
fn delim_to_internal(d: proc_macro::Delimiter, span: bridge::DelimSpan<Span>) -> tt::Delimiter {
225225
let kind = match d {
226226
proc_macro::Delimiter::Parenthesis => tt::DelimiterKind::Parenthesis,
227227
proc_macro::Delimiter::Brace => tt::DelimiterKind::Brace,
228228
proc_macro::Delimiter::Bracket => tt::DelimiterKind::Bracket,
229229
proc_macro::Delimiter::None => tt::DelimiterKind::Invisible,
230230
};
231-
tt::Delimiter { open: tt::TokenId::unspecified(), close: tt::TokenId::unspecified(), kind }
231+
tt::Delimiter { open: span.open, close: span.close, kind }
232232
}
233233

234234
fn delim_to_external(d: tt::Delimiter) -> proc_macro::Delimiter {

0 commit comments

Comments
 (0)