From ade31ad75784265fe23c0d02ecdff3c74999a213 Mon Sep 17 00:00:00 2001 From: Amos Wenger Date: Wed, 20 Jul 2022 15:40:23 +0200 Subject: [PATCH] Rename proc macro server from 'Rustc' to 'RustAnalyzer' --- crates/hir-ty/src/tests/traits.rs | 24 ++++++------- .../proc-macro-srv/src/abis/abi_1_58/mod.rs | 14 ++++---- .../{rustc_server.rs => ra_server.rs} | 36 +++++++++---------- .../proc-macro-srv/src/abis/abi_1_63/mod.rs | 10 +++--- .../{rustc_server.rs => ra_server.rs} | 32 ++++++++--------- .../proc-macro-srv/src/abis/abi_1_64/mod.rs | 10 +++--- .../{rustc_server.rs => ra_server.rs} | 30 ++++++++-------- 7 files changed, 78 insertions(+), 78 deletions(-) rename crates/proc-macro-srv/src/abis/abi_1_58/{rustc_server.rs => ra_server.rs} (97%) rename crates/proc-macro-srv/src/abis/abi_1_63/{rustc_server.rs => ra_server.rs} (97%) rename crates/proc-macro-srv/src/abis/abi_1_64/{rustc_server.rs => ra_server.rs} (97%) diff --git a/crates/hir-ty/src/tests/traits.rs b/crates/hir-ty/src/tests/traits.rs index aa8b420e98..75802a5eb4 100644 --- a/crates/hir-ty/src/tests/traits.rs +++ b/crates/hir-ty/src/tests/traits.rs @@ -2430,29 +2430,29 @@ macro_rules! declare_server_traits { with_api!(Self, self_, declare_server_traits); struct G {} struct T {} -struct Rustc; -impl Types for Rustc { +struct RustAnalyzer; +impl Types for RustAnalyzer { type TokenStream = T; type Group = G; } fn make() -> T { loop {} } -impl TokenStream for Rustc { +impl TokenStream for RustAnalyzer { fn new() -> Self::TokenStream { let group: Self::Group = make(); make() } }"#, expect![[r#" - 1061..1072 '{ loop {} }': T - 1063..1070 'loop {}': ! - 1068..1070 '{}': () - 1136..1199 '{ ... }': T - 1150..1155 'group': G - 1171..1175 'make': fn make() -> G - 1171..1177 'make()': G - 1187..1191 'make': fn make() -> T - 1187..1193 'make()': T + 1075..1086 '{ loop {} }': T + 1077..1084 'loop {}': ! + 1082..1084 '{}': () + 1157..1220 '{ ... }': T + 1171..1176 'group': G + 1192..1196 'make': fn make() -> G + 1192..1198 'make()': G + 1208..1212 'make': fn make() -> T + 1208..1214 'make()': T "#]], ); } diff --git a/crates/proc-macro-srv/src/abis/abi_1_58/mod.rs b/crates/proc-macro-srv/src/abis/abi_1_58/mod.rs index 41e2e45703..1c91ac0fa1 100644 --- a/crates/proc-macro-srv/src/abis/abi_1_58/mod.rs +++ b/crates/proc-macro-srv/src/abis/abi_1_58/mod.rs @@ -6,7 +6,7 @@ mod proc_macro; #[allow(dead_code)] #[doc(hidden)] -mod rustc_server; +mod ra_server; use libloading::Library; use proc_macro_api::ProcMacroKind; @@ -36,10 +36,10 @@ impl Abi { macro_body: &tt::Subtree, attributes: Option<&tt::Subtree>, ) -> Result { - let parsed_body = rustc_server::TokenStream::with_subtree(macro_body.clone()); + let parsed_body = ra_server::TokenStream::with_subtree(macro_body.clone()); - let parsed_attributes = attributes.map_or(rustc_server::TokenStream::new(), |attr| { - rustc_server::TokenStream::with_subtree(attr.clone()) + let parsed_attributes = attributes.map_or(ra_server::TokenStream::new(), |attr| { + ra_server::TokenStream::with_subtree(attr.clone()) }); for proc_macro in &self.exported_macros { @@ -49,7 +49,7 @@ impl Abi { } if *trait_name == macro_name => { let res = client.run( &proc_macro::bridge::server::SameThread, - rustc_server::Rustc::default(), + ra_server::RustAnalyzer::default(), parsed_body, true, ); @@ -60,7 +60,7 @@ impl Abi { { let res = client.run( &proc_macro::bridge::server::SameThread, - rustc_server::Rustc::default(), + ra_server::RustAnalyzer::default(), parsed_body, true, ); @@ -71,7 +71,7 @@ impl Abi { { let res = client.run( &proc_macro::bridge::server::SameThread, - rustc_server::Rustc::default(), + ra_server::RustAnalyzer::default(), parsed_attributes, parsed_body, true, diff --git a/crates/proc-macro-srv/src/abis/abi_1_58/rustc_server.rs b/crates/proc-macro-srv/src/abis/abi_1_58/ra_server.rs similarity index 97% rename from crates/proc-macro-srv/src/abis/abi_1_58/rustc_server.rs rename to crates/proc-macro-srv/src/abis/abi_1_58/ra_server.rs index 5c596bc0e6..ebdfca00d7 100644 --- a/crates/proc-macro-srv/src/abis/abi_1_58/rustc_server.rs +++ b/crates/proc-macro-srv/src/abis/abi_1_58/ra_server.rs @@ -268,12 +268,12 @@ pub struct TokenStreamIter { } #[derive(Default)] -pub struct Rustc { +pub struct RustAnalyzer { ident_interner: IdentInterner, // FIXME: store span information here. } -impl server::Types for Rustc { +impl server::Types for RustAnalyzer { type FreeFunctions = FreeFunctions; type TokenStream = TokenStream; type TokenStreamBuilder = TokenStreamBuilder; @@ -288,7 +288,7 @@ impl server::Types for Rustc { type MultiSpan = Vec; } -impl server::FreeFunctions for Rustc { +impl server::FreeFunctions for RustAnalyzer { fn track_env_var(&mut self, _var: &str, _value: Option<&str>) { // FIXME: track env var accesses // https://github.com/rust-lang/rust/pull/71858 @@ -296,7 +296,7 @@ impl server::FreeFunctions for Rustc { fn track_path(&mut self, _path: &str) {} } -impl server::TokenStream for Rustc { +impl server::TokenStream for RustAnalyzer { fn new(&mut self) -> Self::TokenStream { Self::TokenStream::new() } @@ -354,7 +354,7 @@ impl server::TokenStream for Rustc { } } -impl server::TokenStreamBuilder for Rustc { +impl server::TokenStreamBuilder for RustAnalyzer { fn new(&mut self) -> Self::TokenStreamBuilder { Self::TokenStreamBuilder::new() } @@ -366,7 +366,7 @@ impl server::TokenStreamBuilder for Rustc { } } -impl server::TokenStreamIter for Rustc { +impl server::TokenStreamIter for RustAnalyzer { fn next( &mut self, iter: &mut Self::TokenStreamIter, @@ -415,7 +415,7 @@ fn spacing_to_external(spacing: Spacing) -> bridge::Spacing { } } -impl server::Group for Rustc { +impl server::Group for RustAnalyzer { fn new(&mut self, delimiter: bridge::Delimiter, stream: Self::TokenStream) -> Self::Group { Self::Group { delimiter: delim_to_internal(delimiter), token_trees: stream.token_trees } } @@ -449,7 +449,7 @@ impl server::Group for Rustc { } } -impl server::Punct for Rustc { +impl server::Punct for RustAnalyzer { fn new(&mut self, ch: char, spacing: bridge::Spacing) -> Self::Punct { tt::Punct { char: ch, @@ -471,7 +471,7 @@ impl server::Punct for Rustc { } } -impl server::Ident for Rustc { +impl server::Ident for RustAnalyzer { fn new(&mut self, string: &str, span: Self::Span, _is_raw: bool) -> Self::Ident { IdentId(self.ident_interner.intern(&IdentData(tt::Ident { text: string.into(), id: span }))) } @@ -486,7 +486,7 @@ impl server::Ident for Rustc { } } -impl server::Literal for Rustc { +impl server::Literal for RustAnalyzer { fn debug_kind(&mut self, _literal: &Self::Literal) -> String { // r-a: debug_kind and suffix are unsupported; corresponding client code has been changed to not call these. // They must still be present to be ABI-compatible and work with upstream proc_macro. @@ -597,7 +597,7 @@ impl server::Literal for Rustc { } } -impl server::SourceFile for Rustc { +impl server::SourceFile for RustAnalyzer { // FIXME these are all stubs fn eq(&mut self, _file1: &Self::SourceFile, _file2: &Self::SourceFile) -> bool { true @@ -610,7 +610,7 @@ impl server::SourceFile for Rustc { } } -impl server::Diagnostic for Rustc { +impl server::Diagnostic for RustAnalyzer { fn new(&mut self, level: Level, msg: &str, spans: Self::MultiSpan) -> Self::Diagnostic { let mut diag = Diagnostic::new(level, msg); diag.spans = spans; @@ -634,7 +634,7 @@ impl server::Diagnostic for Rustc { } } -impl server::Span for Rustc { +impl server::Span for RustAnalyzer { fn debug(&mut self, span: Self::Span) -> String { format!("{:?}", span.0) } @@ -706,7 +706,7 @@ impl server::Span for Rustc { } } -impl server::MultiSpan for Rustc { +impl server::MultiSpan for RustAnalyzer { fn new(&mut self) -> Self::MultiSpan { // FIXME handle span vec![] @@ -724,8 +724,8 @@ mod tests { use super::*; #[test] - fn test_rustc_server_literals() { - let mut srv = Rustc { ident_interner: IdentInterner::default() }; + fn test_ra_server_literals() { + let mut srv = RustAnalyzer { ident_interner: IdentInterner::default() }; assert_eq!(srv.integer("1234").text, "1234"); assert_eq!(srv.typed_integer("12", "u8").text, "12u8"); @@ -761,7 +761,7 @@ mod tests { } #[test] - fn test_rustc_server_to_string() { + fn test_ra_server_to_string() { let s = TokenStream { token_trees: vec![ tt::TokenTree::Leaf(tt::Leaf::Ident(tt::Ident { @@ -786,7 +786,7 @@ mod tests { } #[test] - fn test_rustc_server_from_str() { + fn test_ra_server_from_str() { use std::str::FromStr; let subtree_paren_a = tt::TokenTree::Subtree(tt::Subtree { delimiter: Some(tt::Delimiter { diff --git a/crates/proc-macro-srv/src/abis/abi_1_63/mod.rs b/crates/proc-macro-srv/src/abis/abi_1_63/mod.rs index c253b10994..76e89e3191 100644 --- a/crates/proc-macro-srv/src/abis/abi_1_63/mod.rs +++ b/crates/proc-macro-srv/src/abis/abi_1_63/mod.rs @@ -6,14 +6,14 @@ mod proc_macro; #[allow(dead_code)] #[doc(hidden)] -mod rustc_server; +mod ra_server; use libloading::Library; use proc_macro_api::ProcMacroKind; use super::PanicMessage; -pub use rustc_server::TokenStream; +pub use ra_server::TokenStream; pub(crate) struct Abi { exported_macros: Vec, @@ -50,7 +50,7 @@ impl Abi { } if *trait_name == macro_name => { let res = client.run( &proc_macro::bridge::server::SameThread, - rustc_server::Rustc::default(), + ra_server::RustAnalyzer::default(), parsed_body, true, ); @@ -61,7 +61,7 @@ impl Abi { { let res = client.run( &proc_macro::bridge::server::SameThread, - rustc_server::Rustc::default(), + ra_server::RustAnalyzer::default(), parsed_body, true, ); @@ -72,7 +72,7 @@ impl Abi { { let res = client.run( &proc_macro::bridge::server::SameThread, - rustc_server::Rustc::default(), + ra_server::RustAnalyzer::default(), parsed_attributes, parsed_body, true, diff --git a/crates/proc-macro-srv/src/abis/abi_1_63/rustc_server.rs b/crates/proc-macro-srv/src/abis/abi_1_63/ra_server.rs similarity index 97% rename from crates/proc-macro-srv/src/abis/abi_1_63/rustc_server.rs rename to crates/proc-macro-srv/src/abis/abi_1_63/ra_server.rs index 7fd422ca29..05a565fbf3 100644 --- a/crates/proc-macro-srv/src/abis/abi_1_63/rustc_server.rs +++ b/crates/proc-macro-srv/src/abis/abi_1_63/ra_server.rs @@ -268,12 +268,12 @@ pub struct TokenStreamIter { } #[derive(Default)] -pub struct Rustc { +pub struct RustAnalyzer { ident_interner: IdentInterner, // FIXME: store span information here. } -impl server::Types for Rustc { +impl server::Types for RustAnalyzer { type FreeFunctions = FreeFunctions; type TokenStream = TokenStream; type Group = Group; @@ -286,7 +286,7 @@ impl server::Types for Rustc { type MultiSpan = Vec; } -impl server::FreeFunctions for Rustc { +impl server::FreeFunctions for RustAnalyzer { fn track_env_var(&mut self, _var: &str, _value: Option<&str>) { // FIXME: track env var accesses // https://github.com/rust-lang/rust/pull/71858 @@ -294,7 +294,7 @@ impl server::FreeFunctions for Rustc { fn track_path(&mut self, _path: &str) {} } -impl server::TokenStream for Rustc { +impl server::TokenStream for RustAnalyzer { fn is_empty(&mut self, stream: &Self::TokenStream) -> bool { stream.is_empty() } @@ -423,7 +423,7 @@ fn spacing_to_external(spacing: Spacing) -> bridge::Spacing { } } -impl server::Group for Rustc { +impl server::Group for RustAnalyzer { fn new( &mut self, delimiter: bridge::Delimiter, @@ -464,7 +464,7 @@ impl server::Group for Rustc { } } -impl server::Punct for Rustc { +impl server::Punct for RustAnalyzer { fn new(&mut self, ch: char, spacing: bridge::Spacing) -> Self::Punct { tt::Punct { char: ch, @@ -486,7 +486,7 @@ impl server::Punct for Rustc { } } -impl server::Ident for Rustc { +impl server::Ident for RustAnalyzer { fn new(&mut self, string: &str, span: Self::Span, _is_raw: bool) -> Self::Ident { IdentId(self.ident_interner.intern(&IdentData(tt::Ident { text: string.into(), id: span }))) } @@ -501,7 +501,7 @@ impl server::Ident for Rustc { } } -impl server::Literal for Rustc { +impl server::Literal for RustAnalyzer { fn debug_kind(&mut self, _literal: &Self::Literal) -> String { // r-a: debug_kind and suffix are unsupported; corresponding client code has been changed to not call these. // They must still be present to be ABI-compatible and work with upstream proc_macro. @@ -612,7 +612,7 @@ impl server::Literal for Rustc { } } -impl server::SourceFile for Rustc { +impl server::SourceFile for RustAnalyzer { // FIXME these are all stubs fn eq(&mut self, _file1: &Self::SourceFile, _file2: &Self::SourceFile) -> bool { true @@ -625,7 +625,7 @@ impl server::SourceFile for Rustc { } } -impl server::Diagnostic for Rustc { +impl server::Diagnostic for RustAnalyzer { fn new(&mut self, level: Level, msg: &str, spans: Self::MultiSpan) -> Self::Diagnostic { let mut diag = Diagnostic::new(level, msg); diag.spans = spans; @@ -649,7 +649,7 @@ impl server::Diagnostic for Rustc { } } -impl server::Span for Rustc { +impl server::Span for RustAnalyzer { fn debug(&mut self, span: Self::Span) -> String { format!("{:?}", span.0) } @@ -721,7 +721,7 @@ impl server::Span for Rustc { } } -impl server::MultiSpan for Rustc { +impl server::MultiSpan for RustAnalyzer { fn new(&mut self) -> Self::MultiSpan { // FIXME handle span vec![] @@ -739,8 +739,8 @@ mod tests { use super::*; #[test] - fn test_rustc_server_literals() { - let mut srv = Rustc { ident_interner: IdentInterner::default() }; + fn test_ra_server_literals() { + let mut srv = RustAnalyzer { ident_interner: IdentInterner::default() }; assert_eq!(srv.integer("1234").text, "1234"); assert_eq!(srv.typed_integer("12", "u8").text, "12u8"); @@ -776,7 +776,7 @@ mod tests { } #[test] - fn test_rustc_server_to_string() { + fn test_ra_server_to_string() { let s = TokenStream { token_trees: vec![ tt::TokenTree::Leaf(tt::Leaf::Ident(tt::Ident { @@ -801,7 +801,7 @@ mod tests { } #[test] - fn test_rustc_server_from_str() { + fn test_ra_server_from_str() { use std::str::FromStr; let subtree_paren_a = tt::TokenTree::Subtree(tt::Subtree { delimiter: Some(tt::Delimiter { diff --git a/crates/proc-macro-srv/src/abis/abi_1_64/mod.rs b/crates/proc-macro-srv/src/abis/abi_1_64/mod.rs index 0ba4bbbef0..9d56f0eaf8 100644 --- a/crates/proc-macro-srv/src/abis/abi_1_64/mod.rs +++ b/crates/proc-macro-srv/src/abis/abi_1_64/mod.rs @@ -6,14 +6,14 @@ mod proc_macro; #[allow(dead_code)] #[doc(hidden)] -mod rustc_server; +mod ra_server; use libloading::Library; use proc_macro_api::ProcMacroKind; use super::PanicMessage; -pub use rustc_server::TokenStream; +pub use ra_server::TokenStream; pub(crate) struct Abi { exported_macros: Vec, @@ -50,7 +50,7 @@ impl Abi { } if *trait_name == macro_name => { let res = client.run( &proc_macro::bridge::server::SameThread, - rustc_server::Rustc::default(), + ra_server::RustAnalyzer::default(), parsed_body, true, ); @@ -61,7 +61,7 @@ impl Abi { { let res = client.run( &proc_macro::bridge::server::SameThread, - rustc_server::Rustc::default(), + ra_server::RustAnalyzer::default(), parsed_body, true, ); @@ -72,7 +72,7 @@ impl Abi { { let res = client.run( &proc_macro::bridge::server::SameThread, - rustc_server::Rustc::default(), + ra_server::RustAnalyzer::default(), parsed_attributes, parsed_body, true, diff --git a/crates/proc-macro-srv/src/abis/abi_1_64/rustc_server.rs b/crates/proc-macro-srv/src/abis/abi_1_64/ra_server.rs similarity index 97% rename from crates/proc-macro-srv/src/abis/abi_1_64/rustc_server.rs rename to crates/proc-macro-srv/src/abis/abi_1_64/ra_server.rs index 757454a926..7e8e67856e 100644 --- a/crates/proc-macro-srv/src/abis/abi_1_64/rustc_server.rs +++ b/crates/proc-macro-srv/src/abis/abi_1_64/ra_server.rs @@ -268,12 +268,12 @@ pub struct TokenStreamIter { } #[derive(Default)] -pub struct Rustc { +pub struct RustAnalyzer { ident_interner: IdentInterner, // FIXME: store span information here. } -impl server::Types for Rustc { +impl server::Types for RustAnalyzer { type FreeFunctions = FreeFunctions; type TokenStream = TokenStream; type Ident = IdentId; @@ -284,7 +284,7 @@ impl server::Types for Rustc { type MultiSpan = Vec; } -impl server::FreeFunctions for Rustc { +impl server::FreeFunctions for RustAnalyzer { fn track_env_var(&mut self, _var: &str, _value: Option<&str>) { // FIXME: track env var accesses // https://github.com/rust-lang/rust/pull/71858 @@ -292,7 +292,7 @@ impl server::FreeFunctions for Rustc { fn track_path(&mut self, _path: &str) {} } -impl server::TokenStream for Rustc { +impl server::TokenStream for RustAnalyzer { fn is_empty(&mut self, stream: &Self::TokenStream) -> bool { stream.is_empty() } @@ -449,7 +449,7 @@ fn spacing_to_external(spacing: Spacing) -> bridge::Spacing { } } -impl server::Ident for Rustc { +impl server::Ident for RustAnalyzer { fn new(&mut self, string: &str, span: Self::Span, _is_raw: bool) -> Self::Ident { IdentId(self.ident_interner.intern(&IdentData(tt::Ident { text: string.into(), id: span }))) } @@ -464,7 +464,7 @@ impl server::Ident for Rustc { } } -impl server::Literal for Rustc { +impl server::Literal for RustAnalyzer { fn debug_kind(&mut self, _literal: &Self::Literal) -> String { // r-a: debug_kind and suffix are unsupported; corresponding client code has been changed to not call these. // They must still be present to be ABI-compatible and work with upstream proc_macro. @@ -575,7 +575,7 @@ impl server::Literal for Rustc { } } -impl server::SourceFile for Rustc { +impl server::SourceFile for RustAnalyzer { // FIXME these are all stubs fn eq(&mut self, _file1: &Self::SourceFile, _file2: &Self::SourceFile) -> bool { true @@ -588,7 +588,7 @@ impl server::SourceFile for Rustc { } } -impl server::Diagnostic for Rustc { +impl server::Diagnostic for RustAnalyzer { fn new(&mut self, level: Level, msg: &str, spans: Self::MultiSpan) -> Self::Diagnostic { let mut diag = Diagnostic::new(level, msg); diag.spans = spans; @@ -612,7 +612,7 @@ impl server::Diagnostic for Rustc { } } -impl server::Span for Rustc { +impl server::Span for RustAnalyzer { fn debug(&mut self, span: Self::Span) -> String { format!("{:?}", span.0) } @@ -669,7 +669,7 @@ impl server::Span for Rustc { } } -impl server::MultiSpan for Rustc { +impl server::MultiSpan for RustAnalyzer { fn new(&mut self) -> Self::MultiSpan { // FIXME handle span vec![] @@ -681,7 +681,7 @@ impl server::MultiSpan for Rustc { } } -impl server::Server for Rustc { +impl server::Server for RustAnalyzer { fn globals(&mut self) -> bridge::ExpnGlobals { bridge::ExpnGlobals { def_site: Span::unspecified(), @@ -697,8 +697,8 @@ mod tests { use super::*; #[test] - fn test_rustc_server_literals() { - let mut srv = Rustc { ident_interner: IdentInterner::default() }; + fn test_ra_server_literals() { + let mut srv = RustAnalyzer { ident_interner: IdentInterner::default() }; assert_eq!(srv.integer("1234").text, "1234"); assert_eq!(srv.typed_integer("12", "u8").text, "12u8"); @@ -734,7 +734,7 @@ mod tests { } #[test] - fn test_rustc_server_to_string() { + fn test_ra_server_to_string() { let s = TokenStream { token_trees: vec![ tt::TokenTree::Leaf(tt::Leaf::Ident(tt::Ident { @@ -759,7 +759,7 @@ mod tests { } #[test] - fn test_rustc_server_from_str() { + fn test_ra_server_from_str() { use std::str::FromStr; let subtree_paren_a = tt::TokenTree::Subtree(tt::Subtree { delimiter: Some(tt::Delimiter {