Skip to content

Commit 78eacaa

Browse files
committed
more r-a fixes
1 parent 52f3fcc commit 78eacaa

6 files changed

Lines changed: 18 additions & 18 deletions

File tree

src/tools/rust-analyzer/crates/proc-macro-api/src/legacy_protocol/msg/flat.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ impl<'a, T: SpanTransformer, U> Writer<'a, '_, T, U> {
607607
}
608608
}
609609

610-
#[cfg(feature = "sysroot-abi")]
610+
//#[cfg(feature = "sysroot-abi")]
611611
impl<'a, T: SpanTransformer>
612612
Writer<'a, '_, T, Option<proc_macro_srv::TokenStreamIter<'a, T::Span>>>
613613
{
@@ -723,8 +723,8 @@ impl<'a, T: SpanTransformer>
723723
self.subtree.push(SubtreeRepr { open, close, kind: delimiter_kind, tt: [!0, !0] });
724724
self.work.push_back((
725725
idx,
726-
group.stream.as_ref().map_or(0, |stream| stream.len()),
727-
group.stream.as_ref().map(|ts| ts.iter()),
726+
group.stream.as_ref().map_or(0, |stream| stream.trees.len()),
727+
group.stream.clone().map(|ts| TokenStream::from_bridge(ts).iter()),
728728
));
729729
idx as u32
730730
}
@@ -955,7 +955,7 @@ impl<T: SpanTransformer> Reader<'_, T> {
955955
tt::DelimiterKind::Bracket => proc_macro_srv::Delimiter::Bracket,
956956
tt::DelimiterKind::Invisible => proc_macro_srv::Delimiter::None,
957957
},
958-
stream: if stream.is_empty() { None } else { Some(TokenStream::new(stream)) },
958+
stream: if stream.is_empty() { None } else { Some(TokenStream::new(stream).into_bridge()) },
959959
span: proc_macro_srv::DelimSpan {
960960
open,
961961
close,
@@ -967,7 +967,7 @@ impl<T: SpanTransformer> Reader<'_, T> {
967967
}
968968
let group = res[0].take().unwrap();
969969
if group.delimiter == proc_macro_srv::Delimiter::None {
970-
group.stream.unwrap_or_default()
970+
TokenStream::from_bridge(group.stream.unwrap_or_default())
971971
} else {
972972
TokenStream::new(vec![proc_macro_srv::TokenTree::Group(group)])
973973
}

src/tools/rust-analyzer/crates/proc-macro-srv/src/dylib/proc_macros.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,29 +32,29 @@ impl ProcMacros {
3232
let res = client.run(
3333
&bridge::server::SameThread,
3434
S::make_server(call_site, def_site, mixed_site, callback),
35-
macro_body,
35+
macro_body.into_bridge(),
3636
cfg!(debug_assertions),
3737
);
38-
return res.map_err(crate::PanicMessage::from);
38+
return res.map(TokenStream::from_bridge).map_err(crate::PanicMessage::from);
3939
}
4040
bridge::client::ProcMacro::Bang { name, client } if *name == macro_name => {
4141
let res = client.run(
4242
&bridge::server::SameThread,
4343
S::make_server(call_site, def_site, mixed_site, callback),
44-
macro_body,
44+
macro_body.into_bridge(),
4545
cfg!(debug_assertions),
4646
);
47-
return res.map_err(crate::PanicMessage::from);
47+
return res.map(TokenStream::from_bridge).map_err(crate::PanicMessage::from);
4848
}
4949
bridge::client::ProcMacro::Attr { name, client } if *name == macro_name => {
5050
let res = client.run(
5151
&bridge::server::SameThread,
5252
S::make_server(call_site, def_site, mixed_site, callback),
53-
parsed_attributes,
54-
macro_body,
53+
parsed_attributes.into_bridge(),
54+
macro_body.into_bridge(),
5555
cfg!(debug_assertions),
5656
);
57-
return res.map_err(crate::PanicMessage::from);
57+
return res.map(TokenStream::from_bridge).map_err(crate::PanicMessage::from);
5858
}
5959
_ => continue,
6060
}

src/tools/rust-analyzer/crates/proc-macro-srv/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
//! * By **copying** the whole rustc `lib_proc_macro` code, we are able to build this with `stable`
1111
//! rustc rather than `unstable`. (Although in general ABI compatibility is still an issue)…
1212
13-
#![cfg(feature = "sysroot-abi")]
13+
//#![cfg(feature = "sysroot-abi")]
1414
#![cfg_attr(feature = "in-rust-tree", feature(rustc_private))]
1515
#![feature(proc_macro_internals, proc_macro_diagnostic, proc_macro_span)]
1616
#![allow(
@@ -233,7 +233,7 @@ impl ProcMacroSrv<'_> {
233233
}
234234

235235
pub trait ProcMacroSrvSpan: Copy + Send + Sync {
236-
type Server<'a>: rustc_proc_macro::bridge::server::Server;
236+
type Server<'a>: rustc_proc_macro::bridge::server::Server<Span = Self, Symbol = intern::Symbol>;
237237
fn make_server<'a>(
238238
call_site: Self,
239239
def_site: Self,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use span::{FIXUP_ERASED_FILE_AST_ID_MARKER, Span, TextRange, TextSize};
1515

1616
use crate::{
1717
ProcMacroClientHandle,
18-
bridge::{Diagnostic, ExpnGlobals, Literal, TokenTree},
18+
bridge::{Diagnostic, ExpnGlobals, Literal},
1919
server_impl::literal_from_str,
2020
};
2121

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use rustc_proc_macro::bridge::server;
1010

1111
use crate::{
1212
ProcMacroClientHandle,
13-
bridge::{Diagnostic, ExpnGlobals, Literal, TokenTree},
13+
bridge::{Diagnostic, ExpnGlobals, Literal},
1414
server_impl::literal_from_str,
1515
};
1616

src/tools/rust-analyzer/crates/proc-macro-srv/src/token_stream.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! The proc-macro server token stream implementation.
22
33
use core::fmt;
4-
use std::{mem, sync::Arc, rc::Rc};
4+
use std::{mem, sync::Arc};
55

66
use intern::Symbol;
77
use rustc_lexer::{DocStyle, LiteralKind};
@@ -29,7 +29,7 @@ impl<S> TokenStream<S> {
2929
}
3030

3131
pub fn from_bridge(ts: BridgeTokenStream<S>) -> TokenStream<S> where S: Clone {
32-
TokenStream::new(Rc::unwrap_or_clone(ts.trees))
32+
TokenStream::new(Arc::unwrap_or_clone(ts.trees))
3333
}
3434

3535
pub fn into_bridge(self) -> BridgeTokenStream<S> where S: Clone {

0 commit comments

Comments
 (0)