Skip to content

Commit 100ea1d

Browse files
committed
Auto merge of #12828 - fasterthanlime:proc-macro-srv-naming, r=Veykril
Rename proc macro server from 'Rustc' to 'RustAnalyzer' Related to: * #12818 This is mostly a courtesy PR for the sake of rustc maintainers. When they looked at `proc-macro-srv`, they noticed the server was named `Rustc` — probably because of historical copy-paste. Only rustc's proc macro server should be named `Rustc`, ra's can be named `RustAnalyzer`. Maintainer impact: There's no semantic changes in this PR, only naming. One test snapshot was updated since "proc macro server types" were used to test traits somewhere else and I renamed those too, why not.
2 parents 28bab68 + ade31ad commit 100ea1d

File tree

7 files changed

+78
-78
lines changed

7 files changed

+78
-78
lines changed

crates/hir-ty/src/tests/traits.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -2430,29 +2430,29 @@ macro_rules! declare_server_traits {
24302430
with_api!(Self, self_, declare_server_traits);
24312431
struct G {}
24322432
struct T {}
2433-
struct Rustc;
2434-
impl Types for Rustc {
2433+
struct RustAnalyzer;
2434+
impl Types for RustAnalyzer {
24352435
type TokenStream = T;
24362436
type Group = G;
24372437
}
24382438
24392439
fn make<T>() -> T { loop {} }
2440-
impl TokenStream for Rustc {
2440+
impl TokenStream for RustAnalyzer {
24412441
fn new() -> Self::TokenStream {
24422442
let group: Self::Group = make();
24432443
make()
24442444
}
24452445
}"#,
24462446
expect![[r#"
2447-
1061..1072 '{ loop {} }': T
2448-
1063..1070 'loop {}': !
2449-
1068..1070 '{}': ()
2450-
1136..1199 '{ ... }': T
2451-
1150..1155 'group': G
2452-
1171..1175 'make': fn make<G>() -> G
2453-
1171..1177 'make()': G
2454-
1187..1191 'make': fn make<T>() -> T
2455-
1187..1193 'make()': T
2447+
1075..1086 '{ loop {} }': T
2448+
1077..1084 'loop {}': !
2449+
1082..1084 '{}': ()
2450+
1157..1220 '{ ... }': T
2451+
1171..1176 'group': G
2452+
1192..1196 'make': fn make<G>() -> G
2453+
1192..1198 'make()': G
2454+
1208..1212 'make': fn make<T>() -> T
2455+
1208..1214 'make()': T
24562456
"#]],
24572457
);
24582458
}

crates/proc-macro-srv/src/abis/abi_1_58/mod.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ mod proc_macro;
66

77
#[allow(dead_code)]
88
#[doc(hidden)]
9-
mod rustc_server;
9+
mod ra_server;
1010

1111
use libloading::Library;
1212
use proc_macro_api::ProcMacroKind;
@@ -36,10 +36,10 @@ impl Abi {
3636
macro_body: &tt::Subtree,
3737
attributes: Option<&tt::Subtree>,
3838
) -> Result<tt::Subtree, PanicMessage> {
39-
let parsed_body = rustc_server::TokenStream::with_subtree(macro_body.clone());
39+
let parsed_body = ra_server::TokenStream::with_subtree(macro_body.clone());
4040

41-
let parsed_attributes = attributes.map_or(rustc_server::TokenStream::new(), |attr| {
42-
rustc_server::TokenStream::with_subtree(attr.clone())
41+
let parsed_attributes = attributes.map_or(ra_server::TokenStream::new(), |attr| {
42+
ra_server::TokenStream::with_subtree(attr.clone())
4343
});
4444

4545
for proc_macro in &self.exported_macros {
@@ -49,7 +49,7 @@ impl Abi {
4949
} if *trait_name == macro_name => {
5050
let res = client.run(
5151
&proc_macro::bridge::server::SameThread,
52-
rustc_server::Rustc::default(),
52+
ra_server::RustAnalyzer::default(),
5353
parsed_body,
5454
true,
5555
);
@@ -60,7 +60,7 @@ impl Abi {
6060
{
6161
let res = client.run(
6262
&proc_macro::bridge::server::SameThread,
63-
rustc_server::Rustc::default(),
63+
ra_server::RustAnalyzer::default(),
6464
parsed_body,
6565
true,
6666
);
@@ -71,7 +71,7 @@ impl Abi {
7171
{
7272
let res = client.run(
7373
&proc_macro::bridge::server::SameThread,
74-
rustc_server::Rustc::default(),
74+
ra_server::RustAnalyzer::default(),
7575
parsed_attributes,
7676
parsed_body,
7777
true,

crates/proc-macro-srv/src/abis/abi_1_58/rustc_server.rs renamed to crates/proc-macro-srv/src/abis/abi_1_58/ra_server.rs

+18-18
Original file line numberDiff line numberDiff line change
@@ -268,12 +268,12 @@ pub struct TokenStreamIter {
268268
}
269269

270270
#[derive(Default)]
271-
pub struct Rustc {
271+
pub struct RustAnalyzer {
272272
ident_interner: IdentInterner,
273273
// FIXME: store span information here.
274274
}
275275

276-
impl server::Types for Rustc {
276+
impl server::Types for RustAnalyzer {
277277
type FreeFunctions = FreeFunctions;
278278
type TokenStream = TokenStream;
279279
type TokenStreamBuilder = TokenStreamBuilder;
@@ -288,15 +288,15 @@ impl server::Types for Rustc {
288288
type MultiSpan = Vec<Span>;
289289
}
290290

291-
impl server::FreeFunctions for Rustc {
291+
impl server::FreeFunctions for RustAnalyzer {
292292
fn track_env_var(&mut self, _var: &str, _value: Option<&str>) {
293293
// FIXME: track env var accesses
294294
// https://github.com/rust-lang/rust/pull/71858
295295
}
296296
fn track_path(&mut self, _path: &str) {}
297297
}
298298

299-
impl server::TokenStream for Rustc {
299+
impl server::TokenStream for RustAnalyzer {
300300
fn new(&mut self) -> Self::TokenStream {
301301
Self::TokenStream::new()
302302
}
@@ -354,7 +354,7 @@ impl server::TokenStream for Rustc {
354354
}
355355
}
356356

357-
impl server::TokenStreamBuilder for Rustc {
357+
impl server::TokenStreamBuilder for RustAnalyzer {
358358
fn new(&mut self) -> Self::TokenStreamBuilder {
359359
Self::TokenStreamBuilder::new()
360360
}
@@ -366,7 +366,7 @@ impl server::TokenStreamBuilder for Rustc {
366366
}
367367
}
368368

369-
impl server::TokenStreamIter for Rustc {
369+
impl server::TokenStreamIter for RustAnalyzer {
370370
fn next(
371371
&mut self,
372372
iter: &mut Self::TokenStreamIter,
@@ -415,7 +415,7 @@ fn spacing_to_external(spacing: Spacing) -> bridge::Spacing {
415415
}
416416
}
417417

418-
impl server::Group for Rustc {
418+
impl server::Group for RustAnalyzer {
419419
fn new(&mut self, delimiter: bridge::Delimiter, stream: Self::TokenStream) -> Self::Group {
420420
Self::Group { delimiter: delim_to_internal(delimiter), token_trees: stream.token_trees }
421421
}
@@ -449,7 +449,7 @@ impl server::Group for Rustc {
449449
}
450450
}
451451

452-
impl server::Punct for Rustc {
452+
impl server::Punct for RustAnalyzer {
453453
fn new(&mut self, ch: char, spacing: bridge::Spacing) -> Self::Punct {
454454
tt::Punct {
455455
char: ch,
@@ -471,7 +471,7 @@ impl server::Punct for Rustc {
471471
}
472472
}
473473

474-
impl server::Ident for Rustc {
474+
impl server::Ident for RustAnalyzer {
475475
fn new(&mut self, string: &str, span: Self::Span, _is_raw: bool) -> Self::Ident {
476476
IdentId(self.ident_interner.intern(&IdentData(tt::Ident { text: string.into(), id: span })))
477477
}
@@ -486,7 +486,7 @@ impl server::Ident for Rustc {
486486
}
487487
}
488488

489-
impl server::Literal for Rustc {
489+
impl server::Literal for RustAnalyzer {
490490
fn debug_kind(&mut self, _literal: &Self::Literal) -> String {
491491
// r-a: debug_kind and suffix are unsupported; corresponding client code has been changed to not call these.
492492
// They must still be present to be ABI-compatible and work with upstream proc_macro.
@@ -597,7 +597,7 @@ impl server::Literal for Rustc {
597597
}
598598
}
599599

600-
impl server::SourceFile for Rustc {
600+
impl server::SourceFile for RustAnalyzer {
601601
// FIXME these are all stubs
602602
fn eq(&mut self, _file1: &Self::SourceFile, _file2: &Self::SourceFile) -> bool {
603603
true
@@ -610,7 +610,7 @@ impl server::SourceFile for Rustc {
610610
}
611611
}
612612

613-
impl server::Diagnostic for Rustc {
613+
impl server::Diagnostic for RustAnalyzer {
614614
fn new(&mut self, level: Level, msg: &str, spans: Self::MultiSpan) -> Self::Diagnostic {
615615
let mut diag = Diagnostic::new(level, msg);
616616
diag.spans = spans;
@@ -634,7 +634,7 @@ impl server::Diagnostic for Rustc {
634634
}
635635
}
636636

637-
impl server::Span for Rustc {
637+
impl server::Span for RustAnalyzer {
638638
fn debug(&mut self, span: Self::Span) -> String {
639639
format!("{:?}", span.0)
640640
}
@@ -706,7 +706,7 @@ impl server::Span for Rustc {
706706
}
707707
}
708708

709-
impl server::MultiSpan for Rustc {
709+
impl server::MultiSpan for RustAnalyzer {
710710
fn new(&mut self) -> Self::MultiSpan {
711711
// FIXME handle span
712712
vec![]
@@ -724,8 +724,8 @@ mod tests {
724724
use super::*;
725725

726726
#[test]
727-
fn test_rustc_server_literals() {
728-
let mut srv = Rustc { ident_interner: IdentInterner::default() };
727+
fn test_ra_server_literals() {
728+
let mut srv = RustAnalyzer { ident_interner: IdentInterner::default() };
729729
assert_eq!(srv.integer("1234").text, "1234");
730730

731731
assert_eq!(srv.typed_integer("12", "u8").text, "12u8");
@@ -761,7 +761,7 @@ mod tests {
761761
}
762762

763763
#[test]
764-
fn test_rustc_server_to_string() {
764+
fn test_ra_server_to_string() {
765765
let s = TokenStream {
766766
token_trees: vec![
767767
tt::TokenTree::Leaf(tt::Leaf::Ident(tt::Ident {
@@ -786,7 +786,7 @@ mod tests {
786786
}
787787

788788
#[test]
789-
fn test_rustc_server_from_str() {
789+
fn test_ra_server_from_str() {
790790
use std::str::FromStr;
791791
let subtree_paren_a = tt::TokenTree::Subtree(tt::Subtree {
792792
delimiter: Some(tt::Delimiter {

crates/proc-macro-srv/src/abis/abi_1_63/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ mod proc_macro;
66

77
#[allow(dead_code)]
88
#[doc(hidden)]
9-
mod rustc_server;
9+
mod ra_server;
1010

1111
use libloading::Library;
1212
use proc_macro_api::ProcMacroKind;
1313

1414
use super::PanicMessage;
1515

16-
pub use rustc_server::TokenStream;
16+
pub use ra_server::TokenStream;
1717

1818
pub(crate) struct Abi {
1919
exported_macros: Vec<proc_macro::bridge::client::ProcMacro>,
@@ -50,7 +50,7 @@ impl Abi {
5050
} if *trait_name == macro_name => {
5151
let res = client.run(
5252
&proc_macro::bridge::server::SameThread,
53-
rustc_server::Rustc::default(),
53+
ra_server::RustAnalyzer::default(),
5454
parsed_body,
5555
true,
5656
);
@@ -61,7 +61,7 @@ impl Abi {
6161
{
6262
let res = client.run(
6363
&proc_macro::bridge::server::SameThread,
64-
rustc_server::Rustc::default(),
64+
ra_server::RustAnalyzer::default(),
6565
parsed_body,
6666
true,
6767
);
@@ -72,7 +72,7 @@ impl Abi {
7272
{
7373
let res = client.run(
7474
&proc_macro::bridge::server::SameThread,
75-
rustc_server::Rustc::default(),
75+
ra_server::RustAnalyzer::default(),
7676
parsed_attributes,
7777
parsed_body,
7878
true,

0 commit comments

Comments
 (0)