Skip to content

Commit

Permalink
Auto merge of rust-lang#12828 - fasterthanlime:proc-macro-srv-naming,…
Browse files Browse the repository at this point in the history
… r=Veykril

Rename proc macro server from 'Rustc' to 'RustAnalyzer'

Related to:

  * rust-lang/rust-analyzer#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.
  • Loading branch information
bors committed Jul 20, 2022
2 parents 28bab68 + ade31ad commit 100ea1d
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 78 deletions.
24 changes: 12 additions & 12 deletions crates/hir-ty/src/tests/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>() -> 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>() -> G
1171..1177 'make()': G
1187..1191 'make': fn make<T>() -> 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>() -> G
1192..1198 'make()': G
1208..1212 'make': fn make<T>() -> T
1208..1214 'make()': T
"#]],
);
}
Expand Down
14 changes: 7 additions & 7 deletions crates/proc-macro-srv/src/abis/abi_1_58/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -36,10 +36,10 @@ impl Abi {
macro_body: &tt::Subtree,
attributes: Option<&tt::Subtree>,
) -> Result<tt::Subtree, PanicMessage> {
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 {
Expand All @@ -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,
);
Expand All @@ -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,
);
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -288,15 +288,15 @@ impl server::Types for Rustc {
type MultiSpan = Vec<Span>;
}

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
}
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()
}
Expand Down Expand Up @@ -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()
}
Expand All @@ -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,
Expand Down Expand Up @@ -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 }
}
Expand Down Expand Up @@ -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,
Expand All @@ -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 })))
}
Expand All @@ -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.
Expand Down Expand Up @@ -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
Expand All @@ -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;
Expand All @@ -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)
}
Expand Down Expand Up @@ -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![]
Expand All @@ -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");
Expand Down Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down
10 changes: 5 additions & 5 deletions crates/proc-macro-srv/src/abis/abi_1_63/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<proc_macro::bridge::client::ProcMacro>,
Expand Down Expand Up @@ -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,
);
Expand All @@ -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,
);
Expand All @@ -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,
Expand Down
Loading

0 comments on commit 100ea1d

Please sign in to comment.